How does gdb work?

I need help understanding how to use gdb with gfortran. In particular how do I refer to a variable in the calling routine if the program errors out in a called routine. My program is dying in an I/O library with no symbols, but I could probably figure out the problem if I could look at values in the calling routine. documentation isn’t much help I tried
p ‘test.for’::x
p _main::x
But those aren’t valid gdb commands.

Daniel Feenberg

move to the right stack frame (i.e. up), and then you should be able to print x. Getting comfortable with the debugger takes some time.

It has been a while since I’ve used GDB, but there’s this one command, info locals, I found very useful when debugging procedures. It displays the values of all local variables in that procedure.

1 Like

Maybe it is helpful to use a graphical frontend for gdb, which is available for a lot of IDEs (Emacs, VS Code, Eclipse).