compile-fan
compile-fan

Reputation: 17615

How to know which file a specific function is in with gdb?

Anyone knows how to know which file a specific function is in with gdb?

Upvotes: 3

Views: 1047

Answers (2)

matt
matt

Reputation: 5614

there is also info func which accepts a regular expression.

(gdb) info func ^bp1$
All functions matching regular expression "^bp1$":

File test.c:
void bp1();

Upvotes: 2

Itamar Katz
Itamar Katz

Reputation: 9645

Assuming the function name is someFunc, first find the address of the function:

info address someFunc

And assuming you got the adress someAddress, use list with that address:

list *someAddress

Example from a gdb session:

(gdb) info address main
Symbol "main" is a function at address 0x406159.
(gdb) list *0x406159
0x406159 is in main (../src/staapp-test.cpp:221).

Upvotes: 1

Related Questions