From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.179.30]) by sourceware.org (Postfix) with ESMTPS id 97ACE3857C71 for ; Thu, 4 Nov 2021 18:14:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97ACE3857C71 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 cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 2E0CB30987 for ; Thu, 4 Nov 2021 13:12:09 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id ihAqm91x1glrtihAqmjXwq; 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=5tLSoIZ4g/JIM9I3D2HVjQRUeETv7DH4o6NjteBrf5A=; b=ZJXNEArpcG/I4A2W9yfXQ63e/t dF0/jG5lr28vcmiQQhA5p3XpLsC2DELpyzyuZBU1eBHwesHQ5BHterGAEfWBzz7/9VTx4NNPI1CW7 cUYEZs7hpzwYj5wNBUrXyizom; 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 1mihAq-003H6y-75; Thu, 04 Nov 2021 12:09:16 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 29/32] Adapt .debug_names writer to new DWARF scanner Date: Thu, 4 Nov 2021 12:09:04 -0600 Message-Id: <20211104180907.2360627-30-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: 1mihAq-003H6y-75 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: 34 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, OBFU_UNSUB_UL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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:14:06 -0000 This updates the .debug_names writer to work with the new DWARF scanner. --- gdb/dwarf2/index-write.c | 52 ++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 0d8127c2898..71cdb394c51 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -664,15 +664,10 @@ class debug_names enum class unit_kind { cu, tu }; /* Insert one symbol. */ - void insert (const partial_symbol *psym, int cu_index, bool is_static, - unit_kind kind) + void insert (int dwarf_tag, const char *name, int cu_index, bool is_static, + unit_kind kind, enum language lang) { - const int dwarf_tag = psymbol_tag (psym); - if (dwarf_tag == 0) - return; - const char *name = psym->ginfo.search_name (); - - if (psym->ginfo.language () == language_ada) + if (lang == language_ada) { /* We want to ensure that the Ada main function's name appears verbatim in the index. However, this name will be of the @@ -715,6 +710,28 @@ class debug_names value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind)); } + void insert (const partial_symbol *psym, int cu_index, bool is_static, + unit_kind kind) + { + const int dwarf_tag = psymbol_tag (psym); + if (dwarf_tag == 0) + return; + const char *name = psym->ginfo.search_name (); + + insert (dwarf_tag, name, cu_index, is_static, kind, + psym->ginfo.language ()); + } + + void insert (const cooked_index_entry *entry) + { + const auto it = m_cu_index_htab.find (entry->per_cu); + gdb_assert (it != m_cu_index_htab.cend ()); + const char *name = entry->full_name (&m_string_obstack); + insert (entry->tag, name, it->second, (entry->flags & IS_STATIC) != 0, + entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu, + entry->per_cu->lang); + } + /* Build all the tables. All symbols must be already inserted. This function does not call file_write, caller has to do it afterwards. */ @@ -897,6 +914,11 @@ class debug_names m_debugstrlookup.file_write (file_str); } + void add_cu (dwarf2_per_cu_data *per_cu, offset_type index) + { + m_cu_index_htab.emplace (per_cu, index); + } + private: /* Storage for symbol names mapping them to their .debug_str section @@ -1211,6 +1233,8 @@ class debug_names /* Temporary storage for Ada names. */ auto_obstack m_string_obstack; + + cu_index_map m_cu_index_htab; }; /* Return iff any of the needed offsets does not fit into 32-bit @@ -1491,17 +1515,20 @@ write_debug_names (dwarf2_per_objfile *per_objfile, 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 + dwarf2_per_cu_data *per_cu = per_objfile->per_bfd->all_comp_units[i].get (); - partial_symtab *psymtab = per_cu->v.psymtab; 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; + partial_symtab *psymtab = (per_objfile->per_bfd->using_index + ? nullptr + : per_cu->v.psymtab); if (psymtab != nullptr && psymtab->user == nullptr) nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen, this_counter); + nametable.add_cu (per_cu, this_counter); this_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order, to_underlying (per_cu->sect_off)); @@ -1513,6 +1540,11 @@ write_debug_names (dwarf2_per_objfile *per_objfile, - per_objfile->per_bfd->tu_stats.nr_tus)); gdb_assert (types_counter == per_objfile->per_bfd->tu_stats.nr_tus); + if (per_objfile->per_bfd->using_index) + for (const cooked_index_entry *entry + : per_objfile->per_bfd->cooked_index_table->all_entries ()) + nametable.insert (entry); + nametable.build (); /* No addr_vec - DWARF-5 uses .debug_aranges generated by GCC. */ -- 2.31.1