本文介绍了在GDB中遍历C ++ throw语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用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继续运行直到下一个断点,而不是在 catch 块的第一行内停止.

then GDB continues to run until the next breakpoint instead of stopping within the first line of the catch block.

这是GDB中的错误,还是我使用了错误的命令?

Is this a bug within GDB, or am I just using the wrong command?

我在 MinGW32 /Windows上使用GDB版本7.7.

I'm using GDB version 7.7 on MinGW32 / Windows.

推荐答案

在Linux上,此方法正常运行.尤其是,在引发异常时使用的低级展开代码中有一个特殊的调试标记(函数或"SDT探针",取决于事物的构建方式).GDB在此放置了一个断点.当达到此断点时,GDB会检查 throw 的目标堆栈框架,如果它位于 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 nexting frame, puts a temporary breakpoint at the target of the throw.

这需要在GDB中进行一些更改,但也需要在C ++运行时中进行一些更改,以便向GDB通知 throw .据我所知,没有人做过将代码移植到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 throws. 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语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:58