Allocate dwarf2_per_cu_data with 'new'
authorTom Tromey <tom@tromey.com>
Fri, 30 Apr 2021 20:07:58 +0000 (14:07 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 30 Apr 2021 20:07:58 +0000 (14:07 -0600)
commit0d305d5c67e38a65f227e6604c0812797471ace6
treebd53b1efb9f8e574727615b75c0b4c885bda059d
parent1bee48c7ad5b75896ef8d84fedc774e181fb09a7
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.
gdb/ChangeLog
gdb/dwarf2/index-write.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h