Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I jump to a frame in a stack trace according to the function name in gdb?

People also ask

What GDB command verifies and displays the stack frames?

Selects a stack frame or displays the currently selected stack frame.

What are the three commands used in GDB to examine and move within the stack?

Able to view and traverse the function call stack using the where, up, down and frame commands.

What does frame do in GDB?

The frame command allows you to move from one stack frame to another, and to print the stack frame you select. args may be either the address of the frame or the stack frame number. Without an argument, frame prints the current stack frame.

What does BT do in GDB?

To print a backtrace of the entire stack, use the backtrace command, or its alias bt . This command will print one line per frame for frames in the stack. By default, all stack frames are printed. You can stop the backtrace at any time by typing the system interrupt character, normally Ctrl-c .


Two options:

  • up 200 will bring you up 200 frames
  • If you know the initial caller of the recursive routine, you can do f[rame] <caller-func> - this will jump to the frame of address caller-func.

See Frame Selection in the manual.


You have to use bt with minus. It is similar to bt, but print first the outermost n frames.
For example:
bt -100

And it is likely you will see the frame that you need to inspect on the first or second screen.
Once insecting the stack trace using bt -100 helped me to fix a pboblem with a lot of recursive calls easily.

And then issue command
f <here the number of your frame you need to inspect>