Dean
Dean

Reputation: 6958

gdb - how to find current module for a stack frame

After navigating to a stack frame with f stack_frame_number I might see its source code if debugging infos are present and up-to-date. Anyway, how to find out which module my current stack frame is into?

E.g.

(gdb) print current_module
Your stack frame is in libTest.so.1

Is there any way to accomplish this?

Upvotes: 2

Views: 1818

Answers (1)

Mark Plotnick
Mark Plotnick

Reputation: 10271

Gdb provides the symbol $pc as a synonym for the instruction pointer in the current frame.

You can use this with the info symbol command to show the executable or shared library corresponding to that frame:

(gdb) info symbol $pc
pause + 20 in section .text of /lib/x86_64-linux-gnu/libc.so.6
(gdb) up
(gdb) info symbol $pc
main + 9 in section .text of /home/mp/m

Upvotes: 7

Related Questions