Print local variables in GDB

Viewed 5341

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?

1 Answers

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.

Related