From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: Re: [RFC] mips-tdep.c: pseudo-register -> raw register sign extension
Date: Thu, 09 Dec 2010 23:20:00 -0000 [thread overview]
Message-ID: <20101209162000.29cb4e3f@mesquite.lan> (raw)
In-Reply-To: <201012091119.oB9BJ0G1007042@glazunov.sibelius.xs4all.nl>
On Thu, 9 Dec 2010 12:19:00 +0100 (CET)
Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
> > + LONGEST regval = extract_signed_integer (buf, 4, byte_order);
> > + store_signed_integer (buf8, 8, byte_order, regval);
> > + regcache_raw_write (regcache, rawnum, buf8);
>
> How about using regcache_raw_write_signed() here? I think that
> simplifies the code enough to change mips_pseudo_register_read() to
> use regcache_raw_read_signed() and get rid of the explicit endian-ness
> check as well.
I like this suggestion. See below for a revised patch...
Kevin
* 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().
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.508
diff -u -p -r1.508 mips-tdep.c
--- mips-tdep.c 28 Nov 2010 04:31:24 -0000 1.508
+++ mips-tdep.c 9 Dec 2010 23:03:02 -0000
@@ -559,11 +559,15 @@ mips_pseudo_register_read (struct gdbarc
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 gdbar
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"));
next prev parent reply other threads:[~2010-12-09 23:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-07 23:47 Kevin Buettner
2010-12-09 11:19 ` Mark Kettenis
2010-12-09 23:20 ` Kevin Buettner [this message]
2010-12-15 20:54 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101209162000.29cb4e3f@mesquite.lan \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox