Bug 65404 - gdb-6.2.1 fails to find include file in relative directory with dwarf2
Bug#: 65404 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: blocker Priority: P2
Resolution: FIXED Assigned To: toolchain@gentoo.org Reported By: garrison@mail.ru
Component: Core system
URL: 
Summary: gdb-6.2.1 fails to find include file in relative directory with dwarf2
Keywords:  
Status Whiteboard: 
Opened: 2004-09-26 06:57 0000
Description:   Opened: 2004-09-26 06:57 0000
gcc may emit relative directory name for some included files.
While debugging programs which have dwarf2 debug information
and are not in the build hierarchy (i.e. installed to other location)
gdb fails to find such included files though all needed information
(source directory et al) is available.


Reproducible: Always
Steps to Reproduce:
1. Build a package which uses relative include paths and install resulting binary somewhere outside build directory.
2. Start a gdb session, then try to single-step into function which is implemented in #included file.

Actual Results:  
gdb say "No such file or directory" for such a file.

Expected Results:  
Included file should be correctly located.

This problem is addressed in a message thread resulting in a patch by Bryce
McKinlay, see http://sources.redhat.com/ml/gdb-patches/2004-07/msg00456.html for
details.
So this probably would be in the next released gdb, but it is not yet available
in current gdb CVS.

------- Comment #1 From Igor V. Kovalenko 2004-09-26 07:07:35 0000 -------
Created an attachment (id=40447) [details]
A patch by Bryce McKinlay rediffed against gdb-6.2.1

A patch by Bryce McKinlay mentioned in desc, rediffed against gdb-6.2.1
I successively use gdb-6.2.1 with this patch and do not see this problem.

------- Comment #2 From Igor V. Kovalenko 2004-09-26 07:22:49 0000 -------
Created an attachment (id=40448) [details]
test case to verify this bug

To check please unpack a test case, then cd to gdb-relative-test and do 
export WANT_AUTOMAKE=1.8
autoreconf -i
./configure -v --prefix=`/bin/pwd`/inst
make install

then execute gdb as follows:
LD_LIBRARY_PATH=`/bin/pwd`/inst/lib gdb inst/bin/hello

then at gdb prompt do
break main
run
step
step

here you either see "9	aa.hh: No such file or directory"
which means gdb fails to find included file, or you do not see
the error and "list" command would display the correct source
code lines from included file

------- Comment #3 From Igor V. Kovalenko 2004-09-29 17:25:36 0000 -------
Created an attachment (id=40738) [details]
Alternative patch with relation to compilation directory

As I'm reading dwarf standard, relative paths should be handled in relation to
compilation directory. This alternative patch does exactly this everywhere
relative path entry is found in dwarf directory table.
This patch makes some gdb testsuite failures. Now I strongly believe testsuite
should be somewhat fixed in relative paths handling :)

------- Comment #4 From SpanKY 2004-11-09 18:19:03 0000 -------
added patch to 6.2.1-r1, thanks