像这样捕获,使用GDB:
catch throw
当抛出异常时,程序停止。
如何让GDB在抛出异常但被程序捕获时不停止? 或者我应该使用全局 try-catch 而不是 使用 GDB
catch throw
?
编辑1
try
{
// every time exception is thrown
// program is stopped by GDB
}
catch(const std::exception &e)
{
// even if the exception is caught by the program
}
EDIT2启动gdb
gdb
file /usr/home/user/program
shell ps x
attach #pid
catch throw
c
catch throw
将捕获所有抛出的异常,并且没有办法限制它。
您在这里至少有两个选择。你可以根本不使用
catch throw
,如果你使用某种风格的unix,它会分段错误并在抛出异常时停止,如果它不会被捕获。
或者,您可以在
__raise_exception
上设置断点,如 ftp://ftp.gnu.org/pub/old-gnu/Manuals/gdb/html_node/gdb_30.html (这是我使用时的第一个命中) google - 在 Stackoverflow 上发帖之前请尝试先研究一下自己)。
使用“捕获未处理的异常”