From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id D3SzHzdf4GdhmRgAWB0awg (envelope-from ) for ; Sun, 23 Mar 2025 15:21:27 -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=D8spzIHU; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 532151E100; Sun, 23 Mar 2025 15:21: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=-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 10EB71E0C0 for ; Sun, 23 Mar 2025 15:21:26 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6AB6C385772F for ; Sun, 23 Mar 2025 19:21:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AB6C385772F 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=D8spzIHU Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id 7DA0A3857B96 for ; Sun, 23 Mar 2025 19:20:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7DA0A3857B96 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 7DA0A3857B96 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742757606; cv=none; b=cz+pYHC08sZOzRy/zZ0cQot/xJEVgko5CLNCIeGMEM1RuXUkwHhLNrr9tPu8xKlfF0lEFMBK8e4yXJDJT+ZDAeGEj97rM1pmzsJkNa25s2EavVpBsawsIxvuj0kQEKWyV82Ow0GvlpXtrh/4gYLkAyR/LOj48YWCHi3J2iBrBzc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742757606; c=relaxed/simple; bh=YjPAiGuDhRbqCrl/yLUWsEivBfOS+OJSDU1XpqqeJOs=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=uW+uEBm3jvYCEH0RQ9qvxaz5dw3r5hvLpmgWZug/L9Duk3dIk7SMBe37or+TH8Ooais5mkWw05Z+xdk04f1TnZeLwHrHjl7qy/4V150KZegEP6sjTIdrQm7d3Q1SM/3TS0M1eLlw5pYUxDiRQAa6SqDpSZSUEHHoOnnJIPWL/7U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DA0A3857B96 Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id wOkQtZHFNXshwwQrdtG5TK; Sun, 23 Mar 2025 19:20:05 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id wQrcto1cQrfVCwQrctgqSh; Sun, 23 Mar 2025 19:20:04 +0000 X-Authority-Analysis: v=2.4 cv=NK/T+V6g c=1 sm=1 tr=0 ts=67e05ee4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=Vs1iUdzkB0EA:10 a=ItBw4LHWJt0A:10 a=nViPyDIvJI2MZVZLNPYA: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=KNcqKMy2/cHuadIEiByF8CxcNO8afFVISiKbGUSKc/4=; b=D8spzIHUh1qKNdTvX7cEiP9Y4w WQzdPBwSpg8KyNmm7FrWT1UaavcbS5XujP8+upU93jG6RFMLOFclzLWTCEnvJXURWP8krY1QtV6q0 VQe4TFaqUF4a0lLxuMZ2Dy6Cm; Received: from [50.214.9.178] (port=51028 helo=prentzel.rce.guest) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1twQrb-00000004G7J-3FZp; Sun, 23 Mar 2025 13:20:03 -0600 From: Tom Tromey Date: Sun, 23 Mar 2025 13:20:00 -0600 Subject: [PATCH 1/3] Remove 'read' call from dwz_file::read_string MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250323-dwz-dwarf-5-v2-v1-1-3c0775ca5514@tromey.com> References: <20250323-dwz-dwarf-5-v2-v1-0-3c0775ca5514@tromey.com> In-Reply-To: <20250323-dwz-dwarf-5-v2-v1-0-3c0775ca5514@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: 50.214.9.178 X-Source-L: No X-Exim-ID: 1twQrb-00000004G7J-3FZp X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (prentzel.rce.guest) [50.214.9.178]:51028 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBZ+agC72gu+kineWyWRA0uHkiAj/C5646y4qhjsWYSJspiDjwyoMyhAXUzK7bE2E5NQNI38s+iobAde4JX3VaVfHjzdX5FaYBirtuQAqui2uiZFz4Vd DMYNr+o2CWDgIiYyaQL2zhOL0LNsoXpR/E2FN24Q0NuQEpr/hu3eSp2tNbJd00UZzrzSBAw0BmIgICUu5irho5W/q4G7cWwY998= 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 dwz_file::read_string calls 'read' on the section, but this isn't needed as the sections have all been pre-read. This patch makes this change, and refactors dwz_file a bit to make this more obvious -- by making it clear that only the "static constructor" can create a dwz_file. --- gdb/dwarf2/dwz.c | 8 +++++--- gdb/dwarf2/dwz.h | 25 +++++++++++++------------ gdb/dwarf2/read.c | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/gdb/dwarf2/dwz.c b/gdb/dwarf2/dwz.c index f36d6a6418a4220d7d531e3bf5b6e047b40edd6e..14cd8e882ba6bc16b57a82aa31296f4025261f15 100644 --- a/gdb/dwarf2/dwz.c +++ b/gdb/dwarf2/dwz.c @@ -34,7 +34,9 @@ const char * dwz_file::read_string (struct objfile *objfile, LONGEST str_offset) { - str.read (objfile); + /* This must be true because the sections are read in when the + dwz_file is created. */ + gdb_assert (str.readin); if (str.buffer == NULL) error (_("DW_FORM_GNU_strp_alt used without .debug_str " @@ -177,7 +179,7 @@ dwz_search_other_debugdirs (std::string &filename, bfd_byte *buildid, /* See dwz.h. */ void -dwarf2_read_dwz_file (dwarf2_per_objfile *per_objfile) +dwz_file::read_dwz_file (dwarf2_per_objfile *per_objfile) { bfd_size_type buildid_len_arg; size_t buildid_len; @@ -261,7 +263,7 @@ dwarf2_read_dwz_file (dwarf2_per_objfile *per_objfile) error (_("could not find '.gnu_debugaltlink' file for %s"), per_bfd->filename ()); - auto result = std::make_unique (std::move (dwz_bfd)); + dwz_file_up result (new dwz_file (std::move (dwz_bfd))); for (asection *sec : gdb_bfd_sections (result->dwz_bfd)) locate_dwz_sections (per_objfile->objfile, result->dwz_bfd.get (), diff --git a/gdb/dwarf2/dwz.h b/gdb/dwarf2/dwz.h index cd5143ff0848564e1c831f4eb7ddccd7231d28e6..639eea3a41850249a44259e454daa770b246ef2b 100644 --- a/gdb/dwarf2/dwz.h +++ b/gdb/dwarf2/dwz.h @@ -31,10 +31,12 @@ struct dwarf2_per_objfile; struct dwz_file { - dwz_file (gdb_bfd_ref_ptr &&bfd) - : dwz_bfd (std::move (bfd)) - { - } + /* Open the separate '.dwz' debug file, if needed. This will set + the appropriate field in the per-BFD structure. If the DWZ file + exists, the relevant sections are read in as well. Throws an + error if the .gnu_debugaltlink section exists but the file cannot + be found. */ + static void read_dwz_file (dwarf2_per_objfile *per_objfile); const char *filename () const { @@ -64,16 +66,15 @@ struct dwz_file return a pointer to the string. */ const char *read_string (struct objfile *objfile, LONGEST str_offset); -}; -using dwz_file_up = std::unique_ptr; +private: -/* Open the separate '.dwz' debug file, if needed. This just sets the - appropriate field in the per-BFD structure. If the DWZ file - exists, the relevant sections are read in as well. Throws an error - if the .gnu_debugaltlink section exists but the file cannot be - found. */ + explicit dwz_file (gdb_bfd_ref_ptr &&bfd) + : dwz_bfd (std::move (bfd)) + { + } +}; -extern void dwarf2_read_dwz_file (dwarf2_per_objfile *per_objfile); +using dwz_file_up = std::unique_ptr; #endif /* GDB_DWARF2_DWZ_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 8875e97a7b3303c5c8bf7ca90ed21f22f4d23b34..f4198d71ca28811bd02c5fb87b5206629f118874 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1289,7 +1289,7 @@ dwarf2_has_info (struct objfile *objfile, BFD, to avoid races. */ try { - dwarf2_read_dwz_file (per_objfile); + dwz_file::read_dwz_file (per_objfile); } catch (const gdb_exception_error &err) { -- 2.46.1