Ubuntu provides debug symbol as dbgsym package. This article will describe installing dbgsym and debugging package.
Table of Contents
1 Add repository of dbgsym
#!/bin/sh -e U=http://ddebs.ubuntu.com C=$(lsb_release -cs) cat <<EOF | sudo tee /etc/apt/sources.list.d/ddebs.list deb ${U} ${C} main restricted universe multiverse #deb ${U} ${C}-security main restricted universe multiverse deb ${U} ${C}-updates main restricted universe multiverse deb ${U} ${C}-proposed main restricted universe multiverse EOF wget -O - http://ddebs.ubuntu.com/dbgsym-release-key.asc | \ sudo apt-key add - sudo apt update -y
2 Install dbgsym package
Install <pkgname>-dbgsym.
$ sudo apt install -y bash-dbgsym
Download source code in order to this.
$ mkdir bash $ cd bash $ apt source bash
Install GDB and run it.
$ sudo apt install -y gdb
The directory command specifies top directory of source code.
(gdb) directory bash-5.0 Source directories searched: /home/hiroom2/bash/bash-5.0:$cdir:$cwd (gdb) b main Breakpoint 1 at 0x2ebd0: file .././shell.c, line 364. (gdb) r Starting program: /usr/bin/bash Breakpoint 1, main (argc=1, argv=0x7fffffffe188, env=0x7fffffffe198) at .././shell.c:364 364 {
If you run only GDB, la src command is useful to track program.