jonathan_ou
jonathan_ou

Reputation: 766

How to Determine Which Shared Library a Function Belongs to in gdb?

When I get the callstack from gdb, I only get function names and source file information.

(gdb) f
#0  main (argc=1, argv=0xbffff1d4) at main.c:5

I don't get which Shared Library or Application the function belongs to.

On Windows, Windbg or Visual Studio will show callstacks with "myDll!myFunc" format, which shows you which module the function belongs to.

Currently in gdb I'm using "info address [function]" to get the address of the function symbol, and then use "info share" to manually find the range in which the function lies in memory to determine which library it is in.

Anyway to see the library directly without this manual process?

Upvotes: 15

Views: 7950

Answers (1)

user184968
user184968

Reputation:

You can use info symbol. It prints a library name for a function.

Like this:

(gdb) info symbol f
f(double) in section .text of libmylib_gcc.so

(gdb) info symbol printf
printf in section .text of /lib64/libc.so.6

Upvotes: 23

Related Questions