简体   繁体   English

跳过 GDB 中的 C++ throw 语句

[英]Step over a C++ throw statement in GDB

When debugging a C++ program with the GNU GDB debugger, I can step over the next line of code with the GDB command:使用 GNU GDB 调试器调试 C++ 程序时,我可以使用 GDB 命令跳过下一行代码:

next

However, when an exception is thrown within that next line, like eg但是,当在下一行中抛出异常时,例如

throw SomeException();

then GDB continues to run until the next breakpoint instead of stopping within the first line of the catch block.然后 GDB 继续运行直到下一个断点,而不是在catch块的第一行内停止。

Is this a bug within GDB, or am I just using the wrong command?这是 GDB 中的错误,还是我只是使用了错误的命令?

I'm using GDB version 7.7 on MinGW32 / Windows.我在MinGW32 /Windows 上使用 GDB 7.7 版。

On Linux this works properly.在 Linux 上这可以正常工作。 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.特别是在抛出异常时使用的低级展开代码中有一个特殊的调试标记(函数或“SDT 探测器”,取决于事物的构建方式)。 GDB puts a breakpoint at this spot. GDB 在这个位置设置了一个断点。 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 检查throw的目标堆栈帧,如果它next ing 帧之上,则在throw的目标处放置一个临时断点。

This required some changes in GDB, but also some changes in the C++ runtime in order to inform GDB about throw s.这需要在 GDB 中进行一些更改,还需要在 C++ 运行时中进行一些更改,以便将throw通知 GDB。 As far as I know, nobody has ever done the work to port this code to MinGW.据我所知,没有人做过将这段代码移植到 MinGW 的工作。 Maybe it could be done by modifying the appropriate unwind-mumble.c file in the GCC sources.也许可以通过修改 GCC 源代码中适当的unwind-mumble.c文件来完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM