public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* gdb follows symlinks when looking for debuginfo
@ 2008-01-23 16:16 Olaf Hering
  2008-01-23 17:32 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2008-01-23 16:16 UTC (permalink / raw)
  To: gdb


Why does gdb follow symlinks when looking for debuginfo and executables?

The binaries in our installation images are symlinked into a
loop-mounted cramfs image, or to an extracted tree on a remote
filesystem.
The gdb binary itself is a symlink /usr/bin/gdb ->
/mounts/inst-sys/usr/bin/gdb. For some reason, gdb starts to look for
debuginfo in /mounts/inst-sys/usr/lib/debug instead of just
/usr/lib/debug. The same is true for the executable thats being
debugged.

How can this be turned off? I do not see a cmdline switch for that.

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

* Re: gdb follows symlinks when looking for debuginfo
  2008-01-23 16:16 gdb follows symlinks when looking for debuginfo Olaf Hering
@ 2008-01-23 17:32 ` Daniel Jacobowitz
  2008-01-23 18:04   ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-01-23 17:32 UTC (permalink / raw)
  To: Olaf Hering; +Cc: gdb

On Wed, Jan 23, 2008 at 05:15:37PM +0100, Olaf Hering wrote:
> 
> Why does gdb follow symlinks when looking for debuginfo and executables?

Most likely something uses realpath when opening files.  Looks like
exec_file_attach -> openp -> xfullpath.

> The binaries in our installation images are symlinked into a
> loop-mounted cramfs image, or to an extracted tree on a remote
> filesystem.
> The gdb binary itself is a symlink /usr/bin/gdb ->
> /mounts/inst-sys/usr/bin/gdb. For some reason, gdb starts to look for
> debuginfo in /mounts/inst-sys/usr/lib/debug instead of just
> /usr/lib/debug. The same is true for the executable thats being
> debugged.

That path is surprising.  I would have expected
/usr/lib/debug/mounts/inst-sys/...  Does "show sysroot"
show anything?  What about "show debug-file-directory"?

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: gdb follows symlinks when looking for debuginfo
  2008-01-23 17:32 ` Daniel Jacobowitz
@ 2008-01-23 18:04   ` Olaf Hering
  2008-01-23 18:16     ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Olaf Hering @ 2008-01-23 18:04 UTC (permalink / raw)
  To: gdb

On Wed, Jan 23, Daniel Jacobowitz wrote:

> On Wed, Jan 23, 2008 at 05:15:37PM +0100, Olaf Hering wrote:
> > 
> > Why does gdb follow symlinks when looking for debuginfo and executables?
> 
> Most likely something uses realpath when opening files.  Looks like
> exec_file_attach -> openp -> xfullpath.
> 
> > The binaries in our installation images are symlinked into a
> > loop-mounted cramfs image, or to an extracted tree on a remote
> > filesystem.
> > The gdb binary itself is a symlink /usr/bin/gdb ->
> > /mounts/inst-sys/usr/bin/gdb. For some reason, gdb starts to look for
> > debuginfo in /mounts/inst-sys/usr/lib/debug instead of just
> > /usr/lib/debug. The same is true for the executable thats being
> > debugged.
> 
> That path is surprising.  I would have expected
> /usr/lib/debug/mounts/inst-sys/...  Does "show sysroot"
> show anything?  What about "show debug-file-directory"?

The current system root is "".
The directory where separate debug symbols are searched for is "/mounts/instsys/usr/lib/debug".

You are right. I should have pasted the correct path into the mail.

For 3 yast libs (the first 3 libs to load), the path is wrong.

inst-sys:/ # grep y2wfm.so /X
2953  open("/usr/lib/YaST2/plugin/libpy2wfm.so.2", O_RDONLY) = 7
2953  stat64("/usr/lib/YaST2/plugin/libpy2wfm.so.2", {st_mode=S_IFREG|0755, st_size=121048, ...}) = 0
2953  open("/usr/lib/YaST2/plugin/libpy2wfm.so.2", O_RDONLY) = 7
2953  open("/mounts/instsys/usr/lib/YaST2/plugin/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
2953  open("/mounts/instsys/usr/lib/YaST2/plugin/.debug/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
2953  open("/mounts/instsys/usr/lib/debug//mounts/instsys/usr/lib/YaST2/plugin/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
2953  open("/mounts/instsys/usr/lib/debug/mounts/instsys/usr/lib/YaST2/plugin/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)

Should have been /mounts/instsys/usr/lib/debug/usr/lib/YaST2/plugin/libpy2wfm.so.2.0.0.debug
Maybe wrong debuginfo generated by gcc? They are not dlopen objects.

For all others the debuginfo can be loaded.
inst-sys:/ # grep libexpat.so.1 /X
2953  open("/lib/libexpat.so.1", O_RDONLY) = 3
2953  open("/lib/libexpat.so.1", O_RDONLY) = 13
2953  stat64("/lib/libexpat.so.1", {st_mode=S_IFREG|0755, st_size=193996, ...}) = 0
2953  open("/lib/libexpat.so.1", O_RDONLY) = 5
2953  open("/lib/libexpat.so.1.5.2.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
2953  open("/lib/.debug/libexpat.so.1.5.2.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
2953  open("/mounts/instsys/usr/lib/debug//lib/libexpat.so.1.5.2.debug", O_RDONLY) = 6
2953  stat64("/mounts/instsys/usr/lib/debug//lib/libexpat.so.1.5.2.debug", {st_mode=S_IFREG|0644, st_size=289219, ...}) = 0
2953  open("/mounts/instsys/usr/lib/debug//lib/libexpat.so.1.5.2.debug", O_RDONLY) = 6

The gdb output is:
...............
Reading symbols from /mounts/instsys/usr/lib/YaST2/plugin/libpy2wfm.so.2...expanding to full symbols...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/YaST2/plugin/libpy2wfm.so.2
Reading symbols from /mounts/instsys/usr/lib/YaST2/plugin/libpy2scr.so.2...expanding to full symbols...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/YaST2/plugin/libpy2scr.so.2
Reading symbols from /mounts/instsys/usr/lib/YaST2/plugin/libpy2UI.so.2...expanding to full symbols...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/YaST2/plugin/libpy2UI.so.2
Reading symbols from /usr/lib/libscr.so.2...expanding to full symbols...Reading symbols from /mounts/instsys/usr/lib/debug/usr/lib/libscr.so.2.0.0.debug...expanding to full symbols...done.
done.
..............

Why are the first 3 libs searched in  /mounts/instsys instead of /?

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

* Re: gdb follows symlinks when looking for debuginfo
  2008-01-23 18:04   ` Olaf Hering
