我试图做一些半测试驱动的设计,偶尔当我实现一个新功能时,它会在某个地方出现异常。所有gtest都告诉我异常是什么,并没有给我任何回溯信息。
如果我运行gdb --args --gtest_catch_exceptions = 0,它将在测试时停止,但没有任何回溯信息。它只是声明:
[ RUN ] TESTNAME.test_case
EXCEPTION: exception description[Inferior 1 (process 30528) exited with code 0377]
(gdb) bt
No stack.
答案 0 :(得分:3)
使用catch throw
gdb命令在抛出异常之前设置特殊断点。当它被击中时,您可以像往常一样通过命令bt
看到回溯。请参阅https://sourceware.org/gdb/onlinedocs/gdb/Set-Catchpoints.html。
答案 1 :(得分:3)
以更自动的方式,您可以add your own listener然后通过使用How to make backtrace()/backtrace_symbols() print the function names?
打印其他回溯来合并失败的测试用例的输出