aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-05-29 15:12:44 -0600
committerTom Tromey <tom@tromey.com>2022-04-12 09:31:16 -0600
commit600f5f702728f66ced24f8497c75c58ff442aeb6 (patch)
tree3555d81bf2fdc53ed4aa753d38dfb0aa8976a390 /gdb/dwarf2
parent6dd7aa909b6f98202ebe995518613e565e11e1a5 (diff)
downloadgdb-600f5f702728f66ced24f8497c75c58ff442aeb6.zip
gdb-600f5f702728f66ced24f8497c75c58ff442aeb6.tar.gz
gdb-600f5f702728f66ced24f8497c75c58ff442aeb6.tar.bz2
Adapt .debug_names writer to new DWARF scanner
This updates the .debug_names writer to work with the new DWARF scanner.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/index-write.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 4d9a9a1..8efe370 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -664,15 +664,10 @@ public:
enum class unit_kind { cu, tu };
/* Insert one symbol. */
- void insert (const partial_symbol *psym, int cu_index, bool is_static,
- unit_kind kind)
+ void insert (int dwarf_tag, const char *name, int cu_index, bool is_static,
+ unit_kind kind, enum language lang)
{
- const int dwarf_tag = psymbol_tag (psym);
- if (dwarf_tag == 0)
- return;
- const char *name = psym->ginfo.search_name ();
-
- if (psym->ginfo.language () == language_ada)
+ if (lang == 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
@@ -715,6 +710,28 @@ public:
value_set.emplace (symbol_value (dwarf_tag, cu_index, is_static, kind));
}
+ void insert (const partial_symbol *psym, int cu_index, bool is_static,
+ unit_kind kind)
+ {
+ const int dwarf_tag = psymbol_tag (psym);
+ if (dwarf_tag == 0)
+ return;
+ const char *name = psym->ginfo.search_name ();
+
+ insert (dwarf_tag, name, cu_index, is_static, kind,
+ psym->ginfo.language ());
+ }
+
+ void insert (const cooked_index_entry *entry)
+ {
+ const auto it = m_cu_index_htab.find (entry->per_cu);
+ gdb_assert (it != m_cu_index_htab.cend ());
+ const char *name = entry->full_name (&m_string_obstack);
+ insert (entry->tag, name, it->second, (entry->flags & IS_STATIC) != 0,
+ entry->per_cu->is_debug_types ? unit_kind::tu : unit_kind::cu,
+ entry->per_cu->lang);
+ }
+
/* Build all the tables. All symbols must be already inserted.
This function does not call file_write, caller has to do it
afterwards. */
@@ -897,6 +914,11 @@ public:
m_debugstrlookup.file_write (file_str);
}
+ void add_cu (dwarf2_per_cu_data *per_cu, offset_type index)
+ {
+ m_cu_index_htab.emplace (per_cu, index);
+ }
+
private:
/* Storage for symbol names mapping them to their .debug_str section
@@ -1211,6 +1233,8 @@ private:
/* Temporary storage for Ada names. */
auto_obstack m_string_obstack;
+
+ cu_index_map m_cu_index_htab;
};
/* Return iff any of the needed offsets does not fit into 32-bit
@@ -1491,17 +1515,20 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
int types_counter = 0;
for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i)
{
- const dwarf2_per_cu_data *per_cu
+ dwarf2_per_cu_data *per_cu
= per_objfile->per_bfd->all_comp_units[i].get ();
- partial_symtab *psymtab = per_cu->v.psymtab;
int &this_counter = per_cu->is_debug_types ? types_counter : counter;
data_buf &this_list = per_cu->is_debug_types ? types_cu_list : cu_list;
+ partial_symtab *psymtab = (per_objfile->per_bfd->using_index
+ ? nullptr
+ : per_cu->v.psymtab);
if (psymtab != nullptr && psymtab->user == nullptr)
nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen,
this_counter);
+ nametable.add_cu (per_cu, this_counter);
this_list.append_uint (nametable.dwarf5_offset_size (),
dwarf5_byte_order,
to_underlying (per_cu->sect_off));
@@ -1513,6 +1540,11 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
- per_objfile->per_bfd->tu_stats.nr_tus));
gdb_assert (types_counter == per_objfile->per_bfd->tu_stats.nr_tus);
+ if (per_objfile->per_bfd->using_index)
+ for (const cooked_index_entry *entry
+ : per_objfile->per_bfd->cooked_index_table->all_entries ())
+ nametable.insert (entry);
+
nametable.build ();
/* No addr_vec - DWARF-5 uses .debug_aranges generated by GCC. */