From: Tom Tromey Date: Tue, 10 Sep 2024 18:54:19 +0000 (-0600) Subject: Add "synthetic" marker for index entries X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a4a50517b6cb12918beff56b288d6412bca0d0d;p=thirdparty%2Fbinutils-gdb.git Add "synthetic" marker for index entries Currently, gdb will synthesize DW_TAG_module entries for Ada names. These entries are treated specially by the index writer, When GNAT starts emitting DW_TAG_module, the special case will be incorrect, because there will be non-synthetic DW_TAG_module entries in the index. This patch arranges to mark the synthetic entries and changes the index writer to follow. --- diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c index 5184e0c8ae2..a3d5288a264 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -359,7 +359,7 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry, gdb::unique_xmalloc_ptr new_name = make_unique_xstrndup (name.data (), name.length ()); last = create (entry->die_offset, DW_TAG_module, - 0, language_ada, new_name.get (), parent, + IS_SYNTHESIZED, language_ada, new_name.get (), parent, entry->per_cu); last->canonical = last->name; m_names.push_back (std::move (new_name)); diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index 94c13b65df5..0930805cf04 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -60,6 +60,9 @@ enum cooked_index_flag_enum : unsigned char /* True is parent_entry.deferred has a value rather than parent_entry .resolved. */ IS_PARENT_DEFERRED = 16, + /* True if this entry was synthesized by gdb (as opposed to coming + directly from the DWARF). */ + IS_SYNTHESIZED = 32, }; DEF_ENUM_FLAGS_TYPE (enum cooked_index_flag_enum, cooked_index_flag); diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index eb81f4c434c..cfe65cb81f5 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -676,9 +676,8 @@ public: /* Insert one symbol. */ void insert (const cooked_index_entry *entry) { - /* These entries are synthesized by the reader, and so should not - be written. */ - if (entry->lang == language_ada && entry->tag == DW_TAG_module) + /* Synthesized entries should not be written. */ + if ((entry->flags & IS_SYNTHESIZED) != 0) return; m_name_to_value_set[entry->name].emplace_back (entry); @@ -729,11 +728,11 @@ public: unit_kind kind = (entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu); - /* Currently Ada parentage is synthesized by the - reader and so must be ignored here. */ - const cooked_index_entry *parent = (entry->lang == language_ada - ? nullptr - : entry->get_parent ()); + /* Some Ada parentage is synthesized by the reader and so + must be ignored here. */ + const cooked_index_entry *parent = entry->get_parent (); + if (parent != nullptr && (parent->flags & IS_SYNTHESIZED) != 0) + parent = nullptr; int &idx = m_indexkey_to_idx[index_key (entry->tag, kind,