GCC 调试选项 -dH

发布于 2024-11-03 13:08:21 字数 1617 浏览 2 评论 0原文

通过此链接: http://gcc.gnu.org/onlinedocs/gcc/Debugging -选项.html

-dH 每当发生错误时生成核心转储。

因此,我编译了一个有语法错误的程序并生成了核心文件。现在如何使用该核心文件?由于尚未生成任何可执行文件,因此无法调用 GDB。

[11:11:12 Wed Apr 27]
~/junk1  $ls
core  hell.c

[11:11:15 Wed Apr 27]
~/junk1  $gcc -g hell.c -dH
hell.c: In function ‘main’:
hell.c:4: error: expected ‘;’ before ‘}’ token
gcc: Internal error: Aborted (program cc1)
Please submit a full bug report.
See <http://bugs.opensuse.org/> for instructions.

[11:11:36 Wed Apr 27]
~/junk1  $ls
core  hell.c

[11:12:09 Wed Apr 27]
~/junk1  $gdb cc1 core
GNU gdb (GDB) SUSE (6.8.91.20090930-2.4)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
***cc1: No such file or directory.***
Missing separate debuginfo for the main executable file
Try: zypper install -C "debuginfo(build-id)=41f1efcceccfa5fa0b3476021c731c489547f86e"
Core was generated by `/usr/lib64/gcc/x86_64-suse-linux/4.4/cc1 -quiet hell.c -quiet -dumpbase hell.c'.
Program terminated with signal 6, Aborted.
#0  0x00007fb1b01654e5 in ?? ()
(gdb)

GDB 在上面的输出中显示: cc1:没有这样的文件或目录。 我应该如何使用该核心文件?

From this link: http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

-dH Produce a core dump whenever an error occurs.

So, I compiled a program with a syntax error and the core file was generated. How can that core file be used now? GDB can't be invoked since any executable has not been generated, yet.

[11:11:12 Wed Apr 27]
~/junk1  $ls
core  hell.c

[11:11:15 Wed Apr 27]
~/junk1  $gcc -g hell.c -dH
hell.c: In function ‘main’:
hell.c:4: error: expected ‘;’ before ‘}’ token
gcc: Internal error: Aborted (program cc1)
Please submit a full bug report.
See <http://bugs.opensuse.org/> for instructions.

[11:11:36 Wed Apr 27]
~/junk1  $ls
core  hell.c

[11:12:09 Wed Apr 27]
~/junk1  $gdb cc1 core
GNU gdb (GDB) SUSE (6.8.91.20090930-2.4)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
***cc1: No such file or directory.***
Missing separate debuginfo for the main executable file
Try: zypper install -C "debuginfo(build-id)=41f1efcceccfa5fa0b3476021c731c489547f86e"
Core was generated by `/usr/lib64/gcc/x86_64-suse-linux/4.4/cc1 -quiet hell.c -quiet -dumpbase hell.c'.
Program terminated with signal 6, Aborted.
#0  0x00007fb1b01654e5 in ?? ()
(gdb)

The GDB says: cc1: No such file or directory, in the above output.
How I am supposed to use that core file?

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

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

发布评论

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

评论(2

﹏雨一样淡蓝的深情 2024-11-10 13:08:21

我认为这个开关是为了帮助调试gcc,而不是你的程序。 链接到的页面如下所示:

3.9 调试程序的选项或 GCC
GCC 有各种特殊选项,可用于调试您的程序或 GCC

强调我的。

cc1 程序是 GCC 的内部部分,它可能位于 /usr/lib//usr/libexec/ 下的某个位置。

I think that switch is to help debug gcc, not your program. The page you link to starts like this:

3.9 Options for Debugging Your Program or GCC
GCC has various special options that are used for debugging either your program or GCC:

Emphasis mine.

The cc1 program is an internal part of GCC, it is probably somewhere under /usr/lib/ or /usr/libexec/.

暮倦 2024-11-10 13:08:21

gdb -c corefile 应该可以工作。我不必使用 -dH 选项,因此不确定它在帮助调试方面有多大用处。

gdb -c corefile should work. I haven't had to use the -dH option, so not sure how useful it is in helping with debugging.

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