]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add "synthetic" marker for index entries
authorTom Tromey <tromey@adacore.com>
Tue, 10 Sep 2024 18:54:19 +0000 (12:54 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 21:17:17 +0000 (14:17 -0700)
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.

gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/index-write.c

index 5184e0c8ae2d9bd381f27d3927cce7e08f02af93..a3d5288a26485901ab5f606fad9df7aab3fb71c0 100644 (file)
@@ -359,7 +359,7 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
          gdb::unique_xmalloc_ptr<char> 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));
index 94c13b65df52dddabd70490119b9c073366a39bf..0930805cf04b938c90a4e77476e4ec2eb62496ce 100644 (file)
@@ -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);
 
index eb81f4c434ceaa2003320de1ae55d26351cae7f9..cfe65cb81f5ec64d583a11ba83baa5dcad157bbb 100644 (file)
@@ -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,