deb debug package

标准的 debian / ubuntu 打 deb 包,通过将可执行文件的符号表通过剥离成独立的 dbg 包,称为 debug package。引用官方对 debug package 的描述:

Debug packages contain debug symbols and usually are named -dbg. They are useful if program crashes and you want to generate stack trace which contains information about functions where it crashed.

因此如果你的系统使用标准 debian / ubuntu 编译、打包,则一般情况下编译结果会生成一个 _version.deb 和一个 -dbg_version.deb。正常情况下 -dbg.deb 不会安装。
如果运行这个包里的可执行文件时 crash 生成 core dump,则 gdb 看不到符号表信息。解决方法:

  1. 找到与 _version.deb 同时间编译的 -dbg_version.deb,注意,如果是经常自己编译,version 可能是一样的,没有改,需要人工确认两个包是同一次编译生成的。
  2. 安装 -dbg_version.deb 到目标系统
  3. gdb your_core_file your_elf 调试 core file,bt full 即可看到对应的符号表。

安装 orchagent dbg 包前,提示 no debugging symbols found

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
root@sonic:~/core# gdb orchagent -dbg orchagent.1516015456.30.core 
gdb: unrecognized option '-dbg'
Use `gdb --help' for a complete list of options.
root@sonic:~/core# gdb orchagent orchagent.1516015456.30.core
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from orchagent...(no debugging symbols found)...done.
[New LWP 40]
[New LWP 112]
[New LWP 30]
[New LWP 39]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/bin/orchagent -d /var/log/swss -b 8192 -m 00:xx:xx:xx:xx:xx'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007fbc29d25067 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt full
#0 0x00007fbc29d25067 in raise () from /lib/x86_64-linux-gnu/libc.so.6
No symbol table info available.
#1 0x00007fbc29d26448 in abort () from /lib/x86_64-linux-gnu/libc.so.6

安装 orchagent dbg 包后:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
root@sonic:~/core# gdb orchagent orchagent.1516015456.30.core 
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from orchagent...Reading symbols from /usr/lib/debug/.build-id/80/83abbc9424f44c6361452396c75e47249c006b.debug...done.
done.
[New LWP 40]
[New LWP 112]
[New LWP 30]
[New LWP 39]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/bin/orchagent -d /var/log/swss -b 8192 -m 00:xx:xx:xx:xx:xx'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007fbc29d25067 in raise () from /lib/x86_64-linux-gnu/libc.so.6

新版本(debhelper/9.20151219 or newer in Debian)的 debhelper 已经把 -dbg.deb 改为 -dbgsym.deb,详情请见 DebugPackage