aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-09-10 12:54:19 -0600
committerTom Tromey <tromey@adacore.com>2025-03-06 14:17:17 -0700
commit4a4a50517b6cb12918beff56b288d6412bca0d0d (patch)
tree6013af79b1f93d99be5378f9f7864e03e0739a16 /gdb
parente382ede5ea0ef5b0e35a58ac5f67e170b1c69f2b (diff)
downloadbinutils-4a4a50517b6cb12918beff56b288d6412bca0d0d.zip
binutils-4a4a50517b6cb12918beff56b288d6412bca0d0d.tar.gz
binutils-4a4a50517b6cb12918beff56b288d6412bca0d0d.tar.bz2
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/cooked-index.c2
-rw-r--r--gdb/dwarf2/cooked-index.h3
-rw-r--r--gdb/dwarf2/index-write.c15
3 files changed, 11 insertions, 9 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 5184e0c..a3d5288 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<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));
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 94c13b6..0930805 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 eb81f4c..cfe65cb 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,