diff options
author | Tom Tromey <tom@tromey.com> | 2021-04-30 14:07:58 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-04-30 14:07:58 -0600 |
commit | 0d305d5c67e38a65f227e6604c0812797471ace6 (patch) | |
tree | bd53b1efb9f8e574727615b75c0b4c885bda059d /gdb/dwarf2/index-write.c | |
parent | 1bee48c7ad5b75896ef8d84fedc774e181fb09a7 (diff) | |
download | binutils-0d305d5c67e38a65f227e6604c0812797471ace6.zip binutils-0d305d5c67e38a65f227e6604c0812797471ace6.tar.gz binutils-0d305d5c67e38a65f227e6604c0812797471ace6.tar.bz2 |
Allocate dwarf2_per_cu_data with 'new'
In a patch series I am working on, I'd like to have a non-POD member
in dwarf2_per_cu_data. This currently can't be done because
dwarf2_per_cu_data is allocated on an obstack and initialized with
memset.
This patch changes the DWARF reader to allocate objects of this type
with 'new'. The various "subclasses" of this type (signatured_type in
particular) are now changed to derive from dwarf2_per_cu_data, and
also use 'new' for allocation.
Regression tested on x86-64 Fedora 32.
gdb/ChangeLog
2021-04-30 Tom Tromey <tom@tromey.com>
* dwarf2/read.h (struct dwarf2_per_bfd) <allocate_per_cu,
allocate_signatured_type>: Change return type.
<all_comp_units, all_type_units>: Hold unique pointers.
(struct dwarf2_per_cu_data): Add constructor and initializers.
(struct signatured_type): Derive from dwarf2_per_cu_data.
* dwarf2/read.c (type_unit_group): Derive from
dwarf2_per_cu_data.
(dwarf2_per_bfd::get_cutu, dwarf2_per_bfd::get_cu)
(dwarf2_per_bfd::get_tu)
(dwarf2_per_bfd::allocate_signatured_type)
(dwarf2_per_bfd::allocate_signatured_type)
(create_cu_from_index_list, create_cus_from_index_list)
(create_signatured_type_table_from_index)
(create_signatured_type_table_from_debug_names)
(create_addrmap_from_aranges)
(dwarf2_base_index_functions::find_last_source_symtab)
(dw_expand_symtabs_matching_file_matcher)
(dwarf2_gdb_index::expand_symtabs_matching)
(dwarf2_base_index_functions::map_symbol_filenames)
(create_cus_from_debug_names_list)
(dw2_debug_names_iterator::next)
(dwarf2_debug_names_index::expand_symtabs_matching)
(create_debug_type_hash_table, add_type_unit)
(fill_in_sig_entry_from_dwo_entry, lookup_dwo_signatured_type):
Update.
(allocate_type_unit_groups_table): Use delete.
(create_type_unit_group): Change return type. Use new.
(get_type_unit_group, build_type_psymtabs_1)
(build_type_psymtab_dependencies)
(process_skeletonless_type_unit, set_partial_user)
(dwarf2_build_psymtabs_hard, read_comp_units_from_section)
(create_cus_hash_table, queue_and_load_dwo_tu, follow_die_sig_1)
(read_signatured_type): Update.
(dwarf2_find_containing_comp_unit): Change type of
'all_comp_units'.
(run_test): Update.
(dwarf2_per_bfd::allocate_per_cu)
(dwarf2_per_bfd::allocate_signatured_type): Change return type.
Use new.
(add_signatured_type_cu_to_table): Update.
* dwarf2/index-write.c (write_one_signatured_type)
(check_dwarf64_offsets, psyms_seen_size, write_gdbindex)
(write_debug_names): Update.
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r-- | gdb/dwarf2/index-write.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index e27e1e8..b000cd5 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -615,7 +615,7 @@ write_one_signatured_type (void **slot, void *d) struct signatured_type_index_data *info = (struct signatured_type_index_data *) d; struct signatured_type *entry = (struct signatured_type *) *slot; - partial_symtab *psymtab = entry->per_cu.v.psymtab; + partial_symtab *psymtab = entry->v.psymtab; if (psymtab == nullptr) { @@ -633,7 +633,7 @@ write_one_signatured_type (void **slot, void *d) 1); info->types_list.append_uint (8, BFD_ENDIAN_LITTLE, - to_underlying (entry->per_cu.sect_off)); + to_underlying (entry->sect_off)); info->types_list.append_uint (8, BFD_ENDIAN_LITTLE, to_underlying (entry->type_offset_in_tu)); info->types_list.append_uint (8, BFD_ENDIAN_LITTLE, entry->signature); @@ -1259,7 +1259,7 @@ private: write_one_signatured_type (struct signatured_type *entry, struct signatured_type_index_data *info) { - partial_symtab *psymtab = entry->per_cu.v.psymtab; + partial_symtab *psymtab = entry->v.psymtab; write_psymbols (info->psyms_seen, psymtab->global_psymbols, info->cu_index, false, unit_kind::tu); @@ -1267,7 +1267,7 @@ private: info->cu_index, true, unit_kind::tu); info->types_list.append_uint (dwarf5_offset_size (), m_dwarf5_byte_order, - to_underlying (entry->per_cu.sect_off)); + to_underlying (entry->sect_off)); ++info->cu_index; } @@ -1312,16 +1312,16 @@ private: static bool check_dwarf64_offsets (dwarf2_per_objfile *per_objfile) { - for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units) + for (const auto &per_cu : per_objfile->per_bfd->all_comp_units) { - if (to_underlying (per_cu->sect_off) >= (static_cast<uint64_t> (1) << 32)) + if (to_underlying (per_cu->sect_off) + >= (static_cast<uint64_t> (1) << 32)) return true; } - for (const signatured_type *sigtype : per_objfile->per_bfd->all_type_units) + for (const auto &sigtype : per_objfile->per_bfd->all_type_units) { - const dwarf2_per_cu_data &per_cu = sigtype->per_cu; - - if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32)) + if (to_underlying (sigtype->sect_off) + >= (static_cast<uint64_t> (1) << 32)) return true; } return false; @@ -1337,7 +1337,7 @@ static size_t psyms_seen_size (dwarf2_per_objfile *per_objfile) { size_t psyms_count = 0; - for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units) + for (const auto &per_cu : per_objfile->per_bfd->all_comp_units) { partial_symtab *psymtab = per_cu->v.psymtab; @@ -1440,7 +1440,8 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, (psyms_seen_size (per_objfile)); 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]; + dwarf2_per_cu_data *per_cu + = per_objfile->per_bfd->all_comp_units[i].get (); partial_symtab *psymtab = per_cu->v.psymtab; if (psymtab != NULL) @@ -1521,7 +1522,8 @@ write_debug_names (dwarf2_per_objfile *per_objfile, psyms_seen (psyms_seen_size (per_objfile)); 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]; + const dwarf2_per_cu_data *per_cu + = per_objfile->per_bfd->all_comp_units[i].get (); partial_symtab *psymtab = per_cu->v.psymtab; /* CU of a shared file from 'dwz -m' may be unused by this main |