and I would like to know if there is any way to stop a program when is using a function from a certain file. Ideally what I am looking for is something like:
GDB Stop when use a function from file foo.cpp
The reason to do this is because I am debugging a code that is not mine and I do not know exactly what functions are been called and what functions are not. Is there a function in GDB to do what I am looking for, or any other recommended way to do something similar?.
Thanks
Step 1: construct a list of all functions defined in
foo.cppThe simplest way I can think of (assuming you have
binutilsand GNUgrep):Step 2: construct a GDB script which will set a break point on each of the above functions:
[Obviously, steps 1 and 2 could be combined ;-]
Step 3: actually set the breakpoints:
Looking at this answer, an even simpler (if you are on Fedora Linux) way to find out which foo.cpp functions are called:
Too bad ftrace man page says this isn’t implemented yet.