From patchwork Mon Oct 2 12:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 76956 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 7FEBB385414F for ; Mon, 2 Oct 2023 12:53:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FEBB385414F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696251197; bh=YDYSvhRGH38/lETjBlCMubCKL6PjE68BydGrnVzWKG8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XJiJCs1nKkLvrZyr6Eqky55duAaPtlojsRdsGEnWoO5sPr5TMgEH28i6KXSTvr2Ln /q7UFP6+u2cZWxsWEkeIgTAxTMtFFvUi4uUkO10BEc5U0f59NpZsYTSlMpjCIAZGV3 4LqpefmLppFMBjhlwfenLofDQPeWoJUg5ZoeXVCI= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 27775385782B for ; Mon, 2 Oct 2023 12:50:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27775385782B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E68261F74C for ; Mon, 2 Oct 2023 12:50:46 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C918313434 for ; Mon, 2 Oct 2023 12:50:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yHYiMKa8GmVZMgAAMHmgww (envelope-from ) for ; Mon, 02 Oct 2023 12:50:46 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 05/13] [gdb/symtab] Factor out m_deferred_entries usage Date: Mon, 2 Oct 2023 14:50:43 +0200 Message-Id: <20231002125051.29911-6-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231002125051.29911-1-tdevries@suse.de> References: <20231002125051.29911-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Factor out usage of cooked_indexer::m_deferred_entries in new member functions defer_entry, handle_deferred_entries and resolve_deferred_entry. Tested on x86_64-linux. --- gdb/dwarf2/read.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 17bc650a055..54097dd4d21 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4830,6 +4830,32 @@ class cooked_indexer we'll know the containing context of all the DIEs that we might have scanned. This vector stores these deferred entries. */ std::vector m_deferred_entries; + + /* Defer creating a cooked_index_entry corresponding to deferred_entry DE. */ + void defer_entry (const deferred_entry &de) + { + m_deferred_entries.push_back (de); + } + + /* Create a cooked_index_entry corresponding to deferred_entry DE with + parent PARENT_ENTRY. */ + const cooked_index_entry *resolve_deferred_entry + (const deferred_entry &de, const cooked_index_entry *parent_entry) + { + return m_index_storage->add (de.die_offset, de.tag, de.flags, de.name, + parent_entry, m_per_cu); + } + + /* Create cooked_index_entries for the deferred entries. */ + void handle_deferred_entries () + { + for (const auto &entry : m_deferred_entries) + { + const cooked_index_entry *parent_entry + = find_parent (entry.spec_offset); + resolve_deferred_entry (entry, parent_entry); + } + } }; /* Subroutine of dwarf2_build_psymtabs_hard to simplify it. @@ -16557,7 +16583,7 @@ cooked_indexer::index_dies (cutu_reader *reader, if (name != nullptr) { if (defer != 0) - m_deferred_entries.push_back ({ + defer_entry ({ this_die, name, defer, abbrev->tag, flags }); else @@ -16662,12 +16688,7 @@ cooked_indexer::make_index (cutu_reader *reader) return; index_dies (reader, reader->info_ptr, nullptr, false); - for (const auto &entry : m_deferred_entries) - { - const cooked_index_entry *parent = find_parent (entry.spec_offset); - m_index_storage->add (entry.die_offset, entry.tag, entry.flags, - entry.name, parent, m_per_cu); - } + handle_deferred_entries (); } /* An implementation of quick_symbol_functions for the cooked DWARF