6.26.5 GDB Support

Sometimes, you may find it necessary to debug Guile applications at the C level. Doing so can be tedious, in particular because the debugger is oblivious to Guile’s SCM type, and thus unable to display SCM values in any meaningful way:

(gdb) frame
#0  scm_display (obj=0xf04310, port=0x6f9f30) at print.c:1437

To address that, Guile comes with an extension of the GNU Debugger (GDB) that contains a “pretty-printer” for SCM values. With this GDB extension, the C frame in the example above shows up like this:

(gdb) frame
#0  scm_display (obj=("hello" GDB!), port=#<port file 6f9f30>) at print.c:1437

Here GDB was able to decode the list pointed to by obj, and to print it using Scheme’s read syntax.

That extension is a .scm file installed alongside the libguile shared library. When GDB 7.8 or later is installed and compiled with support for extensions written in Guile, the extension is automatically loaded when debugging a program linked against libguile (see Auto-loading in Debugging with GDB). Note that the directory where libguile is installed must be among GDB’s auto-loading “safe directories” (see Auto-loading safe path in Debugging with GDB).