Commit Graph

8 Commits

Author SHA1 Message Date
Tom Tromey c5d0225d25 Remove a VEC from dwarf2read.c
This removes a VEC from dwarf2read.c, replacing it with a std::vector.

Tested by the buildbot.

gdb/ChangeLog
2018-06-09  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (process_cu_includes): Update.
	(process_full_comp_unit): Update.
	* dwarf2read.h (struct dwarf2_per_objfile) <just_read_cus>: Now a
	std::vector.
2018-06-09 16:05:48 -06:00
Tom Tromey 7ff8cb8c51 Allocate dwz_file with new
This adds a constructor to struct dwz_file and arranges for it to be
allocated with "new" and wrapped in a unique_ptr.  This cuts down on
the amount of manual memory management that must be done.

Regression tested by the buildbot.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (struct dwz_file): Add constructor, initializers.
	<dwz_bfd>: Now a gdb_bfd_ref_ptr.
	(~dwarf2_per_objfile): Update
	(dwarf2_get_dwz_file): Use new.
	* dwarf2read.h (struct dwarf2_per_objfile) <dwz_file>: Now a
	unique_ptr.
2018-05-18 15:12:14 -06:00
Tom Tromey 400174b12a Allocate dwp_file with new
This adds a constructor and initializer to dwp_file and changes it to
be allocated with "new".  This removes a bit of manual refcount
management.

Tested by the buildbot.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

	* dwarf2read.h (struct dwarf2_per_objfile) <dwp_file>: Now a
	unique_ptr.
	* dwarf2read.c (struct dwp_file): Add constructor and
	initializers.
	(open_and_init_dwp_file): Return a unique_ptr.
	(dwarf2_per_objfile, create_dwp_hash_table)
	(create_dwo_unit_in_dwp_v1, create_dwo_unit_in_dwp_v2)
	(lookup_dwo_unit_in_dwp): Update.
	(open_and_init_dwp_file, get_dwp_file): Update.
2018-05-18 14:33:24 -06:00
Tom Tromey 3063847f29 Use new to allocate mapped_index
This changes struct mapped_index to be allocated with new.  This
simplifies the creation a bit (see dwarf2_read_index) and also removes
a somewhat ugly explicit destructor call from ~dwarf2_per_objfile.

Tested by the buildbot.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

	* dwarf2read.c (dwarf2_per_objfile): Update.
	(struct mapped_index): Add initializers.
	(dwarf2_read_index): Use new.
	(dw2_symtab_iter_init): Update.
	* dwarf2read.h (struct dwarf2_per_objfile) <index_table>: Now a
	unique_ptr.
2018-05-18 14:10:09 -06:00
Simon Marchi b2bdb8cf39 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.
2018-04-07 13:53:44 -04:00
Simon Marchi b76e467de3 Make dwarf2_per_objfile::all_comp_units an std::vector
Make all_comp_units an std::vector, remove n_comp_units and some manual
memory management.

gdb/ChangeLog:

	* dwarf2read.h (struct dwarf2_per_objfile) <all_comp_units>: Likewise.
	Make an std::vector.
	<n_comp_units>: Remove.
	* dwarf2read.c (dwarf2_per_objfile::~dwarf2_per_objfile): Adjust
	to std::vector change.
	(dwarf2_per_objfile::get_cutu): Likewise.
	(dwarf2_per_objfile::get_cu): Likewise.
	(create_cus_from_index): Likewise.
	(create_addrmap_from_index): Likewise.
	(create_addrmap_from_aranges): Likewise.
	(dwarf2_read_index): Likewise.
	(dw2_find_last_source_symtab): Likewise.
	(dw2_map_symtabs_matching_filename): Likewise.
	(dw2_symtab_iter_next): Likewise.
	(dw2_print_stats): Likewise.
	(dw2_expand_all_symtabs): Likewise.
	(dw2_expand_symtabs_with_fullname): Likewise.
	(dw2_expand_marked_cus): Likewise.
	(dw2_map_symbol_filenames): Likewise.
	(create_cus_from_debug_names): Likewise.
	(dwarf2_read_debug_names): Likewise.
	(dw2_debug_names_iterator::next): Likewise.
	(dwarf2_initialize_objfile): Likewise.
	(set_partial_user): Likewise.
	(dwarf2_build_psymtabs_hard): Likewise.
	(read_comp_units_from_section): Remove arguments, adjust to
	std::vector change.
	(create_all_comp_units): Adjust to std::vector and
	read_comp_units_from_section changes.
	(dwarf2_find_containing_comp_unit): Adjust to std::vector
	change.
	* dwarf-index-write.c (check_dwarf64_offsets): Likewise.
	(psyms_seen_size): Likewise.
	(write_gdbindex): Likewise.
	(write_debug_names): Likewise.
2018-04-07 13:53:43 -04:00
Simon Marchi ff4c9fec84 Replace dw2_get_cu/dw2_get_cutu with methods of dwarf2_per_objfile
Those two functions look like good candidates to become methods of
dwarf2_per_objfile.  I did that, and added get_tu as well.  When
replacing usages of dw2_get_cutu, I changed some instances to get_cutu
and others to get_cu, when appropriate (when we know we want a CU and
not a TU).

