Bug 142122 - (IT_55303) [PATCH] gdb fails to find files in certain cases
[PATCH] gdb fails to find files in certain cases
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gdb (Show other bugs)
3.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Elena Zannoni
Jay Turner
:
Depends On:
Blocks: 132991 146413
  Show dependency treegraph
 
Reported: 2004-12-07 10:05 EST by Neil Horman
Modified: 2015-01-07 19:09 EST (History)
4 users (show)

See Also:
Fixed In Version: RHBA-2005-241
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-05-19 08:09:50 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Neil Horman 2004-12-07 10:05:46 EST
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 10:07:13 EST
Created attachment 108041 [details]
testcase demonstrating bug

This is the testcase demonstrating the gdb bug
Comment 2 Neil Horman 2004-12-07 10:14:59 EST
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 18:23:30 EST
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 13:08:07 EST
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 08:09:50 EDT
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.