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: Randolph Chung <tausq@debian.org>
To: Daniel Jacobowitz <dan@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 08:28:45 -0800

 > > 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.
 
 well, yes, but....
 
 gdb doesn't do the sign extension right? it just writes the byte into
 the register. if i look at the code that gcc generates, it looks
 something like:
 
     load byte into r4
     do sign extension on r4
     use r4
 
 so if we are at "use r4" and we change r4 in gdb, it will not be
 properly sign extended. worse, if the "sign extension" operation places
 r4 into a different temp register and subsequent code operated on that
 temp register instead, setting "r" will not actually affect the outcome
 of "use r4", which is quite confusing. i don't know if there's something
 additional gcc can emit by way of drawf debug information that will make
 this clearer for gdb.
 
 randolph
 -- 
 Randolph Chung
 Debian GNU/Linux Developer, hppa/ia64 ports
 http://www.tausq.org/


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