Is there a GUI (or even a script for the CLI) for GDB that will annotate views of the stack with saved registers, each of the frames, etc? It should be possible to gather this information on each call and add it to a view of the stack. Currently, I just end up looking at the stack with something like x/40wx $esp
, which isn't amazingly enlightening.
1 Answer
As 0xC0000022L was mentioning it in the comments to your question, GDB already has such features through the info frame
command (shorthand i f
) and the backtrace
command (shorthand bt
).
(gdb) info frame
Stack level 0, frame at 0x7fffffffe250:
rip = 0x400517 in foo (hello.c:6); saved rip 0x400531
called by frame at 0x7fffffffe260
source language c.
Arglist at 0x7fffffffe240, args: val=10
Locals at 0x7fffffffe240, Previous frame's sp is 0x7fffffffe250
Saved registers:
rbp at 0x7fffffffe240, rip at 0x7fffffffe248
(gdb) backtrace
#0 foo (val=10) at hello.c:6
#1 0x0000000000400531 in main () at hello.c:12
(gdb)
You may find some other commands about stack exploration in the GDB manual: Examining the stack.
frame
or thebacktrace
command shows what you are interested in? Automating traversal of the frames should be possible.