* [PATCH] MinGW and attribute format(printf/gnu_printf)
@ 2015-10-30 10:45 Pedro Alves
2015-11-17 15:27 ` Pedro Alves
0 siblings, 1 reply; 2+ messages in thread
From: Pedro Alves @ 2015-10-30 10:45 UTC (permalink / raw)
To: gdb-patches
Cross building gdbserver for --host=x86_64-w64-mingw32 with gcc 4.8.4
20141219 (Fedora MinGW 4.8.4-1.fc20), I get:
src/gdb/gdbserver/tracepoint.c: In function 'cmd_qtdp':
src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=]
trace_debug ("Defined %stracepoint %d at 0x%s, "
^
src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=]
src/gdb/gdbserver/tracepoint.c:2577:7: error: too many arguments for format [-Werror=format-extra-args]
src/gdb/gdbserver/tracepoint.c: In function 'stop_tracing':
src/gdb/gdbserver/tracepoint.c:3447:7: error: unknown conversion type character 'l' in format [-Werror=format=]
trace_debug ("Stopping the trace because "
^
src/gdb/gdbserver/tracepoint.c:3447:7: error: too many arguments for format [-Werror=format-extra-args]
src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_tracepoint':
src/gdb/gdbserver/tracepoint.c:4651:3: error: unknown conversion type character 'l' in format [-Werror=format=]
trace_debug ("Making new traceframe for tracepoint %d at 0x%s, hit %" PRIu64,
^
src/gdb/gdbserver/tracepoint.c:4651:3: error: too many arguments for format [-Werror=format-extra-args]
src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_step':
src/gdb/gdbserver/tracepoint.c:4687:3: error: unknown conversion type character 'l' in format [-Werror=format=]
trace_debug ("Making new step traceframe for "
^
trace_debug is a macro that calls:
static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
The calls that fail checking use PRIu64, etc., like:
trace_debug ("Defined %stracepoint %d at 0x%s, "
"enabled %d step %" PRIu64 " pass %" PRIu64,
tpoint->type == fast_tracepoint ? "fast "
: tpoint->type == static_tracepoint ? "static " : "",
tpoint->number, paddress (tpoint->address), tpoint->enabled,
tpoint->step_count, tpoint->pass_count);
gnulib's stdio/printf module replacements may make %llu, etc. work on
mingw, instead of the MS-specific %I64u, and thus may make PRIu64
expand to %llu. However, gcc isn't aware of that, because libiberty's
ansidecl.h defines ATTRIBUTE_PRINTF as using attribute format(printf).
But, with that format, gcc checks for MS-style format strings (%I64u).
In order to have gcc expect gnu/standard formats, we need to use
gnu_printf format instead. Which version to use (printf/gnu_printf)
depends on msvcrt and mingw version, and so gnulib has a
configure-time check, and defines _GL_ATTRIBUTE_FORMAT_PRINTF
accordingly.
Since _GL_ATTRIBUTE_FORMAT_PRINTF is compatible with ATTRIBUTE_PRINTF,
the fix is simply to make use of the former.
gdb/ChangeLog:
2015-10-29 Pedro Alves <palves@redhat.com>
* common/common-defs.h (ATTRIBUTE_PRINTF): Redefine in terms of
_GL_ATTRIBUTE_FORMAT_PRINTF after including ansidecl.h.
---
gdb/common/common-defs.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 2be0d7d..372b404 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -35,7 +35,16 @@
#include <string.h>
#include <errno.h>
#include <alloca.h>
+
#include "ansidecl.h"
+/* This is defined by ansidecl.h, but we prefer gnulib's version. On
+ MinGW, gnulib might enable __USE_MINGW_ANSI_STDIO, which may or not
+ require use of attribute gnu_printf instead of printf. gnulib
+ checks that at configure time. Since _GL_ATTRIBUTE_FORMAT_PRINTF
+ is compatible with ATTRIBUTE_PRINTF, simply use it. */
+#undef ATTRIBUTE_PRINTF
+#define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF
+
#include "libiberty.h"
#include "pathmax.h"
#include "gdb/signals.h"
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] MinGW and attribute format(printf/gnu_printf)
2015-10-30 10:45 [PATCH] MinGW and attribute format(printf/gnu_printf) Pedro Alves
@ 2015-11-17 15:27 ` Pedro Alves
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2015-11-17 15:27 UTC (permalink / raw)
To: gdb-patches
On 10/30/2015 12:19 AM, Pedro Alves wrote:
> Cross building gdbserver for --host=x86_64-w64-mingw32 with gcc 4.8.4
> 20141219 (Fedora MinGW 4.8.4-1.fc20), I get:
>
> src/gdb/gdbserver/tracepoint.c: In function 'cmd_qtdp':
> src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=]
> trace_debug ("Defined %stracepoint %d at 0x%s, "
> ^
> src/gdb/gdbserver/tracepoint.c:2577:7: error: unknown conversion type character 'l' in format [-Werror=format=]
> src/gdb/gdbserver/tracepoint.c:2577:7: error: too many arguments for format [-Werror=format-extra-args]
> src/gdb/gdbserver/tracepoint.c: In function 'stop_tracing':
> src/gdb/gdbserver/tracepoint.c:3447:7: error: unknown conversion type character 'l' in format [-Werror=format=]
> trace_debug ("Stopping the trace because "
> ^
> src/gdb/gdbserver/tracepoint.c:3447:7: error: too many arguments for format [-Werror=format-extra-args]
> src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_tracepoint':
> src/gdb/gdbserver/tracepoint.c:4651:3: error: unknown conversion type character 'l' in format [-Werror=format=]
> trace_debug ("Making new traceframe for tracepoint %d at 0x%s, hit %" PRIu64,
> ^
> src/gdb/gdbserver/tracepoint.c:4651:3: error: too many arguments for format [-Werror=format-extra-args]
> src/gdb/gdbserver/tracepoint.c: In function 'collect_data_at_step':
> src/gdb/gdbserver/tracepoint.c:4687:3: error: unknown conversion type character 'l' in format [-Werror=format=]
> trace_debug ("Making new step traceframe for "
> ^
>
> trace_debug is a macro that calls:
>
> static void trace_vdebug (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
>
> The calls that fail checking use PRIu64, etc., like:
>
> trace_debug ("Defined %stracepoint %d at 0x%s, "
> "enabled %d step %" PRIu64 " pass %" PRIu64,
> tpoint->type == fast_tracepoint ? "fast "
> : tpoint->type == static_tracepoint ? "static " : "",
> tpoint->number, paddress (tpoint->address), tpoint->enabled,
> tpoint->step_count, tpoint->pass_count);
>
> gnulib's stdio/printf module replacements may make %llu, etc. work on
> mingw, instead of the MS-specific %I64u, and thus may make PRIu64
> expand to %llu. However, gcc isn't aware of that, because libiberty's
> ansidecl.h defines ATTRIBUTE_PRINTF as using attribute format(printf).
> But, with that format, gcc checks for MS-style format strings (%I64u).
> In order to have gcc expect gnu/standard formats, we need to use
> gnu_printf format instead. Which version to use (printf/gnu_printf)
> depends on msvcrt and mingw version, and so gnulib has a
> configure-time check, and defines _GL_ATTRIBUTE_FORMAT_PRINTF
> accordingly.
>
> Since _GL_ATTRIBUTE_FORMAT_PRINTF is compatible with ATTRIBUTE_PRINTF,
> the fix is simply to make use of the former.
>
> gdb/ChangeLog:
> 2015-10-29 Pedro Alves <palves@redhat.com>
>
> * common/common-defs.h (ATTRIBUTE_PRINTF): Redefine in terms of
> _GL_ATTRIBUTE_FORMAT_PRINTF after including ansidecl.h.
I've pushed this in.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-17 15:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 10:45 [PATCH] MinGW and attribute format(printf/gnu_printf) Pedro Alves
2015-11-17 15:27 ` Pedro Alves
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).