From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mCujJoHN7WfNjiQAWB0awg (envelope-from ) for ; Wed, 02 Apr 2025 19:51:29 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=TtER6tR6; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 925D41E0C3; Wed, 2 Apr 2025 19:51:29 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 177091E0C0 for ; Wed, 2 Apr 2025 19:51:29 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB649385B804 for ; Wed, 2 Apr 2025 23:51:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB649385B804 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=TtER6tR6 Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 6D8D33857BA5 for ; Wed, 2 Apr 2025 23:45:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D8D33857BA5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D8D33857BA5 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637514; cv=none; b=AqefR/cv+GSPB7FFxl6Wl31P7Fdf0kJsNnUeSW5pD+UOg7gUXIqsefz+xCmPqHDr0HvC9GQY39awLfBtGyW34GEbgkMoJnzkap/3/4gMqXVrhREaGDFXhMdZ2zj7bcnj/mbE5SjFDreiv8wvthMfYe26r5eXjrnrVEvLxPhWO+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743637514; c=relaxed/simple; bh=WSUxMtqtabev1S1qlXDX11CxHIpvgr02999c/yluplQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=IfJj/eVv0vcKuw3msYWRs4etZzK6NvBSQyAkjSEhQFvPZ41LM/TE+7rlFGr452HzuZKqn5r8z2jnMsmO8ZZ3gR9dDwJMCA2unGbKLzISu9F/jYp37cAZyRTa56yDMh3ccPt6iy64AeE35NlMdkhe8hkvJOqfRzSdZy39T9QC2iI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D8D33857BA5 Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id 0272um4X4zZPa07liuJzCU; Wed, 02 Apr 2025 23:45:14 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 07lhuTYTbjrgq07lhu8qYI; Wed, 02 Apr 2025 23:45:13 +0000 X-Authority-Analysis: v=2.4 cv=PK7E+uqC c=1 sm=1 tr=0 ts=67edcc09 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=XR8D0OoHHMoA:10 a=ItBw4LHWJt0A:10 a=6Gav6Y_f6UShaXg7OxMA:9 a=QEXdDO2ut3YA:10 a=6Ogn3jAGHLSNbaov7Orx:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kHbmTLiQIKp1mE1GrYRyf6gi61lOqIpdZzuqQsJ0B2E=; b=TtER6tR63R0a0mXJzct8UWLpG4 FaHwx53M20MhRyruVlmlnSR5wfkYE/ml7Yd263VI7hFhd4ahavsS0SGmOxUEsAvzkAfNbM/H+SF90 EgteP1oZG3E5RmH3Tk7AXAerc; Received: from 97-122-123-18.hlrn.qwest.net ([97.122.123.18]:56394 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1u07lh-000000014hd-027H; Wed, 02 Apr 2025 17:45:13 -0600 From: Tom Tromey Date: Wed, 02 Apr 2025 17:45:06 -0600 Subject: [PATCH v2 07/28] Restore "ingestion" of .debug_str when writing .debug_names MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250402-search-in-psyms-v2-7-ea91704487cb@tromey.com> References: <20250402-search-in-psyms-v2-0-ea91704487cb@tromey.com> In-Reply-To: <20250402-search-in-psyms-v2-0-ea91704487cb@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.123.18 X-Source-L: No X-Exim-ID: 1u07lh-000000014hd-027H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-123-18.hlrn.qwest.net (prentzel.local) [97.122.123.18]:56394 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfM919w+WTCwrev0iPX3Ae8dPAJvx1aFQFaD2745NWOylFXgdArL7IzHSLzKaS2bd5RlculhYKafilydvJE3MxP1reFsohcSapUbi7DVTkudTsIH2k7KG B2MrjJvNLPRuw92RI64Iiwgwj9W3OklE2lHX0noDQ6SNWKfG1nVE5dNd/ercGjvJzsB9xPcRO2k+6E6LYMBtfoOHzofCI0T1cK4= 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 When I rewrote the .debug_names writer (commit 91a42a61), I changed the writer to not import .debug_str into the debug_str_lookup object. However, a later patch in this series needed this again. The issue here was that if a name occurs in the DWARF, and is also allocated, then there is a race, where the created index depends on which DIE is read first. This can cause index-file.exp failures. This patch restores the old approach, avoiding this problem. I also applied a couple of small cleanups to the class. And, I removed the old complaint from the "ingestion" function, as this was not necessary. --- gdb/dwarf2/index-write.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 389fcaa727ce15706a735ce82c047374fbc57d2b..8945b844e2a9e08049902decde2bb6ab7366b1be 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -763,7 +763,7 @@ class debug_names }); m_name_table_string_offs.push_back_reorder - (m_debugstrlookup.lookup (name.c_str ())); /* ??? */ + (m_debugstrlookup.lookup (name.c_str ())); m_name_table_entry_offs.push_back_reorder (m_entry_pool.size ()); for (const cooked_index_entry *entry : these_entries) @@ -928,10 +928,21 @@ class debug_names { public: - /* Object constructor to be called for current DWARF2_PER_BFD. */ - debug_str_lookup (dwarf2_per_bfd *per_bfd) + /* Object constructor to be called for current DWARF2_PER_BFD. + All .debug_str section strings are automatically stored. */ + explicit debug_str_lookup (dwarf2_per_bfd *per_bfd) : m_per_bfd (per_bfd) { + gdb_assert (per_bfd->str.readin); + const gdb_byte *data = per_bfd->str.buffer; + if (data == nullptr) + return; + while (data < per_bfd->str.buffer + per_bfd->str.size) + { + const char *const s = reinterpret_cast (data); + m_str_table.emplace (c_str_view (s), data - per_bfd->str.buffer); + data += strlen (s) + 1; + } } /* Return offset of symbol name S in the .debug_str section. Add @@ -939,13 +950,6 @@ class debug_names yet. */ size_t lookup (const char *s) { - /* Most strings will have come from the string table - already. */ - const gdb_byte *b = (const gdb_byte *) s; - if (b >= m_per_bfd->str.buffer - && b < m_per_bfd->str.buffer + m_per_bfd->str.size) - return b - m_per_bfd->str.buffer; - const auto it = m_str_table.find (c_str_view (s)); if (it != m_str_table.end ()) return it->second; -- 2.46.1