开发者

gdb catchpoint for uncaught C++ exceptions only?

I can tell the gdb debugger to stop as soon as any C++ exception is thrown by setting a catchpoint with the gdb command

catch throw

However, is there any way to only stop at uncaught C++ ex开发者_运维问答ceptions (like in C# or Java)? This would make it much easier to find bugs in some situations.

Thanks!


If an exception is uncaught, the special library function terminate() is automatically called. Terminate is actually a pointer to a function and default value is the Standard C library function abort(). You may be able to set a breakpoint on the call to the abort() function and identify the location of the uncaught exception from there.

break abort
...
run
...
bt

You can install your own terminate() function by using std::set_terminate(). You should be able to set a breakpoint on your terminate function in gdb. You may be able to generate a stack backtrace from your terminate() function and this backtrace may help in identifying the location of the exception. Additional details are provided here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