From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway20.websitewelcome.com (gateway20.websitewelcome.com [192.185.47.18]) by sourceware.org (Postfix) with ESMTPS id E42673857C77 for ; Thu, 4 Nov 2021 18:10:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E42673857C77 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 30A8A4013651D for ; Thu, 4 Nov 2021 13:09:16 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ihAqmjEA3tL6eihAqmwuPj; Thu, 04 Nov 2021 13:09:16 -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=zcXSjRZ3E9wG0ASUARyDGh9yhEsS70mt4aXdbl5POlM=; b=mDUUbQmf1s2z3iGeBrgnZvIKtj GUxb1nvibKeuHO0IYk8WtNXKyWIrQ0wvLsZux355GCv77vJAvcn8dae79ttJZvdE6BEYrRuK+wCGZ ra4JL7qp+yPHUBmE5YPvfL+Mu; Received: from 75-166-134-234.hlrn.qwest.net ([75.166.134.234]:51960 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 1mihAp-003H6y-OT; Thu, 04 Nov 2021 12:09:15 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 27/32] Genericize addrmap handling in the DWARF index writer Date: Thu, 4 Nov 2021 12:09:02 -0600 Message-Id: <20211104180907.2360627-28-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211104180907.2360627-1-tom@tromey.com> References: <20211104180907.2360627-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.134.234 X-Source-L: No X-Exim-ID: 1mihAp-003H6y-OT X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-234.hlrn.qwest.net (localhost.localdomain) [75.166.134.234]:51960 X-Source-Auth: tom+tromey.com X-Email-Count: 32 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.1 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_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 04 Nov 2021 18:10:21 -0000 This updates the DWARF index writing code to make the addrmap-writing a bit more generic. Now, it can handle multiple maps, and it can work using the maps generated by the new indexer. Note that the new addrmap_index_data::using_index field will be deleted in a future patch, when the rest of the DWARF psymtab code is removed. --- gdb/dwarf2/index-write.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 8bf7e8fdd1c..13b929fea54 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -412,8 +412,11 @@ typedef std::unordered_map cu_index_map; /* Helper struct for building the address table. */ struct addrmap_index_data { - addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_) - : addr_vec (addr_vec_), cu_index_htab (cu_index_htab_) + addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_, + bool using_index_) + : addr_vec (addr_vec_), + cu_index_htab (cu_index_htab_), + using_index (using_index_) {} data_buf &addr_vec; @@ -421,6 +424,8 @@ struct addrmap_index_data int operator() (CORE_ADDR start_addr, void *obj); + /* True if the DWARF reader uses the new DWARF indexer. */ + bool using_index; /* True if the previous_* fields are valid. We can't write an entry until we see the next entry (since it is only then that we know the end of the entry). */ @@ -447,7 +452,11 @@ add_address_entry (data_buf &addr_vec, int addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) { - dwarf2_psymtab *pst = (dwarf2_psymtab *) obj; + dwarf2_per_cu_data *per_cu; + if (using_index) + per_cu = (dwarf2_per_cu_data *) obj; + else + per_cu = obj == nullptr ? nullptr : ((dwarf2_psymtab *) obj)->per_cu_data; if (previous_valid) add_address_entry (addr_vec, @@ -455,9 +464,9 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) previous_cu_index); previous_cu_start = start_addr; - if (pst != NULL) + if (per_cu != NULL) { - const auto it = cu_index_htab.find (pst->per_cu_data); + const auto it = cu_index_htab.find (per_cu); gdb_assert (it != cu_index_htab.cend ()); previous_cu_index = it->second; previous_valid = true; @@ -474,9 +483,10 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) static void write_address_map (struct addrmap *addrmap, data_buf &addr_vec, - cu_index_map &cu_index_htab) + cu_index_map &cu_index_htab, bool using_index) { - struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab); + struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab, + using_index); addrmap_foreach (addrmap, addrmap_index_data); @@ -1377,8 +1387,17 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, /* Dump the address map. */ data_buf addr_vec; - write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap, - addr_vec, cu_index_htab); + if (per_objfile->per_bfd->using_index) + { + std::vector addrmaps + = per_objfile->per_bfd->cooked_index_table->get_addrmaps (); + for (auto map : addrmaps) + write_address_map (map, addr_vec, cu_index_htab, true); + } + else + write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap, + addr_vec, cu_index_htab, + per_objfile->per_bfd->using_index); /* Now that we've processed all symbols we can shrink their cu_indices lists. */ -- 2.31.1