linux进阶22——GDB(八):调试coredump文件时函数名显示为问号的解决方案

问题:

[root@localhost day7]# ls
core.test1.2051  core.test1.2066  test1  test1.cpp
[root@localhost day7]# gdb core.test1.2066 
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 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-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
[New LWP 2066]
Core was generated by `./test1'.
Program terminated with signal 6, Aborted.
#0  0x00007f21e61003d7 in ?? ()
"/home/gdb/day7/core.test1.2066" is a core file.
Please specify an executable to debug.
(gdb) bt
#0  0x00007f21e61003d7 in ?? ()  <-------------无法显示函数名
#1  0x00007f21e6101ac8 in ?? ()
#2  0x0000000000000020 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) where
#0  0x00007f21e61003d7 in ?? ()
#1  0x00007f21e6101ac8 in ?? ()
#2  0x0000000000000020 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) 

执行可执行程序test1生成core文件,通过gdb调试core,但是执行bt或where命令后函数名显示为问号。

解决方案:

gdb 应用程序(如:test1)

(gdb) core-file core

[root@localhost day7]# gdb test1
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
Copyright (C) 2013 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-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/gdb/day7/test1...(no debugging symbols found)...done.
(gdb) core-file core.test1.2066 
[New LWP 2066]
Core was generated by `./test1'.
Program terminated with signal 6, Aborted.
#0  0x00007f21e61003d7 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.17-323.el7_9.x86_64 libgcc-4.8.5-44.el7.x86_64
(gdb) bt
#0  0x00007f21e61003d7 in raise () from /lib64/libc.so.6
#1  0x00007f21e6101ac8 in abort () from /lib64/libc.so.6
#2  0x00007f21e6142f67 in __libc_message () from /lib64/libc.so.6
#3  0x00007f21e614b329 in _int_free () from /lib64/libc.so.6
#4  0x000000000040067e in DumpCrash() ()
#5  0x000000000040068a in main ()
(gdb) where
#0  0x00007f21e61003d7 in raise () from /lib64/libc.so.6
#1  0x00007f21e6101ac8 in abort () from /lib64/libc.so.6
#2  0x00007f21e6142f67 in __libc_message () from /lib64/libc.so.6
#3  0x00007f21e614b329 in _int_free () from /lib64/libc.so.6
#4  0x000000000040067e in DumpCrash() ()
#5  0x000000000040068a in main ()
(gdb) 

版权声明:本文为www_dong原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。