From patchwork Mon Oct 2 12:50:39 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: 76946 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 E28043852770 for ; Mon, 2 Oct 2023 12:51:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E28043852770 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696251109; bh=xYMvqXyKruVb58Amc5FiolyuYdiXmyuyyKWjvLbFvN8=; 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=fk7UMdQvZWNkk/OLWcdYTVLKJc/N+R1LmbufTBspXuBQNTHPDJ+MI41zppOfg0xEa znP21QxyohgyR/4KVzVTdqcMjhYlOtpKETNblkUvuiYlmZSKy4BcI7jaI0NgdjwFZe xPLLkN5EXFP/10hNoRXba0pt5pFvTf7h4YwLH9EM= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 622343858004 for ; Mon, 2 Oct 2023 12:50:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 622343858004 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-out1.suse.de (Postfix) with ESMTPS id 808082185D 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 6D8ED139C2 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 SGDPGaa8GmVZMgAAMHmgww (envelope-from ) for ; Mon, 02 Oct 2023 12:50:46 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 01/13] [gdb/symtab] Factor out m_die_range_map usage Date: Mon, 2 Oct 2023 14:50:39 +0200 Message-Id: <20231002125051.29911-2-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.3 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_die_range_map into new class parent_map with member functions find_parent and set_parent. Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.h | 22 ++++++++++++++++++++++ gdb/dwarf2/read.c | 23 +++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 5aacb321c91..a029fcf2cc9 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -239,6 +239,28 @@ struct cooked_index_entry : public allocate_on_obstack bool for_name) const; }; +class parent_map +{ +public: + /* Find the parent of DIE LOOKUP. */ + const cooked_index_entry *find_parent (CORE_ADDR lookup) const + { + const void *obj = m_parent_map.find (lookup); + return static_cast (obj); + } + + /* Set the parent of DIES in range [START, END] to PARENT_ENTRY. */ + void set_parent (CORE_ADDR start, CORE_ADDR end, + const cooked_index_entry *parent_entry) + { + m_parent_map.set_empty (start, end, (void *)parent_entry); + } + +private: + /* An addrmap that maps from section offsets to cooked_index_entry *. */ + addrmap_mutable m_parent_map; +}; + class cooked_index; /* An index of interesting DIEs. This is "cooked", in contrast to a diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5bbc8e24cf9..17bc650a055 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4797,7 +4797,20 @@ class cooked_indexer /* An addrmap that maps from section offsets (see the form_addr method) to newly-created entries. See m_deferred_entries to understand this. */ - addrmap_mutable m_die_range_map; + parent_map m_die_range_map; + + /* Find the parent of DIE LOOKUP. */ + const cooked_index_entry *find_parent (CORE_ADDR lookup) const + { + return m_die_range_map.find_parent (lookup); + } + + /* Set the parent of DIES in range [START, END] to PARENT_ENTRY. */ + void set_parent (CORE_ADDR start, CORE_ADDR end, + const cooked_index_entry *parent_entry) + { + m_die_range_map.set_parent (start, end, parent_entry); + } /* A single deferred entry. */ struct deferred_entry @@ -16356,8 +16369,7 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, else if (*parent_entry == nullptr) { CORE_ADDR lookup = form_addr (origin_offset, origin_is_dwz); - void *obj = m_die_range_map.find (lookup); - *parent_entry = static_cast (obj); + *parent_entry = find_parent (lookup); } unsigned int bytes_read; @@ -16479,7 +16491,7 @@ cooked_indexer::recurse (cutu_reader *reader, reader->cu->per_cu->is_dwz); CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer), reader->cu->per_cu->is_dwz); - m_die_range_map.set_empty (start, end, (void *) parent_entry); + set_parent (start, end, parent_entry); } return info_ptr; @@ -16652,8 +16664,7 @@ cooked_indexer::make_index (cutu_reader *reader) for (const auto &entry : m_deferred_entries) { - void *obj = m_die_range_map.find (entry.spec_offset); - cooked_index_entry *parent = static_cast (obj); + 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); }