Bug 9538 - gdb creates debuginfo path incorrectly for symlinked files
Summary: gdb creates debuginfo path incorrectly for symlinked files
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P3 enhancement
Target Milestone: 7.4
Assignee: Paul Pluzhnikov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-24 18:58 UTC by schommer
Modified: 2012-01-18 19:02 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description schommer 2008-03-24 18:58:01 UTC
[Converted from Gnats 2433]

I have a debug info RPM that installs under /usr/lib/debug

The file is: /opt/cell/sdk/prototype/usr/lib64/dacs/debug/libdacs_hybrid.so.3.1

it install such that the /opt/cell is symlinked to /vnfs/optdev_DRV_20080319/opt/cell

When gdb tries to construct file names for each of the debug info file searches below, it assumes the base name of the shared lib to be:  
/vnfs/optdev_DRV_20080319/opt/cell/sdk/prototype/usr/lib64/dacs/debug/libdacs_hybrid.so.3.1.debug

so when it tries to search in /usr/lib/debug  for the shared lib it looks for:
/usr/lib/debug/vnfs/optdev_DRV_20080319/opt/cell/sdk/prototype/usr/lib64/dacs/debug/libdacs_hybrid.so.3.1.debug
which of course it can't find.

Release:
unknown
Comment 1 Elias Probst 2011-02-01 21:46:55 UTC
I can confirm this behaviour.

The crash happens in:
/usr/lib64/dri/i965_dri.so
which is a symlink to
/usr/lib64/mesa/i965_dri.so

The splitted debugging symbols reside in
/usr/lib/debug/usr/lib64/mesa/i965_dri.so.debug

GDB is only able to create backtraces when copying the debugging symbols to
/usr/lib/debug/usr/lib64/dri/i965_dri.so.debug


I thin the fix is actually rather simple: GDB should simply do a readlink() on the path of the file which is analyzed before looking for the corresponding debugging symbols file.
Comment 2 Paul Pluzhnikov 2012-01-10 20:28:42 UTC
This just hit me as well:
https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/914448
Comment 3 Sourceware Commits 2012-01-18 18:58:46 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	ppluzhnikov@sourceware.org	2012-01-18 18:58:43

Modified files:
	gdb            : ChangeLog symfile.c configure.ac configure 
	                 config.in 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.base: sepdebug.exp 

Log message:
	2012-01-18  Paul Pluzhnikov  <ppluzhnikov@google.com>
	Jan Kratochvil  <jan.kratochvil@redhat.com>
	
	PR gdb/9538
	* symfile.c (find_separate_debug_file): New function.
	(terminate_after_last_dir_separator): Likewise.
	(find_separate_debug_file_by_debuglink): Also try realpath.
	* configure.ac (AC_CHECK_FUNCS): Add lstat.
	* configure: Regenerate.
	* config.in: Regenerate.
	
	testsuite/ChangeLog:
	
	2012-01-18  Paul Pluzhnikov  <ppluzhnikov@google.com>
	
	PR gdb/9538
	* gdb.base/sepdebug.exp: New test.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13747&r2=1.13748
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/symfile.c.diff?cvsroot=src&r1=1.325&r2=1.326
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/configure.ac.diff?cvsroot=src&r1=1.153&r2=1.154
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/configure.diff?cvsroot=src&r1=1.338&r2=1.339
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/config.in.diff?cvsroot=src&r1=1.131&r2=1.132
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3026&r2=1.3027
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/sepdebug.exp.diff?cvsroot=src&r1=1.34&r2=1.35
Comment 4 Paul Pluzhnikov 2012-01-18 19:02:48 UTC
Fixed in trunk.