This is the mail archive of the mailing list for the Insight project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [PATCH] print format does not match argument type

> -----Message d'origine-----
> De?: [] De
> la part de Keith Seitz
> Envoyé?: mardi 10 avril 2012 18:28
> À?: Patrick Monnerat
> Cc?:;
> Objet?: Re: [PATCH] print format does not match argument type
> On 04/10/2012 09:08 AM, Patrick Monnerat wrote:
> > 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 :-(
> 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.
> 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.
> 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 
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

cvs diff: Diffing generic
Index: generic/gdbtk-register.c
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 = xstrprintf ("%lx", (size_t)TYPE_FIELD_TYPE (reg_vtype, i));
+         buff = xstrprintf ("%s", host_address_to_string (
+                                    TYPE_FIELD_TYPE (reg_vtype, i)));
          ar[0] = Tcl_NewStringObj (TYPE_FIELD_NAME (reg_vtype, i), -1);
          ar[1] = Tcl_NewStringObj (buff, -1);
          if (TYPE_CODE (TYPE_FIELD_TYPE (reg_vtype, i)) == TYPE_CODE_FLT)
@@ -255,7 +256,7 @@ get_register_types (int regnum, map_arg
       Tcl_Obj *ar[3], *list;
       char *buff;
-      buff = xstrprintf ("%lx", (size_t)reg_vtype);
+      buff = xstrprintf ("%s", host_address_to_string (reg_vtype));
       ar[0] = Tcl_NewStringObj (TYPE_NAME(reg_vtype), -1);
       ar[1] = Tcl_NewStringObj (buff, -1);
       if (TYPE_CODE (reg_vtype) == 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]