Bug 109921 - gdb is not finding the correct include file for variables
Summary: gdb is not finding the correct include file for variables
Alias: None
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: gdb   
(Show other bugs)
Version: 2.1
Hardware: i586
OS: Linux
Target Milestone: ---
Assignee: Jan Kratochvil
QA Contact: Jay Turner
Depends On: 213784
Blocks: 222381 222382
TreeView+ depends on / blocked
Reported: 2003-11-13 00:05 UTC by Debby Townsend
Modified: 2015-01-08 00:06 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-01-11 22:50:07 UTC
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-13 00:15 UTC, Debby Townsend
no flags Details
second file of the example (238 bytes, text/plain)
2003-11-13 00:16 UTC, Debby Townsend
no flags Details
Preliminary fix. (11.17 KB, patch)
2007-01-02 09:22 UTC, Jan Kratochvil
no flags Details | Diff
Testcase. (3.90 KB, patch)
2007-01-02 09:24 UTC, Jan Kratochvil
no flags Details | Diff

Description Debby Townsend 2003-11-13 00:05:05 UTC
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-13 00:15:13 UTC
Created attachment 95935 [details]
first of two example files

Comment 2 Debby Townsend 2003-11-13 00:16:28 UTC
Created attachment 95936 [details]
second file of the example

compile with:
cc -g -o foo foo.c

Comment 3 Mike Gahagan 2004-06-01 20:16:42 UTC
This is still a problem in U4

[mpg@black-monolith mpg]$ rpm -q gdb

Comment 4 Jan Kratochvil 2007-01-02 09:22:30 UTC
Created attachment 144625 [details]
Preliminary fix.

Comment 5 Jan Kratochvil 2007-01-02 09:24:51 UTC
Created attachment 144627 [details]

Comment 7 Jan Kratochvil 2007-01-09 11:38:10 UTC
Comment on attachment 144625 [details]
Preliminary fix.

Buggy - regression.

Comment 8 Jan Kratochvil 2007-01-09 11:40:17 UTC
Comment on attachment 144627 [details]

Buggy - directory sensitive.

Comment 9 Jan Kratochvil 2007-01-09 12:38:48 UTC
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 22:40:50 UTC
Posted upstream:

Comment 11 Jan Kratochvil 2007-01-11 22:50:07 UTC
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.