Debian 9: Debug package with dbgsym for debug symbol

This article will describe debugging package with dbgsym for debug symbol.

1 Append debian-debug repository

Append debian-debug repository to apt sources.list.d.

$ cat <<EOF | sudo tee /etc/apt/sources.list.d/dbgsym.list
deb stretch-debug main
$ sudo apt update -y

2 Install dbgsym

Packages which have dbgsym suffix are debug symbol.


This article installs debug symbol for coretuils.

$ sudo apt install -y coreutils-dbgsym

Debug symbol will be installed to /usr/lib/debug. GDB will search /usr/lib/debug automatically.

$ dpkg -L coreutils-dbgsym

3 Debug package with dbgsym

Install GDB.

$ sudo apt install -y gdb

Download coretuils source code.

$ mkdir coreutils
$ cd coreutils
$ apt source coreutils-dbgsym
$ cd ./coreutils-*

Debug ls command in coreutils.

$ gdb ls
(gdb) la src
(gdb) b main
(gdb) r

GDB breaks at main function.