From patchwork Tue Dec 12 17:32:28 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: 81981 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 9E1263856951 for ; Tue, 12 Dec 2023 17:32:59 +0000 (GMT) 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.223.130]) by sourceware.org (Postfix) with ESMTPS id 871E63858C2A for ; Tue, 12 Dec 2023 17:32:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 871E63858C2A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 871E63858C2A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702402345; cv=none; b=Xti9LZSuhtBKHaYLmNZBvhgaOhgzasIuLdyQgoC9YwKeio30nmrgwsDxkHJxrOCK8Zh5v901Cln8KkCpg53PwsVDVcXN658YXDpnLwCUL0gs67odKQM6+BYbrYmY3P/UjrCIqkx4hHhp4JjXFUHL4oMjQqtQYFsE42mmUkC4AiE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702402345; c=relaxed/simple; bh=8hukvbik9nnDhMa7y+s2TbOl/l3mRj5gVIg2zvogeEg=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=RELbEft+GFlAH5I1+yEELrwbtFbaCOlcoGPMK76sTXSX2X7m6Xv1XVoLwiqnrrp+UAFi39idX4chIW4ULH+7qIxNzdPtBNf5vEuC0eBcCTpABra5lJHbWQOnEkA7CbWRItCttxGtG02IFoYz6Jbk6np9WPQET/D3F4JXtJGd6P4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0E8F621DA5 for ; Tue, 12 Dec 2023 17:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702402342; 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=eVFA4BwaVJpdVO3D/0psJLkcvHpR7oG1/c7v4Tf4cOM=; b=Qfn5hEfFs7Euo0R9ikfgSUzbd5UQOlpz1/NPlhCcFssZNTHjKaEYQ8G1xZgCD78Vf8a7Q0 N3ozJ96rltZ4CETMsTzk1idSEUSg8Ow9504vWCVvY87LRuLJPL8BGUbxPZD2/op4H7ctcH tHHHTK+Gas9r7uLueIp2n97Lgmb9L6o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702402342; 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=eVFA4BwaVJpdVO3D/0psJLkcvHpR7oG1/c7v4Tf4cOM=; b=OrhjvTOMaAol6eZa3FSPqm3HVFHPMECzm0UhFI9eNEF7RWwQjuduhdhowL/GmIhEAdd1J0 zj8NH8k4zOugh/Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1702402342; 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=eVFA4BwaVJpdVO3D/0psJLkcvHpR7oG1/c7v4Tf4cOM=; b=Qfn5hEfFs7Euo0R9ikfgSUzbd5UQOlpz1/NPlhCcFssZNTHjKaEYQ8G1xZgCD78Vf8a7Q0 N3ozJ96rltZ4CETMsTzk1idSEUSg8Ow9504vWCVvY87LRuLJPL8BGUbxPZD2/op4H7ctcH tHHHTK+Gas9r7uLueIp2n97Lgmb9L6o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1702402342; 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=eVFA4BwaVJpdVO3D/0psJLkcvHpR7oG1/c7v4Tf4cOM=; b=OrhjvTOMaAol6eZa3FSPqm3HVFHPMECzm0UhFI9eNEF7RWwQjuduhdhowL/GmIhEAdd1J0 zj8NH8k4zOugh/Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EC3C913A9A for ; Tue, 12 Dec 2023 17:32:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IKprOCWZeGVaPQAAD6G6ig (envelope-from ) for ; Tue, 12 Dec 2023 17:32:21 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 02/13] [gdb/symtab] Factor out m_die_range_map usage Date: Tue, 12 Dec 2023 18:32:28 +0100 Message-Id: <20231212173239.16793-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231212173239.16793-1-tdevries@suse.de> References: <20231212173239.16793-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Score: 17.73 X-Rspamd-Server: rspamd1 X-Spamd-Result: default: False [2.79 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_SPAM(5.10)[100.00%]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; R_MISSING_CHARSET(2.50)[]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+]; DMARC_POLICY_ALLOW(0.00)[suse.de,none]; MX_GOOD(-0.01)[]; DMARC_POLICY_ALLOW_WITH_FAILURES(-0.50)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAM_FLAG(5.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; DWL_DNSWL_HI(-3.50)[suse.de:dkim]; RCPT_COUNT_ONE(0.00)[1]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; WHITELIST_DMARC(-7.00)[suse.de:D:+]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Queue-Id: 0E8F621DA5 X-Spam-Flag: NO Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Qfn5hEfF; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=OrhjvTOM; dmarc=pass (policy=none) header.from=suse.de; spf=softfail (smtp-out1.suse.de: 2a07:de40:b281:104:10:150:64:97 is neither permitted nor denied by domain of tdevries@suse.de) smtp.mailfrom=tdevries@suse.de X-Spamd-Bar: ++ X-Spam-Score: 2.79 X-Spam-Status: No, score=-12.4 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, 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 Factor out usage of cooked_indexer::m_die_range_map into new class parent_map with member functions find_parent and set_parent, and static member function form_addr. Tested on x86_64-linux. --- gdb/dwarf2/cooked-index.h | 32 +++++++++++++++++++++++++++ gdb/dwarf2/read.c | 46 ++++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 5675ea68bb8..fa274b37c20 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -239,6 +239,38 @@ struct cooked_index_entry : public allocate_on_obstack bool for_name) const; }; +class parent_map +{ +public: + /* A helper function to turn a section offset into an address that + can be used in a parent_map. */ + static CORE_ADDR form_addr (sect_offset offset, bool is_dwz) + { + CORE_ADDR value = to_underlying (offset); + if (is_dwz) + value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1); + return value; + } + + /* 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 a6700ba3b40..806cc5902b3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4541,16 +4541,6 @@ class cooked_indexer private: - /* A helper function to turn a section offset into an address that - can be used in an addrmap. */ - CORE_ADDR form_addr (sect_offset offset, bool is_dwz) - { - CORE_ADDR value = to_underlying (offset); - if (is_dwz) - value |= ((CORE_ADDR) 1) << (8 * sizeof (CORE_ADDR) - 1); - return value; - } - /* A helper function to scan the PC bounds of READER and record them in the storage's addrmap. */ void check_bounds (cutu_reader *reader); @@ -4618,7 +4608,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 @@ -16172,15 +16175,13 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, if (*parent_entry == nullptr) { - CORE_ADDR addr = form_addr (origin_offset, origin_is_dwz); + CORE_ADDR addr + = parent_map::form_addr (origin_offset, origin_is_dwz); if (new_reader->cu == reader->cu && new_info_ptr > watermark_ptr) *maybe_defer = addr; else - { - void *obj = m_die_range_map.find (addr); - *parent_entry = static_cast (obj); - } + *parent_entry = find_parent (addr); } unsigned int bytes_read; @@ -16298,11 +16299,13 @@ cooked_indexer::recurse (cutu_reader *reader, { /* Both start and end are inclusive, so use both "+ 1" and "- 1" to limit the range to the children of parent_entry. */ - CORE_ADDR start = form_addr (parent_entry->die_offset + 1, - reader->cu->per_cu->is_dwz); - CORE_ADDR end = form_addr (sect_offset (info_ptr - 1 - reader->buffer), + CORE_ADDR start + = parent_map::form_addr (parent_entry->die_offset + 1, + reader->cu->per_cu->is_dwz); + CORE_ADDR end + = parent_map::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; @@ -16475,8 +16478,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); }