From: Kevin Buettner Date: Wed, 15 Dec 2010 20:53:08 +0000 (+0000) Subject: * mips-tdep.c (mips_pseudo_register_write): Sign extend 32-bit X-Git-Tag: cgen-snapshot-20110101~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8bdf35dcae2506a183214562484f24b4aaffe3ab;p=external%2Fbinutils.git * mips-tdep.c (mips_pseudo_register_write): Sign extend 32-bit cooked values that are being transferred to 64-bit raw registers. (mips_pseudo_register_read): Revise to preserve symmetry with mips_pseudo_register_write(). --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 013ff83..629abfe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2010-12-15 Kevin Buettner + + * mips-tdep.c (mips_pseudo_register_write): Sign extend 32-bit + cooked values that are being transferred to 64-bit raw registers. + (mips_pseudo_register_read): Revise to preserve symmetry with + mips_pseudo_register_write(). + 2010-12-15 Greg Watson * f-exp.y (yylex): Check entire token against keywords. diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 98e7a3e..36d59dd 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -559,11 +559,15 @@ mips_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache, else if (register_size (gdbarch, rawnum) > register_size (gdbarch, cookednum)) { - if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p - || gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) + if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p) regcache_raw_read_part (regcache, rawnum, 0, 4, buf); else - regcache_raw_read_part (regcache, rawnum, 4, 4, buf); + { + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + LONGEST regval; + regcache_raw_read_signed (regcache, rawnum, ®val); + store_signed_integer (buf, 4, byte_order, regval); + } } else internal_error (__FILE__, __LINE__, _("bad register size")); @@ -582,11 +586,17 @@ mips_pseudo_register_write (struct gdbarch *gdbarch, else if (register_size (gdbarch, rawnum) > register_size (gdbarch, cookednum)) { - if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p - || gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE) + if (gdbarch_tdep (gdbarch)->mips64_transfers_32bit_regs_p) regcache_raw_write_part (regcache, rawnum, 0, 4, buf); else - regcache_raw_write_part (regcache, rawnum, 4, 4, buf); + { + /* Sign extend the shortened version of the register prior + to placing it in the raw register. This is required for + some mips64 parts in order to avoid unpredictable behavior. */ + enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); + LONGEST regval = extract_signed_integer (buf, 4, byte_order); + regcache_raw_write_signed (regcache, rawnum, regval); + } } else internal_error (__FILE__, __LINE__, _("bad register size"));