From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by sourceware.org (Postfix) with ESMTPS id CB628384F015 for ; Thu, 23 Nov 2023 05:32:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB628384F015 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 CB628384F015 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700717527; cv=none; b=clmeuTQSi/TJYto1175SBbhWptTI7cPXhBR5Fjb3O6TguQO1M/uiPQ23JGq0NMTrnkJ2etkFEPi4mcWsdgwx4YgzG9R1/GuK+VpkNHsMyBaSxqwvva7gmQhjSXSF+jyeypEUQVSe/r1XhPFxnsTW0B2KK/H599PnWwN8XHu1l7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700717527; c=relaxed/simple; bh=QkWx799nW19z29QznXyFNQpqBpyTfQ0kgeS3Jl5+MSs=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JDjtOgbB8WjKztdcva+O2vsBnfgcRXlotkT8dt96Hrzqjrdfku4QQoN/RS4CQ7qK7K+VXg157m6pbFdvJOGbv7D7U1G/aO28uvFy2CKi0kSbWHAInPFaT1Y7/N37Nr2HqILDApdyNMBRFiepNgEucrObQF0n0F4BnOKgo5fdX+s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTPS id 5ykLrclo8jtZ362Jtrsord; Thu, 23 Nov 2023 05:32:09 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 62JnrlLPGnCfv62Jnrn5OE; Thu, 23 Nov 2023 05:32:04 +0000 X-Authority-Analysis: v=2.4 cv=KKpJsXJo c=1 sm=1 tr=0 ts=655ee3d4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=v0RHch5GQAZndExIyqMA: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=Ly97BqzAAt/aSgpF1cpYhgfgC/ex9p8xXrX1Mapkq0U=; b=j7qJWRafx+Qv3IG7VSpvgBwV0L PdPpH1SrgZLko+gtKTAnPgLLOjQDnQU9silngKUU5zwVpFzDykVDJWAkgEpxA6MkmnXS+o0N4/OtH H8g4YJUIYeLOSXE00Wm98JH2+; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:46354 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 1r62Jn-003TGR-0s for gdb-patches@sourceware.org; Wed, 22 Nov 2023 22:32:03 -0700 From: Tom Tromey Date: Wed, 22 Nov 2023 22:32:17 -0700 Subject: [PATCH v3 08/18] Move cooked_index_storage to cooked-index.h MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231122-t-bg-dwarf-reading-v3-8-fc3180de63c4@tromey.com> References: <20231122-t-bg-dwarf-reading-v3-0-fc3180de63c4@tromey.com> In-Reply-To: <20231122-t-bg-dwarf-reading-v3-0-fc3180de63c4@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.77.73 X-Source-L: No X-Exim-ID: 1r62Jn-003TGR-0s X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:46354 X-Source-Auth: tom+tromey.com X-Email-Count: 10 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEsOwnrUdhA36y/ji2H6L55C4oT9uzUw3iTH6CbG31GxwYp1MexLtmnXIt3yNcgaUsnEIKi6I6OHUnEIjQ9rwiB8xfoKij8Ccu5Koe2AprbJKARmxcu1 81Trci1xpJSJKsx78cEmh+jB2Fgl4v9/TZGYsJC6phexkJiY5gpSi71Jlt/zwzKKle5dsxqg4v7Y96xyuKFdV38/kI7rsCcmxh0= X-Spam-Status: No, score=-3024.0 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 List-Id: This moves cooked_index_storage to cooked-index.h. This is needed by a subsequent patch. --- gdb/dwarf2/cooked-index.h | 70 ++++++++++++++++++++++++ gdb/dwarf2/read.c | 135 ++++++++++++++-------------------------------- 2 files changed, 111 insertions(+), 94 deletions(-) diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 5675ea68bb8..36b734f0fb6 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -33,6 +33,7 @@ #include "gdbsupport/thread-pool.h" #include "dwarf2/mapped-index.h" #include "dwarf2/tag.h" +#include "dwarf2/abbrev-cache.h" #include "gdbsupport/range-chain.h" struct dwarf2_per_cu_data; @@ -354,6 +355,75 @@ class cooked_index_shard gdb::future m_future; }; +class cutu_reader; + +/* An instance of this is created when scanning DWARF to create a + cooked index. */ + +class cooked_index_storage +{ +public: + + cooked_index_storage (); + DISABLE_COPY_AND_ASSIGN (cooked_index_storage); + + /* Return the current abbrev cache. */ + abbrev_cache *get_abbrev_cache () + { + return &m_abbrev_cache; + } + + /* Return the DIE reader corresponding to PER_CU. If no such reader + has been registered, return NULL. */ + cutu_reader *get_reader (dwarf2_per_cu_data *per_cu); + + /* Preserve READER by storing it in the local hash table. */ + cutu_reader *preserve (std::unique_ptr reader); + + /* Add an entry to the index. The arguments describe the entry; see + cooked-index.h. The new entry is returned. */ + const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, + cooked_index_flag flags, + const char *name, + const cooked_index_entry *parent_entry, + dwarf2_per_cu_data *per_cu) + { + return m_index->add (die_offset, tag, flags, name, parent_entry, per_cu); + } + + /* Install the current addrmap into the shard being constructed, + then transfer ownership of the index to the caller. */ + std::unique_ptr release () + { + m_index->install_addrmap (&m_addrmap); + return std::move (m_index); + } + + /* Return the mutable addrmap that is currently being created. */ + addrmap_mutable *get_addrmap () + { + return &m_addrmap; + } + +private: + + /* Hash function for a cutu_reader. */ + static hashval_t hash_cutu_reader (const void *a); + + /* Equality function for cutu_reader. */ + static int eq_cutu_reader (const void *a, const void *b); + + /* The abbrev cache used by this indexer. */ + abbrev_cache m_abbrev_cache; + /* A hash table of cutu_reader objects. */ + htab_up m_reader_hash; + /* The index shard that is being constructed. */ + std::unique_ptr m_index; + + /* A writeable addrmap being constructed by this scanner. */ + addrmap_mutable m_addrmap; +}; + /* The main index of DIEs. The parallel DIE indexers create cooked_index_shard objects. Then, these are all handled to a cooked_index for storage and final indexing. The index is diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 113fe02871f..68144918adf 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -742,7 +742,6 @@ show_dwarf_max_cache_age (struct ui_file *file, int from_tty, static void dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu); -class cooked_index_storage; static void build_type_psymtabs_reader (cutu_reader *reader, cooked_index_storage *storage); @@ -4429,105 +4428,53 @@ get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list) } -/* An instance of this is created when scanning DWARF to create a - cooked index. */ - -class cooked_index_storage +cooked_index_storage::cooked_index_storage () + : m_reader_hash (htab_create_alloc (10, hash_cutu_reader, + eq_cutu_reader, + htab_delete_entry, + xcalloc, xfree)), + m_index (new cooked_index_shard) { -public: - - cooked_index_storage () - : m_reader_hash (htab_create_alloc (10, hash_cutu_reader, - eq_cutu_reader, - htab_delete_entry, - xcalloc, xfree)), - m_index (new cooked_index_shard) - { - } - - DISABLE_COPY_AND_ASSIGN (cooked_index_storage); - - /* Return the current abbrev cache. */ - abbrev_cache *get_abbrev_cache () - { - return &m_abbrev_cache; - } - - /* Return the DIE reader corresponding to PER_CU. If no such reader - has been registered, return NULL. */ - cutu_reader *get_reader (dwarf2_per_cu_data *per_cu) - { - int index = per_cu->index; - return (cutu_reader *) htab_find_with_hash (m_reader_hash.get (), - &index, index); - } - - /* Preserve READER by storing it in the local hash table. */ - cutu_reader *preserve (std::unique_ptr reader) - { - m_abbrev_cache.add (reader->release_abbrev_table ()); - - int index = reader->cu->per_cu->index; - void **slot = htab_find_slot_with_hash (m_reader_hash.get (), &index, - index, INSERT); - gdb_assert (*slot == nullptr); - cutu_reader *result = reader.get (); - *slot = reader.release (); - return result; - } - - /* Add an entry to the index. The arguments describe the entry; see - cooked-index.h. The new entry is returned. */ - const cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, - cooked_index_flag flags, - const char *name, - const cooked_index_entry *parent_entry, - dwarf2_per_cu_data *per_cu) - { - return m_index->add (die_offset, tag, flags, name, parent_entry, per_cu); - } - - /* Install the current addrmap into the index shard being constructed, - then transfer ownership of the index to the caller. */ - std::unique_ptr release () - { - m_index->install_addrmap (&m_addrmap); - return std::move (m_index); - } - - /* Return the mutable addrmap that is currently being created. */ - addrmap_mutable *get_addrmap () - { - return &m_addrmap; - } +} -private: +cutu_reader * +cooked_index_storage::get_reader (dwarf2_per_cu_data *per_cu) +{ + int index = per_cu->index; + return (cutu_reader *) htab_find_with_hash (m_reader_hash.get (), + &index, index); +} - /* Hash function for a cutu_reader. */ - static hashval_t hash_cutu_reader (const void *a) - { - const cutu_reader *reader = (const cutu_reader *) a; - return reader->cu->per_cu->index; - } +cutu_reader * +cooked_index_storage::preserve (std::unique_ptr reader) +{ + m_abbrev_cache.add (reader->release_abbrev_table ()); - /* Equality function for cutu_reader. */ - static int eq_cutu_reader (const void *a, const void *b) - { - const cutu_reader *ra = (const cutu_reader *) a; - const int *rb = (const int *) b; - return ra->cu->per_cu->index == *rb; - } + int index = reader->cu->per_cu->index; + void **slot = htab_find_slot_with_hash (m_reader_hash.get (), &index, + index, INSERT); + gdb_assert (*slot == nullptr); + cutu_reader *result = reader.get (); + *slot = reader.release (); + return result; +} - /* The abbrev cache used by this indexer. */ - abbrev_cache m_abbrev_cache; - /* A hash table of cutu_reader objects. */ - htab_up m_reader_hash; - /* The index shard that is being constructed. */ - std::unique_ptr m_index; +/* Hash function for a cutu_reader. */ +hashval_t +cooked_index_storage::hash_cutu_reader (const void *a) +{ + const cutu_reader *reader = (const cutu_reader *) a; + return reader->cu->per_cu->index; +} - /* A writeable addrmap being constructed by this scanner. */ - addrmap_mutable m_addrmap; -}; +/* Equality function for cutu_reader. */ +int +cooked_index_storage::eq_cutu_reader (const void *a, const void *b) +{ + const cutu_reader *ra = (const cutu_reader *) a; + const int *rb = (const int *) b; + return ra->cu->per_cu->index == *rb; +} /* An instance of this is created to index a CU. */ -- 2.41.0