code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

How to see global variables?

Open duhd1993 opened this issue 6 years ago • 3 comments

If submitting a bug please make sure

  • [x] If you are using gdb
    • [x] gdb --version >= 7.7.1
    • [x] it works on the command line with gdb
    • [x] cwd and target are properly set
  • [ ] If you are using lldb
    • [ ] lldb --version >= 3.7.1
    • [ ] it works on the command line with lldb-mi
    • [ ] cwd and target are properly set

Screenshots are helpful but not required I'm using vscode on Windows with the MingW toolset to write and debug Fortran code. I have gdb 8.1 and gfortran 8.1. I got some global variables declared in a module and used in other modules. The variables are not shown in the variables list (of course, it's showing local variables only). I can show them by print in the gdb console, and i can also add them to the watch list. But the watch list is not displaying the same way, making it hard to read. In watch: image in variable list: image

UPDATE: I just tried the Microsoft c/c++ ext. In watch list, it's also showing the same way as in the variable list. I'm switching to that before i get a solution with this ext.

duhd1993 avatar Feb 16 '19 01:02 duhd1993

there is no GDB MI command to list all variables. There has been one in version 5, but it seems to have been removed. There are too many globals in a program and the non-MI command info variables just lists their name and address so there would need to be some sort of lazy loading of values.

So this can't be implemented right now because there is no support for it in the debuggers.

WebFreak001 avatar Feb 16 '19 09:02 WebFreak001

@WebFreak001 Thank you for the reply. The microsoft c/c++ extension display the same variable in watch list as image which I think looks better. Is this something achievable?

duhd1993 avatar Feb 17 '19 22:02 duhd1993

uhh probably but I didn't really write it to be possible like that from the start so it would be difficult to make this work too I think

haven't touched the repo for a while

WebFreak001 avatar Feb 18 '19 17:02 WebFreak001