有些时候发布出去的程序被strip后,出了core后没法调试。。因为缺乏调试符号文件。html
能够用linux
将test的调试信息保存到 test.debug文件中。须要的时候装入就可。、redis
[root@localhost gxh]# objcopy --only-keep-debug t test.debug ide
[root@localhost gxh]# strip -s tspa
[root@localhost gxh]# gdb tdebug
GNU gdb Fedora (6.8-27.el5)调试
Copyright (C) 2008 Free Software Foundation, Inc.htm
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>blog
This is free software: you are free to change and redistribute it.ip
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(no debugging symbols found)
(gdb) l
No symbol table is loaded. Use the "file" command.
(gdb) file test.debug
Reading symbols from /root/gxh/test.debug...done.
(gdb) l
100 {
101 sum += i;
102 }
103 return sum;
104 }
105 #include <sys/time.h>
106 #include <fstream>
107
108 using namespace std;
109 int main(int argc,char* argv[])
(gdb)
#objcopy --only-keep-debug [被提取的文件] [提取出来的调试符号文件,建议加.debug后缀]另外要把调试信息去掉是用strip命令。你能够man下看看。strip --strip-debug [须要处理的文件]把debug信息加回去:objcopy --add-gnu-debuglink=[debug文件] [须要添加debug信息的文件]