Previous: Separate Debug Info, Up: 安装调试文件 [Contents][Index]
As we saw above, some packages, but not all, provide debugging info in a
debug
output. What can you do when debugging info is missing? The
--with-debug-info option provides a solution to that: it allows you
to rebuild the package(s) for which debugging info is missing—and only
those—and to graft those onto the application you’re debugging. Thus,
while it’s not as fast as installing a debug
output, it is relatively
inexpensive.
Let’s illustrate that. Suppose you’re experiencing a bug in Inkscape and
would like to see what’s going on in GLib, a library that’s deep down in its
dependency graph. As it turns out, GLib does not have a debug
output
and the backtrace GDB shows is all sadness:
(gdb) bt #0 0x00007ffff5f92190 in g_getenv () from /gnu/store/…-glib-2.62.6/lib/libglib-2.0.so.0 #1 0x00007ffff608a7d6 in gobject_init_ctor () from /gnu/store/…-glib-2.62.6/lib/libgobject-2.0.so.0 #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@entry=1, argv=argv@entry=0x7fffffffcfd8, env=env@entry=0x7fffffffcfe8) at dl-init.c:72 #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>) at dl-init.c:118
To address that, you install Inkscape linked against a variant GLib that contains debug info:
guix install inkscape --with-debug-info=glib
This time, debugging will be a whole lot nicer:
$ gdb --args sh -c 'exec inkscape' … (gdb) b g_getenv Function "g_getenv" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (g_getenv) pending. (gdb) r Starting program: /gnu/store/…-profile/bin/sh -c exec\ inkscape … (gdb) bt #0 g_getenv (variable=variable@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252 #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380 #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493 #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@entry=3, argv=argv@entry=0x7fffffffd088, env=env@entry=0x7fffffffd0a8) at dl-init.c:72 …
Much better!
Note that there can be packages for which --with-debug-info will not have the desired effect. See --with-debug-info, for more information.
Previous: Separate Debug Info, Up: 安装调试文件 [Contents][Index]