Muhammad Khaled
Muhammad Khaled

Reputation: 61

Print local variables in GDB

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?

Upvotes: 6

Views: 8671

Answers (1)

Employed Russian
Employed Russian

Reputation: 213897

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.

Upvotes: 5

Related Questions