Subject: Re: bug#19973: Grafts break debug outputs

From: [email-masked] (Ludovic Courtès)
Date: Tue, 21 Aug 2018 22:53:57 +0200

Hello!

[email-masked] (Ludovic Courtès) skribis:

> However, one very likely problem is that .debug files include a CRC of
> the binary they correspond to (info "(gdb) Separate Debug Files"), and
> that CRC is not updated when we graft things.
>
> We could change our grafting code to specifically address this problem
> (using (guix elf) & co.).

The patches below address this by adding code to update the CRC in the
‘.gnu_debuglink’ section upon grafting.  It uses a simple hook
mechanism, a simplified version of what Timothy proposed.

The ‘.gnu_debuglink’ hook does nothing for packages that lack a “debug”
output.  For packages that have a “debug” output, only ELF files from
bin/, lib/, etc. are considered.  Overall the run-time cost should be
low.

I tested it with guile-ssh on current master (commit
bab4dc58f7278e481c7eb8c6f954d6f1751deb23).  When running:

  guix build guile-ssh

you see messages like this:

  updating '.gnu_debuglink' CRC in '/gnu/store/523lgdnmr4x0q7cnn8wr7f2zzcnlvrpp-guile-ssh-0.11.3/lib/guile/2.2/site-ccache/ssh/tunnel.go'
  updating '.gnu_debuglink' CRC in '/gnu/store/523lgdnmr4x0q7cnn8wr7f2zzcnlvrpp-guile-ssh-0.11.3/lib/guile/2.2/site-ccache/ssh/version.go'
  updating '.gnu_debuglink' CRC in '/gnu/store/523lgdnmr4x0q7cnn8wr7f2zzcnlvrpp-guile-ssh-0.11.3/lib/libguile-ssh.so.11.0.0'

The thing about .go files isn’t very useful (the ‘strip’ phase should
ignore them in the first place probably).  However I’ve confirmed that
gdb is happy with the grafted libguile-ssh.so: if you add breakpoints
with “rb guile_ssh” and then call one of the guile-ssh procedures from
the REPL, you see that you get proper debugging info and all (don’t
forget to “set debug-file-directory” upfront.)

That’s it!  It’s a relief to fix a 3-year old bug.  :-)

Next we can fix build IDs similarly (see <https://bugs.gnu.org/25752>),
and maybe the Racket CRC issue that Timothy and Chris looked at
recently, and maybe the Java manifest issue as well (is it still
relevant?).

Thanks,
Ludo’.