This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: exp/1811: "set var x = y" doesn't work properly if sizeof(x) < sizeof(register)


The following reply was made to PR exp/1811; it has been noted by GNATS.

From: Daniel Jacobowitz <dan@debian.org>
To: tausq@debian.org
Cc: gdb-gnats@sources.redhat.com
Subject: Re: exp/1811: "set var x = y" doesn't work properly if sizeof(x) < sizeof(register)
Date: Fri, 19 Nov 2004 00:03:07 -0500

 On Tue, Nov 16, 2004 at 01:47:22AM -0000, tausq@debian.org wrote:
 > 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.
 
 This bit, you said down-bug, might be a debug info problem.  I think
 that's very likely.
 
 > 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.
 
 This, on the other hand, looks pretty broken!  Most architectures
 require either sign or zero extension for sub-word values.
 
 -- 
 Daniel Jacobowitz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]