linux - GDB 不会介入一个文件之外的功能

标签 linux debugging gdb

我尝试使用 gdbstep 函数调试我的程序。 只要函数在同一个文件中,一切都可以正常工作。

但是如果函数在外面,gdb 会跳过它。

我该如何解决?

注意:

  • 我使用 -ggdb 选项编译
  • 我正在使用 GNU gdb Red Hat Linux (6.7-1rh)
    (如果可能的话,出现在 gdb 的启动频率中)

例子:

#include "foo2.h"  // contains function foo2

void foo(void){ printf("hello"); }


void main (void){

  foo();    // debuggable -> jump into possible
  foo2();   // not debuggable 


}

最佳答案

使用 gdb 调试应用程序时,请使用 si (stepi) 而不是 ni (nexti)。 si 将进入其他函数,ni 停留在当前函数内。查看 http://sourceware.org/gdb/current/onlinedocs/gdb/Continuing-and-Stepping.html#Continuing-and-Stepping 处的文档更多信息(^F 表示 nexti 或 stepi)。

关于linux - GDB 不会介入一个文件之外的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12956486/

相关文章:

无法在 gdb 中重现段错误

c - 在 Linux 上检测键盘按键按下和释放

c++ - 是否可以使用 IDiaDataSource::LoadDataFromPdb 从符号存储中读取 pdb?

c - 从调试器中退出段错误

javascript - 如何获取 Firefox 调试器监视的目标元素?

java - 共享首选项未更新

linux - 64 位上的堆栈驻留缓冲区溢出?

linux - 无法访问 apache http 服务器上的 .mov 文件

linux - "wc -w < file.txt"是如何工作的?

c - 我如何在 ncurses 中使用超过 8 种颜色?