Add ATTRIBUTE_PRINTF attributes, and fix fallout
Fixes building gdb on x86_64-apple-darwin14 with clang, which produces a number of warnings from -Wformat-nonliteral. Ref: https://sourceware.org/ml/gdb/2015-02/msg00047.html gdb/ChangeLog: 2015-02-26 Pedro Alves <palves@redhat.com> * auto-load.h (file_is_auto_load_safe): Add ATTRIBUTE_PRINTF. * complaints.c (vcomplaint): Pass argument FMT directly to printf-like functions instead of complaint->fmt. * ctf.c (ctf_save_write_metadata): Add ATTRIBUTE_PRINTF. * darwin-nat.c (inferior_debug): Add ATTRIBUTE_PRINTF. * compile/compile-loc2c.c (pushf, unary, binary): Add ATTRIBUTE_PRINTF. (do_compile_dwarf_expr_to_c): Pass string literal as format string to pushf. (BINARY): Pass string literal as format string to 'binary'. * compile/compile-object-load.c (link_callbacks_einfo): Add ATTRIBUTE_PRINTF. * guile/guile-internal.h (gdbscm_printf): Add ATTRIBUTE_PRINTF.
This commit is contained in:
parent
06b73f4199
commit
77b64a49e2
9 changed files with 61 additions and 13 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2015-02-26 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* auto-load.h (file_is_auto_load_safe): Add ATTRIBUTE_PRINTF.
|
||||||
|
* complaints.c (vcomplaint): Pass argument FMT directly to
|
||||||
|
printf-like functions instead of complaint->fmt.
|
||||||
|
* ctf.c (ctf_save_write_metadata): Add ATTRIBUTE_PRINTF.
|
||||||
|
* darwin-nat.c (inferior_debug): Add ATTRIBUTE_PRINTF.
|
||||||
|
* compile/compile-loc2c.c (pushf, unary, binary): Add
|
||||||
|
ATTRIBUTE_PRINTF.
|
||||||
|
(do_compile_dwarf_expr_to_c): Pass string literal as format string
|
||||||
|
to pushf.
|
||||||
|
(BINARY): Pass string literal as format string to 'binary'.
|
||||||
|
* compile/compile-object-load.c (link_callbacks_einfo): Add
|
||||||
|
ATTRIBUTE_PRINTF.
|
||||||
|
* guile/guile-internal.h (gdbscm_printf): Add ATTRIBUTE_PRINTF.
|
||||||
|
|
||||||
2015-02-26 Pedro Alves <palves@redhat.com>
|
2015-02-26 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* windows-termcap.c: Rename to ...
|
* windows-termcap.c: Rename to ...
|
||||||
|
|
|
@ -45,7 +45,8 @@ extern struct cmd_list_element **auto_load_show_cmdlist_get (void);
|
||||||
extern struct cmd_list_element **auto_load_info_cmdlist_get (void);
|
extern struct cmd_list_element **auto_load_info_cmdlist_get (void);
|
||||||
|
|
||||||
extern int file_is_auto_load_safe (const char *filename,
|
extern int file_is_auto_load_safe (const char *filename,
|
||||||
const char *debug_fmt, ...);
|
const char *debug_fmt, ...)
|
||||||
|
ATTRIBUTE_PRINTF (2, 3);
|
||||||
|
|
||||||
extern int auto_load_gdb_scripts_enabled
|
extern int auto_load_gdb_scripts_enabled
|
||||||
(const struct extension_language_defn *extlang);
|
(const struct extension_language_defn *extlang);
|
||||||
|
|
|
@ -443,6 +443,9 @@ push (int indent, struct ui_file *stream, ULONGEST l)
|
||||||
/* Emit code to push an arbitrary expression. This works like
|
/* Emit code to push an arbitrary expression. This works like
|
||||||
printf. */
|
printf. */
|
||||||
|
|
||||||
|
static void pushf (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (3, 4);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pushf (int indent, struct ui_file *stream, const char *format, ...)
|
pushf (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
{
|
{
|
||||||
|
@ -460,6 +463,9 @@ pushf (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
/* Emit code for a unary expression -- one which operates in-place on
|
/* Emit code for a unary expression -- one which operates in-place on
|
||||||
the top-of-stack. This works like printf. */
|
the top-of-stack. This works like printf. */
|
||||||
|
|
||||||
|
static void unary (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (3, 4);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unary (int indent, struct ui_file *stream, const char *format, ...)
|
unary (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
{
|
{
|
||||||
|
@ -474,6 +480,8 @@ unary (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
|
|
||||||
/* Emit code for a unary expression -- one which uses the top two
|
/* Emit code for a unary expression -- one which uses the top two
|
||||||
stack items, popping the topmost one. This works like printf. */
|
stack items, popping the topmost one. This works like printf. */
|
||||||
|
static void binary (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (3, 4);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
binary (int indent, struct ui_file *stream, const char *format, ...)
|
binary (int indent, struct ui_file *stream, const char *format, ...)
|
||||||
|
@ -651,7 +659,7 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
|
||||||
fprintfi_filtered (indent, stream, "int __gdb_tos = -1;\n");
|
fprintfi_filtered (indent, stream, "int __gdb_tos = -1;\n");
|
||||||
|
|
||||||
if (initial != NULL)
|
if (initial != NULL)
|
||||||
pushf (indent, stream, core_addr_to_string (*initial));
|
pushf (indent, stream, "%s", core_addr_to_string (*initial));
|
||||||
|
|
||||||
while (op_ptr < op_end)
|
while (op_ptr < op_end)
|
||||||
{
|
{
|
||||||
|
@ -911,7 +919,8 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
|
||||||
|
|
||||||
case DW_OP_pick:
|
case DW_OP_pick:
|
||||||
offset = *op_ptr++;
|
offset = *op_ptr++;
|
||||||
pushf (indent, stream, "__gdb_stack[__gdb_tos - %d]", offset);
|
pushf (indent, stream, "__gdb_stack[__gdb_tos - %s]",
|
||||||
|
plongest (offset));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DW_OP_swap:
|
case DW_OP_swap:
|
||||||
|
@ -1000,8 +1009,8 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#define BINARY(OP) \
|
#define BINARY(OP) \
|
||||||
binary (indent, stream, ("__gdb_stack[__gdb_tos-1] " #OP \
|
binary (indent, stream, "%s", "__gdb_stack[__gdb_tos-1] " #OP \
|
||||||
" __gdb_stack[__gdb_tos]")); \
|
" __gdb_stack[__gdb_tos]"); \
|
||||||
break
|
break
|
||||||
|
|
||||||
case DW_OP_and:
|
case DW_OP_and:
|
||||||
|
@ -1076,7 +1085,7 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
|
||||||
addr_size,
|
addr_size,
|
||||||
cfa_start, cfa_end,
|
cfa_start, cfa_end,
|
||||||
&text_offset, per_cu);
|
&text_offset, per_cu);
|
||||||
pushf (indent, stream, cfa_name);
|
pushf (indent, stream, "%s", cfa_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,9 @@ link_callbacks_unattached_reloc (struct bfd_link_info *link_info,
|
||||||
|
|
||||||
/* Helper for link_callbacks callbacks vector. */
|
/* Helper for link_callbacks callbacks vector. */
|
||||||
|
|
||||||
|
static void link_callbacks_einfo (const char *fmt, ...)
|
||||||
|
ATTRIBUTE_PRINTF (1, 2);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_callbacks_einfo (const char *fmt, ...)
|
link_callbacks_einfo (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -183,21 +183,27 @@ vcomplaint (struct complaints **c, const char *file,
|
||||||
else
|
else
|
||||||
series = complaints->series;
|
series = complaints->series;
|
||||||
|
|
||||||
|
/* Pass 'fmt' instead of 'complaint->fmt' to printf-like callees
|
||||||
|
from here on, to avoid "format string is not a string literal"
|
||||||
|
warnings. 'fmt' is this function's printf-format parameter, so
|
||||||
|
the compiler can assume the passed in argument is a literal
|
||||||
|
string somewhere up the call chain. */
|
||||||
|
gdb_assert (complaint->fmt == fmt);
|
||||||
|
|
||||||
if (complaint->file != NULL)
|
if (complaint->file != NULL)
|
||||||
internal_vwarning (complaint->file, complaint->line,
|
internal_vwarning (complaint->file, complaint->line, fmt, args);
|
||||||
complaint->fmt, args);
|
|
||||||
else if (deprecated_warning_hook)
|
else if (deprecated_warning_hook)
|
||||||
(*deprecated_warning_hook) (complaint->fmt, args);
|
(*deprecated_warning_hook) (fmt, args);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (complaints->explanation == NULL)
|
if (complaints->explanation == NULL)
|
||||||
/* A [v]warning() call always appends a newline. */
|
/* A [v]warning() call always appends a newline. */
|
||||||
vwarning (complaint->fmt, args);
|
vwarning (fmt, args);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *msg;
|
char *msg;
|
||||||
struct cleanup *cleanups;
|
struct cleanup *cleanups;
|
||||||
msg = xstrvprintf (complaint->fmt, args);
|
msg = xstrvprintf (fmt, args);
|
||||||
cleanups = make_cleanup (xfree, msg);
|
cleanups = make_cleanup (xfree, msg);
|
||||||
wrap_here ("");
|
wrap_here ("");
|
||||||
if (series != SUBSEQUENT_MESSAGE)
|
if (series != SUBSEQUENT_MESSAGE)
|
||||||
|
|
|
@ -99,6 +99,11 @@ struct trace_write_handler
|
||||||
|
|
||||||
/* Write metadata in FORMAT. */
|
/* Write metadata in FORMAT. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
ctf_save_write_metadata (struct trace_write_handler *handler,
|
||||||
|
const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (2, 3);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ctf_save_write_metadata (struct trace_write_handler *handler,
|
ctf_save_write_metadata (struct trace_write_handler *handler,
|
||||||
const char *format, ...)
|
const char *format, ...)
|
||||||
|
|
|
@ -171,6 +171,9 @@ __attribute__ ((section ("__TEXT,__info_plist"),used)) =
|
||||||
"</dict>\n"
|
"</dict>\n"
|
||||||
"</plist>\n";
|
"</plist>\n";
|
||||||
|
|
||||||
|
static void inferior_debug (int level, const char *fmt, ...)
|
||||||
|
ATTRIBUTE_PRINTF (2, 3);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
inferior_debug (int level, const char *fmt, ...)
|
inferior_debug (int level, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -146,7 +146,8 @@ extern void gdbscm_define_functions (const scheme_function *, int public);
|
||||||
extern void gdbscm_define_integer_constants (const scheme_integer_constant *,
|
extern void gdbscm_define_integer_constants (const scheme_integer_constant *,
|
||||||
int public);
|
int public);
|
||||||
|
|
||||||
extern void gdbscm_printf (SCM port, const char *format, ...);
|
extern void gdbscm_printf (SCM port, const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (2, 3);
|
||||||
|
|
||||||
extern void gdbscm_debug_display (SCM obj);
|
extern void gdbscm_debug_display (SCM obj);
|
||||||
|
|
||||||
|
@ -484,7 +485,8 @@ extern char *gdbscm_scm_to_c_string (SCM string);
|
||||||
|
|
||||||
extern SCM gdbscm_scm_from_c_string (const char *string);
|
extern SCM gdbscm_scm_from_c_string (const char *string);
|
||||||
|
|
||||||
extern SCM gdbscm_scm_from_printf (const char *format, ...);
|
extern SCM gdbscm_scm_from_printf (const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (1, 2);
|
||||||
|
|
||||||
extern char *gdbscm_scm_to_string (SCM string, size_t *lenp,
|
extern char *gdbscm_scm_to_string (SCM string, size_t *lenp,
|
||||||
const char *charset,
|
const char *charset,
|
||||||
|
|
|
@ -6986,6 +6986,9 @@ remote_read_bytes (struct target_ops *ops, CORE_ADDR memaddr,
|
||||||
FORMAT and the remaining arguments, then gets the reply. Returns
|
FORMAT and the remaining arguments, then gets the reply. Returns
|
||||||
whether the packet was a success, a failure, or unknown. */
|
whether the packet was a success, a failure, or unknown. */
|
||||||
|
|
||||||
|
static enum packet_result remote_send_printf (const char *format, ...)
|
||||||
|
ATTRIBUTE_PRINTF (1, 2);
|
||||||
|
|
||||||
static enum packet_result
|
static enum packet_result
|
||||||
remote_send_printf (const char *format, ...)
|
remote_send_printf (const char *format, ...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue