public inbox for insight@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] print format does not match argument type
@ 2012-04-11 11:38 Roland Schwingel
  2012-04-11 17:24 ` Patrick Monnerat
  0 siblings, 1 reply; 11+ messages in thread
From: Roland Schwingel @ 2012-04-11 11:38 UTC (permalink / raw)
  To: insight, insight, Keith Seitz, Patrick.Monnerat

Hi...

Yesterday I could not finish this... Sorry...

 >  > But for now, if your suggestion works (Roland will hopefully
 >  > verify),
 >  > then I say we go with that for the time being.
%llx appears to work (tested it on win32,win64 and linux 32bit).
We can even remove the cast at all. I got no warning here.

So ok... Who is doing the change?

Roland

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH] print format does not match argument type
@ 2012-04-10 16:59 Roland Schwingel
  0 siblings, 0 replies; 11+ messages in thread
From: Roland Schwingel @ 2012-04-10 16:59 UTC (permalink / raw)
  To: insight, Keith Seitz, Patrick.Monnerat

Hi...

Keith Seitz <keiths@redhat.com> wrote on 10.04.2012 18:27:42:

 > 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 :-(
MS is not really caring about standards ... for native printf on windows 
(as deliverd in msvcrt.dll) "%llx" is not supported.

 > But for now, if your suggestion works (Roland will hopefully verify),
 > then I say we go with that for the time being.
I am already testing but seeing a "funny" hang now when opening
the register window when using %llx.

Still evaluating. Have to see what xstrprintf() does exactly.
But as far as I can see at the moment it appears that vasprintf is 
getting handled by libiberty in gdb on windows.

Roland

BTW: Insight is not built using MSVC on windows, but with gcc...

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [PATCH] print format does not match argument type
@ 2012-04-10 14:30 Roland Schwingel
  2012-04-10 15:10 ` Patrick Monnerat
  2012-04-10 16:08 ` Patrick Monnerat
  0 siblings, 2 replies; 11+ messages in thread
From: Roland Schwingel @ 2012-04-10 14:30 UTC (permalink / raw)
  To: insight, Patrick.Monnerat

Hi Patrick,

insight-owner@sourceware.org wrote on 05.04.2012 18:34:27:
 > In gdb/gdbtk/generic/gdbtk-register.c, 2 statements try to use a print
 > format of "%lx" for a size_t argument. The correctness of such
 > statements is architecture dependent. If warnings are treated as
 > errors,the compilation fails.
Which warnings do you get on which platform?

The casts to size_t where introduced by myself some days ago.
Previously they where casted to long.

The TYPE_FIELD_TYPE macro returns a pointer to a struct type.
Treating this as (unsigned) long is pretty correct on *nix style
systems but not on windows. On 64bit windows a long is still 4 bytes
long, so the downcasted value is simply wrong.

Roland


^ permalink raw reply	[flat|nested] 11+ messages in thread
* [PATCH] print format does not match argument type
@ 2012-04-05 16:34 Patrick Monnerat
  0 siblings, 0 replies; 11+ messages in thread
From: Patrick Monnerat @ 2012-04-05 16:34 UTC (permalink / raw)
  To: insight

[-- Attachment #1: Type: text/plain, Size: 373 bytes --]

In gdb/gdbtk/generic/gdbtk-register.c, 2 statements try to use a print
format of "%lx" for a size_t argument. The correctness of such
statements is architecture dependent. If warnings are treated as errors,
the compilation fails.
 
The attached patch fixes these statements by unconditionally converting
the size_t argument to an unsigned long.
 
Cheers,
Patrick

[-- Attachment #2: insight-7.4.50-sizesizet.patch --]
[-- Type: application/octet-stream, Size: 1072 bytes --]

diff -Naur insight-7.4.50.orig/gdb/gdbtk/generic/gdbtk-register.c insight-7.4.50.new/gdb/gdbtk/generic/gdbtk-register.c
--- insight-7.4.50.orig/gdb/gdbtk/generic/gdbtk-register.c	2012-03-30 09:36:10.000000000 +0200
+++ insight-7.4.50.new/gdb/gdbtk/generic/gdbtk-register.c	2012-04-05 18:03:20.875181085 +0200
@@ -239,7 +239,8 @@
 	{
 	  Tcl_Obj *ar[3], *list;
 	  char *buff;
-	  buff = xstrprintf ("%lx", (size_t)TYPE_FIELD_TYPE (reg_vtype, i));
+	  buff = xstrprintf ("%lx", (unsigned long)
+				    (size_t)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 @@
     {
       Tcl_Obj *ar[3], *list;
       char *buff;
-      buff = xstrprintf ("%lx", (size_t)reg_vtype);
+      buff = xstrprintf ("%lx", (unsigned long)(size_t)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)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-04-13 15:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11 11:38 [PATCH] print format does not match argument type Roland Schwingel
2012-04-11 17:24 ` Patrick Monnerat
  -- strict thread matches above, loose matches on Subject: below --
2012-04-10 16:59 Roland Schwingel
2012-04-10 14:30 Roland Schwingel
2012-04-10 15:10 ` Patrick Monnerat
2012-04-10 16:08 ` Patrick Monnerat
2012-04-10 16:28   ` Keith Seitz
2012-04-13 14:52     ` Pierre Muller
2012-04-13 15:18       ` Keith Seitz
2012-04-13 15:25         ` Pierre Muller
2012-04-05 16:34 Patrick Monnerat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).