This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
exp/1811: "set var x = y" doesn't work properly if sizeof(x) < sizeof(register)
- From: tausq at debian dot org
- To: gdb-gnats at sources dot redhat dot com
- Date: 16 Nov 2004 01:47:22 -0000
- Subject: exp/1811: "set var x = y" doesn't work properly if sizeof(x) < sizeof(register)
- Reply-to: tausq at debian dot org
>Number: 1811
>Category: exp
>Synopsis: "set var x = y" doesn't work properly if sizeof(x) < sizeof(register)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 16 01:48:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: tausq@debian.org
>Release: GNU gdb 6.3.50_2004-11-15-cvs
>Organization:
>Environment:
hppa-linux
>Description:
>From testsuite/gdb.base/store.exp:
suppose you have:
void foo() {
char x;
[...]
}
in your program, and then you do this in gdb:
(gdb) set var x = 4
gdb will try to convert 4 into a char to store it into x, as expected. However, the ABI representation of x may have a minimum size requirement (i.e word-size for register or stack slot). Since x's type has len == 1, gdb will only store 1 byte into the inferior's stack slot or register. If we subsequently use that stack slot or register for another operation, the value will be wrong.
Another symptom of this problem is that:
(gdb) print /x $r4
$2 = 0xffffffff
(gdb) print &r
Address requested for identifier "r" which is in register $r4
(gdb) set var r = 4
(gdb) print r
$3 = 4 '\004'
(gdb) print /x $r4
$4 = 0xffffff04
After evaluating the expression, the value of r seems to be cached by gdb but it doesn't match the value in the inferior.
In value_assign (), we seem to equate "gdb's representation of a value" with "target's representation of a value". We obviously cannot blindly cast up the value of a smaller-than-word-size value. Suppose the variable is part of a packed structure with several char's, then storing only one byte is the right behavior.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: