From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11621 invoked by alias); 16 Jun 2006 16:23:40 -0000 Received: (qmail 11594 invoked by uid 22791); 16 Jun 2006 16:23:38 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Fri, 16 Jun 2006 16:23:35 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 6CAA7544001; Fri, 16 Jun 2006 18:23:32 +0200 (CEST) Date: Fri, 16 Jun 2006 16:23:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: [PATCH] mips-tdep.c: Fix bug in evaluating signed address Message-ID: <20060616162332.GA11814@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2i 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-06/txt/msg00238.txt.bz2 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. 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 Vinschen Cygwin Project Co-Leader Red Hat