Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1361813
  • 博文数量: 343
  • 博客积分: 13098
  • 博客等级: 上将
  • 技术积分: 2862
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-06 00:35
文章存档

2012年(131)

2011年(31)

2010年(53)

2009年(23)

2008年(62)

2007年(2)

2006年(36)

2005年(5)

分类: C/C++

2008-07-06 22:28:34

gdb allows you to put a program’s debugging information in a ?le separate from the executable itself, in a way that allows gdb to find and load the debugging information automatically. Since debugging information can be very large — sometimes larger than the executable code itself — some systems distribute debugging information for their executables in separate files, which users can install only when they need to debug a problem.

If an executable’s debugging information has been extracted to a separate file, the executable should contain a debug link giving the name of the debugging information file(with no directory components), and a checksum of its contents.


1. Link the executable as normal. Assuming that is is called "foo":
   gcc -g -o foo foo.c

2. Run "objcopy --only-keep-debug foo foo.dbg" to create a file containing the debugging info.

3. Run "objcopy --strip-debug foo" to create a stripped executable 

4. Run "objcopy --add-gnu-debuglink=foo.dbg foo" to add a link to the debugging info into the stripped executable.

5. Run "objdump -s -j .gnu_debuglink fp" to verify debug link:

brian@debian:~/ctest$ objdump -s -j .gnu_debuglink fp

fp: file format elf32-i386

Contents of section .gnu_debuglink:
0000 66702e64 62670000 67b83207 fp.dbg..g.2.
brian@debian:~/ctest$







阅读(1359) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~