Bug 142122 (IT_55303) - [PATCH] gdb fails to find files in certain cases
Summary: [PATCH] gdb fails to find files in certain cases
Keywords:
Status: CLOSED ERRATA
Alias: IT_55303
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gdb
Version: 3.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Elena Zannoni
QA Contact: Jay Turner
URL:
Whiteboard:
Depends On:
Blocks: 132991 146413
TreeView+ depends on / blocked
 
Reported: 2004-12-07 15:05 UTC by Neil Horman
Modified: 2015-01-08 00:09 UTC (History)
4 users (show)

Fixed In Version: RHBA-2005-241
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-05-19 12:09:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
testcase demonstrating bug (10.00 KB, application/octet-stream)
2004-12-07 15:07 UTC, Neil Horman
no flags Details
patch to fix gdb file searching (1.19 KB, patch)
2004-12-07 15:14 UTC, Neil Horman
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2005:187 0 normal SHIPPED_LIVE gdb bug fix update 2005-05-19 04:00:00 UTC
Red Hat Product Errata RHBA-2005:241 0 high SHIPPED_LIVE gdb bug fix update 2005-06-09 04:00:00 UTC

Description Neil Horman 2004-12-07 15:05:46 UTC
Description of problem:
When include files are placed in subdirectories, and a binary is run
under gdb from a location other than the compilation directory, gdb
cannot find the source code corresponding to functions/symbols defined
in that header file

Version-Release number of selected component (if applicable):
all RHEL3 releases/updates

How reproducible:
always

Steps to Reproduce:
1.untar the attached test case
2.type 'cd sandbox'
3.type 'make'
4.type 'cd ..'
5.type 'gdb sandbox/debug_test'
6.type list other

  
Actual results:
the symbol other is found, but the source file for it (other.h) is not
and is reported as 'No such file or directory'

Expected results:
the definition of the function other should be listed from the source
in other.h

Additional info:

Comment 1 Neil Horman 2004-12-07 15:07:13 UTC
Created attachment 108041 [details]
testcase demonstrating bug

This is the testcase demonstrating the gdb bug

Comment 2 Neil Horman 2004-12-07 15:14:59 UTC
Created attachment 108043 [details]
patch to fix gdb file searching

This is a patch to fix the way gdb searches for files.	I've tested it and it
seems to work well.  I'm not sure its the best fix, as there are a few
alternatives.  The problem stems from the fact that in open_source_file, as
part of the search algorithm, gdb attempts to open the needed source file in
$cdir/<symtab->dirname>/<symtab->filename>, but unfortunately:
1) nothing in gdb ever sets $cdir, and it should be set to the compilation
directory if one exists in the binary debug information
2) open_source_file is broken in the way it seems to parse the directory
information in this manner

I wasn't sure of the history behind cdir, and why nobody seems to use it, so I
opted instead in this patch to modify dwarf_decode_lines such that the
compilation directory was prepended to the symtab->dirname field.  This allows
a different code path to be taken in open_source_file, and as a result the file
is properly found.  I'm not 100% sure of all the repercussions of doing this,
but it seems to me to be reasonably safe since the C files seem to be handled
in this fashion.

Comment 5 Jeff Johnston 2005-01-25 23:23:30 UTC
A patch has been built into gdb version 6.1post-1.20040607.52.6 which fixes the
problem.

Comment 6 Dave Maley 2005-01-26 18:08:07 UTC
I just ran through a quick test w/ the customers reproducer and this does indeed
appear to be fixed in 6.1post-1.20040607.52.6.  I'll provide this to the
customer for verification.

Comment 7 Tim Powers 2005-05-19 12:09:50 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2005-187.html



Note You need to log in before you can comment on or make changes to this bug.