问题描述
当使用GNU gdb调试器调试C ++程序时,我可以使用gdb命令跳过下一行代码
When debugging a C++ program with the GNU gdb debugger, I can step over the next line of code with the gdb command
next
但是,当下一行中抛出异常时,例如
However, when an exception is thrown within that next line, like e.g.
throw SomeException();
然后gdb继续运行直到下一个断点,而不是在<$ c的第一行内停止$ c> catch 块。
then gdb continues to run until the next breakpoint instead of stopping within the first line of the catch
block.
这是gdb中的错误,还是我使用了错误的命令?我在mingw32 / Windows上使用的是gdb版本7.7。
Is this a bug within gdb, or am I just using the wrong command? I'm using gdb version 7.7 on mingw32 / Windows.
推荐答案
在Linux上,此功能正常运行。特别是,在引发异常时使用的低级展开代码中有一个特殊的调试标记(函数或 SDT探针,具体取决于构建方式)。 gdb在该位置放置一个断点。当达到此断点时,gdb会检查抛出
的目标堆栈帧,如果它位于 next
之上,框架,在抛出
的目标处放置一个临时断点。
On Linux this works properly. In particular there is a special debugging marker (either a function or an "SDT probe", depending on how things were built) in the low-level unwinding code that is used when an exception is thrown. gdb puts a breakpoint at this spot. When this breakpoint is hit, gdb examines the target stack frame of the throw
and, if it is above the next
ing frame, puts a temporary breakpoint at the target of the throw
.
这需要对gdb进行一些更改,但也需要进行一些更改为了通知gdb 抛出
s,在C ++运行时中进行了更改。据我所知,没有人做过将代码移植到mingw的工作。也许可以通过修改gcc来源中的相应 unwind-mumble.c
文件来完成。
This required some changes in gdb but also some changes in the C++ runtime in order to inform gdb about throw
s. As far as I know, nobody has ever done the work to port this code to mingw. Maybe it could be done by modifying the appropriate unwind-mumble.c
file in the gcc sources.
这篇关于gdb:在C ++中跳过throw语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!