From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QTmhHI9A4WkT2hwAWB0awg (envelope-from ) for ; Thu, 16 Apr 2026 16:03:27 -0400 Received: by simark.ca (Postfix, from userid 112) id 721141E04F; Thu, 16 Apr 2026 16:03:27 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F08D41E04F for ; Thu, 16 Apr 2026 16:03:26 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 9126A4C900FB for ; Thu, 16 Apr 2026 20:03:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9126A4C900FB Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 367764C318BE for ; Thu, 16 Apr 2026 20:03:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 367764C318BE Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 367764C318BE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776369783; cv=none; b=bpSxVlCS7t+ji+l+ByspyTtq6aRCMlb7apVq2M/ZyK7UArwItfGrvSWjPKqmmCEBp+js+vphtg0fbwqKlrVuSb9Z5WNduosJniCkYHDYJxgawQM4NwFMDzCxa9iiAaJCBYNcuUeAt+ygwfC/3pfwnfbt9HYw68Xiq8Yeq323l7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776369783; c=relaxed/simple; bh=gV7NiVS5N/43cJVMkl6RMriRlOFuvTBMd+/52R6PlCo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=DkM4k417tt/ZVe88SlfPQw8q8tmyXX+mFpQXPayfpnlVfGGXW6dRRtDDYj42TltTbC1YkUYXP3iCKrZwUNjEcFw5p/3UZgt15P0z0jm91sMBZCYoX2OZn9oG/EStp78kQP555HC+IBVY83IJPbCPQ+MXP3b51YihxLdO2AF7I6Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 367764C318BE Received: by simark.ca (Postfix) id 129541E0EA; Thu, 16 Apr 2026 16:03:00 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 7/8] gdb/dwarf: add more context to complaints in mapped_debug_names_reader::scan_one_entry Date: Thu, 16 Apr 2026 15:59:10 -0400 Message-ID: <20260416200256.386186-8-simon.marchi@efficios.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260416200256.386186-1-simon.marchi@efficios.com> References: <20260316232042.368080-1-simon.marchi@polymtl.ca> <20260416200256.386186-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Simon Marchi I realize that complaints are not often enabled and shown, but if we emit them, I think they should include enough context to help a user who wishes to dig in the problem to pinpoint where the problem happened exactly. For this reason, change the complaints in mapped_debug_names_reader::scan_one_entry to include precisions regarding which index entry is problematic exactly. I am not attached to the particular format. I thought that because this is extra contextual information, I would put it in the square brackets at the end (which only shows the module name currently). However, it would be nice to converge towards a format that we could replicate elsewhere in the DWARF reader, so feel free to chime in. I factored out the formatting to a separate function, because I will be adding more of these in a subsequent patch, and it's easier to have the formatting centralized. I have not touched the "Unsupported .debug_names form" warning. If that comes up, we probably don't care about the specific index entry, we just need to implement support for that form. Change-Id: Id68a0ae406a3ca620408576b81f893f05c7e3df2 --- gdb/dwarf2/read-debug-names.c | 43 ++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c index 6ac65d101b16..487e2ea87edb 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -155,6 +155,25 @@ struct mapped_debug_names_reader std::vector> all_entries; }; +/* Emit a complaint about a specific index entry. */ + +static void ATTRIBUTE_PRINTF (4, 5) +complain_about_index_entry (bfd *abfd, const char *name, + ptrdiff_t offset_in_entry_pool, const char *fmt, + ...) +{ + va_list ap; + va_start (ap, fmt); + std::string msg = string_vprintf (fmt, ap); + va_end (ap); + + msg += string_printf (_(" [in module %s, index entry for name %s," + " entry pool offset 0x%tx]"), + bfd_get_filename (abfd), name, offset_in_entry_pool); + + complaint ("%s", msg.c_str ()); +} + /* Scan a single entry from the entries table. Set *RESULT and PARENT (if needed) and return the updated pointer on success, or return nullptr on error, or at the end of the table. */ @@ -180,9 +199,11 @@ mapped_debug_names_reader::scan_one_entry (const char *name, const auto indexval_it = abbrev_map.find (abbrev); if (indexval_it == abbrev_map.cend ()) { - complaint (_("Wrong .debug_names undefined abbrev code %s " - "[in module %s]"), - pulongest (abbrev), bfd_get_filename (abfd)); + complain_about_index_entry (abfd, name, offset_in_entry_pool, + _("Wrong .debug_names abbrev code %s"), + pulongest (abbrev)); + /* We can't go past this entry because we don't know its size, stop + reading this entry chain. */ return nullptr; } @@ -264,10 +285,10 @@ mapped_debug_names_reader::scan_one_entry (const char *name, /* Don't crash on bad data. */ if (ull >= this->comp_units.size ()) { - complaint (_(".debug_names entry has bad CU index %s" - " [in module %s]"), - pulongest (ull), - bfd_get_filename (abfd)); + complain_about_index_entry + (abfd, name, offset_in_entry_pool, + _(".debug_names entry has bad CU index %s"), + pulongest (ull)); continue; } @@ -279,10 +300,10 @@ mapped_debug_names_reader::scan_one_entry (const char *name, /* Don't crash on bad data. */ if (ull >= this->type_units.size ()) { - complaint (_(".debug_names entry has bad TU index %s" - " [in module %s]"), - pulongest (ull), - bfd_get_filename (abfd)); + complain_about_index_entry + (abfd, name, offset_in_entry_pool, + _(".debug_names entry has bad TU index %s"), + pulongest (ull)); continue; } -- 2.53.0