Make dwarf2_per_objfile::all_type_units an std::vector

Make all_type_units an std::vector, remove
n_type_units/n_allocated_type_units and some manual memory management.

gdb/ChangeLog:

	* dwarf2read.h (struct dwarf2_per_objfile) <n_type_units>:
	Remove.
	<n_allocated_type_units>: Remove.
	<all_type_units>: Change to std::vector.
	* dwarf2read.c (dwarf2_per_objfile::~dwarf2_per_objfile): Adjust
	to std::vector change.
	(dwarf2_per_objfile::get_cutu): Likewise.
	(dwarf2_per_objfile::get_tu): Likewise.
	(create_signatured_type_table_from_index): Likewise.
	(create_signatured_type_table_from_debug_names): Likewise.
	(dw2_symtab_iter_next): Likewise.
	(dw2_print_stats): Likewise.
	(dw2_expand_all_symtabs): Likewise.
	(dw2_expand_marked_cus): Likewise.
	(dw2_debug_names_iterator::next): Likewise.
	(dwarf2_initialize_objfile): Likewise.
	(add_signatured_type_cu_to_table): Likewise.
	(create_all_type_units): Likewise.
	(add_type_unit): Likewise.
	(struct tu_abbrev_offset): Add constructor.
	(build_type_psymtabs_1): Adjust to std::vector change.
	(print_tu_stats): Likewise.
	* dwarf-index-write.c (check_dwarf64_offsets): Likewise.
	(write_debug_names): Likewise.
This commit is contained in:
Simon Marchi 2018-04-07 13:53:44 -04:00
parent b76e467de3
commit b2bdb8cf39
4 changed files with 84 additions and 92 deletions

View file

@ -1256,10 +1256,9 @@ check_dwarf64_offsets (struct dwarf2_per_objfile *dwarf2_per_objfile)
if (to_underlying (per_cu->sect_off) >= (static_cast<uint64_t> (1) << 32))
return true;
}
for (int i = 0; i < dwarf2_per_objfile->n_type_units; ++i)
for (const signatured_type *sigtype : dwarf2_per_objfile->all_type_units)
{
const signatured_type &sigtype = *dwarf2_per_objfile->all_type_units[i];
const dwarf2_per_cu_data &per_cu = sigtype.per_cu;
const dwarf2_per_cu_data &per_cu = sigtype->per_cu;
if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32))
return true;
@ -1497,7 +1496,8 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
/* local_type_unit_count - The number of TUs in the local TU
list. */
header.append_uint (4, dwarf5_byte_order, dwarf2_per_objfile->n_type_units);
header.append_uint (4, dwarf5_byte_order,
dwarf2_per_objfile->all_type_units.size ());
/* foreign_type_unit_count - The number of TUs in the foreign TU
list. */