Fix gdb_xml_debug/gdb_xml_error ATTRIBUTE_PRINTF use
authorPedro Alves <palves@redhat.com>
Mon, 27 Mar 2017 11:28:03 +0000 (12:28 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 27 Mar 2017 11:28:03 +0000 (12:28 +0100)
The declarations of gdb_xml_debug and gdb_xml_error are passing "0" as
"first-to-check" argument to ATTRIBUTE_PRINTF, as if they were va_args
functions.  Consequently, the arguments to gdb_xml_debug /
gdb_xml_error aren't being checked against the format strings.

With that fixed, a couple obvious bugs are exposed, both fixed by this
commit.

gdb/ChangeLog:
2017-03-27  Pedro Alves  <palves@redhat.com>

* xml-support.h (gdb_xml_debug): Pass a "first-to-check" argument
to ATTRIBUTE_PRINTF.
* solib-target.c (library_list_start_list): Print "string" not
"version".
* xml-tdesc.c (tdesc_start_field): Pass "field_name" to
gdb_xml_error call.

gdb/ChangeLog
gdb/solib-target.c
gdb/xml-support.h
gdb/xml-tdesc.c

index 82213e8..b4d995a 100644 (file)
@@ -1,5 +1,14 @@
 2017-03-27  Pedro Alves  <palves@redhat.com>
 
+       * xml-support.h (gdb_xml_debug): Pass a "first-to-check" argument
+       to ATTRIBUTE_PRINTF.
+       * solib-target.c (library_list_start_list): Print "string" not
+       "version".
+       * xml-tdesc.c (tdesc_start_field): Pass "field_name" to
+       gdb_xml_error call.
+
+2017-03-27  Pedro Alves  <palves@redhat.com>
+
        * dwarf2read.c (struct file_and_directory): New.
        (dwarf2_get_dwz_file): Adjust to use std::string.
        (dw2_get_file_names_reader): Adjust to use file_and_directory.
index 1577e31..1b10e4e 100644 (file)
@@ -159,7 +159,7 @@ library_list_start_list (struct gdb_xml_parser *parser,
       if (strcmp (string, "1.0") != 0)
        gdb_xml_error (parser,
                       _("Library list has unsupported version \"%s\""),
-                      version);
+                      string);
     }
 }
 
index 9d4e29f..de685e2 100644 (file)
@@ -200,13 +200,13 @@ int gdb_xml_parse_quick (const char *name, const char *dtd_name,
 /* Issue a debugging message from one of PARSER's handlers.  */
 
 void gdb_xml_debug (struct gdb_xml_parser *parser, const char *format, ...)
-     ATTRIBUTE_PRINTF (2, 0);
+  ATTRIBUTE_PRINTF (2, 3);
 
 /* Issue an error message from one of PARSER's handlers, and stop
    parsing.  */
 
 void gdb_xml_error (struct gdb_xml_parser *parser, const char *format, ...)
-     ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
+  ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
 
 /* Find the attribute named NAME in the set of parsed attributes
    ATTRIBUTES.  Returns NULL if not found.  */
index effe652..d24c5ad 100644 (file)
@@ -413,8 +413,8 @@ tdesc_start_field (struct gdb_xml_parser *parser,
        gdb_xml_error (parser, _("Bitfield \"%s\" has start after end"),
                       field_name);
       if (end >= data->current_type_size * TARGET_CHAR_BIT)
-       gdb_xml_error (parser,
-                      _("Bitfield \"%s\" does not fit in struct"));
+       gdb_xml_error (parser, _("Bitfield \"%s\" does not fit in struct"),
+                      field_name);
 
       if (field_type != NULL)
        tdesc_add_typed_bitfield (t, field_name, start, end, field_type);