From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15749 invoked by alias); 20 Jul 2010 18:12:17 -0000 Received: (qmail 15736 invoked by uid 22791); 20 Jul 2010 18:12:16 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,TW_XS X-Spam-Check-By: sourceware.org Received: from mail-ew0-f41.google.com (HELO mail-ew0-f41.google.com) (209.85.215.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Jul 2010 18:12:11 +0000 Received: by ewy28 with SMTP id 28so2089577ewy.0 for ; Tue, 20 Jul 2010 11:12:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.4.146 with SMTP id 18mr5107136ebr.24.1279649527566; Tue, 20 Jul 2010 11:12:07 -0700 (PDT) Received: by 10.213.20.148 with HTTP; Tue, 20 Jul 2010 11:12:07 -0700 (PDT) In-Reply-To: <201007201900.36018.pedro@codesourcery.com> References: <201007201900.36018.pedro@codesourcery.com> Date: Tue, 20 Jul 2010 18:12:00 -0000 Message-ID: Subject: Re: [ping] [gdbserver] paddress() can truncate its argument From: Ozkan Sezer To: Pedro Alves Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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/msg00307.txt.bz2 On Tue, Jul 20, 2010 at 9:00 PM, Pedro Alves wrote: > On Tuesday 20 July 2010 18:51:40, Ozkan Sezer wrote: >> PING. >> Any objections? Can I apply this change? > > Yes. > Applied. Thanks. >> >> >> 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) =3D=3D 4 always) and it truncat= es >> > its argument. >> > >> > Shouldn't paddress() just return phex_nz() instead, like the following: >> > >> > Index: utils.c >> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> > RCS file: /cvs/src/src/gdb/gdbserver/utils.c,v >> > retrieving revision 1.23 >> > diff -u -p -r1.23 utils.c >> > --- utils.c =A0 =A0 1 Jun 2010 13:20:52 -0000 =A0 =A0 =A0 1.23 >> > +++ utils.c =A0 =A0 16 Jul 2010 20:41:14 -0000 >> > @@ -257,17 +257,6 @@ xsnprintf (char *str, size_t size, const >> > =A0 return ret; >> > =A0} >> > >> > -/* Convert a CORE_ADDR into a HEX string, like %lx. >> > - =A0 The result is stored in a circular static buffer, NUMCELLS deep.= =A0*/ >> > - >> > -char * >> > -paddress (CORE_ADDR addr) >> > -{ >> > - =A0char *str =3D get_cell (); >> > - =A0xsnprintf (str, CELLSIZE, "%lx", (long) addr); >> > - =A0return str; >> > -} >> > - >> > =A0static char * >> > =A0decimal2str (char *sign, ULONGEST addr, int width) >> > =A0{ >> > @@ -372,3 +361,12 @@ phex_nz (ULONGEST l, int sizeof_l) >> > >> > =A0 return str; >> > =A0} >> > + >> > +/* Convert a CORE_ADDR into a HEX string, like %lx. >> > + =A0 The result is stored in a circular static buffer, NUMCELLS deep.= =A0*/ >> > + >> > +char * >> > +paddress (CORE_ADDR addr) >> > +{ >> > + =A0return phex_nz (addr, sizeof (CORE_ADDR)); >> > +} >> > >> > Comments? >> > >> > -- >> > Ozkan >> > >> > > > -- > Pedro Alves > -- Ozkan