有些時候發佈出去的程序被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信息的文件]