Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a breakpoint in gdb for all invocations of a function?

Tags:

c++

gdb

I have a third part library function call scattered at a lot of places in my executable. My executable is built using debug symbols, but the third party library does not have the debug symbols, hence I cannot place a breakpoint on the function. I want to put a breakpoint whenever the library function is called, to examine the call stack. How can I set a breakpoint at all invocations of a library function call within my executable.

like image 749
paseena Avatar asked Oct 06 '22 18:10

paseena


1 Answers

I think that the only way is to:

  • find any call of this function in your code;
  • create a breakpoint in that line;
  • run the debugger and stop there;
  • write in gdb nexti to get to the first function instruction;
  • get current eip which will point at the beginning of that function;
  • create a new breakpoint at the address pointed by eip;
like image 88
Adam Sznajder Avatar answered Oct 10 '22 02:10

Adam Sznajder