Debugging Information in Separate Files
[Debugging Information in Separate Files]
gdb allows you to put a program's debugging information in a file 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.
gdb supports two ways of specifying the separate debug info file:
- The executable contains a debug link that specifies the name of the separate debug info file. The separate debug file's name is usually executable.debug, where executable is the name of the corresponding executable file without leading directories (e.g., ls.debug for /usr/bin/ls). In addition, the debug link specifies a 32-bit Cyclic Redundancy Check (CRC) checksum for the debug file, which gdb uses to validate that the executable and the debug file came from the same build.
- The executable contains a build ID, a unique bit string that is also present in the corresponding debug info file. (This is supported only on some operating systems, notably those which use the ELF format for binary files and the gnu Binutils.) For more details about this feature, see the description of the --build-id command-line option in Command Line Options. The debug info file's name is not specified explicitly by the build ID, but can be computed from the build ID, see below.
Depending on the way the debug info file is specified, gdb uses two different methods of looking for the debug file:
- For the “debug link” method, gdb (1) looks up the named file in the directory of the executable file, then (2) in a subdirectory of that directory named .debug, and finally (3) under each one of the global debug directories, in a subdirectory whose name is identical to the leading directories of the executable's absolute file name.
- For the “build ID” method, gdb looks in the .build-id subdirectory of each one of the global debug directories for a file named nn/nnnnnnnn.debug, where nn are the first 2 hex characters of the build ID bit string, and nnnnnnnn are the rest of the bit string. (Real build ID strings are 32 or more hex characters, not 10.)
So, for example, suppose you ask gdb to debug /usr/bin/ls, which has a debug link that specifies the file ls.debug, and a build ID whose value in hex is abcdef1234. If the list of the global debug directories includes /usr/lib/debug, then gdb will look for the following debug information files, in the indicated order:
- /usr/lib/debug/.build-id/ab/cdef1234.debug
- /usr/bin/ls.debug
- /usr/bin/.debug/ls.debug
- /usr/lib/debug/usr/bin/ls.debug.
Global debugging info directories default to what is set by gdb configure option --with-separate-debug-dir. During gdb run you can also set the global debugging info directories, and view the list gdb is currently using.
set debug-file-directory directories
Set the directories which gdb searches for separate debugging information files to directory. Multiple path components can be set concatenating them by a path separator.
show debug-file-directory- Show the directories gdb searches for separate debugging information files.
.gnu_debuglink with the contents described above..note.gnu.build-id, but that name is not mandatory. It contains unique identification for the built files—the ID remains the same across multiple builds of the same build tree. The default algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the content for the build ID string. The same section with an identical value is present in the original built binary with symbols, in its stripped variant, and in the separate debugging information file.The debugging information file itself should be an ordinary executable, containing a full set of linker symbols, sections, and debugging information. The sections of the debugging information file should have the same names, addresses, and sizes as the original file, but they need not contain any data—much like a .bss section in an ordinary executable.
The gnu binary utilities (Binutils) package includes the ‘objcopy’ utility that can produce the separated executable / debugging information file pairs using the following commands:
objcopy --only-keep-debug foo foo.debug
strip -g foo
These commands remove the debugging information from the executable file foo and place it in the file foo.debug. You can use the first, second or both methods to link the two files:
- The debug link method needs the following additional command to also leave behind a debug link in foo:
objcopy --add-gnu-debuglink=foo.debug foo
Ulrich Drepper's elfutils package, starting with version 0.53, contains a version of the
stripcommand such that the command strip foo -f foo.debug has the same functionality as the twoobjcopycommands and theln -scommand above, together. - Build ID gets embedded into the main executable using
ld --build-idor the gcc counterpartgcc -Wl,--build-id. Build ID support plus compatibility fixes for debug files separation are present in gnu binary utilities (Binutils) package since version 2.18.
参考: https://sourceware.org/gdb/download/onlinedocs/gdb/Separate-Debug-Files.html#Separate-Debug-Files
Debugging Information in Separate Files的更多相关文章
- Detailed Information for Outputted Files from Somatic Mutation Annotators(annovar 注释文件条目详细解释)
CONTENTS *_annoTable.txt (ANNOVAR) *_annoTable.txt (SnpEff) *_genelist.txt (ANNOVAR & SnpEff) db ...
- hive: insert数据时Error during job, obtaining debugging information 以及beyond physical memory limits
insert overwrite table canal_amt1...... 2014-10-09 10:40:27,368 Stage-1 map = 100%, reduce = 32%, Cu ...
- GDB技巧整理
https://blog.atime.me/note/gdb-tricks.html 整理常用的gdb技巧. 常用命令 常用的gdb命令... 启动gdb 直接运行 gdb --args prog a ...
- Make命令完全详解教程
Make命令完全详解教程 无论是在Linux还是在Unix环境中,make都是一个非常重要的编译命令.不管是自己进行项目开发还是安装应用软件,我们都经常要用到make或make install.利用m ...
- Beginning Linux Programming 学习-chapter2-Shell programming-Pipes and Redirection
"为了从事创造性工作,人类需要孤独,可是在孤独中,广义的人类仍存在于内心."--(德国)奥铿 ...
- Options for Debugging Your Program or GCC
[Options for Debugging Your Program or GCC] -g Produce debugging information in the operating system ...
- The Kernel Newbie Corner: Kernel Debugging with proc "Sequence" Files--Part 3
转载:https://www.linux.com/learn/linux-career-center/44184-the-kernel-newbie-corner-kernel-debugging-w ...
- PDB Files: What Every Developer Must Know
Reference: http://www.wintellect.com/blogs/jrobbins/pdb-files-what-every-developer-must-know Most d ...
- Files and Directories
Files and Directories Introduction In the previous chapter we coveredthe basic functions that pe ...
随机推荐
- 51nod1294 修改数组
看题解的...就是将必须要修改的数去掉后求最长的不递减子序列. upper_bound+lower_bound要理解.有时候-1有时候不用是有原因的. #include<cstdio> # ...
- 解决iis出现这个问题-2147467259 (0x80004005)
在运行中运行下面命令就可解决问题 regsvr32 vbscript.dllregsvr32 jscript.dllregsvr32 %windir%\system32\inetsrv\asp.dll
- mysql 调用带返回值的存储过程
存储过程: create procedure proc_t(out uname varchar(50),out upwd varchar(50),in uid int) BEGIN select na ...
- BZOJ 4597 随机序列
一定要想到,对于一个空位如果填了+,那么一定有一个表达式这里填-号使得后面的全部抵消掉.这点十分重要. 于是发现这个答案只和前缀积有关,线段树维护即可. #include<iostream> ...
- UVA 11354 Bond 邦德 (RMQ,最小瓶颈MST)
题意: n个城市,m条路,每条路有个危险值,要使得从s走到t的危险值最小.回答q个询问,每个询问有s和t,要求输出从s到t最小的危险值.(5万个点,10万条边) 思路: 其实要求的是任意点对之间的最小 ...
- 【英语】Bingo口语笔记(10) - 常见词汇的缩读
- Hibernate-Native SQL
1.标量(值)查询: sess.createSQLQuery("SELECT * FROM CATS").list(); sess.createSQLQuery("SEL ...
- 国内YUM源收集
1. 企业贡献: 搜狐开源镜像站:http://mirrors.sohu.com/网易开源镜像站:http://mirrors.163.com/ 阿里云开源站:http://mirrors.aliyu ...
- 实验室 Linux 集群的管理常用命令
实验室有一个Linux集群,本文做一下记录. SSH相关命令 通过SSH登录集群中的其他机器上的操作系统(或虚拟机中的操作系统).操作系统之间已经设置免密码登录. 1. 无选项参数运行 SSH 通常使 ...
- Mysql事物与Metadata lock 问题
环境说明: MySQL 5.6.16 OS:Linux RedHat 6.2 64bit 1.问题描述 目前新上一个使用MySQL数据库项目,在数据库中,每隔5分钟做truncate某 ...