unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* Debugging information
@ 2013-07-03 22:19 Ludovic Courtès
  2013-07-08 22:28 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Ludovic Courtès @ 2013-07-03 22:19 UTC (permalink / raw)
  To: bug-guix

Hello,

Commit be58d01 in ‘core-updates’ changes ‘gnu-build-system’ such that,
if a package has a derivation output called “debug”, the ‘strip’ phase
saves debugging info in separate files there, instead of just losing it
(info "(gdb) Separate Debug Files").

Currently this is an opt-in mechanism, hence commit 9bf62d9, which
enables it for a few packages.  I think it’d be great to make it opt-out
instead, but the downside is that it takes a lot of disk space; this is
not a problem when using the substituter, but it means that local builds
require more space, at least temporarily (the “debug” outputs can be
GC’d eventually.)  For the record, the debugging output for glibc takes
67 MiB, and that of Guile takes 25 MiB.  Hmm, maybe that’s not that much?

Anyway, here’s a sample session where GDB uses debugging info from libc
and libguile, both of which are installed in profile ‘foo’:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix package -p foo -i guile-2.0.9:debug -i guile-2.0.9 -i glibc:debug
The following packages will be installed:
   glibc-2.17     debug      /nix/store/hr9rimw4zdbygxb44yddi9zkhffwfxmy-glibc-2.17-debug
   guile-2.0.9    out        /nix/store/gbcsdddb4jc3iiraly1dhkgyj95pd3nj-guile-2.0.9
   guile-2.0.9    debug      /nix/store/5ziwsxvcfqa1dpx893kc9r9sjmq21x1f-guile-2.0.9-debug

3 packages in profile

$ gdb 
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set debug-file-directory foo/lib/debug
(gdb) file foo/bin/guile
Reading symbols from /nix/store/gbcsdddb4jc3iiraly1dhkgyj95pd3nj-guile-2.0.9/bin/guile...Reading symbols from /nix/store/5ziwsxvcfqa1dpx893kc9r9sjmq21x1f-guile-2.0.9-debug/lib/debug/nix/store/gbcsdddb4jc3iiraly1dhkgyj95pd3nj-guile-2.0.9/bin/guile.debug...done.
done.
(gdb) b strcmp
Function "strcmp" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (strcmp) pending.
(gdb) b scm_from_locale_string
Function "scm_from_locale_string" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (scm_from_locale_string) pending.
(gdb) r
Starting program: /nix/store/gbcsdddb4jc3iiraly1dhkgyj95pd3nj-guile-2.0.9/bin/guile 

Breakpoint 1, strcmp () at ../sysdeps/x86_64/multiarch/../strcmp.S:134
134     ../sysdeps/x86_64/multiarch/../strcmp.S: No such file or directory.
(gdb) disable 1
(gdb) c
Continuing.
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/ybdv89csf4sn7wbmgj9kfjjk1b0mhrlb-glibc-2.17/lib/libthread_db.so.1".

Breakpoint 2, scm_from_locale_string (str=str@entry=0x7ffff7b763d6 "pruhsruhpwphuhuh") at strings.c:1583
1583    strings.c: No such file or directory.
--8<---------------cut here---------------end--------------->8---

The important thing here is ‘set debug-file-directory’, which tells GDB
where to look for separate debugging info files.

Neat, isn’t it?  :-)

I think it’s an important feature if we are to make software freedom practical.

Comments?

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Debugging information
  2013-07-03 22:19 Debugging information Ludovic Courtès
@ 2013-07-08 22:28 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2013-07-08 22:28 UTC (permalink / raw)
  To: bug-guix

ludo@gnu.org (Ludovic Courtès) skribis:

> Commit be58d01 in ‘core-updates’ changes ‘gnu-build-system’ such that,
> if a package has a derivation output called “debug”, the ‘strip’ phase
> saves debugging info in separate files there, instead of just losing it
> (info "(gdb) Separate Debug Files").

Commit 91ef73d adds documentation for this, copied below.
While at it, I also documented multiple-output packages.

Comments welcome!

Ludo’.


6.2 Installing Debugging Files
==============================

Program binaries, as produced by the GCC compilers for instance, are
typically written in the ELF format, with a section containing
"debugging information".  Debugging information is what allows the
debugger, GDB, to map binary code to source code; it is required to
debug a compiled program in good conditions.

   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 (*note 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 (*note (gdb)Separate Debug Files::).

   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’ (*note Packages with Multiple
Outputs::).  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 package -i glibc:debug -i 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, *note (gdb)Startup::):

     (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’.

   The ‘debug’ output mechanism in Guix is implemented by the
‘gnu-build-system’ (*note Defining Packages::).  Currently, it is
opt-in—debugging information is available only for those packages whose
definition explicitly declares a ‘debug’ output.  This may be changed to
opt-out in the future, if our build farm servers can handle the load.
To check whether a package has a ‘debug’ output, use ‘guix package
--list-available’ (*note Invoking guix package::).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-08 22:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-03 22:19 Debugging information Ludovic Courtès
2013-07-08 22:28 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).