From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 2C3EF3858CDB; Sat, 8 Oct 2022 15:04:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2C3EF3858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665241484; bh=YIfnLMalnayPblDcF/hwZVhBdUCv+l1ASTaL3CpKLmY=; h=From:To:Subject:Date:From; b=sn+jySdHNfJFDvNeh4xQVc3KwHn/LI7lEUDLo0ZZWBZPkqeVdE3Aqutte1zMaJnQu 15NjYBgTNfTrts3anW2B5V9Q2xZ21eAd0QWlt2OsXWxe8IHnJgf0OXIn4V0Py9Bbtz AEpo0yt9FDacIFQzv82axtJwuuIh7wX8ztrWuekQ= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Merge both implementations of debug_names::insert X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: db95282ce93b6453bc533ea1dbe1637213daf59b X-Git-Newrev: 4482b068b2b50878b7a03651318cd8cd32d698cf Message-Id: <20221008150444.2C3EF3858CDB@sourceware.org> Date: Sat, 8 Oct 2022 15:04:44 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D4482b068b2b5= 0878b7a03651318cd8cd32d698cf commit 4482b068b2b50878b7a03651318cd8cd32d698cf Author: Tom Tromey Date: Fri Sep 23 16:23:41 2022 -0600 Merge both implementations of debug_names::insert =20 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. Diff: --- 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 @@ public: enum class unit_kind { cu, tu }; =20 /* Insert one symbol. */ - void insert (int dwarf_tag, const char *name, int cu_index, bool is_stat= ic, - unit_kind kind, enum language lang) + void insert (const cooked_index_entry *entry) { - if (lang =3D=3D language_ada) + const auto it =3D m_cu_index_htab.find (entry->per_cu); + gdb_assert (it !=3D m_cu_index_htab.cend ()); + const char *name =3D 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 =3D entry->tag; + if (tag !=3D DW_TAG_typedef && tag_is_type (tag)) + tag =3D DW_TAG_structure_type; + else if (tag =3D=3D DW_TAG_enumerator || tag =3D=3D DW_TAG_constant) + tag =3D DW_TAG_variable; + + int cu_index =3D it->second; + bool is_static =3D (entry->flags & IS_STATIC) !=3D 0; + unit_kind kind =3D (entry->per_cu->is_debug_types + ? unit_kind::tu + : unit_kind::cu); + + if (entry->per_cu->lang () =3D=3D 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 @@ public: =3D m_name_to_value_set.emplace (c_str_view (name), std::set ()); std::set &value_set =3D 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)); } =20 /* In order for the index to work when read back into gdb, it @@ -562,28 +580,7 @@ public: =3D m_name_to_value_set.emplace (c_str_view (name), std::set ()); std::set &value_set =3D 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 =3D m_cu_index_htab.find (entry->per_cu); - gdb_assert (it !=3D m_cu_index_htab.cend ()); - const char *name =3D 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 =3D entry->tag; - if (tag !=3D DW_TAG_typedef && tag_is_type (tag)) - tag =3D DW_TAG_structure_type; - else if (tag =3D=3D DW_TAG_enumerator || tag =3D=3D DW_TAG_constant) - tag =3D DW_TAG_variable; - - insert (tag, name, it->second, (entry->flags & IS_STATIC) !=3D 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)); } =20 /* Build all the tables. All symbols must be already inserted.