Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] mips-tdep.c: Fix bug in evaluating signed address
Date: Wed, 28 Jun 2006 13:22:00 -0000	[thread overview]
Message-ID: <20060628132201.GC24606@calimero.vinschen.de> (raw)
In-Reply-To: <20060616162332.GA11814@calimero.vinschen.de>

Ping?

On Jun 16 18:23, Corinna Vinschen wrote:
> If the incoming type is an *unsigned* value, then unpack_long takes the
> (un)signedness into account.  This results in `val' not being signed
> extended, as the mips_integer_to_address function was originally
> designed for.

I missed to add the fact that this can be demonstrated using an existing
testcase, gdb.base/ending-run.exp with mips64-elf.  There's a statement

  (gdb) cle *0xa0123456

Which fails with

  No breakpoint at 0xa0123456

The reason is that the breakpoint address is correctly stored sign
extended (0xffffffffa0123456), but the evaluation of "*0xa0123456"
evaluates the expression 0xa0123456 as unsigned int type.  This in
turn leads to the above described behaviour.

> So, to enforce correct signedness of the resulting address, I changed
> the unpack_long call to extract_signed_integer.  This way, val is always
> sign extended and the mips address is correctly signed.
> 
> 
> Ok to apply?
> 
> 
> Thanks,
> Corinna
> 
> 
> 	* mips-tdep.c (mips_integer_to_address): Call extract_signed_integer
> 	instead of unpack_long to maintain signedness.
> 
> 
> Index: gdb/mips-tdep.c
> ===================================================================
> RCS file: /cvs/cvsfiles/gnupro/gdb/mips-tdep.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 mips-tdep.c
> --- gdb/mips-tdep.c	15 Jun 2006 08:57:17 -0000	1.24
> +++ gdb/mips-tdep.c	16 Jun 2006 16:15:48 -0000
> @@ -4749,7 +4749,7 @@ mips_integer_to_address (struct gdbarch 
>  			 struct type *type, const gdb_byte *buf)
>  {
>    gdb_byte *tmp = alloca (TYPE_LENGTH (builtin_type_void_data_ptr));
> -  LONGEST val = unpack_long (type, buf);
> +  LONGEST val = extract_signed_integer (buf, TYPE_LENGTH (type));
>    store_signed_integer (tmp, TYPE_LENGTH (builtin_type_void_data_ptr), val);
>    return extract_signed_integer (tmp,
>  				 TYPE_LENGTH (builtin_type_void_data_ptr));

Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


  reply	other threads:[~2006-06-28 13:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-16 16:23 Corinna Vinschen
2006-06-28 13:22 ` Corinna Vinschen [this message]
2006-07-12 19:31 ` Daniel Jacobowitz
2006-07-13 11:55   ` Corinna Vinschen
2006-07-13 13:00     ` Daniel Jacobowitz
2006-07-13 13:15       ` Corinna Vinschen

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=20060628132201.GC24606@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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