CentOS 7: Debug package with debug symbol

CentOS provides debug symbol as debuginfo package. This article will describe installing debuginfo and debugging package.

1 Install yum-utils

Install yum-utils which has debuginfo-install.

$ sudo yum install -y yum-utils

This package name does not have suffix.

$ sudo debuginfo-install -y <pkg>

2 Debug command

Set command to GDB.

$ gdb <prog>

In case of ls command is as below.

$ sudo debuginfo-install -y coreutils
$ gdb ls

3 Debug running process

Set PID to GDB. The pidof command can be used for only one process.

$ sudo gdb -p $(pidof <prog>)

In case of rsyslog is as below.

$ sudo debuginfo-install -y rsyslog
$ sudo gdb -p $(pidof rsyslogd)