简体   繁体   English

如何在gdb中为函数的所有调用设置断点?

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

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. 如何在我的可执行文件中的库函数调用的所有调用中设置断点。

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; 写入gdb nexti以获取第一个函数指令;
  • get current eip which will point at the beginning of that function; 得到当前的eip,它将指向该函数的开头;
  • create a new breakpoint at the address pointed by eip; 在eip指向的地址创建一个新的断点;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM