开发者

GCC debugging option -dH

开发者 https://www.devze.com 2023-03-01 03:17 出处:网络
From this link: http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html -dH Produce a core dump whenever an error occurs.

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 开发者_JS百科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?


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/.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消