gdb/ChangeLog:

	* dwarf2read.h (struct signatured_type): Forward declare.
	(struct dwarf2_per_objfile) <get_cutu, get_cu, get_tu>:
	New methods.
	* dwarf2read.c (dwarf2_per_objfile::get_cutu): Rename from...
	(dw2_get_cutu): ...this.
	(dwarf2_per_objfile::get_cu): Rename from...
	(dw2_get_cu): ...this.
	(dwarf2_per_objfile::get_tu): New.
	(create_addrmap_from_index): Adjust.
	(create_addrmap_from_aranges): Adjust.
	(dw2_find_last_source_symtab): Adjust.
	(dw2_map_symtabs_matching_filename): Adjust.
	(dw2_symtab_iter_next): Adjust.
	(dw2_print_stats): Adjust.
	(dw2_expand_all_symtabs): Adjust.
	(dw2_expand_symtabs_with_fullname): Adjust.
	(dw2_expand_marked_cus): Adjust.
	(dw_expand_symtabs_matching_file_matcher): Adjust.
	(dw2_map_symbol_filenames): Adjust.
	(dw2_debug_names_iterator::next): Adjust.
	(dwarf2_initialize_objfile): Adjust.
	(set_partial_user): Adjust.
	(dwarf2_build_psymtabs_hard): Adjust.
2018-04-07 13:53:41 -04:00
Simon Marchi cd4fb1b2ff Move DWARF index-related things to a separate file
I want to add a DWARF index-related feature (automatically produce index
files when loading objfiles in GDB), but I don't want to add many
hundred lines to the already too big dwarf2read.c.  I thought it would
be a logical split to move everything related to the DWARF index to its
own file.

I first tried to move everything that reads and writes DWARF indices to
a separate file, but found that the "read" part is a little bit
entangled with the rest of dwarf2read.c, so the line is hard to draw
about where to split.  The write part is quite isolated though, so I
moved this part to a new file, dwarf-index-write.c.  Some things are
necessary to both reading and writing indices, so I placed them in
dwarf-index-common.{c,h}.  The idea would be to have a
dwarf-index-read.c eventually that would use it too (for now that code
is still in dwarf2read.c).

This required moving some things to a new dwarf2read.h header, so they
can be read by the code that writes the index.

The patch is big in number of lines, but it's all existing code being
moved around.  The only changes are that some functions are not static
anymore, a declaration is added in a .h file, and therefore the comment
is moved there.

I built-tested it with a little and big endian target.

This patch is also available on the users/simark/split-dwarf2read
branch.

gdb/ChangeLog:

	* Makefile.in (COMMON_SFILES): Add dwarf-index-common.c and
	dwarf-index-write.c
	(HFILES_NO_SRCDIR): Add dwarf-index-common.h and dwarf2read.h.
	* dwarf-index-common.c: New file.
	* dwarf-index-common.h: New file.
	* dwarf-index-write.c: New file.
	* dwarf2read.c: Include dwarf2read.h and dwarf-index-common.h.
	(struct dwarf2_section_info): Move from here.
	(dwarf2_section_info_def): Likewise.
	(DEF_VEC_O (dwarf2_section_info_def)): Likewise.
	(offset_type): Likewise.
	(DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE): Likewise.
	(DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE): Likewise.
	(DW2_GDB_INDEX_CU_SET_VALUE): Likewise.
	(byte_swap): Likewise.
	(MAYBE_SWAP): Likewise.
	(dwarf2_per_cu_ptr): Likewise.
	(DEF_VEC_P (dwarf2_per_cu_ptr)): Likewise.
	(struct tu_stats): Likewise.
	(struct dwarf2_per_objfile): Likewise.
	(struct dwarf2_per_cu_data): Likewise.
	(struct signatured_type): Likewise.
	(sig_type_ptr): Likewise.
	(DEF_VEC_P (sig_type_ptr)): Likewise.
	(INDEX4_SUFFIX): Likewise.
	(INDEX5_SUFFIX): Likewise.
	(DEBUG_STR_SUFFIX): Likewise.
	(dwarf2_read_section): Make non-static.
	(mapped_index_string_hash): Move from here.
	(dwarf5_djb_hash): Likewise.
	(file_write): Likewise.
	(class data_buf): Likewise.
	(struct symtab_index_entry): Likewise.
	(struct mapped_symtab): Likewise.
	(find_slot): Likewise.
	(hash_expand): Likewise.
	(add_index_entry): Likewise.
	(uniquify_cu_indices): Likewise.
	(class c_str_view): Likewise.
	(class c_str_view_hasher): Likewise.
	(class vector_hasher): Likewise.
	(write_hash_table): Likewise.
	(psym_index_map): Likewise.
	(struct addrmap_index_data): Likewise.
	(add_address_entry): Likewise.
	(add_address_entry_worker): Likewise.
	(write_address_map): Likewise.
	(symbol_kind): Likewise.
	(write_psymbols): Likewise.
	(struct signatured_type_index_data): Likewise.
	(write_one_signatured_type): Likewise.
	(recursively_count_psymbols): Likewise.
	(recursively_write_psymbols): Likewise.
	(class debug_names): Likewise.
	(check_dwarf64_offsets): Likewise.
	(psyms_seen_size): Likewise.
	(write_gdbindex): Likewise.
	(write_debug_names): Likewise.
	(assert_file_size): Likewise.
	(write_psymtabs_to_index): Likewise.
	(save_gdb_index_command): Likewise.
	(_initialize_dwarf2_read): Don't register the "save gdb-index"
	command.
	* dwarf2read.h: New file.
2018-03-27 10:07:47 -04:00