From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18701 invoked by alias); 28 Jun 2006 13:22:12 -0000 Received: (qmail 18687 invoked by uid 22791); 28 Jun 2006 13:22:09 -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; Wed, 28 Jun 2006 13:22:06 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id B7A50544001; Wed, 28 Jun 2006 15:22:01 +0200 (CEST) Date: Wed, 28 Jun 2006 13:22:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [PATCH] mips-tdep.c: Fix bug in evaluating signed address Message-ID: <20060628132201.GC24606@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.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.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/msg00387.txt.bz2 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