GDB。只捕获未捕获的异常

问题描述 投票:0回答:2

像这样捕获,使用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
c++ c gdb
2个回答
4
投票

catch throw
将捕获所有抛出的异常,并且没有办法限制它。

您在这里至少有两个选择。你可以根本不使用

catch throw
,如果你使用某种风格的unix,它会分段错误并在抛出异常时停止,如果它不会被捕获。

或者,您可以在

__raise_exception
上设置断点,如 ftp://ftp.gnu.org/pub/old-gnu/Manuals/gdb/html_node/gdb_30.html (这是我使用时的第一个命中) google - 在 Stackoverflow 上发帖之前请尝试先研究一下自己)。


0
投票

使用“捕获未处理的异常”

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.