5

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,738
  • 21
  • 105
  • 131
  • 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

5

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
  • 199,314
  • 34
  • 295
  • 362