dev*_*vil 8 c++ debugging winapi gdb assert
如何在窗口上设置gdb,以便它不允许断言失败的程序终止?我打算检查程序中的堆栈跟踪和变量.
例如,g++ -g test.cpp -o test在gdb中运行使用MinGW编译的test.cpp程序:
#include <cassert>
int main(int argc, char ** argv) { assert(1==2); return 0; }
Run Code Online (Sandbox Code Playgroud)
得到:
$ gdb test.exe
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32"...
(gdb) r
Starting program: f:\code/test.exe
[New thread 4616.0x1200]
Error: dll starting at 0x77030000 not found.
Error: dll starting at 0x75f80000 not found.
Error: dll starting at 0x77030000 not found.
Error: dll starting at 0x76f30000 not found.
Assertion failed: 1==2, file test.cpp, line 2
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Program exited with code 03.
(gdb)
Run Code Online (Sandbox Code Playgroud)
我希望能够阻止程序立即终止,就像Visual Studio的调试器和Linux上的gdb一样.我做了一个搜索,发现了捕获信号的一些东西,但我似乎无法找到关于如何设置gdb来做到这一点的好帖子.
发现断点可以放在.gdbinit带有以下行的文件中:
set breakpoint pending on
b exit
Run Code Online (Sandbox Code Playgroud)
这消除了为Windows输入yes的需要.
| 归档时间: |
|
| 查看次数: |
3820 次 |
| 最近记录: |