linux调试符号表,linux保存调试符号表

有些时候发布出去的程序被strip后,出了core后无法调试。。由于缺少调试符号文件。

可以用

objcopy --only-keep-debug test test.debug

将test的调试信息保存到 test.debug文件中。需要的时候装入就可。、

[root@localhost gxh]# objcopy --only-keep-debug t test.debug

[root@localhost gxh]# strip -s t

[root@localhost gxh]# gdb t

GNU gdb Fedora (6.8-27.el5)

Copyright (C) 2008 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later

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 "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

106     #include

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信息的文件]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值