Emacs/gud-gdb:失败时显示断言位置

发布于 2024-12-11 02:04:53 字数 644 浏览 8 评论 0原文

当代码中的断言失败时,我会从 gdb 得到如下回溯:

(gdb) bt
#0  0x00007ffff455b3a5 in __GI_raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff455eb0b in __GI_abort () at abort.c:92
#2  0x00007ffff4553d4d in __GI___assert_fail (
    assertion=0x123136d "<some failed test>", file=<optimized out>, 
    line=1573, function=<optimized out>) at assert.c:81
#3  <the actual place in my code where I called assert>
    ...

因此,为了到达实际的失败点,我必须“up” <返回>',这看起来效率有点低。有没有办法配置 gdb 自动转到堆栈中的#3?我对在 emacs 中运行 gdb 特别感兴趣,因此如果有一种方法可以配置 gud 来执行此操作,那也可以。

When an assertion in my code fails, I get a backtrace like this from gdb:

(gdb) bt
#0  0x00007ffff455b3a5 in __GI_raise (sig=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff455eb0b in __GI_abort () at abort.c:92
#2  0x00007ffff4553d4d in __GI___assert_fail (
    assertion=0x123136d "<some failed test>", file=<optimized out>, 
    line=1573, function=<optimized out>) at assert.c:81
#3  <the actual place in my code where I called assert>
    ...

So in order to get to the actual point of failure I have to go 'up <RET> <RET> <RET>', which seems a bit inefficient. Is there a way to configure gdb to automatically go to #3 in the stack? I'm specifically interested in running gdb in emacs, so if there's a way to configure gud to do it, that would work too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷你仙 2024-12-18 02:04:53

我必须去'向上; <返回>'

您可以执行fr 3

有没有办法配置 gdb 自动转到堆栈中的#3?

我不相信是这样。

I have to go 'up <RET> <RET> <RET>'

You could do fr 3 instead.

Is there a way to configure gdb to automatically go to #3 in the stack?

I don't believe so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文