【问题标题】:GCC debugging option -dHGCC 调试选项 -dH
【发布时间】:2011-04-27 06:15:25
【问题描述】:

来自这个链接:http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.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:没有这样的文件或目录。 我应该如何使用该核心文件?

【问题讨论】:

    标签: gcc


    【解决方案1】:

    我认为这个开关是为了帮助调试 gcc,而不是你的程序。 page you link to 开头是这样的:

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

    强调我的。

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

    【讨论】:

    • 也许你是对的,GDB有什么选项可以找到语法错​​误吗?
    • @Anisha:我认为您需要了解 GCC 内部结构才能弄清楚语法错误是什么。
    【解决方案2】:

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

    【讨论】:

    • 它没有用:我写了:gdb -c core 而GDB说:(gdb) r Starting program: No executable file specified. Use the "file" or "exec-file" command. (gdb)
    • @Anisha Kaul 我不明白。既然您知道由于您引入的错误而没有生成可执行文件,为什么还要在 gdb 中尝试run?检查核心文件应该可以工作。检查框架等。
    • GCC 说(如第一篇文章所示):gcc: Internal error: Aborted (program cc1) 所以我认为 cc1 可能是某种可执行文件 :eek: 核心文件不是人类可读的,那么我应该如何检查它们?其次你让我跑:gdb -c core?
    • gdb -c core 是要求 gdb 打开核心文件的一种方式。它内置了用于检查核心文件的命令。也许你可以尝试调试 cc1 二进制文件,但这需要更多的工作和 gcc 内部的知识
    • gdb -c core 只是拒绝工作,至少在这种情况下是这样。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-27
    • 2018-11-10
    • 2013-01-17
    • 2013-03-28
    • 2011-07-15
    • 1970-01-01
    • 2020-08-25
    相关资源
    最近更新 更多