From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 7B5843858CDA for ; Sun, 25 Sep 2022 17:35:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B5843858CDA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id D664F1004CA7B for ; Sun, 25 Sep 2022 17:34:57 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id cVWqoaCxGaT2RcVWroFDr4; Sun, 25 Sep 2022 17:34:57 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=BO52EHcG c=1 sm=1 tr=0 ts=63309141 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=xOM3xZuef0cA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=tjzs_qlI3C7ozM9ProUA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KGycmYLSYn/IRYBXQ8N0UBp/FsI7HHhqZWXBbAe3dLs=; b=PEXHauQlIK1snziNSS5b563pT9 UOeU407PkCwVP+4s7FR4OD8JR1wF2m+OvKyWWWyihIgA5fqjHVm6m2FPnjpXWh5UbDF7veaPkPlrw 4O2VGmvhW56wec2V+Z5V35NZ6; Received: from 71-211-160-49.hlrn.qwest.net ([71.211.160.49]:47274 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ocVWq-002Plr-Eo; Sun, 25 Sep 2022 11:34:56 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Merge both implementations of debug_names::insert Date: Sun, 25 Sep 2022 11:34:43 -0600 Message-Id: <20220925173443.3561411-1-tom@tromey.com> X-Mailer: git-send-email 2.34.3 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: 71.211.160.49 X-Source-L: No X-Exim-ID: 1ocVWq-002Plr-Eo X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-160-49.hlrn.qwest.net (localhost.localdomain) [71.211.160.49]:47274 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3028.7 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Sun, 25 Sep 2022 17:35:12 -0000 The class debug_names has two 'insert' overloads, but only one of them is ever called externally, and it simply forwards to the other implementation. It seems cleaner to me to have a single method, so this patch merges the two. --- gdb/dwarf2/index-write.c | 51 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 4cc0ee53070..4827b594994 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -519,10 +519,29 @@ class debug_names enum class unit_kind { cu, tu }; /* Insert one symbol. */ - void insert (int dwarf_tag, const char *name, int cu_index, bool is_static, - unit_kind kind, enum language lang) + void insert (const cooked_index_entry *entry) { - if (lang == language_ada) + 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); + + /* This is incorrect but it mirrors gdb's historical behavior; and + because the current .debug_names generation is also incorrect, + it seems better to follow what was done before, rather than + introduce a mismatch between the newer and older gdb. */ + dwarf_tag tag = entry->tag; + if (tag != DW_TAG_typedef && tag_is_type (tag)) + tag = DW_TAG_structure_type; + else if (tag == DW_TAG_enumerator || tag == DW_TAG_constant) + tag = DW_TAG_variable; + + int cu_index = it->second; + bool is_static = (entry->flags & IS_STATIC) != 0; + unit_kind kind = (entry->per_cu->is_debug_types + ? unit_kind::tu + : unit_kind::cu); + + if (entry->per_cu->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 @@ -535,8 +554,7 @@ class debug_names = m_name_to_value_set.emplace (c_str_view (name), std::set ()); std::set &value_set = insertpair.first->second; - value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, - kind)); + value_set.emplace (symbol_value (tag, cu_index, is_static, kind)); } /* In order for the index to work when read back into gdb, it @@ -562,28 +580,7 @@ class debug_names = m_name_to_value_set.emplace (c_str_view (name), std::set ()); std::set &value_set = insertpair.first->second; - value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind)); - } - - 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); - - /* This is incorrect but it mirrors gdb's historical behavior; and - because the current .debug_names generation is also incorrect, - it seems better to follow what was done before, rather than - introduce a mismatch between the newer and older gdb. */ - dwarf_tag tag = entry->tag; - if (tag != DW_TAG_typedef && tag_is_type (tag)) - tag = DW_TAG_structure_type; - else if (tag == DW_TAG_enumerator || tag == DW_TAG_constant) - tag = DW_TAG_variable; - - insert (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 ()); + value_set.emplace (symbol_value (tag, cu_index, is_static, kind)); } /* Build all the tables. All symbols must be already inserted. -- 2.34.3