From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29078 invoked by alias); 13 Apr 2012 14:52:47 -0000 Received: (qmail 29044 invoked by uid 22791); 13 Apr 2012 14:52:42 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,MSGID_MULTIPLE_AT,TW_BT,TW_DB X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.151) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Apr 2012 14:52:28 +0000 Received: from md2.u-strasbg.fr (md2.u-strasbg.fr [IPv6:2001:660:2402::187]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id q3DEq3VZ044519 ; Fri, 13 Apr 2012 16:52:04 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms3.u-strasbg.fr [130.79.204.12]) by md2.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id q3DEq2vc063725 ; Fri, 13 Apr 2012 16:52:03 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id q3DEq1rH097478 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Fri, 13 Apr 2012 16:52:01 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Keith Seitz'" , "'Patrick Monnerat'" Cc: , References: <4F8443D1.9080105@onevision.com> <4F845F7E.1010603@redhat.com> In-Reply-To: <4F845F7E.1010603@redhat.com> Subject: RE: [PATCH] print format does not match argument type Date: Fri, 13 Apr 2012 14:52:00 -0000 Message-ID: <000001cd1984$fce97c30$f6bc7490$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact insight-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sourceware.org X-SW-Source: 2012-q2/txt/msg00014.txt.bz2 > -----Message d'origine----- > De=A0: insight-owner@sourceware.org [mailto:insight-owner@sourceware.org]= De > la part de Keith Seitz > Envoy=E9=A0: mardi 10 avril 2012 18:28 > =C0=A0: Patrick Monnerat > Cc=A0: insight@sourceware.org; roland@onevision.com > Objet=A0: Re: [PATCH] print format does not match argument type >=20 > On 04/10/2012 09:08 AM, Patrick Monnerat wrote: >=20 > > I think I've found the universal (well: almost!) coding: > > > > Use format "%llx" and cast arg to (unsigned long long): This is C99 and > > supported by MSVC, at least since 2005. Not OK for C89 :-( >=20 > To be honest, I didn't even know that we did this. [The register code is > some of the oldest code in insight.] Passing host memory addresses into > the interpreter and back again as a string is just plain evil. >=20 > The C code should create a map/hashtable and store the pointers to the > types itself; then pass a string representation of the key into the > interpreter. >=20 > But for now, if your suggestion works (Roland will hopefully verify), > then I say we go with that for the time being. The gdb/utils.c function called host_address_to_string was created to allow printing of host pointer without need to bother with %llX or typecasts... It does add a '0x' at the start of the=20 generated pchar, but I don't think that this is a big problem. This second field (ar[1]) is probably added to avoid confusion between type with same name... Should we use this patch? Pierre Muller ChangeLog entry: 2012-04-13 Pierre Muller * generic/gdbtk-register.c (get_register_types): Use host_address_to_string function to avoid use of "%lx" and typecasts. cvs diff: Diffing generic Index: generic/gdbtk-register.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/gdbtk/generic/gdbtk-register.c,v retrieving revision 1.42 diff -u -p -r1.42 gdbtk-register.c --- generic/gdbtk-register.c 30 Mar 2012 07:36:10 -0000 1.42 +++ generic/gdbtk-register.c 13 Apr 2012 14:42:56 -0000 @@ -239,7 +239,8 @@ get_register_types (int regnum, map_arg { Tcl_Obj *ar[3], *list; char *buff; - buff =3D xstrprintf ("%lx", (size_t)TYPE_FIELD_TYPE (reg_vtype, i= )); + buff =3D xstrprintf ("%s", host_address_to_string ( + TYPE_FIELD_TYPE (reg_vtype, i))); ar[0] =3D Tcl_NewStringObj (TYPE_FIELD_NAME (reg_vtype, i), -1); ar[1] =3D Tcl_NewStringObj (buff, -1); if (TYPE_CODE (TYPE_FIELD_TYPE (reg_vtype, i)) =3D=3D TYPE_CODE_F= LT) @@ -255,7 +256,7 @@ get_register_types (int regnum, map_arg { Tcl_Obj *ar[3], *list; char *buff; - buff =3D xstrprintf ("%lx", (size_t)reg_vtype); + buff =3D xstrprintf ("%s", host_address_to_string (reg_vtype)); ar[0] =3D Tcl_NewStringObj (TYPE_NAME(reg_vtype), -1); ar[1] =3D Tcl_NewStringObj (buff, -1); if (TYPE_CODE (reg_vtype) =3D=3D TYPE_CODE_FLT) cvs diff: Diffing library cvs diff: Diffing library/help cvs diff: Diffing library/help/images cvs diff: Diffing library/help/trace cvs diff: Diffing library/images cvs diff: Diffing library/images2 cvs diff: Diffing plugins cvs diff: Diffing plugins/intel-pentium cvs diff: Diffing plugins/rhabout