From patchwork Mon Mar 27 11:37:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 19734 Received: (qmail 38818 invoked by alias); 27 Mar 2017 11:37:24 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 38802 invoked by uid 89); 27 Mar 2017 11:37:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Mar 2017 11:37:22 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8639AC084AC9 for ; Mon, 27 Mar 2017 11:37:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8639AC084AC9 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8639AC084AC9 Received: from cascais.lan (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1095C179F2 for ; Mon, 27 Mar 2017 11:37:21 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed/ob] Fix gdb_xml_debug/gdb_xml_error ATTRIBUTE_PRINTF use Date: Mon, 27 Mar 2017 12:37:21 +0100 Message-Id: <1490614641-28441-1-git-send-email-palves@redhat.com> 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 * 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 | 9 +++++++++ gdb/solib-target.c | 2 +- gdb/xml-support.h | 4 ++-- gdb/xml-tdesc.c | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 82213e8..b4d995a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2017-03-27 Pedro Alves + * 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 + * 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. diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 1577e31..1b10e4e 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -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); } } diff --git a/gdb/xml-support.h b/gdb/xml-support.h index 9d4e29f..de685e2 100644 --- a/gdb/xml-support.h +++ b/gdb/xml-support.h @@ -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. */ diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c index effe652..d24c5ad 100644 --- a/gdb/xml-tdesc.c +++ b/gdb/xml-tdesc.c @@ -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);