You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Debugger: On stopping event, Code does display any source location if top stack frame does not have source information. #4027
The issue: If the top stack frame does not have source information, the debugger fails to show a current location (even if another stack frame does have source information).
In C#, when stopping on an unhandled exception, the top stack frame is often in "non-user code" and the frame is either "[external code]" or a frame in OS code that the user will not have source info for. Example:
In this file, I found that when the debugger receives a stopping event, it is hard coded to set the 0th frame as the current frame:
Prior to calling setFocusedStackFrameAndEvaluate or openOrRevealEditor, the debugService should walk it's callstack looking for a frame that has valid source information. The first frame it finds should be passed to setFocusedStackFrameAndEvaluate and openOrRevealEditor.
Additionally: I found that if a debugAdapter does not provide source information for a frame, VS Code creates a default Source object for the stack frame:
Chuck Ries (@chuckries) If a stack frame does not have source information, the debugger UI cannot "infer" a location from some other frame by "walking its callstack looking for a frame that has valid source information". That would be too much guessing in a language agnostic UI.
So if you need this behaviour, just implement it in the debug adapter.
From your screenshot I do not really understand what is the problem because I only see the name of the frame?
Isidor Nikolic (@isidorn) could you please look into the issue of "default Source objects sets source available to true"
The issue is that when the exception goes unhandled and the debugger stops, it does not set the current location.
In this image I have just stopped but I do not know where I am.
After selecting the ConsoleApplication.... frame it looks like this:
I believe that the location seen in the second screenshot should be the behavior when the debugger stops on the exception. The debug adapter should not control this sort of UI feature. It simply hands back a callstack. It is up to the UI to determine from those stack frames which should be set as the active frame. If there is no source info availalbe in frame[0], but there is source info available in frame[1], why would the debugger not set frame[1] as the active frame with the green arrow? The green arrow signifies that this is the current source location for the active frame, but it is not the current IP.
changed the title [-]Debugger: On stopping event, Code does not display current location if top stack frame does not have source information. [/-][+]Debugger: On stopping event, Code does not any location if top stack frame does not have source information. [/+]on Mar 11, 2016
changed the title [-]Debugger: On stopping event, Code does not any location if top stack frame does not have source information. [/-][+]Debugger: On stopping event, Code does display any source location if top stack frame does not have source information. [/+]on Mar 11, 2016
I still cannot see the relevant information in your stackframes.
Could you try to make the Call Stack viewlet wider so that we can see the right hand side of it.
Like this:
“The debug adapter should not control this sort of UI feature.”
This is not really true.
The debug adapter is an adapter between a debugger API and the VS Code debugger UI.
The VS Code debug protocol is a protocol for serving the VS Code debugger UI (and nothing else). It is not a protocol for serving any other tool.
The VS Code debugger UI is debugger and language agnostic, that means that the debug adapter has to control how types, values and the structure of variables is presented in the UI. The same is true for other areas of the protocol.
I understand that, but I discovered a secondary issue while investigating this that StackFrame's are never created with nullSource fields. Here you can see that if a nullSource is provided by the debug adapter, the StackFrame will be created with a default Source object that has its name field set to uknown. I believe this was done so that the callstack viewlet willl display the string "unkown" when a stackframe does not have have a source field, but this will interfere with setting the current stack frame.
I can confirm that even with this change I am not seeing the current stack frame get set correctly because my debug adapter returns a null Source for the stackframe and code is creating non null default source object. I am having trouble debugging code with code however using current master.
Activity
chuckries commentedon Mar 11, 2016
Andre Weinand (@weinand)
weinand commentedon Mar 11, 2016
Chuck Ries (@chuckries) If a stack frame does not have source information, the debugger UI cannot "infer" a location from some other frame by "walking its callstack looking for a frame that has valid source information". That would be too much guessing in a language agnostic UI.
So if you need this behaviour, just implement it in the debug adapter.
From your screenshot I do not really understand what is the problem because I only see the name of the frame?
Isidor Nikolic (@isidorn) could you please look into the issue of "default Source objects sets source available to true"
chuckries commentedon Mar 11, 2016
The issue is that when the exception goes unhandled and the debugger stops, it does not set the current location.
In this image I have just stopped but I do not know where I am.

After selecting the ConsoleApplication.... frame it looks like this:

I believe that the location seen in the second screenshot should be the behavior when the debugger stops on the exception. The debug adapter should not control this sort of UI feature. It simply hands back a callstack. It is up to the UI to determine from those stack frames which should be set as the active frame. If there is no source info availalbe in frame[0], but there is source info available in frame[1], why would the debugger not set frame[1] as the active frame with the green arrow? The green arrow signifies that this is the current source location for the active frame, but it is not the current IP.
[-]Debugger: On stopping event, Code does not display current location if top stack frame does not have source information. [/-][+]Debugger: On stopping event, Code does not any location if top stack frame does not have source information. [/+][-]Debugger: On stopping event, Code does not any location if top stack frame does not have source information. [/-][+]Debugger: On stopping event, Code does display any source location if top stack frame does not have source information. [/+]weinand commentedon Mar 11, 2016
I still cannot see the relevant information in your stackframes.
Could you try to make the Call Stack viewlet wider so that we can see the right hand side of it.
Like this:
This is not really true.
The debug adapter is an adapter between a debugger API and the VS Code debugger UI.
The VS Code debug protocol is a protocol for serving the VS Code debugger UI (and nothing else). It is not a protocol for serving any other tool.
The VS Code debugger UI is debugger and language agnostic, that means that the debug adapter has to control how types, values and the structure of variables is presented in the UI. The same is true for other areas of the protocol.
8 remaining items
chuckries commentedon Mar 16, 2016
I understand that, but I discovered a secondary issue while investigating this that
StackFrame's are never created withnullSourcefields. Here you can see that if anullSourceis provided by the debug adapter, theStackFramewill be created with a default Source object that has itsnamefield set to uknown. I believe this was done so that the callstack viewlet willl display the string "unkown" when a stackframe does not have have a source field, but this will interfere with setting the current stack frame.chuckries commentedon Mar 16, 2016
I can confirm that even with this change I am not seeing the current stack frame get set correctly because my debug adapter returns a null Source for the stackframe and code is creating non null default source object. I am having trouble debugging code with code however using current master.
chuckries commentedon Mar 16, 2016
Isidor Nikolic (@isidorn) Can this be reopened or should I file another issue?
isidorn commentedon Mar 16, 2016
Chuck Ries (@chuckries) good catch, I will fix this tomorrow, unless it is urgent then let me know and I can look right away
chuckries commentedon Mar 16, 2016
any time before next release is fine, but tomorrow is great! thanks!
isidorn commentedon Mar 17, 2016
Giving to Andre Weinand (@weinand) to verify, also Chuck Ries (@chuckries) let us know if it still does not work for you
chuckries commentedon Mar 17, 2016
Looks great! Thanks!