Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Incorrect frame for breakpoint #752

Closed
huguesv opened this issue Aug 14, 2018 · 2 comments
Closed

Incorrect frame for breakpoint #752

huguesv opened this issue Aug 14, 2018 · 2 comments
Assignees

Comments

@huguesv
Copy link
Contributor

huguesv commented Aug 14, 2018

Environment data

  • PTVSD version: today's master
  • OS and version: Win10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6
  • Using VS Code or Visual Studio: Visual Studio

Steps to reproduce:

  1. Type this code and set breakpoint on line 9 as in the picture and start debugging.
import threading
from queue import Queue
import time

print_lock = threading.Lock()

def get_url(current_url):

    time.sleep(2)
    with print_lock:
        print("\nStarting thread {}".format(threading.current_thread().name))

def process_queue():
    while True:
        current_url = url_queue.get()
        get_url(current_url)
        url_queue.task_done()

url_queue = Queue()

url_list = ["https://www.google.com"]*5

for i in range(5):
    t = threading.Thread(target=process_queue)
    t.daemon = True
    t.start()

start = time.time()

for current_url in url_list:
    url_queue.put(current_url)

url_queue.join()

image

Actual behavior

VS breaks on line 16.

Expected behavior

VS breaks on line 9.

@karthiknadig
Copy link
Member

karthiknadig commented Aug 15, 2018

This looks like it is paused on the wrong thread. VS UI shows the last paused thread instead of the thread that hit break point. We could probably use preserveFocusHint to control that.

if the stop reason is breakpoint or exception then preserveFocusHint should be false, and it should be true for all other cases.

@karthiknadig karthiknadig self-assigned this Aug 15, 2018
@karthiknadig
Copy link
Member

karthiknadig commented Aug 15, 2018

@DonJayamanne Can you look at this change karthiknadig@cf7a5f6 ? Basically VS has special requirements about stopped Event.
see: https://github.com/Microsoft/VSDebugAdapterHost/wiki/Differences-between-Visual-Studio-Code-and-the-Visual-Studio-Debug-Adapter-Host#stopped-event

There is a bit more to it. we have to send stopped event if the reason in ['breakpoint', 'exception', 'step'] events, even if we sent a stopped event with reason == 'pause' otherwise VS has no clue which stack to show.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants