This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
exp/1090: gdb prints wrong value for 8-byte variable in two 4-byte registers
- From: mec at shout dot net
- To: gdb-gnats at sources dot redhat dot com
- Date: 24 Feb 2003 02:27:02 -0000
- Subject: exp/1090: gdb prints wrong value for 8-byte variable in two 4-byte registers
- Reply-to: mec at shout dot net
>Number: 1090
>Category: exp
>Synopsis: gdb prints wrong value for 8-byte variable in two 4-byte registers
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Feb 24 02:28:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: mec at shout dot net
>Release: gdb 5.3
>Organization:
>Environment:
target=native, host=i686-pc-linux-gnu, osversion=red-hat-8.0
gdb=5.3, gcc=2.95.3, binutils=2.13.2.1, glibc=2.2.93-5-rh
gformat => dwarf-2, stabs+
>Description:
gcc 2.95.3 can allocate a variable into multiple registers. gdb gets confused when this happens.
Test program:
struct s_2_by_4
{
int field_0;
int field_1;
};
void bar (struct s_2_by_4 s_whatever)
{
s_whatever = s_whatever;
return;
}
void foo ()
{
register struct s_2_by_4 s24;
s24.field_0 = 1170;
s24.field_1 = 64701;
bar (s24);
return;
}
int main ()
{
foo ();
}
Compile with gcc 2.95.3. gcc 3.2.2 does not exhibit the problem because it puts s24 into memory, not registers. Either dwarf-2 or stabs+ exhibits the problem.
Break on 'foo', go down a couple of lines, and print the variable 's24'. gdb prints the wrong value.
The test suite catches one instance of this:
FAIL: gdb.base/store.exp: new check struct 4
This particular test PASSed with gdb 5.3, although I think gdb is bogus internally -- I think it is writing to some bogus place and then reading back from the same bogus place.
This test FAILed with gdb HEAD%20030222. I narrowed the failure down to this patch:
http://sources.redhat.com/ml/gdb-cvs/2003-02/msg00216.html
... but gdb was broken before then.
I will write a test case for this PR tonight.
>How-To-Repeat:
>Fix:
gdb may not be able to print the right values: there may not be enough debug information in the gcc 2.95.3 case. After I write a test case, I'll attack a couple of executables to this PR, and we can talk about it.
But there is probably plenty of information for gdb to say "oops, you have a variable with size=8 and I know about only one register for it, I can't print the value at all". It's much better for gdb to say that than to print random values.
>Release-Note:
>Audit-Trail:
>Unformatted: