From: Simon Marchi Date: Mon, 3 Mar 2025 19:43:15 +0000 (-0500) Subject: gdb/dwarf: track comp and type units count X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30ba744189820f4ae546aa05e905d97e8516bcd2;p=thirdparty%2Fbinutils-gdb.git gdb/dwarf: track comp and type units count A subsequent commit will remove the all_comp_units and all_type_units array views, since the all_units vector will no longer be segmented between comp and type units. Some callers still need to know the number of each kind, so track that separately. Change-Id: I6ef184767a96e5be095bbf9142aa850adbb083ac --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7b1f977787e..469c2900ce4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1733,6 +1733,7 @@ dwarf2_per_bfd::allocate_per_cu (dwarf2_section_info *section, dwarf2_per_cu_up result (new dwarf2_per_cu (this, section, sect_off, length, is_dwz)); result->index = all_units.size (); + this->num_comp_units++; return result; } @@ -1749,7 +1750,7 @@ dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section, = std::make_unique (this, section, sect_off, length, is_dwz, signature); result->index = all_units.size (); - tu_stats.nr_tus++; + this->num_type_units++; return result; } @@ -3629,10 +3630,11 @@ build_type_psymtabs (dwarf2_per_objfile *per_objfile, static void print_tu_stats (dwarf2_per_objfile *per_objfile) { - struct tu_stats *tu_stats = &per_objfile->per_bfd->tu_stats; + dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; + struct tu_stats *tu_stats = &per_bfd->tu_stats; dwarf_read_debug_printf ("Type unit statistics:"); - dwarf_read_debug_printf (" %d TUs", tu_stats->nr_tus); + dwarf_read_debug_printf (" %d TUs", per_bfd->num_type_units); dwarf_read_debug_printf (" %d uniq abbrev tables", tu_stats->nr_uniq_abbrev_tables); dwarf_read_debug_printf (" %d symtabs from stmt_list entries", @@ -3941,11 +3943,10 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile, void finalize_all_units (dwarf2_per_bfd *per_bfd) { - size_t nr_tus = per_bfd->tu_stats.nr_tus; - size_t nr_cus = per_bfd->all_units.size () - nr_tus; gdb::array_view tmp = per_bfd->all_units; - per_bfd->all_comp_units = tmp.slice (0, nr_cus); - per_bfd->all_type_units = tmp.slice (nr_cus, nr_tus); + per_bfd->all_comp_units = tmp.slice (0, per_bfd->num_comp_units); + per_bfd->all_type_units + = tmp.slice (per_bfd->num_comp_units, per_bfd->num_type_units); } /* See read.h. */ diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index e178c60509e..b7780cef650 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -44,7 +44,6 @@ struct tu_stats int nr_symtab_sharers = 0; int nr_stmt_less_type_units = 0; int nr_all_type_units_reallocs = 0; - int nr_tus = 0; }; struct abbrev_table_cache; @@ -604,6 +603,9 @@ public: gdb::array_view all_comp_units; gdb::array_view all_type_units; + unsigned int num_comp_units = 0; + unsigned int num_type_units = 0; + std::vector all_comp_units_index_cus; std::vector all_comp_units_index_tus;