From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21539 invoked by alias); 12 Jul 2006 19:31:57 -0000 Received: (qmail 21499 invoked by uid 22791); 12 Jul 2006 19:31:56 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Wed, 12 Jul 2006 19:31:51 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1G0kR4-0007kK-0E for gdb-patches@sourceware.org; Wed, 12 Jul 2006 15:31:50 -0400 Date: Wed, 12 Jul 2006 19:31:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: Re: [PATCH] mips-tdep.c: Fix bug in evaluating signed address Message-ID: <20060712193149.GP24622@nevyn.them.org> Mail-Followup-To: gdb-patches@sourceware.org References: <20060616162332.GA11814@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060616162332.GA11814@calimero.vinschen.de> User-Agent: Mutt/1.5.11+cvs20060403 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00128.txt.bz2 On Fri, Jun 16, 2006 at 06:23:32PM +0200, Corinna Vinschen wrote: > Hi, > > the below patch fixes the mips_integer_to_address function. What > happens is this: > > 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. > > 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. I might be missing something, but isn't the function mostly redundant now? > 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)); Those last two have got to be a no-op. -- Daniel Jacobowitz CodeSourcery