From patchwork Wed Jan 17 16:39:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84270 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 160CC3857C55 for ; Wed, 17 Jan 2024 16:41:58 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 626183858291 for ; Wed, 17 Jan 2024 16:39:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 626183858291 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 626183858291 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=1705509581; cv=none; b=D/2jOvNcx9WGxD41u/kTxI+vz7ouNBtrotc4GoU6nSakwXkMYBsb9f3nZG7eFEQAE7eiP7IqaevCJ4Z4FLTm+ua61F0mK2US93G3EqbnKZEk0GrXm76MVUGYhWHwlwFL40RAXMUb6Dy/4VjH+EyLi7j+r8fczaT5UB/9yvZLvtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705509581; c=relaxed/simple; bh=nOiaRi2UQZROOPks+DiCcq3oCdErV6ulWb/3RAeC5JQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=FFdmF7IX4qAVsEYO/sqZPHS9luZuriyeOPCRNg3KQKQHnoHhocvISle7BwOSvR6Y3svVpGpkOItKIShFQv9pFclJhlf37yObda2d5PXPivyQJ8iMDDlV7lxlCZFUKIsF+VTZQvYuWpVYNsbSX4OF4FGWcMpZaZHaoTmdqXT9E+U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6008a.ext.cloudfilter.net ([10.0.30.227]) by cmsmtp with ESMTPS id Q4aSrAW388uLRQ8x1riXzs; Wed, 17 Jan 2024 16:39:39 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Q8x0rkYGOZKctQ8x0rni74; Wed, 17 Jan 2024 16:39:38 +0000 X-Authority-Analysis: v=2.4 cv=a+kjSGeF c=1 sm=1 tr=0 ts=65a802ca a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=QVOhxxRJGtlG8CAijpQA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=90w9tDzpwCx7iyeFeplau1rCWbv4x5U9nZ+PZqkXHt0=; b=C5Ha8rpTckCnKck/OZSDd5DReY O0PWM2KH1YpqssukkUJLSdIW4ZTib2t6BvEV4FfctfjrrOdXRx3qZCHmdW7Ag3epAk6izQ/Re3Kyz 29dWj5kwK9jEL+8SM/GGsytp1; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:56636 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rQ8wz-002OXE-2j for gdb-patches@sourceware.org; Wed, 17 Jan 2024 09:39:37 -0700 From: Tom Tromey Date: Wed, 17 Jan 2024 09:39:35 -0700 Subject: [PATCH v2 07/17] Do not write the index cache from an index MIME-Version: 1.0 Message-Id: <20240117-debug-names-fix-v2-7-dbd5971a9c31@tromey.com> References: <20240117-debug-names-fix-v2-0-dbd5971a9c31@tromey.com> In-Reply-To: <20240117-debug-names-fix-v2-0-dbd5971a9c31@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 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.68.157 X-Source-L: No X-Exim-ID: 1rQ8wz-002OXE-2j X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:56636 X-Source-Auth: tom+tromey.com X-Email-Count: 12 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfIl+2VJL+CmTSUAbY5V2diGB2joUuh7n+d9+I719USHJmgXBz8VHca+/dF6IAELco0XOikkOtDuAePsXCu2LApxMA4/8iYlQEoM0TsFOJBbN5iR3tqpA WG6g9ndKlAJ95MVxOEzrs0g9QujwYHNMVM1acIe6BYFkSaB/9e9E7GOY3x4fLlAqYpJzdLYtwBiyseBmx2icqHRYBxyWwx5HtXA= X-Spam-Status: No, score=-3022.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org The new .debug_names reader will work by creating a cooked index from .debug_names. This patch updates cooked_index::maybe_write_index to avoid writing the index in this case. However, in order to do this in a clean way, the readers are changed so that a nullptr result from index_for_writing means "cannot be done", and then the error message is moved into write_dwarf_index (where it historically lived). --- gdb/dwarf2/cooked-index.c | 7 +++++-- gdb/dwarf2/index-write.c | 2 ++ gdb/dwarf2/mapped-index.h | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 542ec2fd69f..d63fd0ab5bc 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -704,8 +704,11 @@ void cooked_index::maybe_write_index (dwarf2_per_bfd *per_bfd, const index_cache_store_context &ctx) { - /* (maybe) store an index in the cache. */ - global_index_cache.store (m_per_bfd, ctx); + if (index_for_writing () != nullptr) + { + /* (maybe) store an index in the cache. */ + global_index_cache.store (m_per_bfd, ctx); + } m_state->set (cooked_state::CACHE_DONE); } diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 2decee62a4c..5cd550ef2d8 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -1629,6 +1629,8 @@ write_dwarf_index (dwarf2_per_bfd *per_bfd, const char *dir, if (per_bfd->index_table == nullptr) error (_("No debugging symbols")); cooked_index *table = per_bfd->index_table->index_for_writing (); + if (table == nullptr) + error (_("Cannot use an index to create the index")); if (per_bfd->types.size () > 1) error (_("Cannot make an index when the file has multiple .debug_types sections")); diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h index df91e6402dc..86a3c59e7e4 100644 --- a/gdb/dwarf2/mapped-index.h +++ b/gdb/dwarf2/mapped-index.h @@ -127,9 +127,7 @@ struct mapped_index_base : public dwarf_scanner_base dwarf2_per_objfile *per_objfile) const; cooked_index *index_for_writing () override - { - error (_("Cannot use an index to create the index")); - } + { return nullptr; } }; #endif /* GDB_DWARF2_MAPPED_INDEX_H */