public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Stepping into glibc
@ 2015-01-14 22:23 Kip Warner
  2015-01-14 23:00 ` Simon Marchi
  2015-01-15 13:12 ` Jan Kratochvil
  0 siblings, 2 replies; 5+ messages in thread
From: Kip Warner @ 2015-01-14 22:23 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: Stepping into glibc
  2015-01-14 22:23 Stepping into glibc Kip Warner
@ 2015-01-14 23:00 ` Simon Marchi
  2015-01-14 23:12   ` Kip Warner
  2015-01-15 13:12 ` Jan Kratochvil
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2015-01-14 23:00 UTC (permalink / raw)
  To: Kip Warner; +Cc: gdb

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

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

* Re: Stepping into glibc
  2015-01-14 23:00 ` Simon Marchi
@ 2015-01-14 23:12   ` Kip Warner
  0 siblings, 0 replies; 5+ messages in thread
From: Kip Warner @ 2015-01-14 23:12 UTC (permalink / raw)
  To: Simon Marchi; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

On Wed, 2015-01-14 at 18:00 -0500, Simon Marchi wrote:
> You are looking for "set substitute-path" [1].

Thank you so much Simon. That was exactly what I needed and it worked.

-- 
Kip Warner -- Senior Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: Stepping into glibc
  2015-01-14 22:23 Stepping into glibc Kip Warner
  2015-01-14 23:00 ` Simon Marchi
@ 2015-01-15 13:12 ` Jan Kratochvil
  2015-01-15 17:53   ` Kip Warner
  1 sibling, 1 reply; 5+ messages in thread
From: Jan Kratochvil @ 2015-01-15 13:12 UTC (permalink / raw)
  To: Kip Warner; +Cc: gdb

On Wed, 14 Jan 2015 23:23:33 +0100, Kip Warner wrote:
> 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.

With Fedoras/RHELs it works out of the box.


Jan

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

* Re: Stepping into glibc
  2015-01-15 13:12 ` Jan Kratochvil
@ 2015-01-15 17:53   ` Kip Warner
  0 siblings, 0 replies; 5+ messages in thread
From: Kip Warner @ 2015-01-15 17:53 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

On Thu, 2015-01-15 at 14:12 +0100, Jan Kratochvil wrote:
> With Fedoras/RHELs it works out of the box.

Thanks Jan, but as I indicated already, I'm using a different distro.

-- 
Kip Warner -- Senior Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

end of thread, other threads:[~2015-01-15 17:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 22:23 Stepping into glibc Kip Warner
2015-01-14 23:00 ` Simon Marchi
2015-01-14 23:12   ` Kip Warner
2015-01-15 13:12 ` Jan Kratochvil
2015-01-15 17:53   ` Kip Warner

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).