From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IOHRIrBHsmAJegAAWB0awg (envelope-from ) for ; Sat, 29 May 2021 09:54:56 -0400 Received: by simark.ca (Postfix, from userid 112) id 88E0F1F11E; Sat, 29 May 2021 09:54:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,RDNS_DYNAMIC,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9CFAA1F11C for ; Sat, 29 May 2021 09:54:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC5A4386FC37; Sat, 29 May 2021 13:54:50 +0000 (GMT) Received: from gateway23.websitewelcome.com (gateway23.websitewelcome.com [192.185.49.184]) by sourceware.org (Postfix) with ESMTPS id AEE35383543A for ; Sat, 29 May 2021 13:54:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AEE35383543A 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 5A58A5BC8 for ; Sat, 29 May 2021 08:54:46 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id mzQMlisU9FRe9mzQMlbz46; 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=kQGBmGYr+bJ3e7oPeRf9sQmABdmk7GbBCLRzUsWENp4=; b=oZgxS9Xh6iB/igupyKeIAp40AZ NnVQMGEqv1SXAp2WJoEnybw/ywZZ/KBJUGRMA4MexQFE5R65wkRmsvZAGkCj0Hhvngkk5N7F63HFO 5fIkmK5vGyv3BSuVuWGYzds36; 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-5N; Sat, 29 May 2021 07:54:46 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 3/4] Simplify gdb_index writing Date: Sat, 29 May 2021 07:54:42 -0600 Message-Id: <20210529135443.1446279-4-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-5N 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: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Cc: Tom Tromey Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" write_gdbindex write the CUs first, then walks the signatured type hash table to write out the TUs. However, now that CUs and TUs are unified in the DWARF reader, it's simpler to handle both of these in the same loop. 2021-05-28 Tom Tromey * dwarf2/index-write.c (write_one_signatured_type): Remove. (write_gdbindex): Write type CUs in loop. --- gdb/ChangeLog | 5 +++ gdb/dwarf2/index-write.c | 84 ++++++++++++---------------------------- 2 files changed, 29 insertions(+), 60 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 656742f2e0a..06c8e1026f0 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -600,43 +600,6 @@ struct signatured_type_index_data int cu_index; }; -/* A helper function that writes a single signatured_type to an - obstack. */ - -static int -write_one_signatured_type (void **slot, void *d) -{ - struct signatured_type_index_data *info - = (struct signatured_type_index_data *) d; - struct signatured_type *entry = (struct signatured_type *) *slot; - partial_symtab *psymtab = entry->v.psymtab; - - if (psymtab == nullptr) - { - /* We can end up here when processing a skeleton CU referring to a - .dwo file that hasn't been found. There's not much we can do in - such a case, so skip this CU. */ - return 1; - } - - write_psymbols (info->symtab, info->psyms_seen, - psymtab->global_psymbols, info->cu_index, - 0); - write_psymbols (info->symtab, info->psyms_seen, - psymtab->static_psymbols, info->cu_index, - 1); - - info->types_list.append_uint (8, BFD_ENDIAN_LITTLE, - to_underlying (entry->sect_off)); - info->types_list.append_uint (8, BFD_ENDIAN_LITTLE, - to_underlying (entry->type_offset_in_tu)); - info->types_list.append_uint (8, BFD_ENDIAN_LITTLE, entry->signature); - - ++info->cu_index; - - return 1; -} - /* Recurse into all "included" dependencies and count their symbols as if they appeared in this psymtab. */ @@ -1420,6 +1383,9 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, psym_index_map cu_index_htab; cu_index_htab.reserve (per_objfile->per_bfd->all_comp_units.size ()); + /* Store out the .debug_type CUs, if any. */ + data_buf types_cu_list; + /* The CU list is already sorted, so we don't need to do additional work here. Also, the debug_types entries do not appear in all_comp_units, but only in their own hash table. */ @@ -1427,54 +1393,52 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, 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) { 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; + int &this_counter = per_cu->is_debug_types ? types_counter : counter; + if (psymtab != NULL) { if (psymtab->user == NULL) recursively_write_psymbols (objfile, psymtab, &symtab, - psyms_seen, counter); + psyms_seen, this_counter); - const auto insertpair = cu_index_htab.emplace (psymtab, counter); + const auto insertpair = cu_index_htab.emplace (psymtab, + this_counter); gdb_assert (insertpair.second); } /* The all_comp_units list contains CUs read from the objfile as well as from the eventual dwz file. We need to place the entry in the corresponding index. */ - data_buf &cu_list = per_cu->is_dwz ? dwz_cu_list : objfile_cu_list; + data_buf &cu_list = (per_cu->is_debug_types + ? types_cu_list + : per_cu->is_dwz ? dwz_cu_list : objfile_cu_list); cu_list.append_uint (8, BFD_ENDIAN_LITTLE, to_underlying (per_cu->sect_off)); - cu_list.append_uint (8, BFD_ENDIAN_LITTLE, per_cu->length); - ++counter; + if (per_cu->is_debug_types) + { + signatured_type *sig_type = (signatured_type *) per_cu; + cu_list.append_uint (8, BFD_ENDIAN_LITTLE, + to_underlying (sig_type->type_offset_in_tu)); + cu_list.append_uint (8, BFD_ENDIAN_LITTLE, + sig_type->signature); + } + else + cu_list.append_uint (8, BFD_ENDIAN_LITTLE, per_cu->length); + + ++this_counter; } /* Dump the address map. */ data_buf addr_vec; write_address_map (per_objfile->per_bfd, addr_vec, cu_index_htab); - /* Write out the .debug_type entries, if any. */ - data_buf types_cu_list; - if (per_objfile->per_bfd->signatured_types) - { - signatured_type_index_data sig_data (types_cu_list, - psyms_seen); - - sig_data.objfile = objfile; - sig_data.symtab = &symtab; - sig_data.cu_index = (per_objfile->per_bfd->all_comp_units.size () - - per_objfile->per_bfd->tu_stats.nr_tus); - htab_traverse_noresize (per_objfile->per_bfd->signatured_types.get (), - write_one_signatured_type, &sig_data); - } - /* Now that we've processed all symbols we can shrink their cu_indices lists. */ uniquify_cu_indices (&symtab); -- 2.26.3