From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27836 invoked by alias); 20 Jul 2010 18:00:48 -0000 Received: (qmail 27824 invoked by uid 22791); 20 Jul 2010 18:00:46 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_XS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Jul 2010 18:00:40 +0000 Received: (qmail 28868 invoked from network); 20 Jul 2010 18:00:39 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Jul 2010 18:00:39 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [ping] [gdbserver] paddress() can truncate its argument Date: Tue, 20 Jul 2010 18:00:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.31-11-rt; KDE/4.4.2; x86_64; ; ) Cc: Ozkan Sezer References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201007201900.36018.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00306.txt.bz2 On Tuesday 20 July 2010 18:51:40, Ozkan Sezer wrote: > PING. > Any objections? Can I apply this change? Yes. > > > On Fri, Jul 16, 2010 at 11:49 PM, Ozkan Sezer wrote: > > Hi: > > > > Noticed this while messing around with win64 support: paddress() casts > > its CORE_ADDR argument (which is specifically defined as long long in > > gdbserver) to long, probably assuming LP64 convention. For win64, which > > is LLP64, it is not true (sizeof(long) == 4 always) and it truncates > > its argument. > > > > Shouldn't paddress() just return phex_nz() instead, like the following: > > > > Index: utils.c > > =================================================================== > > RCS file: /cvs/src/src/gdb/gdbserver/utils.c,v > > retrieving revision 1.23 > > diff -u -p -r1.23 utils.c > > --- utils.c 1 Jun 2010 13:20:52 -0000 1.23 > > +++ utils.c 16 Jul 2010 20:41:14 -0000 > > @@ -257,17 +257,6 @@ xsnprintf (char *str, size_t size, const > > return ret; > > } > > > > -/* Convert a CORE_ADDR into a HEX string, like %lx. > > - The result is stored in a circular static buffer, NUMCELLS deep. */ > > - > > -char * > > -paddress (CORE_ADDR addr) > > -{ > > - char *str = get_cell (); > > - xsnprintf (str, CELLSIZE, "%lx", (long) addr); > > - return str; > > -} > > - > > static char * > > decimal2str (char *sign, ULONGEST addr, int width) > > { > > @@ -372,3 +361,12 @@ phex_nz (ULONGEST l, int sizeof_l) > > > > return str; > > } > > + > > +/* Convert a CORE_ADDR into a HEX string, like %lx. > > + The result is stored in a circular static buffer, NUMCELLS deep. */ > > + > > +char * > > +paddress (CORE_ADDR addr) > > +{ > > + return phex_nz (addr, sizeof (CORE_ADDR)); > > +} > > > > Comments? > > > > -- > > Ozkan > > > -- Pedro Alves