Change dwarf2_per_objfile::signatured_types to be htab_up

This changes dwarf2_per_objfile::signatured_types to be an htab_up.
This in turn lets us change it not to use the objfile obstack for
allocation; obstack allocation for hash tables is a bad practice
because it leads to excess memory use if the table is ever resized.

gdb/ChangeLog
2020-02-08  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_objfile) <signatured_types>:
	Change type to htab_up.
	* dwarf2/read.c (create_signatured_type_table_from_index)
	(create_signatured_type_table_from_debug_names)
	(create_all_type_units, add_type_unit)
	(lookup_dwo_signatured_type, lookup_signatured_type)
	(process_skeletonless_type_unit): Update.
	(create_debug_type_hash_table, create_debug_types_hash_table):
	Change type of types_htab.
	(allocate_signatured_type_table, allocate_dwo_unit_table): Return
	htab_up.  Don't allocate on obstack.
	(create_cus_hash_table): Change type of cus_htab parameter.
	(struct dwo_file) <cus, tus>: Now htab_up.
	(lookup_dwo_signatured_type, lookup_dwo_cutu)
	(process_dwo_file_for_skeletonless_type_units, lookup_dwo_cutu)
	(queue_and_load_all_dwo_tus): Update.
	* dwarf2/index-write.c (write_gdbindex): Update.
	(write_debug_names): Update.

Change-Id: I290a209b96945fb5f415c82723b62830e9c4b467
This commit is contained in:
Tom Tromey 2020-02-08 13:40:54 -07:00
parent 39856def4f
commit b0b6a9878a
4 changed files with 71 additions and 52 deletions

View file

@ -1461,7 +1461,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
sig_data.objfile = objfile;
sig_data.symtab = &symtab;
sig_data.cu_index = dwarf2_per_objfile->all_comp_units.size ();
htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
htab_traverse_noresize (dwarf2_per_objfile->signatured_types.get (),
write_one_signatured_type, &sig_data);
}
@ -1534,7 +1534,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
/* It is used only for gdb_index. */
sig_data.info.symtab = nullptr;
sig_data.info.cu_index = 0;
htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
htab_traverse_noresize (dwarf2_per_objfile->signatured_types.get (),
debug_names::write_one_signatured_type,
&sig_data);
}