rogalmic / vscode-bash-debug

Bash shell debugger extension for VSCode (based on bashdb)
MIT License
222 stars 26 forks source link

Add variables to "VARIABLES" panel automatically. #168

Open senhui2intel opened 2 years ago

senhui2intel commented 2 years ago

There are only two variables in the "VARIABLES" Panel for now: $PWD and $?. The variable HELLO declared by last line is not added to "VARIABLES" Panel automatically. I have to add it to watch manually.

When I debug other language such python, variables are usually add to "VARIABLES" panel automatically. If this feature could be implemented, the user experience will be greatly improved.

Thanks!

image

image

Makeshift commented 2 years ago

I was hoping this could be worked around by adding a hack to the Watch list, eg $(printenv), but sadly that doesn't work due to #144

Makeshift commented 2 years ago

I think it might be possible to add them automatically to the watch list, if not the variables panel, with something along the lines of:

await vscode.commands.executeCommand<vscode.Location[]>('workbench.debug.viewlet.action.addWatchExpression', `${variables[0].name}`);

I tried to code this into the extension but unfortunately can't test it as my extension development host starts then exits the extension immediately in development mode :(

amlamarra commented 1 year ago

+1 for this. Would be great to get it fixed.

nixomose commented 1 year ago

+1 from me too, but this is so awesome to begin with, I'm happy enough. I can see where this is hard because how do you distinguish existing environment variables from ones set by the script?

ioogithub commented 1 year ago

This would be the number one reason for using this extension and the first thing I looked for after installing it. Is there no work around for this, the functionality simply does not exist?

nixomose commented 1 year ago

add watches for the ones you want to look at. consider the alternative, there's no way to tell one environment variable from the other being local or not, so if you put all the environment variables in the locals list, it would be unreadable and nearly useless anyway.

ioogithub commented 1 year ago

add watches for the ones you want to look at.

Thanks for replying. I would like to try this but I don't know how to do this. Do any of the videos here show how to add watchers: https://github.com/rogalmic/vscode-bash-debug and where to see their status?

ioogithub commented 1 year ago

In this video: https://raw.githubusercontent.com/rogalmic/vscode-bash-debug/gif/images/bash-debug-samp-watch-advanced.gif he adds a watcher: ${PWD -4 and that returns the last 4 characters of the file path? I have no idea what this means, how is this a watcher?

nixomose commented 1 year ago

not sure what you mean by "watcher" but you see the panel he's putting that ${PWD - 4} in, that's the 'watch window' or watch panel. all it means is that it the debugger will evaluate the expression in the watch window when the debugger stops to let you step through the next line. It's just like the local variables window except instead of trying to evaluate all local variables it only evaluates what you've specifically listed as wanting to watch. The particular watch expression ${PWD - 4} is bash string manipulation... https://tldp.org/LDP/abs/html/string-manipulation.html see the bit about "substring extraction", it takes the value of $PWD and strips off everything but the last 4 characters.

So anyway, all the watch window is doing is evaluating ${PWD - 4} every time you step through a line in the debugger.

pgeng-nv commented 9 months ago

This is a duplicate of #98. It's an unknown issue and hasn't been fixed unfortunately.

Chealer commented 3 months ago

@pgeng-nv : Thanks, but ticket #98 is a question (indeed related).

Chealer commented 3 months ago

@senhui2intel : This is an issue tracker. Please retitle this ticket as an issue report. For example:

Most variables not added to "VARIABLES" panel automatically

Also, please clarify your description adding text to make it obvious that the second screenshot is a screenshot of a different script. For example, you could add a "Screenshot of the Python debugger on an equivalent script" caption to the image. Or, you could modify the screenshot highlighting the word "Python".

Chealer commented 3 months ago

there's no way to tell one environment variable from the other being local or not, so if you put all the environment variables in the locals list, it would be unreadable and nearly useless anyway.

That depends on how the list is sorted, and on whether it can be filtered.

Chealer commented 3 months ago

Can someone with the necessary privileges please:

  1. "pin" this ticket
  2. link to this ticket from the Overview tab's Limitations and known problems section (unless this can be fixed in the very short term)