Next: , Up: Установка файлов отладки   [Contents][Index]


17.1 Отдельная информация об отладке

The problem with debugging information is that it 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).

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 Пакеты со множественным выходом). Users can choose to install the debug output of a package when they need it. For instance, the following command installs the debugging information for the GNU C Library and for GNU Guile:

guix install glibc:debug guile:debug

GDB must then be told to look for debug files in the user’s profile, by setting the debug-file-directory variable (consider setting it from the ~/.gdbinit file, see Startup in Debugging with GDB):

(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 guix build --source, see Запуск guix build), and to point GDB to that source directory using the directory command (see directory in Debugging with GDB).

The debug output mechanism in Guix is implemented by the gnu-build-system (see Системы сборки). 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 guix package --list-available (see Вызов guix package).

Read on for how to deal with packages lacking a debug output.


Next: Сборка с отладочной информацией, Up: Установка файлов отладки   [Contents][Index]