Stepping into glibc
Simon Marchi
simon.marchi@polymtl.ca
Wed Jan 14 23:00:00 GMT 2015
On 14 January 2015 at 17:23, Kip Warner <kip@thevertigo.com> wrote:
> Hey list,
>
> I'm trying to debug some code with Nemiver (a Gtk+ frontend for GDB).
> When I try to step into glibc functions, it complains about not being
> able to find its source. e.g.
>
> Cannot find file '/build/buildd/glibc-2.19/posix/getopt1.c'.
>
> I have installed libc6-dbg and glibc-source packages (using Ubuntu
> 14.10).
>
> Is there something I need to add to my ~/.gdbinit, such as a directory
> / set solib-absolute-prefix / set sysroot or what have you?
>
> I could always download the source of my distro's version of glibc into
> the above location, but I'm sure there is a more elegant way of
> handling this.
>
> Respectfully,
>
> --
> Kip Warner -- Senior Software Engineer
> OpenPGP encrypted/signed mail preferred
> http://www.thevertigo.com
You are looking for "set substitute-path" [1].
On Ubuntu/Debian, you can easily download the exact source of a
package you are running (including distribution-specific patches), by
using "apt-get source". In your case, it would be:
$ apt-get source libc6
You would then use set substitute-path to tell gdb to replace the
"/build/buildd" part, which is the path where the source was on
Ubuntu's server when the package was built, with your own path. For
example, assuming that you download package sources in
/home/kip/package-sources:
$ set substitute-path /build/buildd /home/kip/package-sources
I might be forgetting something, but that's the idea.
Also, if it happens that you want to debug a program that does not
have a *-dbg version, you can use the dbgsym which is built
automatically for every Ubuntu package [2].
Simon
[1] https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html#set%20substitute-path
[2] https://wiki.ubuntu.com/DebuggingProgramCrash#Non-built-in_debug_symbol_packages_.28.2A-dbgsym.29
More information about the Gdb
mailing list