@ 2008-01-23 18:16     ` Daniel Jacobowitz
  2008-01-24 13:38       ` Olaf Hering
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-01-23 18:16 UTC (permalink / raw)
  To: Olaf Hering; +Cc: gdb

On Wed, Jan 23, 2008 at 07:04:28PM +0100, Olaf Hering wrote:
> For 3 yast libs (the first 3 libs to load), the path is wrong.

Are these the only ones symlinked?  I bet this:

> 2953  open("/usr/lib/YaST2/plugin/libpy2wfm.so.2", O_RDONLY) = 7

is a symlink to /mounts/instsys, and this:

> 2953  open("/lib/libexpat.so.1", O_RDONLY) = 3

is not.

I don't know what to suggest.  The real location of the file, on an
installed system, is probably relative to where the real debug info
will be found.

You can work around this with a couple of creative symlinks.  For
instance:

> 2953  open("/mounts/instsys/usr/lib/YaST2/plugin/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
> 2953  open("/mounts/instsys/usr/lib/YaST2/plugin/.debug/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
> 2953  open("/mounts/instsys/usr/lib/debug//mounts/instsys/usr/lib/YaST2/plugin/libpy2wfm.so.2.0.0.debug", O_RDONLY) = -1 ENOENT (No such file or directory)

The third path is wrong for you, but you can make the second path
right.  Symlink /mounts/instsys/usr/lib/YaST2/plugin/.debug to
/mounts/instsys/usr/lib/debug/usr/lib/YaST2/plugin.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: gdb follows symlinks when looking for debuginfo
  2008-01-23 18:16     ` Daniel Jacobowitz
@ 2008-01-24 13:38       ` Olaf Hering
  0 siblings, 0 replies; 5+ messages in thread
From: Olaf Hering @ 2008-01-24 13:38 UTC (permalink / raw)
  To: gdb

On Wed, Jan 23, Daniel Jacobowitz wrote:

> On Wed, Jan 23, 2008 at 07:04:28PM +0100, Olaf Hering wrote:
> > For 3 yast libs (the first 3 libs to load), the path is wrong.
> 
> Are these the only ones symlinked?  I bet this:
> 
> > 2953  open("/usr/lib/YaST2/plugin/libpy2wfm.so.2", O_RDONLY) = 7
> 
> is a symlink to /mounts/instsys, and this:

The YaST2 directory is a symlink:
/usr/lib/YaST2 -> /mounts/instsys/usr/lib/YaST2

> > 2953  open("/lib/libexpat.so.1", O_RDONLY) = 3
> 
> is not.

/lib/libexpat.so.1 -> libexpat.so.1.5.2 -> /mounts/instsys/lib/libexpat.so.1.5.2

I will create a tmpfs bind mount to store the debuginfo in
/mounts/instsys/usr/lib/debug. This will work for all libs, except the
ones in /usr/lib/YaST2/plugin/


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

end of thread, other threads:[~2008-01-24 13:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-23 16:16 gdb follows symlinks when looking for debuginfo Olaf Hering
2008-01-23 17:32 ` Daniel Jacobowitz
2008-01-23 18:04   ` Olaf Hering
2008-01-23 18:16     ` Daniel Jacobowitz
2008-01-24 13:38       ` Olaf Hering

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