From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696251046; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xYMvqXyKruVb58Amc5FiolyuYdiXmyuyyKWjvLbFvN8=; b=MxzQyny729qhfaO+KUtnSAPjTkDFYnXBlZ15WvWeqSfcbU8+7U9S3T3fK2ig/GgC/Lq+j/ VPm9j0Be/rOrL9p3YFpWNILTD6V2zfOt4mZNN8I17C0iQ7Rmnf5WkyKbWJ/E9UO3I1Onxq JXashY7BnVd+TaKpxuTZTJXbk37PUsM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696251046; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xYMvqXyKruVb58Amc5FiolyuYdiXmyuyyKWjvLbFvN8=; b=xF2EcBHLXm3n1/qKUcCd49o5XqbwsM24SLxdEGDgV7672BwevIlmMsrkfg9WPvTjsIrQp7 FIDKrkGqjHdFP/CQ== 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 From: Tom de Vries 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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); } -- 2.35.3