Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gdb

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

like image 310
compile-fan Avatar asked Jan 28 '26 16:01

compile-fan


2 Answers

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();
like image 180
matt Avatar answered Jan 31 '26 02:01

matt


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).
like image 21
Itamar Katz Avatar answered Jan 31 '26 04:01

Itamar Katz