From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23934 invoked by alias); 20 Jul 2010 17:51:50 -0000 Received: (qmail 23924 invoked by uid 22791); 20 Jul 2010 17:51:49 -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,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-ey0-f169.google.com (HELO mail-ey0-f169.google.com) (209.85.215.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Jul 2010 17:51:43 +0000 Received: by eydd26 with SMTP id d26so1555313eyd.0 for ; Tue, 20 Jul 2010 10:51:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.27.195 with SMTP id j3mr6473525ebc.97.1279648300735; Tue, 20 Jul 2010 10:51:40 -0700 (PDT) Received: by 10.213.20.148 with HTTP; Tue, 20 Jul 2010 10:51:40 -0700 (PDT) In-Reply-To: References: Date: Tue, 20 Jul 2010 17:51:00 -0000 Message-ID: Subject: [ping] [gdbserver] paddress() can truncate its argument From: Ozkan Sezer To: 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/msg00305.txt.bz2 PING. Any objections? Can I apply this change? 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 truncates > 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 >