aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-06-12 11:24:27 -0600
committerTom Tromey <tromey@adacore.com>2025-03-06 14:17:18 -0700
commitc70ac07a791bf50ae9322a3096a3b8b1220e60c9 (patch)
tree990c63ef4922284a0b0f1725550cc32f90411943 /gdb
parent8cf79a06467464fe7df292555dd0ce9e839db832 (diff)
downloadbinutils-c70ac07a791bf50ae9322a3096a3b8b1220e60c9.zip
binutils-c70ac07a791bf50ae9322a3096a3b8b1220e60c9.tar.gz
binutils-c70ac07a791bf50ae9322a3096a3b8b1220e60c9.tar.bz2
Store new Ada entries in cooked_index_shard::m_entries
handle_gnat_encoded_entry might create synthetic cooked index entries for Ada packages. These aren't currently kept in m_entries, but it seems to me that they should be, particularly because a forthcoming GNAT will emit explicit DW_TAG_module for these names -- with this change, the indexes will be roughly equivalent regardless of which compiler was used.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/dwarf2/cooked-index.c17
-rw-r--r--gdb/dwarf2/cooked-index.h12
2 files changed, 21 insertions, 8 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index a3d5288..f630d34 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -327,8 +327,10 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag,
/* See cooked-index.h. */
void
-cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
- htab_t gnat_entries)
+cooked_index_shard::handle_gnat_encoded_entry
+ (cooked_index_entry *entry,
+ htab_t gnat_entries,
+ std::vector<cooked_index_entry *> &new_entries)
{
/* We decode Ada names in a particular way: operators and wide
characters are left as-is. This is done to make name matching a
@@ -363,6 +365,7 @@ cooked_index_shard::handle_gnat_encoded_entry (cooked_index_entry *entry,
entry->per_cu);
last->canonical = last->name;
m_names.push_back (std::move (new_name));
+ new_entries.push_back (last);
*slot = last;
}
@@ -416,6 +419,7 @@ cooked_index_shard::finalize (const parent_map_map *parent_maps)
htab_up gnat_entries (htab_create_alloc (10, hash_entry, eq_entry,
nullptr, xcalloc, xfree));
+ std::vector<cooked_index_entry *> new_gnat_entries;
for (cooked_index_entry *entry : m_entries)
{
@@ -432,7 +436,8 @@ cooked_index_shard::finalize (const parent_map_map *parent_maps)
if ((entry->flags & IS_LINKAGE) != 0)
entry->canonical = entry->name;
else if (entry->lang == language_ada)
- handle_gnat_encoded_entry (entry, gnat_entries.get ());
+ handle_gnat_encoded_entry (entry, gnat_entries.get (),
+ new_gnat_entries);
else if (entry->lang == language_cplus || entry->lang == language_c)
{
void **slot = htab_find_slot (seen_names.get (), entry,
@@ -463,6 +468,12 @@ cooked_index_shard::finalize (const parent_map_map *parent_maps)
entry->canonical = entry->name;
}
+ /* Make sure any new Ada entries end up in the results. This isn't
+ done when creating these new entries to avoid invalidating the
+ m_entries iterator used in the foreach above. */
+ m_entries.insert (m_entries.end (), new_gnat_entries.begin (),
+ new_gnat_entries.end ());
+
m_names.shrink_to_fit ();
m_entries.shrink_to_fit ();
std::sort (m_entries.begin (), m_entries.end (),
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 0930805..c47f84e 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -338,12 +338,14 @@ private:
cooked_index_entry_ref parent_entry,
dwarf2_per_cu *per_cu);
- /* GNAT only emits mangled ("encoded") names in the DWARF, and does
- not emit the module structure. However, we need this structure
- to do lookups. This function recreates that structure for an
- existing entry, modifying ENTRY as appropriate. */
+ /* When GNAT emits mangled ("encoded") names in the DWARF, and does
+ not emit the module structure, we still need this structuring to
+ do lookups. This function recreates that information for an
+ existing entry, modifying ENTRY as appropriate. Any new entries
+ are added to NEW_ENTRIES. */
void handle_gnat_encoded_entry
- (cooked_index_entry *entry, htab_t gnat_entries);
+ (cooked_index_entry *entry, htab_t gnat_entries,
+ std::vector<cooked_index_entry *> &new_entries);
/* Finalize the index. This should be called a single time, when
the index has been fully populated. It enters all the entries