Skip to content
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

Variable explorer in interactive window debug session does not show locals #5626

Closed
joyceerhl opened this issue Apr 25, 2021 · 3 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug interactive-window Impacts interactive window interactive-window-debugging variable-explorer

Comments

@joyceerhl
Copy link
Contributor

joyceerhl commented Apr 25, 2021

The root cause of this is that when there is a local and global scope, e.g. we're stopped on a breakpoint inside a function in a Python module, two variables requests are sent from the client to the debug adapter. However it looks like our debug adapter tracker code assumes only one variables request is ever sent, and we overwrite this.lastKnownVariables for each response we process:

this.lastKnownVariables = allowedVariables.map((v) => {
return convertDebugProtocolVariableToIJupyterVariable(v);
});

In the case where there is only a global scope, two variables requests are still sent (you can see this by setting a breakpoint in onDidSendMessage in debugLocationTracker.ts), but their contents are identical, which is why the variable explorer still shows the right variables. But when we're stopped in a function and the local scope variables response is processed before the global scope variables response, this results in the variable explorer failing to show local variables. E.g. in the screenshot below, the variable explorer only shows the globally declared a and b, when it should also be showing the local df (which is shown in the locals window on the left):

image

Instead I think we should combine the allowedVariables with the existing this.lastKnownVariables. We must also clear this.lastKnownVariables to avoid showing variables that have gone out of scope in the variable explorer, e.g. we can clear on a continue event (since we'll recompute the lastKnownVariables the next time we receive variables responses from the debug adapter).

@joyceerhl joyceerhl added the bug Issue identified by VS Code Team member as probable bug label Apr 25, 2021
@joyceerhl
Copy link
Contributor Author

joyceerhl commented Apr 25, 2021

86a198e partially fixes this. If a globally scoped variable is shadowed by a local variable, should we show both (in which case we would need to indicate which scope each variable belongs to) or show the local by default?

image

@amunger
Copy link
Contributor

amunger commented Apr 4, 2022

Just went through a repro for this with the modern variable explorer - it looks like we now only show the variables in the local scope, and globals don't appear at all.
image

@roblourens
Copy link
Member

Rather than risk showing duplicate variables where it's not clear what scope the variable is in (since the explorer doesn't have this concept), I'll leave it as-is, ensure that we have a story for this in the new variable explorer, and close in favor of microsoft/vscode#165445

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug interactive-window Impacts interactive window interactive-window-debugging variable-explorer
Projects
None yet
Development

No branches or pull requests

8 participants