Bug 109921 - gdb is not finding the correct include file for variables
gdb is not finding the correct include file for variables
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: gdb (Show other bugs)
i586 Linux
medium Severity low
: ---
: ---
Assigned To: Jan Kratochvil
Jay Turner
Depends On: 213784
Blocks: 222381 222382
  Show dependency treegraph
Reported: 2003-11-12 19:05 EST by Debby Townsend
Modified: 2015-01-07 19:06 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-01-11 17:50:07 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
first of two example files (378 bytes, text/plain)
2003-11-12 19:15 EST, Debby Townsend
no flags Details
second file of the example (238 bytes, text/plain)
2003-11-12 19:16 EST, Debby Townsend
no flags Details
Preliminary fix. (11.17 KB, patch)
2007-01-02 04:22 EST, Jan Kratochvil
no flags Details | Diff
Testcase. (3.90 KB, patch)
2007-01-02 04:24 EST, Jan Kratochvil
no flags Details | Diff

  None (edit)
Description Debby Townsend 2003-11-12 19:05:05 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

Description of problem:
Both the "info variable" and the "list" command, when given the name 
of an external variable which is defined in an #include'd file,  list 
the incorrect file-name.  In the case of "list" the line number is 
extrapolated correctly; but the wrong source file is listed. 

The problem does not occur for functions defined in the same 
#include'd file. 

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. Create a header file ( foo2.c )  which defines an external 
variable (bar)
2. #include the header file in a small program ( foo.c )
3. compile with -g and run under gdb

Actual Results:  
(gdb) info variable bar
All variables matching regular expression "bar":

File foo.c:
static int bar;

(gdb) list bar
7       int i5;
8       int i6;
9       int i7;
10      int i8;
11      int i9;
13      int main(void)
14      {
15              return circle(1);
16      }

(gdb) shell grep -n bar foo.c
(gdb) shell grep -n bar foo2.c
12:static int bar = 16;

Expected Results:  The "info variable bar" command correctly lists 
the variable definition but credits foo.c rather than foo2.c

The "list bar" command lists lines 7-16 of foo.c instead of lines 7-
16 of foo2.c

Additional info: See attachments for example
Comment 1 Debby Townsend 2003-11-12 19:15:13 EST
Created attachment 95935 [details]
first of two example files
Comment 2 Debby Townsend 2003-11-12 19:16:28 EST
Created attachment 95936 [details]
second file of the example

compile with:
cc -g -o foo foo.c
Comment 3 Mike Gahagan 2004-06-01 16:16:42 EDT
This is still a problem in U4

[mpg@black-monolith mpg]$ rpm -q gdb
Comment 4 Jan Kratochvil 2007-01-02 04:22:30 EST
Created attachment 144625 [details]
Preliminary fix.
Comment 5 Jan Kratochvil 2007-01-02 04:24:51 EST
Created attachment 144627 [details]
Comment 7 Jan Kratochvil 2007-01-09 06:38:10 EST
Comment on attachment 144625 [details]
Preliminary fix.

Buggy - regression.
Comment 8 Jan Kratochvil 2007-01-09 06:40:17 EST
Comment on attachment 144627 [details]

Buggy - directory sensitive.
Comment 9 Jan Kratochvil 2007-01-09 07:38:48 EST
Committed to RawHide:

* Tue Jan  9 2007 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.5-23
- Find symbols properly at their original (included) file (BZ 109921).
Comment 10 Jan Kratochvil 2007-01-11 17:40:50 EST
Posted upstream:
Comment 11 Jan Kratochvil 2007-01-11 17:50:07 EST
Committed in RawHide.
Not going to fix in RHEL2 as it is strictly a maintenance only (if at all) release.
To be considered for fixing in RHEL4+.

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