From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.184]) by sourceware.org (Postfix) with ESMTPS id E8EA53833026 for ; Sat, 29 May 2021 13:54:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E8EA53833026 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 99D165D89 for ; Sat, 29 May 2021 08:54:46 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id mzQMlisUOFRe9mzQMlbz4L; Sat, 29 May 2021 08:54:46 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=ml4YIZt6v3PpdMCUl9QHtf0FQ8dPWwgSCLr4g0xjLUA=; b=VuzdjNVVNBQjozKS1CmXocrn5B Dkx9I29gbmsO/u73bCQ0WW0ANfqqnfSrBhcLcMzVm228yCwG9+MA2aAE/0HrTd6tRgABn6ojwgXZu pBGzNRKd1y46ejdyyyLvu9tKn; Received: from 75-166-146-111.hlrn.qwest.net ([75.166.146.111]:52106 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1lmzQM-0042F2-Cx; Sat, 29 May 2021 07:54:46 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/4] Simplify debug_names index writing Date: Sat, 29 May 2021 07:54:43 -0600 Message-Id: <20210529135443.1446279-5-tom@tromey.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210529135443.1446279-1-tom@tromey.com> References: <20210529135443.1446279-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 75.166.146.111 X-Source-L: No X-Exim-ID: 1lmzQM-0042F2-Cx X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-146-111.hlrn.qwest.net (localhost.localdomain) [75.166.146.111]:52106 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, OBFU_UNSUB_UL, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 May 2021 13:54:49 -0000 Like the previous patch, this changes the .debug_names writer to find the TU indices in the main loop over all CUs and TUs. 2021-05-29 Tom Tromey * dwarf2/index-write.c (struct signatured_type_index_data): Remove. (debug_names::write_one_signatured_type_data) (debug_names::write_one_signatured_type): Remove. (write_debug_names): Write type CUs in loop. --- gdb/ChangeLog | 8 ++++ gdb/dwarf2/index-write.c | 93 +++++----------------------------------- 2 files changed, 18 insertions(+), 83 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 06c8e1026f0..6e593310d28 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -585,21 +585,6 @@ write_psymbols (struct mapped_symtab *symtab, } } -/* A helper struct used when iterating over debug_types. */ -struct signatured_type_index_data -{ - signatured_type_index_data (data_buf &types_list_, - std::unordered_set &psyms_seen_) - : types_list (types_list_), psyms_seen (psyms_seen_) - {} - - struct objfile *objfile; - struct mapped_symtab *symtab; - data_buf &types_list; - std::unordered_set &psyms_seen; - int cu_index; -}; - /* Recurse into all "included" dependencies and count their symbols as if they appeared in this psymtab. */ @@ -902,32 +887,6 @@ class debug_names m_debugstrlookup.file_write (file_str); } - /* A helper user data for write_one_signatured_type. */ - class write_one_signatured_type_data - { - public: - write_one_signatured_type_data (debug_names &nametable_, - signatured_type_index_data &&info_) - : nametable (nametable_), info (std::move (info_)) - {} - debug_names &nametable; - struct signatured_type_index_data info; - }; - - /* A helper function to pass write_one_signatured_type to - htab_traverse_noresize. */ - static int - write_one_signatured_type (void **slot, void *d) - { - write_one_signatured_type_data *data = (write_one_signatured_type_data *) d; - struct signatured_type_index_data *info = &data->info; - struct signatured_type *entry = (struct signatured_type *) *slot; - - data->nametable.write_one_signatured_type (entry, info); - - return 1; - } - private: /* Storage for symbol names mapping them to their .debug_str section @@ -1210,25 +1169,6 @@ class debug_names } } - /* A helper function that writes a single signatured_type - to a debug_names. */ - void - write_one_signatured_type (struct signatured_type *entry, - struct signatured_type_index_data *info) - { - partial_symtab *psymtab = entry->v.psymtab; - - write_psymbols (info->psyms_seen, psymtab->global_psymbols, - info->cu_index, false, unit_kind::tu); - write_psymbols (info->psyms_seen, psymtab->static_psymbols, - info->cu_index, true, unit_kind::tu); - - info->types_list.append_uint (dwarf5_offset_size (), m_dwarf5_byte_order, - to_underlying (entry->sect_off)); - - ++info->cu_index; - } - /* Store value of each symbol. */ std::unordered_map, c_str_view_hasher> m_name_to_value_set; @@ -1475,17 +1415,16 @@ write_debug_names (dwarf2_per_objfile *per_objfile, work here. Also, the debug_types entries do not appear in all_comp_units, but only in their own hash table. */ data_buf cu_list; + data_buf types_cu_list; debug_names nametable (per_objfile, dwarf5_is_dwarf64, dwarf5_byte_order); std::unordered_set psyms_seen (psyms_seen_size (per_objfile)); int counter = 0; + int types_counter = 0; for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i) { const dwarf2_per_cu_data *per_cu = per_objfile->per_bfd->all_comp_units[i].get (); - if (per_cu->is_debug_types) - continue; - partial_symtab *psymtab = per_cu->v.psymtab; /* CU of a shared file from 'dwz -m' may be unused by this main @@ -1494,29 +1433,17 @@ write_debug_names (dwarf2_per_objfile *per_objfile, if (psymtab == NULL) continue; + int &this_counter = per_cu->is_debug_types ? types_counter : counter; + data_buf &this_list = per_cu->is_debug_types ? types_cu_list : cu_list; + if (psymtab->user == NULL) nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen, - counter); - - cu_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order, - to_underlying (per_cu->sect_off)); - ++counter; - } + this_counter); - /* Write out the .debug_type entries, if any. */ - data_buf types_cu_list; - if (per_objfile->per_bfd->signatured_types) - { - debug_names::write_one_signatured_type_data sig_data (nametable, - signatured_type_index_data (types_cu_list, psyms_seen)); - - sig_data.info.objfile = objfile; - /* It is used only for gdb_index. */ - sig_data.info.symtab = nullptr; - sig_data.info.cu_index = 0; - htab_traverse_noresize (per_objfile->per_bfd->signatured_types.get (), - debug_names::write_one_signatured_type, - &sig_data); + this_list.append_uint (nametable.dwarf5_offset_size (), + dwarf5_byte_order, + to_underlying (per_cu->sect_off)); + ++this_counter; } nametable.build (); -- 2.26.3