From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2585 invoked by alias); 17 Jul 2010 18:59:23 -0000 Received: (qmail 2576 invoked by uid 22791); 17 Jul 2010 18:59:22 -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 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; Sat, 17 Jul 2010 18:59:18 +0000 Received: by eydd26 with SMTP id d26so878855eyd.0 for ; Sat, 17 Jul 2010 11:59:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.19.205 with SMTP id c13mr2521504ebb.99.1279393156178; Sat, 17 Jul 2010 11:59:16 -0700 (PDT) Received: by 10.213.11.1 with HTTP; Sat, 17 Jul 2010 11:59:16 -0700 (PDT) In-Reply-To: <201007171447.38746.vapier@gentoo.org> References: <201007171447.38746.vapier@gentoo.org> Date: Sat, 17 Jul 2010 18:59:00 -0000 Message-ID: Subject: Re: [PATCH] [Windows] fix format string for 64 bit var in gdbserver From: Ozkan Sezer To: Mike Frysinger Cc: gdb-patches@sourceware.org, Tom Tromey 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/msg00263.txt.bz2 On Sat, Jul 17, 2010 at 9:47 PM, Mike Frysinger wrote: > On Saturday, July 17, 2010 05:53:04 Ozkan Sezer wrote: >> On Sat, Jul 17, 2010 at 12:42 PM, Ozkan Sezer wrote: >> > On Sat, Jul 17, 2010 at 12:37 PM, Mike Frysinger > wrote: >> >> On Friday, July 16, 2010 16:10:23 Ozkan Sezer wrote: >> >>> For windows targets, (x86_64-w64-mingw32, i686-w64-mingw32) >> >>> gcc complains: >> >>> >> >>> ../../../gdb-cvs/gdb/gdbserver/server.c: In function 'handle_query': >> >>> ../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: unknown >> >>> conversion type character 'l' in format >> >>> ../../../gdb-cvs/gdb/gdbserver/server.c:1542: warning: too many >> >>> arguments for format >> >>> ../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: unknown >> >>> conversion type character 'l' in format >> >>> ../../../gdb-cvs/gdb/gdbserver/server.c:1566: warning: too many >> >>> arguments for format >> >>> >> >>> This is due to the fact that MS printf doesn't support %lld, it uses >> >>> its own %I64d which gcc already knows about. The attached patch >> >>> changes that. OK for apply? >> >> >> >> ugh, no. =A0why not use a sane define like PRIx64 from inttypes.h ? >> > >> > I would happily do that, however that would require inttypes >> > module merge from gnulib to gdb/gnulib, am I wrong? >> >> To be clear, I modified a patch I submitted before to not use >> the inttypes PRI macros: >> http://sourceware.org/ml/gdb-patches/2010-07/msg00244.html >> >> By analogy, I might use paddress() instead, but for that case >> please see the issue I reported at >> http://sourceware.org/ml/gdb-patches/2010-07/msg00254.html >> >> Comments? > > random #ifdefs like this are highly discouraged. =A0if you could find ano= ther > way, that'd be great. =A0but i dont think importing a few small modules f= rom I do agree that the ifdefs are ugly. The cleanest way would be using paddress() like this: Index: server.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/server.c,v retrieving revision 1.125 diff -u -p -r1.125 server.c --- server.c 7 Jul 2010 16:14:04 -0000 1.125 +++ server.c 17 Jul 2010 18:54:41 -0000 @@ -1539,7 +1539,7 @@ handle_query (char *own_buf, int packet_ if (err =3D=3D 0) { - sprintf (own_buf, "%llx", address); + sprintf (own_buf, "%s", paddress(address)); return; } else if (err > 0) @@ -1563,7 +1563,7 @@ handle_query (char *own_buf, int packet_ n =3D (*the_target->get_tib_address) (ptid, &tlb); if (n =3D=3D 1) { - sprintf (own_buf, "%llx", tlb); + sprintf (own_buf, "%s", paddress(tlb)); return; } else if (n =3D=3D 0) ... which is non-intrusive and easy. However, as I reported here: http://sourceware.org/ml/gdb-patches/2010-07/msg00254.html ... paddress() truncates its arguments and should be fixed. > gnulib is a big deal ? I might agree with that, but not everyone does ;) If the above paddress() solution is not acceptable, I can easily cook something using PRI macros (but someone else should import inttypes from gnulib, that't not something I am comfortable with.) > -mike > Regards. -- Ozkan