weblog d’un abbe

20080103

How Split Debug Symbols work ?

Filed under: Research — abbe @ 0147

I’ve been using a custom built package for a software since a long time, But it used to crash (reproducible) sometimes, so tonight I thought, it’ll be great to debug the problem, so I checked my package directories to see if I’ve built any -dbg package (I use Gobuntu, a distro based on Debian, so no -debuginfo packages for me :-P ). And I found that I’ve not built any -dbg package, so I quickly added --dbg-package=foo-dbg to dh_strip (yup I use debhelper too) invocation in binary-arch target of debian/rules Makefile, and also added a entry for foo-dbg in debian/control. And, then I built (dpkg-buildpackage -rfakeroot) and installed (dpkg -i) the -dbg package.

Now, I fired gdb, started executing foo, it SIGSEGVed, and I did bt, oops no symbols listed. So, then I joined #gdb on irc.freenode.net, and there bauermann told me that about debug-file-directory option in gdb. I showed that option, and found that it is set to /usr/lib/debug. Then I tried manually loading symbols, using symbol-file option. And symbols are loaded without any problem.

Now, the problem is how to autoload those symbols, so I followed the path of RTFM and then I opened gdb.info, searched for debug-file-directory, and there I found this:

So, for example, if you ask GDB to debug `/usr/bin/ls', which has a
link containing the name `ls.debug', and the global debug directory
is `/usr/lib/debug', then GDB will look for debug information in
`/usr/bin/ls.debug', `/usr/bin/.debug/ls.debug', and
`/usr/lib/debug/usr/bin/ls.debug'.

and this:

A debug link is a special section of the executable file named
`.gnu_debuglink'.

And then I did objdump -x /usr/bin/foo |fgrep debuglink to see if it has .gnu_debuglink section, oops, its not present. So, I installed the newly built package, as I’ve only installed -dbg package earlier. And now again I did objdump -x /usr/bin/foo |fgrep debuglink, and this time its present.

So I fired gdb again, and started executing foo, and now this time when it SIGSEGVed, I’m able to get the symbol names, and the line no. where it segfaulted. So gdb rocks :)

Advertisements

1 Comment »

  1. […] So I fired gdb again, and started executing foo, and now this time when it SIGSEGVed, I’m able to get the symbol names, and the line no. where it segfaulted. So gdb rocks by Ashish Shukla, https://wahjava.wordpress.com/2008/01/03/how-split-debug-symbols-work/ […]

    Pingback by How Split Debug Symbols work ? — 20090529 @ 1315


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: