4

How do I print the local variables in GDB every "next" or "step" command?

Is there a way instead of writing "info locals" every time?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
  • 1
    The answer for https://stackoverflow.com/questions/4362581/how-to-get-gdb-to-do-a-list-after-every-step happens to apply here also, with a trivial adjustment – Michael Veksler Aug 30 '18 at 07:11

1 Answers1

4

If you can use GDB TUI mode, that's probably best. See this answer.

If you can't use TUI for some reason, this should also work:

# put this into ~/.gdbinit:
define hook-next
  info locals
end

More info on hooking commands here.

Employed Russian
  • 182,696
  • 29
  • 267
  • 329