如何在GDB中打印最后接收到的信号?

发布于 2024-12-27 09:18:57 字数 196 浏览 4 评论 0原文

当将核心转储加载到 GDB 时,会显示它自动崩溃的原因。例如

程序因信号 11(分段错误)而终止。

有什么办法可以再次获取信息吗? 问题是,我正在编写一个需要这些信息的脚本。但是,如果信号仅在加载核心转储后才可用,我以后将无法访问该信息。

这么重要的功能真的没有命令吗?

when loading a core dump into GDB the reason why it crashed automatically is displayed. For example

Program terminated with signal 11, Segmentation fault.

Is there any way to get the information again?
The thing is, that I'm writing a script which needs this information. But if the signal is only available after loading the core dump amd I can't access the information later on.

Is there really no command for such an important feature?

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

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

发布评论

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

评论(2

屋檐 2025-01-03 09:18:58

打印有关最后一个信号执行的信息

p $_siginfo

To print the information about the last signal execute

p $_siginfo
不乱于心 2025-01-03 09:18:58

如果您知道核心文件名是什么,则可以发出target core命令来重新指定目标核心文件:

(gdb) target core core.8577
[New LWP 8577]
Core was generated by `./fault'.
Program terminated with signal 11, Segmentation fault.
#0  0x080483d5 in main () at fault.c:10
10      *ptr = '\123';
(gdb) 

至于隐含的问题,info last signal是什么< /code> 命令?,我不知道。好像没有。


核心文件的名称可以通过命令 info target 获取:

(gdb) info target
Symbols from "/home/wally/.bin/fault".
Local core dump file:
    `/home/wally/.bin/core.8577', file type elf32-i386.
    0x00da1000 - 0x00da2000 is load1
    0x08048000 - 0x08049000 is load2
...
    0xbfe8d000 - 0xbfeaf000 is load14
Local exec file:
    `/home/wally/.bin/fault', file type elf32-i386.
    Entry point: 0x8048300
    0x08048134 - 0x08048147 is .interp
    0x08048148 - 0x08048168 is .note.ABI-tag
    0x08048168 - 0x0804818c is .note.gnu.build-id
    0x0804818c - 0x080481ac is .gnu.hash
    0x080481ac - 0x080481fc is .dynsym
    0x080481fc - 0x08048246 is .dynstr
...

If you know what the core file name is, you can issue the target core command which respecifies the target core file:

(gdb) target core core.8577
[New LWP 8577]
Core was generated by `./fault'.
Program terminated with signal 11, Segmentation fault.
#0  0x080483d5 in main () at fault.c:10
10      *ptr = '\123';
(gdb) 

As for the implied question, what is the info last signal command?, I don't know. There does not seem to be one.


The core file's name can be obtained from the command info target:

(gdb) info target
Symbols from "/home/wally/.bin/fault".
Local core dump file:
    `/home/wally/.bin/core.8577', file type elf32-i386.
    0x00da1000 - 0x00da2000 is load1
    0x08048000 - 0x08049000 is load2
...
    0xbfe8d000 - 0xbfeaf000 is load14
Local exec file:
    `/home/wally/.bin/fault', file type elf32-i386.
    Entry point: 0x8048300
    0x08048134 - 0x08048147 is .interp
    0x08048148 - 0x08048168 is .note.ABI-tag
    0x08048168 - 0x0804818c is .note.gnu.build-id
    0x0804818c - 0x080481ac is .gnu.hash
    0x080481ac - 0x080481fc is .dynsym
    0x080481fc - 0x08048246 is .dynstr
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文