-
Notifications
You must be signed in to change notification settings - Fork 29.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging shifts focus to another thread, while running, under certain conditions #65920
Comments
@segevfiner thanks for this nice investigation. @testforstephen what would be ideal for the Java use case? |
@isidorn are you saying that the functionality before was broken and now it's working as intended? I've been running into this lately and never used to hit it. If it's valid functionality I find that it makes debugging a huge pain, on almost every step over it jumps into |
I don't think that's really such a desired behavior... Have you ever debugged anything in Visual Studio, windbg, gdb, Eclipse, IntelliJ. and had it jump around to other threads while stepping? I know I haven't. They will only jump to a different thread when the debugee hits a stop event in a different thread, like a breakpoint. It doesn't matter what the other threads are doing, running or stopped. The debugger will keep the debugged thread focused so long as no other thread hits a stop event |
@isidorn the scenario you described seems sensible in the case of a continue. However, if A and B are stopped, and I do a step, I would expect to stay in the context of A and not switch to B. I'm not sure what the difference is (if any) between a step and a continue from the perspective of a debugger, but from a user perspective they definitely seem like different things. |
@isidorn Maybe I don't understand your response, but the scenario defined by this report does not have two threads stopped. At least not by the user doing the debugging. The user is debugging a single thread and the debugging environment is flashing (temporarily) to another thread. Very annoying. Pretty much like trying to read a web page and every time you read the next sentence it flips to some random page for a second. It makes debugging a painful process. I think the OP did a great job identifying where the problem is happening. Were you able to confirm what was said? Thanks! |
@ramya-rao-a You were involved in the initial discussion of this bug Debugging goes into proc.go at every step #2133 Work on this problem seems to have been dropped. Could you help move the conversation forward? Thanks! |
The issue is assigned to december/januar which means I plan to investigate more in this milestone. |
That was just the bot closing the issue due to inactivity on the issue. I have re-opened that bug. Work on this problem has not been dropped. It just got moved here :) @segevfiner has some great findings on the issue and @isidorn will be following up on this. |
Thanks again to @segevfiner for this investigation and for everybody else for providing feedback. Now we only auto focus threads if that particular thread is stopped. @testforstephen it would be graet if you also try this out for the java case |
I can confirm that it is working for the Go case. |
@leesjensen thanks for confirming, adding verified label. |
Here is the vscode insider version where i tried java multiple threads program. It still has similar switching problem as the issue #55862 when exec
Below is the java program ThreadTest.java i used. Add two breakpoints at line 14 and line 27. When exec ThreadTest.javaimport java.util.concurrent.atomic.AtomicInteger; Below are the reproduce steps in vscode-insider:
|
Have a look at the discussion history. What @segevfiner complains is stepping ( |
@testforstephen thanks for your feedback and sorry for the slow response I was on vacation. Can you please create a new issue and ping me on it so we continue the discussion there. |
@isidorn sure, i will open a new issue to continue the discussion. A quick question here, is there any technical limit that needs keep the step and continue behaving the same? because in eclipse and intellij, step and continue are not the same behavior. |
There is no technical limit, we could change the behavior in theory. |
a more comment here. maybe java is a little special because it supports Thread Level suspend, that means you can choose to continue one stopping thread, and keep other threads still on stopping state. Other languages, like nodejs, continue will resume the whole program, so it doesn't need concern the focus switch. |
Experienced while debugging using vscode-go/delve: microsoft/vscode-go#2133
Steps to Reproduce
time.Sleep
line:gopark
while the code is running. Returning to the real debugged thread while stopped.Analysis
Debugging VS Code a bit, it seems to me we are hitting this line in VS Code: vscode/src/vs/workbench/parts/debug/electron-browser/debugService.ts:496 and that call to
focusStackFrame
is selecting to focus some other thread than the one currently being debugged, and that thread is, more often than not, stopped ongopark
.We really shouldn't be reaching a code path where VS Code selects some arbitrary thread to focus, that seems like a bug in VS Code.
The code there is a bit weird too, like vscode/src/vs/workbench/parts/debug/electron-browser/debugService.ts:773 with that
shift
... selecting the second stopped thread...? 😕I launched VS Code (Git build) with
--remote-debugging-port=9222
and vscode-go installed (--extensionDevelopmentPath
or just install it), used the "Attach to VS Code" launch configuration in VS Code's repository, and then conditional breakpoints to stop when it's requesting a stackTrace onthreadId === 2
.Does this issue occur when all extensions are disabled?: No
cc @ramya-rao-a
The text was updated successfully, but these errors were encountered: