GCC调试选项-dH

时间:2011-04-27 06:15:25

标签: gcc

从此链接: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:在上面的输出中没有这样的文件或目录。 我该如何使用该核心文件?

2 个答案:

答案 0 :(得分:1)

我认为切换是为了帮助调试 gcc ,而不是你的程序。 page you link to的开头如下:

  

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

强调我的。

cc1计划是GCC的内部部分,可能位于/usr/lib//usr/libexec/之下。

答案 1 :(得分:1)

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