From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30567 invoked by alias); 10 Nov 2004 14:39:51 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30242 invoked from network); 10 Nov 2004 14:39:41 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 10 Nov 2004 14:39:41 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iAAEdZde006719 for ; Wed, 10 Nov 2004 09:39:35 -0500 Received: from localhost.redhat.com (to-dhcp51.toronto.redhat.com [172.16.14.151]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iAAEdPr02660; Wed, 10 Nov 2004 09:39:25 -0500 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id F0CB2129D8C; Wed, 10 Nov 2004 09:38:23 -0500 (EST) Message-ID: <419227DC.4070201@gnu.org> Date: Wed, 10 Nov 2004 14:39:00 -0000 From: Andrew Cagney User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) MIME-Version: 1.0 To: Mark Kettenis Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Fix mips32_relative_offset() References: <200411091256.iA9CujKE090590@elgar.sibelius.xs4all.nl> In-Reply-To: <200411091256.iA9CujKE090590@elgar.sibelius.xs4all.nl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-11/txt/msg00193.txt.bz2 Mark Kettenis wrote: > The current code assumes that sizeof(long) == 32, which obviously > isn't true on LP64 platforms. The attached patch fixes that by using > the sign-extension idiom that's also used for SPARC. It still assumes > that a long can hold a 18-bit signed integer, but ISO C guarantees > that it can. > > OK? Yes. > P.S. Incidentally I think the function should return a LONGEST instead > of CORE_ADDR. and take a ULONGEST as input. If you want to do that, ok. Andrew > Index: ChangeLog > from Mark Kettenis > > * mips-tdep.c (mips32_relative_offset): Avoid ussumption that > sizeof(long) == 32. > > Index: mips-tdep.c > =================================================================== > RCS file: /cvs/src/src/gdb/mips-tdep.c,v > retrieving revision 1.362 > diff -u -p -r1.362 mips-tdep.c > --- mips-tdep.c 31 Oct 2004 21:51:58 -0000 1.362 > +++ mips-tdep.c 9 Nov 2004 12:51:40 -0000 > @@ -881,14 +881,8 @@ mips_fetch_instruction (CORE_ADDR addr) > static CORE_ADDR > mips32_relative_offset (unsigned long inst) > { > - long x; > - x = itype_immediate (inst); > - if (x & 0x8000) /* sign bit set */ > - { > - x |= 0xffff0000; /* sign extension */ > - } > - x = x << 2; > - return x; > + long x = ((itype_immediate (inst) ^ 0x8000) - 0x8000); > + return x << 2; > } > > /* Determine whate to set a single step breakpoint while considering >