aboutsummaryrefslogtreecommitdiff
path: root/gdb/compile
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-02-26 18:29:12 +0000
committerPedro Alves <palves@redhat.com>2015-02-26 18:29:12 +0000
commit77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44 (patch)
treebd4b5c8c78a0837edcbde0d135ca6f96bfc556a7 /gdb/compile
parent06b73f4199944fb8a7d2c8874f91ed1deb7f4c44 (diff)
downloadgdb-77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44.zip
gdb-77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44.tar.gz
gdb-77b64a49e24dd4b5f4c7edb5d4030fe8aa1eec44.tar.bz2
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.
Diffstat (limited to 'gdb/compile')
-rw-r--r--gdb/compile/compile-loc2c.c19
-rw-r--r--gdb/compile/compile-object-load.c3
2 files changed, 17 insertions, 5 deletions
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index 3f43e58..6a3615d 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -443,6 +443,9 @@ push (int indent, struct ui_file *stream, ULONGEST l)
/* Emit code to push an arbitrary expression. This works like
printf. */
+static void pushf (int indent, struct ui_file *stream, const char *format, ...)
+ ATTRIBUTE_PRINTF (3, 4);
+
static void
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
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
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
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
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");
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)
{
@@ -911,7 +919,8 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
case DW_OP_pick:
offset = *op_ptr++;
- pushf (indent, stream, "__gdb_stack[__gdb_tos - %d]", offset);
+ pushf (indent, stream, "__gdb_stack[__gdb_tos - %s]",
+ plongest (offset));
break;
case DW_OP_swap:
@@ -1000,8 +1009,8 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
break;
#define BINARY(OP) \
- binary (indent, stream, ("__gdb_stack[__gdb_tos-1] " #OP \
- " __gdb_stack[__gdb_tos]")); \
+ binary (indent, stream, "%s", "__gdb_stack[__gdb_tos-1] " #OP \
+ " __gdb_stack[__gdb_tos]"); \
break
case DW_OP_and:
@@ -1076,7 +1085,7 @@ do_compile_dwarf_expr_to_c (int indent, struct ui_file *stream,
addr_size,
cfa_start, cfa_end,
&text_offset, per_cu);
- pushf (indent, stream, cfa_name);
+ pushf (indent, stream, "%s", cfa_name);
}
}
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index e187970..8a7f232 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -224,6 +224,9 @@ link_callbacks_unattached_reloc (struct bfd_link_info *link_info,
/* Helper for link_callbacks callbacks vector. */
+static void link_callbacks_einfo (const char *fmt, ...)
+ ATTRIBUTE_PRINTF (1, 2);
+
static void
link_callbacks_einfo (const char *fmt, ...)
{