aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-04-30 14:07:58 -0600
committerTom Tromey <tom@tromey.com>2021-04-30 14:07:58 -0600
commit91eea9cc48a17763dae5a4f10eaa111c512ee2d0 (patch)
tree22e069d7bba326a0e9500e7d4ebcaaf8ae850382 /gdb/dwarf2/index-write.c
parent0d305d5c67e38a65f227e6604c0812797471ace6 (diff)
downloadgdb-91eea9cc48a17763dae5a4f10eaa111c512ee2d0.zip
gdb-91eea9cc48a17763dae5a4f10eaa111c512ee2d0.tar.gz
gdb-91eea9cc48a17763dae5a4f10eaa111c512ee2d0.tar.bz2
Remove dwarf2_per_bfd::all_type_units
I don't think there is any deep reason to separate CUs and TUs in dwarf2_per_bfd. This patch removes all_type_units and unifies these two containers. Some minor tweaks are needed to the index writers, because both forms of index keep CUs and TUs separate; Regression tested on x86-63 Fedora 32. gdb/ChangeLog 2021-04-30 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct tu_stats) <nr_tus>: New member. (struct dwarf2_per_bfd) <get_cutu, get_tu>: Remove <get_cu>: Now inline. <all_type_units>: Remove. * dwarf2/read.c (dwarf2_per_bfd::~dwarf2_per_bfd): Update. (dwarf2_per_bfd::get_cutu, dwarf2_per_bfd::get_cu) (dwarf2_per_bfd::get_tu): Remove. (dwarf2_per_bfd::allocate_signatured_type): Update nr_tus. (create_signatured_type_table_from_index) (create_signatured_type_table_from_debug_names) (dw2_symtab_iter_next, dwarf2_base_index_functions::print_stats) (dwarf2_base_index_functions::expand_all_symtabs) (dw2_expand_marked_cus, dw_expand_symtabs_matching_file_matcher) (dwarf2_base_index_functions::map_symbol_filenames) (dw2_debug_names_iterator::next, dwarf2_initialize_objfile) (add_signatured_type_cu_to_table, create_all_type_units) (add_type_unit, build_type_psymtabs_1, print_tu_stats) (create_all_comp_units): Update. * dwarf2/index-write.c (check_dwarf64_offsets, write_gdbindex) (write_debug_names): Update.
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r--gdb/dwarf2/index-write.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index b000cd5..8cdfac7 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1318,12 +1318,6 @@ check_dwarf64_offsets (dwarf2_per_objfile *per_objfile)
>= (static_cast<uint64_t> (1) << 32))
return true;
}
- for (const auto &sigtype : per_objfile->per_bfd->all_type_units)
- {
- if (to_underlying (sigtype->sect_off)
- >= (static_cast<uint64_t> (1) << 32))
- return true;
- }
return false;
}
@@ -1438,10 +1432,14 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
std::unordered_set<partial_symbol *> psyms_seen
(psyms_seen_size (per_objfile));
+ int counter = 0;
for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i)
{
dwarf2_per_cu_data *per_cu
= per_objfile->per_bfd->all_comp_units[i].get ();
+ if (per_cu->is_debug_types)
+ continue;
+
partial_symtab *psymtab = per_cu->v.psymtab;
if (psymtab != NULL)
@@ -1450,7 +1448,7 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
recursively_write_psymbols (objfile, psymtab, &symtab,
psyms_seen, i);
- const auto insertpair = cu_index_htab.emplace (psymtab, i);
+ const auto insertpair = cu_index_htab.emplace (psymtab, counter);
gdb_assert (insertpair.second);
}
@@ -1461,6 +1459,7 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
cu_list.append_uint (8, BFD_ENDIAN_LITTLE,
to_underlying (per_cu->sect_off));
cu_list.append_uint (8, BFD_ENDIAN_LITTLE, per_cu->length);
+ ++counter;
}
/* Dump the address map. */
@@ -1476,7 +1475,8 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
sig_data.objfile = objfile;
sig_data.symtab = &symtab;
- sig_data.cu_index = per_objfile->per_bfd->all_comp_units.size ();
+ sig_data.cu_index = (per_objfile->per_bfd->all_comp_units.size ()
+ - per_objfile->per_bfd->tu_stats.nr_tus);
htab_traverse_noresize (per_objfile->per_bfd->signatured_types.get (),
write_one_signatured_type, &sig_data);
}
@@ -1520,10 +1520,14 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
debug_names nametable (per_objfile, dwarf5_is_dwarf64, dwarf5_byte_order);
std::unordered_set<partial_symbol *>
psyms_seen (psyms_seen_size (per_objfile));
+ int counter = 0;
for (int i = 0; i < per_objfile->per_bfd->all_comp_units.size (); ++i)
{
const dwarf2_per_cu_data *per_cu
= per_objfile->per_bfd->all_comp_units[i].get ();
+ if (per_cu->is_debug_types)
+ continue;
+
partial_symtab *psymtab = per_cu->v.psymtab;
/* CU of a shared file from 'dwz -m' may be unused by this main
@@ -1533,10 +1537,12 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
continue;
if (psymtab->user == NULL)
- nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen, i);
+ nametable.recursively_write_psymbols (objfile, psymtab, psyms_seen,
+ counter);
cu_list.append_uint (nametable.dwarf5_offset_size (), dwarf5_byte_order,
to_underlying (per_cu->sect_off));
+ ++counter;
}
/* Write out the .debug_type entries, if any. */
@@ -1590,12 +1596,13 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
/* comp_unit_count - The number of CUs in the CU list. */
header.append_uint (4, dwarf5_byte_order,
- per_objfile->per_bfd->all_comp_units.size ());
+ per_objfile->per_bfd->all_comp_units.size ()
+ - per_objfile->per_bfd->tu_stats.nr_tus);
/* local_type_unit_count - The number of TUs in the local TU
list. */
header.append_uint (4, dwarf5_byte_order,
- per_objfile->per_bfd->all_type_units.size ());
+ per_objfile->per_bfd->tu_stats.nr_tus);
/* foreign_type_unit_count - The number of TUs in the foreign TU
list. */