The problem with debugging information is that is takes up a fair amount of disk space. For example, debugging information for the GNU C Library weighs in at more than 60 MiB. Thus, as a user, keeping all the debugging info of all the installed programs is usually not an option. Yet, space savings should not come at the cost of an impediment to debugging—especially in the GNU system, which should make it easier for users to exert their computing freedom (see GNU Distribution).
Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a mechanism that allows users to get the best of both worlds: debugging information can be stripped from the binaries and stored in separate files. GDB is then able to load debugging information from those files, when they are available (see Separate Debug Files in Debugging with GDB).
The GNU distribution takes advantage of this by storing debugging
information in the
lib/debug sub-directory of a separate package
output unimaginatively called
debug (see Packages with Multiple Outputs). Users can choose to install the
of a package when they need it. For instance, the following command
installs the debugging information for the GNU C Library and for GNU
guix install glibc:debug guile:debug
GDB must then be told to look for debug files in the user’s profile, by
debug-file-directory variable (consider setting it
from the ~/.gdbinit file, see Startup in Debugging with
(gdb) set debug-file-directory ~/.guix-profile/lib/debug
From there on, GDB will pick up debugging information from the .debug files under ~/.guix-profile/lib/debug.
Below is an alternative GDB script which is useful when working with other profiles. It takes advantage of the optional Guile integration in GDB. This snippet is included by default on Guix System in the ~/.gdbinit file.
guile (use-modules (gdb)) (execute (string-append "set debug-file-directory " (or (getenv "GDB_DEBUG_FILE_DIRECTORY") "~/.guix-profile/lib/debug"))) end
In addition, you will most likely want GDB to be able to show the source
code being debugged. To do that, you will have to unpack the source
code of the package of interest (obtained with
--source, see Invoking guix build), and to point GDB to that source
directory using the
directory command (see
directory in Debugging with GDB).
debug output mechanism in Guix is implemented by the
gnu-build-system (see Build Systems). Currently, it is
opt-in—debugging information is available only for the packages with
definitions explicitly declaring a
debug output. To check
whether a package has a
debug output, use
--list-available (see Invoking guix package).
Read on for how to deal with packages lacking a