Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: kevinb@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] mips-tdep.c: Update mips_register_to_value(), et al...
Date: Thu, 09 Dec 2010 11:06:00 -0000	[thread overview]
Message-ID: <201012091106.oB9B6HvF003270@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <20101208164657.7d9ce88e@mesquite.lan> (message from Kevin	Buettner on Wed, 8 Dec 2010 16:46:57 -0700)

> Date: Wed, 8 Dec 2010 16:46:57 -0700
> From: Kevin Buettner <kevinb@redhat.com>
> 
> Below is yet another patch that fixes a problem arising from the
> simulator catching UNPREDICTABLE behavior.   This time though, it's
> for mips64 targets that are being run in 64-bit mode.  (My earlier
> two patches dealt with 32-bit mode.)
> 
> When executing the command "set variable l = 4", GDB is writing to the
> low 32 bits of the register containing `l'.  The value was previously
> -1.  Writing only the low 32 bits with a positive value causes a
> sign mismatch between the lower 32 bits and the upper 32 bits which
> eventually causes the sim to abort back to GDB.  The instruction
> that causes the abort is the 32-bit addu instruction:
> 
> => 0xffffffff800203a4 <add_int+20>:     addu    v0,v1,v0
> (gdb) p/x $v0
> $8 = 0xfffffffffffffffe
> (gdb) p/x $v1
> $9 = 0xffffffff00000004
> (gdb) si
> UNPREDICTABLE: PC = 0x800203a4
> 
> (If the 64-bit daddu had been used instead, this abort would not have
> been triggered.)
> 
> The patch below adds a case to mips_value_to_register() to ensure that
> sign extension is performed when writing a value shorter than 64-bits
> to a 64-bit register.  It updates mips_convert_register_p() and
> mips_register_to_value() as well.
> 
> Comments?

So what if we were adding a 32-bit unsigned integer to a 64-bit
integer signed integer?  Then it would presumably be using the 64-bit
daddu instruction, and sign extending the 32-bit value when placing it
into the register would yield the wrong result wouldn't it?

> (Can anyone think of better names for the two new functions that I
> introduced?)

Yeah, they're pretty horrific.


  parent reply	other threads:[~2010-12-09 11:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08 23:47 Kevin Buettner
2010-12-09  9:01 ` Yao Qi
2010-12-10  0:34   ` Kevin Buettner
2010-12-10  1:28     ` Yao Qi
2010-12-09 11:06 ` Mark Kettenis [this message]
2010-12-11  0:04   ` Kevin Buettner
2010-12-16 22:52     ` 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=201012091106.oB9B6HvF003270@glazunov.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    /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