使用GDB在代码块中添加和删除断点时,为什么会引发SIGTRAP和SIGILL?

时间:2018-07-20 13:42:28

标签: gdb codeblocks gnu-toolchain

我正在将CodeBlocks 17.12 bundled 与MingGW一起使用:GDB 7.11.1,mingw32-gcc 5.1.0和mingw32-g ++ 5.1.0。

在程序运行时设置断点时,我会收到SIGTRAP信号。我能够继续通过断点并多次击中它。当我删除断点时,该程序仍与SIGTRAP停在同一行。在下一次继续时,它会以SIGILL停止,我不再能够继续。

在第9行(cout行)设置断点:

#include <iostream>

using namespace std;

int main()
{
    for(int i = 0; i < 65000; i++)
    {
        cout << "Hello world!" << endl;
    }
    return 0;
}

代码块中的调试器输出:

Trying to interrupt process with pid: 19600; child pid: 19600 gdb pid: 20264
Continuing...
Program received signal SIGTRAP, Trace/breakpoint trap.
At C:\Users\twalczak\Desktop\test\main.cpp:9
Continuing...
At C:\Users\twalczak\Desktop\test\main.cpp:9
Continuing...
At C:\Users\twalczak\Desktop\test\main.cpp:9
Continuing...
At C:\Users\twalczak\Desktop\test\main.cpp:9
Continuing...
At C:\Users\twalczak\Desktop\test\main.cpp:9
Continuing...
At C:\Users\twalczak\Desktop\test\main.cpp:9
PC register is not available                   <-- 'Breakpoint removed at this point'
Continuing...
Program received signal SIGTRAP, Trace/breakpoint trap.
At C:\Users\twalczak\Desktop\test\main.cpp:9
Continuing...
Program received signal SIGILL, Illegal instruction.
At C:\Users\twalczak\Desktop\test\main.cpp:9

编辑,因为我使用的是自定义MinGW安装,而不是捆绑安装,因此删除了捆绑。

1 个答案:

答案 0 :(得分:0)

我克服了这个问题,指向CodeBlocks来使用它捆绑在的MinGW安装

C:\Program Files (x86)\CodeBlocks\MinGW 

代替我的安装

C:\MinGW