Compare commits

...

42 Commits

Author SHA1 Message Date
Tom Tromey
dd787f5e65 Share DWARF partial symtabs
This changes the DWARF reader to share partial symtabs (or indices if
they are available) across objfiles.  This has a few parts.

* If multiple objfiles backed by the same BFD can share partial symtabs
  (see below), a single dwarf2_per_bfd is created.  It is stored in the
  per-bfd `dwarf2_per_bfd_bfd_data_key` registry.  Multiple
  dwarf2_per_objfile objects will point to the same instance.  The
  lifetime of these dwarf2_per_bfd objects is naturally handled.  When
  all the objfiles using the BFD are destroyed, the BFD's refount drops
  to 0, which triggers the removal of the corresponding dwarf2_per_bfd
  object from the registry and its destruction.

* If multiple objfiles backed by the same BFD can't share partial
  symtabs (see below), one dwarf2_per_bfd object is created for each
  objfile.  Each dwarf2_per_objfile will point to their own instance of
  dwarf2_per_bfd.  These instances of dwarf2_per_bfd are kept in a
  per-objfile registry, meaning that when the objfile gets destroyed,
  the dwarf2_per_bfd instance gets destroyed as well.

* objfile::partial_symtabs is changed to be a shared_ptr again.  This
  lets us stash a second reference in dwarf2_per_bfd; if the DWARF
  data is being shared, we can simply copy this value to the new
  objfile.

* Two dwarf2_per_objfile objects backed by the same BFD may share a
  dwarf2_per_bfd instance if:

  * No other symbol reader has found symbols, and
  * No BFD section rqeuires relocation

YYYY-MM-DD  Tom Tromey  <tom@tromey.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

	* objfiles.h (struct objfile) <partial_symtabs>: Now a
	shared_ptr.
	* dwarf2/read.h (struct dwarf2_per_objfile) <partial_symtabs>: New
	member.
	* dwarf2/read.c (dwarf2_per_bfd_bfd_data_key,
	dwarf2_per_bfd_objfile_data_key>: New globals.
	(dwarf2_has_info): Use shared dwarf2_per_bfd if possible.
	(dwarf2_get_section_info): Use get_dwarf2_per_objfile.
	(dwarf2_initialize_objfile): Consider cases where per_bfd can be
	shared.
	(dwarf2_build_psymtabs): Set objfile::partial_symtabs and
	short-circuit when sharing.
	(dwarf2_build_psymtabs): Set dwarf2_per_objfile::partial_symtabs.
	(dwarf2_psymtab::expand_psymtab): Use free_cached_comp_units.
2020-05-12 15:24:51 -04:00
Simon Marchi
fb113f4f48 Make mapped_debug_names independent of objfile
mapped_debug_names currently has a dwarf2_per_objfile field.  Since we
want it to become objfile-independent, this field must be removed.

This patch removes it, and then arranges for all methods that needed it
to accept a dwarf2_per_objfile parameter.  This trickles down at various
places, like the dw2_debug_names_iterator type.

Ultimately, the objfile only seems to be needed because we might need to
read a string from the string section.  For that, we might need to read
in the section, and if it's a relocatable section, the objfile is needed
in order to do the relocation.  This pattern happens often (that we to
pass an objfile only because a section might be read).  I think it's a
bit ugly, but I don't have a good alternative right now.

gdb/ChangeLog:

	* dwarf2/read.c (struct mapped_index_base) <symbol_name_at,
	build_name_components, find_name_components_bounds>:
	Add per_objfile parameter.
	(struct mapped_index) <symbol_name_at>: Likewise.
	(struct mapped_debug_names): Remove constructor.
	<dwarf2_per_objfile>: Remove field.
	<namei_to_name, symbol_name_at>: Add per_objfile parameter.
	(mapped_index_base::find_name_components_bounds,
	mapped_index_base::build_name_components,
	dw2_expand_symtabs_matching_symbol): Likewise.
	(class mock_mapped_index) <symbol_name_at>: Likewise.
	(check_match): Likewise.
	(check_find_bounds_finds): Likewise.
	(test_mapped_index_find_name_component_bounds): Update.
	(CHECK_MATCH): Update.
	(dw2_expand_symtabs_matching): Update.
	(class dw2_debug_names_iterator) <dw2_debug_names_iterator>: Add
	per_objfile parameter.
	<find_vec_in_debug_names>: Likewise.
	<m_per_objfile>: New field.
	(mapped_debug_names::namei_to_name): Add dwarf2_per_objfile
	parameter.
	(dw2_debug_names_iterator::find_vec_in_debug_names): Likewise.
	(dw2_debug_names_iterator::next): Update.
	(dw2_debug_names_lookup_symbol): Update.
	(dw2_debug_names_expand_symtabs_for_function): Update.
	(dw2_debug_names_map_matching_symbols): Update.
	(dw2_debug_names_expand_symtabs_matching): Update.
	(dwarf2_read_debug_names): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
5b75b03006 Replace dwarf2_per_cu_data::cu backlink with per-objfile map
The dwarf2_per_cu_data type is going to become objfile-independent,
while the dwarf2_cu type will stay object-dependent.  This patch removes
the backlink from dwarf2_per_cu_data to dwarf2_cu, in favor of the
dwarf2_per_objfile::m_dwarf2_cus map.  It maps dwarf2_per_cu_data
objects to the corresponding dwarf2_cu objects for this objfile.  If a
CU has been read in in the context of this objfile, then an entry will
be present in the map.

The dwarf2_cu objects that are read in are currently kept in a linked
list rooted in the dwarf2_per_bfd.  Except that the dwarf2_cu objects
are not simply linked together, they are interleaved with their
corresponding dwarf2_per_cu_data objects.  So if we have CUs A and B
read in, the dwarf2_per_bfd::read_in_chain will point to a chain like
this (DPCD == dwarf2_per_cu_data, DC == dwarf2_cu):

 DPCD A -> DC A -> DPCD B -> DC B

Obviously, this can't stay as is, since a same CU can be read in for an
objfile but not read in for another objfile sharing the same BFD, and
the dwarf2_per_cu_data::cu link is removed.   This is all replaced by
the dwarf2_per_objfile::m_dwarf2_cus map.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_cu): Forward-declare.
	(struct dwarf2_per_bfd) <free_cached_comp_units>: Remove,
	move to dwarf2_per_objfile.
	<read_in_chain>: Remove.
	(struct dwarf2_per_objfile) <get_cu, set_cu, remove_cu,
	remove_all_cus, age_comp_units>: New methods.
	<m_dwarf2_cus>: New member.
	(struct dwarf2_per_cu_data) <cu>: Remove.
	* dwarf2/read.c (struct dwarf2_cu) <read_in_chain>: Remove.
	(age_cached_comp_units, free_one_cached_comp_unit): Remove,
	moved to methods of dwarf2_per_objfile.
	(dwarf2_clear_marks): Remove.
	(dwarf2_queue_item::~dwarf2_queue_item): Update.
	(dwarf2_per_bfd::~dwarf2_per_bfd): Don't free dwarf2_cus.
	(dwarf2_per_bfd::free_cached_comp_units): Remove.
	(dwarf2_per_objfile::remove_all_cus): New.
	(class free_cached_comp_units) <~free_cached_comp_units>:
	Update.
	(load_cu): Update.
	(dw2_do_instantiate_symtab): Adjust.
	(fill_in_sig_entry_from_dwo_entry): Adjust.
	(cutu_reader::init_tu_and_read_dwo_dies): Update.
	(cutu_reader::cutu_reader): Likewise.
	(cutu_reader::keep): Use dwarf2_per_objfile::set_cu.
	(cutu_reader::cutu_reader): Use dwarf2_per_objfile::get_cu.
	(process_psymtab_comp_unit): Use dwarf2_per_objfile::remove_cu
	and dwarf2_per_objfile::age_comp_units.
	(load_partial_comp_unit): Update.
	(maybe_queue_comp_unit): Use dwarf2_per_objfile::get_cu.
	(process_queue): Likewise.
	(find_partial_die): Use dwarf2_per_objfile::get_cu instead of cu
	backlink.
	(dwarf2_read_addr_index): Likewise.
	(follow_die_offset): Likewise.
	(dwarf2_fetch_die_loc_sect_off): Likewise.
	(dwarf2_fetch_constant_bytes): Likewise.
	(dwarf2_fetch_die_type_sect_off): Likewise.
	(follow_die_sig_1): Likewise.
	(load_full_type_unit): Likewise.
	(read_signatured_type): Likewise.
	(dwarf2_cu::dwarf2_cu): Don't set cu field.
	(dwarf2_cu::~dwarf2_cu): Remove.
	(dwarf2_per_objfile::get_cu): New.
	(dwarf2_per_objfile::set_cu): New.
	(age_cached_comp_units): Rename to...
	(dwarf2_per_objfile::age_comp_units): ... this.  Adjust
	to std::unordered_map.
	(free_one_cached_comp_unit): Rename to...
	(dwarf2_per_objfile::remove_cu): ... this.  Adjust
	to std::unordered_map.
	(dwarf2_per_objfile::~dwarf2_per_objfile): New.
	(dwarf2_mark_helper): Use dwarf2_per_objfile::get_cu, expect
	a dwarf2_per_objfile in data.
	(dwarf2_mark): Pass dwarf2_per_objfile in data to htab_traverse.
	(dwarf2_clear_marks): Remove.
2020-05-12 15:24:51 -04:00
Simon Marchi
bd6776c1f7 Pass existing_cu object to cutu_reader
It is possible, seemingly for a special case described in
find_partial_die, for cutu_reader to re-use an existing dwarf2_cu
instead of creating a new one.  This happens
2020-05-12 15:24:51 -04:00
Simon Marchi
d8ec15198c Add comp_unit_head to dwarf2_per_cu_data
The per_cu_header_read_in function allows obtaining a filled
comp_unit_head object for a given dwarf2_per_cu_data object.  If a
dwarf2_cu object exists for this dwarf2_per_cu_data, then it just
returns a pointer to the comp_unit_head from that dwarf2_cu.  Otherwise,
it reads the header into a temporary buffer provided by the caller, and
returns a pointer to that.

Since the dwarf2_per_cu_data::cu link is going to be removed
(dwarf2_per_cu_data will become objfile-independent while dwarf2_cu
stays objfile-dependent), we cannot rely anymore on returning the header
from the dwarf2_cu object.

The not too complex solution implemented by this patch is to keep a copy
of the header in the dwarf2_per_cu_data object, independent from the
copy in dwarf2_cu.  The new copy is only used in the addr_size,
offset_size and ref_addr_size methods of dwarf2_per_cu_data.

There's nothing intrinsic to the comp_unit_head object that prevents it
to be shared between two dwarf2_cu objects (belonging to different
objfiles) representing the same CU.  In other words, I think we could
eventually get rid of the copy in dwarf2_cu to only keep the one in
dwarf2_per_cu_data.  It is not trivial, however, so I have decided not
to do it for the moment.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_cu_data) <m_header,
	m_header_read_in>: New fields.
	<get_header>: New method.
	* dwarf2/read.c (per_cu_header_read_in): Remove.
	(dwarf2_per_cu_data::get_header): New.
	(dwarf2_per_cu_data::addr_size): Update.
	(dwarf2_per_cu_data::offset_size): Update.
	(dwarf2_per_cu_data::ref_addr_size): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
7d58fe1431 Make load_cu return the loaded dwarf2_cu
In a subsequent patch, the dwarf2_per_cu_data::cu link will be removed.
dwarf2_cu objects will instead need to be looked up from a per-objfile
map, using the dwarf2_per_cu_data object as the key.

To make it easier for some callers, this patch makes load_cu return the
dwarf2_cu it creates.  If the caller needs to use the created dwarf2_cu,
it will have it available right away, rather than having to do a map
lookup.

At the same time, this allows changing queue_and_load_all_dwo_tus to
take a dwarf2_cu instead of a dwarf2_per_cu_data.

gdb/ChangeLog:

	* dwarf2/read.c (load_cu): Return dwarf2_cu.
	(dw2_do_instantiate_symtab): Update.
	(queue_and_load_all_dwo_tus): Change parameter from
	dwarf2_per_cu_data to dwarf2_cu.
	(dwarf2_fetch_die_loc_sect_off): Update.
	(dwarf2_fetch_constant_bytes): Update.
	(dwarf2_fetch_die_type_sect_off): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
a3ddd1a46c Pass dwarf2_cu to process_full_{comp,type}_unit
These two functions work on a dwarf2_cu.  It is currently obtained from
the per_cu->cu link, which we want to remove.  Make them accept the
dwarf2_cu directly as a parameter.  This moves the per_cu->cu references
one level up, but that one will be removed too in a subsequent patch.

gdb/ChangeLog:

	* dwarf2/read.c (process_full_comp_unit,
	process_full_type_unit): Remove per_cu, per_objfile paramters.
	Add dwarf2_cu parameter.
	(process_queue): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
d4b0ea1629 Pass dwarf2_per_bfd instead of dwarf2_per_objfile to some index-related functions
All these functions actually only need to receive a dwarf2_per_bfd, pass
that instead of dwarf2_per_objfile.

gdb/ChangeLog:

	* dwarf2/read.c (create_cu_from_index_list): Replace
	dwarf2_per_objfile parameter with dwarf2_per_bfd.
	(create_cus_from_index_list): Likewise.
	(create_cus_from_index): Likewise.
	(create_signatured_type_table_from_index): Likewise.
	(create_cus_from_debug_names_list): Likewise.
	(create_cus_from_debug_names): Likewise.
	(dwarf2_read_gdb_index): Update.
	(dwarf2_read_debug_names): Update.
2020-05-12 15:24:51 -04:00
Tom Tromey
f4a3bd8117 Move signatured_type::type to unshareable object
signatured_type has a link to the "struct type".  However, types are
inherently objfile-specific, so once sharing is implemented, this will
be incorrect.

This patch moves the type to a new map in the DWARF unshareable
object.

YYYY-MM-DD  Tom Tromey  <tom@tromey.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

	* dwarf2/read.h (struct dwarf2_per_objfile)
	<get_type_for_signatured_type, set_type_for_signatured_type>:
	New methods.
	<m_type_map>: New member.
	(struct signatured_type) <type>: Remove.
	* dwarf2/read.c
	(dwarf2_per_objfile::get_type_for_signatured_type,
	dwarf2_per_objfile::set_type_for_signatured_type): New.
	(get_signatured_type): Use new methods.
2020-05-12 15:24:51 -04:00
Tom Tromey
5b9cfc4c6d Split type_unit_group
type_unit_group has links to the compunit_symtab and other symtabs.
However, once this object is shared across objfiles, this will no
longer be ok.

This patch introduces a new type_unit_group_unshareable and arranges to
store a map from type unit groups to type_unit_group_unshareable objects
in dwarf2_per_objfile.

YYYY-MM-DD  Tom Tromey  <tom@tromey.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

	* dwarf2/read.h (struct type_unit_group_unshareable): New.
	(struct dwarf2_per_objfile) <type_units>: New member.
	<get_type_unit_group_unshareable>: New method.
	* dwarf2/read.c (struct type_unit_group) <compunit_symtab,
	num_symtabs, symtabs>: Remove; move to
	type_unit_group_unshareable.
	(dwarf2_per_objfile::get_type_unit_group_unshareable): New.
	(process_full_type_unit, dwarf2_cu::setup_type_unit_groups)
	(dwarf2_cu::setup_type_unit_groups): Use type_unit_group_unshareable.
2020-05-12 15:24:51 -04:00
Simon Marchi
a35610c98b Remove dwarf2_per_cu_data::dwarf2_per_objfile
Nothing references this field anymore, remove it.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_cu_data):
	<dwarf2_per_objfile>: Remove.
	* dwarf2/read.c (create_cu_from_index_list): Don't assign
	dwarf2_per_objfile.
	(create_signatured_type_table_from_index): Likewise.
	(create_signatured_type_table_from_debug_names): Likewise.
	(create_debug_type_hash_table): Likewise.
	(fill_in_sig_entry_from_dwo_entry): Likewise.
	(create_type_unit_group): Likewise.
	(read_comp_units_from_section): Likewise.
	(create_cus_hash_table): Likewise.
2020-05-12 15:24:51 -04:00
Simon Marchi
df7a679852 Remove leftover references to dwarf2_per_cu_data::dwarf2_per_objfile
This patch removes the remaining references to that field in obvious
ways (the same object is already available some other way in these
contexts).

gdb/ChangeLog:

	* dwarf2/read.c (process_psymtab_comp_unit): Remove reference to
	dwarf2_per_cu_data::dwarf2_per_objfile.
	(compute_compunit_symtab_includes): Likewise.
	(dwarf2_cu::start_symtab): Likewise.
2020-05-12 15:24:51 -04:00
Simon Marchi
2a651b1f4a Add dwarf2_per_objfile parameter to get_die_type_at_offset
This allows removing some dwarf2_per_cu_data::dwarf2_per_objfile
references.

gdb/ChangeLog:

	* dwarf2/read.h (dwarf2_get_die_type): Add dwarf2_per_objfile
	parameter.
	* dwarf2/read.c (get_die_type_at_offset): Likewise.
	(read_namespace_alias): Update.
	(lookup_die_type): Update.
	(dwarf2_get_die_type): Add dwarf2_per_objfile parameter.
	* dwarf2/loc.c (class dwarf_evaluate_loc_desc) <get_base_type>:
	Update.
	(disassemble_dwarf_expression): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
bd3914c780 Add dwarf2_per_objfile parameter to free_one_cached_comp_unit
This allows removing some references to
dwarf2_per_cu_data::dwarf2_per_objfile.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_queue_item): Add
	dwarf2_per_objfile parameter, assign new parameter.
	<per_objfile>: New field.
	* dwarf2/read.c (free_one_cached_comp_unit): Add
	dwarf2_per_objfile parameter.
	(queue_comp_unit): Likewise.
	(dw2_do_instantiate_symtab): Update.
	(process_psymtab_comp_unit): Update.
	(maybe_queue_comp_unit): Add dwarf2_per_objfile parameter.
	(process_imported_unit_die): Update.
	(queue_and_load_dwo_tu): Update.
	(follow_die_offset): Update.
	(follow_die_sig_1): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
c8b42195c2 Remove dwarf2_per_cu_data::objfile ()
Since dwarf2_per_cu_data objects are going to become
objfile-independent, the backlink from dwarf2_per_cu_data to one
particular objfile must be removed.  Instead, users of
dwarf2_per_cu_data that need an objfile must know from somewhere else in
the context of which objfile they are using this CU.

This also helps remove a dwarf2_per_cu_data::dwarf2_per_objfile
reference (from where the objfile was obtained).

Note that the dwarf2_per_cu_data::objfile method has a special case to
make sure to return the main objfile, if the objfile associated to the
dwarf2_per_cu_data is a separate debug objfile.  I don't really know if
this is necessary: I ignored that, and didn't see any regression when
testing with the various Dejagnu boards with separate debug info, so I
presume it wasn't needed.  If it turns out this was needed, then we can
have a helper method on the objfile type for that.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_cu_data) <objfile>: Remove.
	* dwarf2/read.c (dwarf2_compute_name): Pass per_objfile down.
	(read_call_site_scope): Assign per_objfile.
	(dwarf2_per_cu_data::objfile): Remove.
	* gdbtypes.h (struct call_site) <per_objfile>: New member.
	* dwarf2/loc.h (dwarf2_evaluate_loc_desc): Add
	dwarf2_per_objfile parameter.
	* dwarf2/loc.c (dwarf2_evaluate_loc_desc_full): Add
	dwarf2_per_objfile parameter.
	(dwarf_expr_reg_to_entry_parameter): Add output
	dwarf2_per_objfile parameter.
	(locexpr_get_frame_base): Update.
	(class dwarf_evaluate_loc_desc) <get_tls_address>: Update.
	<push_dwarf_reg_entry_value>: Update.
	<call_site_to_target_addr>: Update.
	(dwarf_entry_parameter_to_value): Add dwarf2_per_objfile
	parameter.
	(value_of_dwarf_reg_entry): Update.
	(rw_pieced_value): Update.
	(indirect_synthetic_pointer): Update.
	(dwarf2_evaluate_property): Update.
	(dwarf2_loc_desc_get_symbol_read_needs): Add dwarf2_per_objfile
	parameter.
	(locexpr_read_variable): Update.
	(locexpr_get_symbol_read_needs): Update.
	(loclist_read_variable): Update.
2020-05-12 15:24:51 -04:00
Simon Marchi
2a2b2a782d Add dwarf2_per_objfile parameters to dwarf2_fetch_* functions
This allows removing dwarf2_per_cu_data references.

gdb/ChangeLog:

	* dwarf2/read.h (dwarf2_fetch_die_loc_sect_off,
	dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes,
	dwarf2_fetch_die_type_sect_off): Add dwarf2_per_objfile
	parameter.
	* dwarf2/read.c (dwarf2_fetch_die_loc_sect_off,
	dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes,
	dwarf2_fetch_die_type_sect_off): Add dwarf2_per_objfile
	parameter.
	* dwarf2/loc.c (indirect_synthetic_pointer, per_cu_dwarf_call,
	sect_variable_value): Add dwarf2_per_objfile parameter.
	(class dwarf_evaluate_loc_desc) <dwarf_call,
	dwarf_variable_value>: Update.
	(fetch_const_value_from_synthetic_pointer): Add
	dwarf2_per_objfile parameter.
	(fetch_const_value_from_synthetic_pointer): Update.
	(coerced_pieced_ref): Update.
	(class symbol_needs_eval_context) <dwarf_call,
	dwarf_variable_value>: Update.
	(dwarf2_compile_expr_to_ax): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
caca6f5b4e Add dwarf2_per_objfile parameter to allocate_piece_closure
This allows removing a dwarf2_per_cu_data::dwarf2_per_objfile reference.

gdb/ChangeLog:

	* dwarf2/loc.c (allocate_piece_closure): Add dwarf2_per_objfile
	parameter.
	(dwarf2_evaluate_loc_desc_full): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
7b9424e488 Add dwarf2_per_objfile parameter to dwarf2_read_addr_index
Pass it all the way from the symbol batons.  This allows removing a
dwarf2_per_cu_data::dwarf2_per_objfile reference.

gdb/ChangeLog:

	* dwarf2/read.h (dwarf2_read_addr_index): Add dwarf2_per_objfile
	parameter.
	* dwarf2/read.c (dwarf2_read_addr_index): Likewise.
	* dwarf2/loc.c (decode_debug_loclists_addresses): Add
	dwarf2_per_objfile parameter.
	(decode_debug_loc_dwo_addresses): Likewise.
	(dwarf2_find_location_expression): Update.
	(class dwarf_evaluate_loc_desc) <get_addr_index>: Update.
	(locexpr_describe_location_piece): Add dwarf2_per_objfile
	parameter.
	(disassemble_dwarf_expression): Add dwarf2_per_objfile
	parameter.
	(locexpr_describe_location_1): Likewise.
	(locexpr_describe_location): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
a2ffabb61b Remove dwarf2_per_cu_data::text_offset
This method simply returns the text offset of the objfile associated to
the dwarf2_per_cu_data object.  Since dwarf2_per_cu_data objects are
going to become objfile-independent, we can't keep this method.  This
patch removes it.

Existing callers need to figure out the in the context of which objfile
this is being used, and call text_offset on it.  Typically, this comes
from a symbol baton, where we store the corresponding
dwarf2_per_objfile.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_cu_data) <text_offset>:
	Remove.
	* dwarf2/read.c (dwarf2_per_cu_data::text_offset): Remove.
	* dwarf2/loc.c (dwarf2_find_location_expression): Update.
	(dwarf2_compile_property_to_c): Update.
	(dwarf2_compile_expr_to_ax): Add dwarf2_per_objfile parameter,
	use text offset from objfile.
	(locexpr_tracepoint_var_ref): Update.
	(locexpr_generate_c_location): Update.
	(loclist_describe_location): Update.
	(loclist_tracepoint_var_ref): Update.
	* dwarf2/compile.h (compile_dwarf_bounds_to_c): Add
	dwarf2_per_objfile parameter.
	* dwarf2/loc2c.c (do_compile_dwarf_expr_to_c): Likewise,
	use text offset from objfile.
	(compile_dwarf_expr_to_c): Add dwarf2_per_objfile parameter.
2020-05-12 15:24:50 -04:00
Simon Marchi
a03eab7536 Add dwarf2_per_objfile to dwarf_expr_context and dwarf2_frame_cache
Evaluating DWARF expressions (such as location expressions) requires
knowing about the current objfile.  For example, it may call functions
like dwarf2_fetch_die_loc_sect_off, which currently obtain the
dwarf2_per_objfile object it needs from the dwarf2_per_cu_data object.
However, since we are going to remove this
dwarf2_per_cu_data::dwarf2_per_objfile link, these functions will need
to obtain the current dwarf2_per_objfile by parmeter.

If we go up the stack, we see that the DWARF expression contexts
(dwarf_expr_context and the classes that derive from it) need to store
the dwarf2_per_objfile, to be able to pass it to those functions that
will need it.

This patch adds a constructor to all these dwarf_expr_context variants,
accepting a dwarf2_per_objfile parameter.  This dwarf2_per_objfile
generally comes from a symbol baton created earlier.

For frame-related expressions, the dwarf2_per_objfile object must be
passed through the dwarf2_frame_cache object.  This lead to the
dwarf2_frame_find_fde function returning (by parameter) a
dwarf2_per_objfile object.  I then realized that this made the existing
"out_offset" parameter redundant.  This offset is
`objfile->text_section_offset ()`, so it can be recomputed from the
dwarf2_per_objfile object at any time.  I therefore opted to remove this
output parameter, as well as the offset field of dwarf2_frame_cache.

*Note*, there's one spot I'm particularly unsure about.  In
dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value, we would save and
overwrite the offset value in the context, along with a bunch of other
state.  This is because we might be about to evaluate something in a
different CU that the current one.  If the two CUs are in the same
objfile, then the text_offset is the same, as it's a property of the
objfile.  However, if the two CUs are possibly in different objfiles,
then it means the text_offsets are different.  It would also mean we
would need to save and restore the dwarf2_per_objfile in the context.
Is that even possible?

gdb/ChangeLog:

	* dwarf2/expr.h (struct dwarf_expr_context)
	<dwarf_expr_context>: Add dwarf2_per_objfile parameter.
	<offset>: Remove.
	<per_objfile>: New member.
	* dwarf2/expr.c (dwarf_expr_context::dwarf_expr_context): Add
	dwarf2_per_objfile parameter.  Don't set offset, set
	per_objfile.
	(dwarf_expr_context::execute_stack_op): Use offset from objfile.
	* dwarf2/frame.c (dwarf2_frame_find_fde): Return (by parameter)
	a dwarf2_per_objfile object instead of an offset.
	(class dwarf_expr_executor) <dwarf_expr_executor>: Add
	constructor.
	(execute_stack_op): Add dwarf2_per_objfile parameter, pass it
	to dwarf2_expr_executor constructor.  Don't set offset.
	(dwarf2_fetch_cfa_info): Update.
	(struct dwarf2_frame_cache) <text_offset>: Remove.
	<per_objfile>: New field.
	(dwarf2_frame_cache): Update.
	(dwarf2_frame_prev_register): Update.
	* dwarf2/loc.c (class dwarf_evaluate_loc_desc)
	<dwarf_evaluate_loc_desc>: Add constructor.
	(dwarf2_evaluate_loc_desc_full): Update.
	(dwarf2_locexpr_baton_eval): Update.
	(class symbol_needs_eval_context) <symbol_needs_eval_context>:
	Add constructor.
	(dwarf2_loc_desc_get_symbol_read_needs): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
d2634098f3 Move int type methods out of dwarf2_per_cu_data
These methods rely on the current objfile to create types based on it.
Since dwarf2_per_cu_data is to become objfile-independent, these methods
need to mvoe.

int_type can be in dwarf2_per_objfile, as it only requires knowing about
the objfile.

addr_sized_int_type and addr_type also need to know about the DWARF
address type size, which is CU-specific.  The dwarf2_cu objects seems
like a good place for it, as it knows both about the current objfile and
the current CU.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_cu_data) <addr_type,
	addr_sized_int_type>: Move to dwarf2_cu.
	<int_type>: Move to dwarf2_per_objfile.
	(struct dwarf2_per_objfile) <int_type>: Move here.
	* dwarf2/read.c (struct dwarf2_cu) <addr_type,
	addr_sized_int_type>: Move here.
	(read_func_scope): Update.
	(read_array_type): Update.
	(read_tag_string_type): Update.
	(attr_to_dynamic_prop): Update.
	(dwarf2_per_cu_data::int_type): Rename to...
	(dwarf2_per_objfile::int_type): ... this.
	(dwarf2_per_cu_data::addr_sized_int_type): Rename to...
	(dwarf2_cu::addr_sized_int_type): ... this.
	(read_subrange_type): Update.
	(dwarf2_per_cu_data::addr_type): Rename to...
	(dwarf2_cu::addr_type): ... this.
	(set_die_type): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
30677c82cd Remove reference to dwarf2_per_cu_data::dwarf2_per_objfile in queue_and_load_all_dwo_tus
In this context, we know that per_cu->cu will be set, as there is this
assertion:

    gdb_assert (per_cu->cu != NULL)

So in order to remove the dwarf2_per_cu_data::dwarf2_per_objfile
reference in queue_and_load_all_dwo_tus, we can go through per_cu->cu.
This adds a reference to dwarf2_per_cu_data::cu, but it will get removed
eventually, in a subsequent patch.

gdb/ChangeLog:

	* dwarf2/read.c (queue_and_load_all_dwo_tus): Access per_objfile
	data through per_cu->cu.
2020-05-12 15:24:50 -04:00
Simon Marchi
9e575d411d Pass dwarf2_cu objects to dwo-related functions, instead of dwarf2_per_cu_data
This allows removing references to the
dwarf2_per_cu_data::dwarf2_per_objfile field.

I am not too sure of the code flow here, but ultimately
open_and_init_dwo_file calls create_cus_hash_table, and passes it
per_cu->cu.  create_cus_hash_table requires a dwarf2_cu to pass to
cutu_reader, as the "parent_cu".

The dwarf2_per_cu_data::cu link is only set when in a certain context.
It's not easy to convince myself in which situations it's safe to use
it.  Instead, if a function is going to use a dwarf2_cu, I think it's
simpler if it takes that object directly.  If it needs access to the
corresponding dwarf2_per_cu_data object, then it can used the
dwarf2_cu::per_cu field, which we know is always set.

This patch adds some references to dwarf2_per_cu_data::cu in the
cutu_reader context.  In this context, we know this field will be set,
as it's cutu_reader that is responsible for instantiating the dwarf2_cu
and assigning the field.

gdb/ChangeLog:

	* dwarf2/read.c (lookup_dwo_comp_unit): Change
	dwarf2_per_cu_data parameter fo dwarf2_cu.
	(lookup_dwo_type_unit): Likewise.
	(read_cutu_die_from_dwo): Likewise.
	(lookup_dwo_unit): Likewise.
	(open_and_init_dwo_file): Likewise.
	(lookup_dwo_cutu): Likewise.
	(lookup_dwo_comp_unit): Likewise.
	(lookup_dwo_type_unit): Likewise.
	(cutu_reader::init_tu_and_read_dwo_dies): Update.
	(cutu_reader::cutu_reader): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
e734976f6c Add dwarf2_per_objfile parameter to process_full_{comp,type}_unit
This allows removing the dwarf2_per_cu_data::dwarf2_per_objfile
references in them.

gdb/ChangeLog:

	* dwarf2/read.c (process_full_comp_unit): Add dwarf2_per_objfile
	parameter.
	(process_full_type_unit): Likewise.
	(process_queue): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
6174efd6a4 Add dwarf2_per_objfile parameter to recursively_compute_inclusions
This allows removing dwarf2_per_cu_data::dwarf2_per_objfile references
in recursively_compute_inclusions and compute_compunit_symtab_includes.

gdb/ChangeLog:

	* dwarf2/read.c (recursively_compute_inclusions): Add
	dwarf2_per_objfile parameter.
	(compute_compunit_symtab_includes): Likewise.
	(process_cu_includes): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
d4ea1c4e01 Add dwarf2_per_objfile parameter to create_partial_symtab
This allows removing a dwarf2_per_cu_data::dwarf2_per_objfile reference.

gdb/ChangeLog:

	* dwarf2/read.c (create_partial_symtab): Add dwarf2_per_objfile
	parameter.
	(create_type_unit_group): Update.
	(process_psymtab_comp_unit_reader): Update.
	(build_type_psymtabs_reader): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
68a44194a5 Remove dwarf2_per_cu_data::dwarf2_per_objfile reference in cutu_reader::keep
Here, it should be safe to use dwarf2_per_cu_data->cu->per_objfile, as
we know that dwarf2_per_cu_data->cu will be set at this point.

Note that this adds a reference to dwarf2_per_cu_data::cu, which we'll
want to remove later, but the current focus is to remove references to
dwarf2_per_cu_data::dwarf2_per_objfile.  We'll deal with that in a
subsequent patch.

gdb/ChangeLog:

	* dwarf2/read.c (cutu_reader::keep): Access dwarf2_per_objfile
	object through m_this_cu->cu.
2020-05-12 15:24:50 -04:00
Simon Marchi
4132873d03 Make queue_and_load_dwo_tu receive a dwarf2_cu
queue_and_load_dwo_tu, used as a callback for htab_traverse_noresize,
currently receives a dwarf2_per_cu_data as its `info` user data.  It
accesses the current dwarf2_cu object through the dwarf2_per_cu_data::cu field.
This field will be removed, because the dwarf2_per_cu_data will become
objfile-independent, while dwarf_cu will remain objfile-dependent.

To remove references to this field, change queue_and_load_dwo_tu so
that it expects to receive a pointer to the dwarf2_cu as its info
parameter.

A reference to dwarf2_per_cu_data::cu needs to be added, but it will get
removed in a subsequent patch, when this function gets re-worked.

I kept this as a separate patch, because since there's no strong typing
here, it's easy to miss something.

gdb/ChangeLog:

	* dwarf2/read.c (queue_and_load_dwo_tu): Expect a dwarf2_cu as
	the info parameter.
	(queue_and_load_all_dwo_tus): Pass per_cu->cu.
2020-05-12 15:24:50 -04:00
Simon Marchi
9fb9ca853d Add dwarf2_per_objfile parameter to cutu_reader's constructors
The cutu_reader type is used for reading the CU represented by the
passed dwarf2_per_cu_data object.  This reading is done in the context
of a given obfile, which is currently the one associated to the passed
dwarf2_per_cu_data object.  Since the dwarf2_per_cu_data type will
become objfile-independent, we will need to pass the objfile separately.

This patch therefore adds a dwarf2_per_objfile parameter to the
cutu_reader constructors, as well as to their callers, up until the
point where we can get the dwarf2_per_objfile object from somewhere
else.  In the end, this allows removing the reference to
dwarf2_per_cu_data::dwarf2_per_objfile in cutu_reader::cutu_reader.

A few dwarf2_per_cu_data::dwarf2_per_objfile references are added (e.g.
in dwarf2_fetch_die_type_sect_off).  This is temporary, this will be
removed once these functions will get re-worked in subsequent patches.

gdb/ChangeLog:

	* dwarf2/read.c (class cutu_reader) <cutu_reader>: Add
	per_objfile parameter.
	(load_full_type_unit): Add per_objfile parameter.
	(read_signatured_type): Likewise.
	(load_full_comp_unit): Likewise.
	(load_cu): Likewise.
	(dw2_do_instantiate_symtab): Likewise.
	(dw2_get_file_names): Likewise.
	(dw2_map_symtabs_matching_filename): Update.
	(dw_expand_symtabs_matching_file_matcher): Update.
	(dw2_map_symbol_filenames): Update.
	(process_psymtab_comp_unit): Add per_objfile parameter.
	(build_type_psymtabs_1): Update.
	(process_skeletonless_type_unit): Update.
	(dwarf2_build_psymtabs_hard): Update.
	(load_partial_comp_unit): Add per_objfile parameter.
	(scan_partial_symbols): Update.
	(load_full_comp_unit): Add per_objfile parameter.
	(process_imported_unit_die): Update.
	(create_cus_hash_table): Update.
	(find_partial_die): Update.
	(dwarf2_read_addr_index): Update.
	(follow_die_offset): Update.
	(dwarf2_fetch_die_loc_sect_off): Update.
	(dwarf2_fetch_constant_bytes): Update.
	(dwarf2_fetch_die_type_sect_off): Update.
	(follow_die_sig_1): Update.
	(load_full_type_unit): Add per_objfile parameter.
	(read_signatured_type): Likewise.
2020-05-12 15:24:50 -04:00
Simon Marchi
bf1c1db5b2 Use bfd_get_filename instead of objfile_name in lookup_dwo_unit
There should be no functional difference, as objfile_name defers to
bfd_get_filename if objfile::obfd is non-NULL, which should be the case
here.  This allows to remove a reference to
dwarf2_per_cu_data::dwarf2_per_objfile.

gdb/ChangeLog:

	* dwarf2/read.c (lookup_dwo_unit): Use bfd_get_filename instead
	of objfile_name.
2020-05-12 15:24:50 -04:00
Simon Marchi
1d2852ed0a Make dwarf2_get_dwz_file take a dwarf2_per_bfd
This allows removing a per_bfd->dwarf2_per_objfile reference in
get_abbrev_section_for_cu.

This requires saving the bfd in dwarf2_per_bfd.  The constructor of
dwarf2_per_bfd already accepts the bfd, so it's just a matter of saving
it in a field.

I replaced uses of objfile_name with bfd_get_filename, which should be
equivalent in this case.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_bfd) <obfd>: New member.
	(dwarf2_get_dwz_file): Replace parameter with dwarf2_per_bfd.
	* dwarf2/read.c (dwarf2_per_bfd::dwarf2_per_bfd): Assign obfd
	field.
	(dwarf2_get_dwz_file): Replace parameter with dwarf2_per_bfd.
	(create_cus_from_index): Update.
	(dwarf2_read_gdb_index): Update.
	(create_cus_from_debug_names): Update.
	(dwarf2_read_debug_names): Update.
	(get_abbrev_section_for_cu): Update.
	(create_all_comp_units): Update.
	(read_attribute_value): Update.
	(get_debug_line_section): Update.
	* dwarf2/index-cache.c (index_cache::store): Update.
	* dwarf2/index-write.c (save_gdb_index_command): Update.
	* dwarf2/macro.c (dwarf_decode_macro_bytes): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
89b41af1b1 Add dwarf2_per_bfd field to dwarf2_per_cu_data
Some code using dwarf2_per_cu_data objects accesses the corresponding
dwarf2_per_bfd using the following pattern:

    per_cu->dwarf2_per_objfile->per_bfd

Since dwarf2_per_cu_data objects are going to become
objfile-independent, the dwarf2_per_objfile link must go.  To replace
it, add a dwarf2_per_cu_data->per_bfd link.  It makes sense to have it
there because the dwarf2_per_cu_data objects belong to the
dwarf2_per_bfd, so this is essentially just a backlink to their owner.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_cu_data) <per_bfd>: New
	member.
	* dwarf2/read.c (dwarf2_per_bfd::allocate_per_cu): Initialize
	dwarf2_per_cu_data::per_bfd.
	(dwarf2_per_bfd::allocate_signatured_type): Likewise.
	(create_type_unit_group): Likewise.
	(queue_comp_unit): Remove reference to
	per_cu->dwarf2_per_objfile.
	(maybe_queue_comp_unit): Likewise.
	(fill_in_sig_entry_from_dwo_entry): Assign new field.
	(create_cus_hash_table): Assign new field.
2020-05-12 15:24:50 -04:00
Simon Marchi
acd2b91adf Remove dwarf2_cu->per_cu->dwarf2_per_objfile references
Change spots that access the dwarf2_per_objfile object through this
pattern:

  dwarf2_cu->per_cu->dwarf2_per_objfile

to

  dwarf2_cu->per_objfile

This allows removing many references to
dwarf2_per_cu_data::dwarf2_per_objfile.

Again, I hope the following ChangeLog entry will be fine.  I'd rather not
list all the affected functions, as it would be time-consuming and a bit
pointless.

gdb/ChangeLog:

	* dwarf2/read.c: Replace
	dwarf2_cu->per_cu->dwarf2_per_objfile references with
	dwarf2_cu->per_objfile throughout.
2020-05-12 15:24:50 -04:00
Simon Marchi
b574ecffd1 Remove reference to dwarf2_per_cu_data::dwarf2_per_objfile in dw2_do_instantiate_symtab
This patch begins by removing the per_cu->dwarf2_per_objfile reference
in dw2_do_instantiate_symtab, instead accepting a dwarf2_per_objfile
object as a parameter.  It then fixes the fallouts.  In this context,
the dwarf2_per_objfile is generally derived from an objfile passed to a
quick_symbol_functions callback.

gdb/ChangeLog:

	* dwarf2/read.c (dw2_do_instantiate_symtab): Add per_objfile
	parameter, don't use per_cu->dwarf2_per_objfile.
	(dw2_instantiate_symtab): Likewise.
	(dw2_find_last_source_symtab): Update.
	(dw2_map_expand_apply): Update.
	(dw2_lookup_symbol): Update.
	(dw2_expand_symtabs_for_function): Update.
	(dw2_expand_all_symtabs): Update.
	(dw2_expand_symtabs_with_fullname): Update.
	(dw2_expand_symtabs_matching_one): Add per_objfile parameter,
	don't use per_cu->dwarf2_per_objfile.
	(dw2_expand_marked_cus): Update.
	(dw2_find_pc_sect_compunit_symtab): Update.
	(dw2_debug_names_lookup_symbol): Update.
	(dw2_debug_names_expand_symtabs_for_function): Update.
	(dw2_debug_names_map_matching_symbols): Update.
	(dwarf2_psymtab::expand_psymtab): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
63ed5b5889 Add dwarf2_per_objfile field to dwarf2_cu
Subsequent patches will make dwarf2_per_cu_data objfile-independent.
This means that the dwarf2_per_cu_data::dwarf2_per_objfile field must
go.

The code using a dwarf2_cu structure currently accesses the current
dwarf2_per_objfile object through dwarf2_cu->per_cu->dwarf2_per_objfile.
Since it's ok for the dwarf2_cu to know about the current objfile (a
dwarf2_cu is always used in the context of a particular objfile), add a
dwarf2_per_objfile field to dwarf2_cu.  Upcoming patches will gradually
remove uses of dwarf2_per_cu_data::dwarf2_per_objfile in favor of
dwarf2_cu::dwarf2_per_objfile, until the former can be removed.

gdb/ChangeLog:

	* dwarf2/read.c (struct dwarf2_cu) <dwarf2_cu>: Add parameter.
	<per_objfile>: New member.
	(class cutu_reader) <init_tu_and_read_dwo_dies>: Add parameter.
	(cutu_reader::init_tu_and_read_dwo_dies): Add parameter, update
	call to dwarf2_cu.
	(cutu_reader::cutu_reader): Update.
	(dwarf2_cu::dwarf2_cu): Add parameter, initialize per_objfile.
2020-05-12 15:24:50 -04:00
Simon Marchi
35f1c44ab7 Move die_type_hash to dwarf2_per_objfile
The die_type_hash field can't be shared between multiple obfiles, as it
holds `struct type` objects, which are objfile-specific.  Move it from
dwarf2_per_bfd to dwarf2_per_objfile and update all references.

gdb/ChangeLog:

	* dwarf2/read.h (struct dwarf2_per_bfd) <die_type_hash>: Move to
	struct dwarf2_per_objfile.
	(struct dwarf2_per_objfile) <die_type_hash>: Move from struct
	dwarf2_per_bfd.
	* dwarf2/read.c (set_die_type): Update.
	(get_die_type_at_offset): Update.
2020-05-12 15:24:50 -04:00
Simon Marchi
60684704c1 Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data
The dwarf2_psymtab and dwarf2_per_cu_quick_data types contain a pointer
to a compunit_symtab, which is a pointer to the corresponding full
symtab.  The dwarf2_psymtab and dwarf2_per_cu_quick_data objects are
going to become objfile-independent, and possibly shared by multiple
objfiles, whereas compunit_symtab will stay objfile-dependent.  This
backlink to the compunit_symtab must therefore be removed.

This patch replaces them with a vector in the dwarf2_per_objfile type,
that serves as a mapping from dwarf2_per_cu_data objects to
compunit_symtab objects, for this particular objfile.  The vector is
indexed using the index assigned to the dwarf2_per_cu_data at its
creation.

I removed the get_compunit_symtab, as it appears to bring not much value
over calling dwarf2_per_objfile::get_symtab directly.

YYYY-MM-DD  Tom Tromey  <tom@tromey.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

	* dwarf2/read.h (struct dwarf2_per_bfd) <num_psymtabs>: New
	method.
	(struct dwarf2_per_objfile) <resize_symtabs, symtab_set_p,
	get_symtab, set_symtab>: New methods.
	<m_symtabs>: New field.
	(struct dwarf2_psymtab): Derive from partial_symtab.
	<readin_p, get_compunit_symtab>: Declare methods.
	* dwarf2/read.c (dwarf2_per_objfile::symtab_set_p,
	dwarf2_per_objfile::get_symtab, dwarf2_per_objfile::set_symtab):
	New methods.
	(struct dwarf2_per_cu_quick_data) <compunit_symtab>: Remove.
	(dw2_do_instantiate_symtab, dw2_instantiate_symtab)
	(dw2_map_expand_apply, dw2_map_symtabs_matching_filename)
	(dw2_symtab_iter_next, dw2_print_stats)
	(dw2_expand_symtabs_with_fullname)
	(dw2_expand_symtabs_matching_one)
	(dw_expand_symtabs_matching_file_matcher)
	(dw2_find_pc_sect_compunit_symtab, dw2_map_symbol_filenames)
	(dw2_debug_names_iterator::next)
	(dw2_debug_names_map_matching_symbols)
	(fill_in_sig_entry_from_dwo_entry, dwarf2_psymtab::read_symtab)
	(process_queue, dwarf2_psymtab::expand_psymtab): Update.
	(dwarf2_psymtab::readin_p, dwarf2_psymtab::get_compunit_symtab):
	New methods.
	(get_compunit_symtab, process_full_comp_unit)
	(process_full_type_unit): Update.
	(dwarf2_build_psymtabs, dwarf2_initialize_objfile, add_type_unit): Call
2020-05-12 15:24:49 -04:00
Simon Marchi
a309b520ba Split dwarf2_per_objfile into dwarf2_per_objfile and dwarf2_per_bfd
This is the first step of splitting dwarf2_per_objfile in two, one
structure for objfile-independent data (dwarf2_per_bfd) and one for
objfile-dependent data (dwarf2_per_objfile).

The existing dwarf2_per_objfile is renamed dwarf2_per_bfd, and a new
dwarf2_per_objfile type is introduced, which sits "in between" the
objfile and dwarf2_per_bfd.

So where we had this before:

  objfile -> dwarf2_per_objfile (*)

we now have this:

  objfile -> dwarf2_per_objfile -> dwarf2_per_bfd (*)

(*) Note that the dwarf2_per_objfile in the former corresponds to
the dwarf2_per_bfd in the latter.

I've done the minimal amount of changes in this patch: following patches
will incrementally move things that are not actually shareable between
objfiles from dwarf2_per_bfd to dwarf2_per_objfile.

Most references to dwarf2_per_objfile objects are changed to
dwarf2_per_objfile->per_bfd.  To avoid many of these replacements, which
would have to be reverted later anyway, I've moved right away the
objfile backlink to the new dwarf2_per_objfile structure in this patch.
I've also moved the read_line_string method, since it references the
objfile backlink, and it's actually not difficult to move.

Once the moves are completed, multiple dwarf2_per_objfile sharing the
same BFD will point to the same single instance of dwarf2_per_bfd (as
long as they don't require relocation).

dwarf2_has_info, where we create these objects, is updated to the new
architecture.

I've had to change the get_gdb_index_contents_ftype typedef and related
functions.  The parameter type was changed from dwarf2_per_objfile to
dwarf2_per_bfd, otherwise the template wouldn't work.

Please excuse the terse ChangeLog entry, I have not listed all the
functions where dwarf2_per_objfile has been changed to
dwarf2_per_objfile->per_bfd.  It would take a considerable amount of
time and would not really be useful in the end.

gdb/ChangeLog:

	* dwarf2/read.h (dwarf2_per_objfile): Rename to dwarf2_per_bfd,
	then introduce a new dwarf2_per_objfile type.
	<read_line_string>: Move to the new dwarf2_per_objfile type.
	<objfile>: Likewise.
	(dwarf2_per_bfd): Rename dwarf2_per_objfile to this.
	* dwarf2/read.c: Replace references to dwarf2_per_objfile with
	dwarf2_per_objfile->per_bfd.
	(dwarf2_per_objfile::dwarf2_per_objfile): Rename to...
	(dwarf2_per_bfd::dwarf2_per_bfd): ... this.
	(dwarf2_per_objfile::free_cached_comp_units): Rename to...
	(dwarf2_per_bfd::free_cached_comp_units): ... this.
	(dwarf2_has_info): Allocate dwarf2_per_bfd.
	(dwarf2_per_objfile::locate_sections): Rename to...
	(dwarf2_per_bfd::locate_sections): ... this.
	(dwarf2_per_objfile::get_cutu): Rename to...
	(dwarf2_per_bfd::get_cutu): ... this.
	(dwarf2_per_objfile::get_cu): Rename to...
	(dwarf2_per_bfd::get_cu): ... this.
	(dwarf2_per_objfile::get_tu): Rename to...
	(dwarf2_per_bfd::get_tu): ... this.
	(dwarf2_per_objfile::allocate_per_cu): Rename to...
	(dwarf2_per_bfd::allocate_per_cu): ... this.
	(dwarf2_per_objfile::allocate_signatured_type): Rename to...
	(dwarf2_per_bfd::allocate_signatured_type): ... this.
	(get_gdb_index_contents_ftype): Change parameter from
	dwarf2_per_objfile to dwarf2_per_bfd.
	* dwarf2/macro.c, dwarf2/index-write.c: Replace references to
	dwarf2_per_objfile with dwarf2_per_objfile->per_bfd.
2020-05-12 15:24:49 -04:00
Tom Tromey
93f68a2429 Add dwarf2_per_objfile member to DWARF batons
Various DWARF callbacks expect to be able to fetch the objfile and / or
dwarf2_per_objfile from the DWARF CU object.  However, this won't be
possible once sharing is implemented.

Because these objects are related to full symbols (e.g., they are used
to implement location expressions), they can simply store the
dwarf2_per_objfile they need.

This patch adds a per_objfile member to the various "baton" structures
and arranges to set this value when constructing the baton.

YYYY-MM-DD  Tom Tromey  <tom@tromey.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@efficios.com>

	* dwarf2/loc.c (struct piece_closure) <per_objfile>: New member.
	(allocate_piece_closure): Set "per_objfile" member.
	(dwarf2_find_location_expression, dwarf2_locexpr_baton_eval)
	(locexpr_describe_location, loclist_describe_location): Use new
	member.
	* dwarf2/read.c (read_call_site_scope)
	(mark_common_block_symbol_computed, attr_to_dynamic_prop)
	(dwarf2_const_value_attr, dwarf2_fetch_die_loc_sect_off)
	(fill_in_loclist_baton, dwarf2_symbol_mark_computed): Set
	per_objfile member.
	* dwarf2/loc.h (struct dwarf2_locexpr_baton) <per_objfile>: New
	member.
	(struct dwarf2_loclist_baton) <per_objfile>: New member.
2020-05-12 15:24:49 -04:00
Tom Tromey
1b9f401923 Add dwarf2_per_cu_data::index
Currently, a dwarf2_per_cu_data can hold a link to the corresponding
expanded compunit_symtab.  However, the dwarf2_per_cu_data objects are
shared across objfiles, a simple pointer won't work: each objfile
sharing the dwarf2_per_cu_data instance will have a corresponding
compunit_symtab.

Instead, this link will be stored in the dwarf2_per_objfile object
(which will contain the objfile-specific data).  To enable this, we add
an index to each dwarf2_per_cu_data and signatured_type.  The data
structure in the dwarf2_per_objfile will use this new index to map a
dwarf2_per_cu_data to its corresponding compunit_symtab, for this
objfile.

2020-02-21  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_objfile) <allocate_per_cu,
	allocate_signatured_type>: Declare new methods.
	<m_num_psymtabs>: New member.
	(struct dwarf2_per_cu_data) <index>: New member.
	* dwarf2/read.c (dwarf2_per_objfile::allocate_per_cu)
	(dwarf2_per_objfile::allocate_signatured_type): New methods.
	(create_cu_from_index_list): Use allocate_per_cu.
	(create_signatured_type_table_from_index)
	(create_signatured_type_table_from_debug_names)
	(create_debug_type_hash_table, add_type_unit)
	(read_comp_units_from_section): Use allocate_signatured_type.
2020-05-12 15:24:49 -04:00
Tom Tromey
db8d868ffa Add "objfile" parameter to two partial_symtab methods
This series will cause partial symtabs to be shared across objfiles.
However, full symtabs and symbols will still be objfile-dependent, so
will be expanded separately for each objfile.  So, a debug info reader
will need to know which objfile to consult when expanding a partial
symtab.

This patch adds an objfile parameter to the two relevant methods of
partial_symtab.  Current implementations simply ignore them.

2020-02-21  Tom Tromey  <tom@tromey.com>

	* psymtab.c (partial_map_expand_apply)
	(psym_find_pc_sect_compunit_symtab, psym_lookup_symbol)
	(psym_lookup_global_symbol_language)
	(psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab)
	(psym_print_stats, psym_expand_symtabs_for_function)
	(psym_map_symbol_filenames, psym_map_matching_symbols)
	(psym_expand_symtabs_matching)
	(partial_symtab::read_dependencies, maintenance_info_psymtabs)
	(maintenance_check_psymtabs): Update.
	* psympriv.h (struct partial_symtab) <readin_p,
	get_compunit_symtab>: Add objfile parameter.
	(struct standard_psymtab) <readin_p, get_compunit_symtab>:
	Likewise.
	* dwarf2/read.c (struct dwarf2_include_psymtab) <readin_p,
	get_compunit_symtab>: Likewise.
	(dwarf2_psymtab::expand_psymtab): Pass objfile argument.
2020-05-12 15:24:49 -04:00
Tom Tromey
9b3670b5bb Introduce dwarf2_per_objfile::obstack
Currently much of the DWARF-related data is stored on the objfile
obstack.  This prevents sharing this data across objfiles, so this patch
adds a new obstack to dwarf2_per_objfile.  Note that the
dwarf2_per_objfile type is going to become "dwarf2_per_bfd" in a
subsequent patch, which is indeed going to be shared between objfiles.

One way to check whether this is correct is to look at the remaining
uses of objfile_obstack in the DWARF code and note that they all
appear in the "full CU" code paths.

The converse -- storing per-objfile data on the shared obstack -- is
not good, but it is just a memory leak, not a potential
use-after-free.  Double-checking this would also be useful, though.

2020-02-21  Tom Tromey  <tom@tromey.com>

	* dwarf2/read.h (struct dwarf2_per_objfile) <obstack>: New
	member.
	* dwarf2/read.c (delete_file_name_entry): Fix comment.
	(create_cu_from_index_list)
	(create_signatured_type_table_from_index)
	(create_signatured_type_table_from_debug_names)
	(dw2_get_file_names_reader, dwarf2_initialize_objfile)
	(dwarf2_create_include_psymtab)
	(create_debug_type_hash_table, add_type_unit)
	(create_type_unit_group, read_comp_units_from_section)
	(dwarf2_compute_name, create_cus_hash_table)
	(create_dwp_hash_table, create_dwo_unit_in_dwp_v1)
	(create_dwo_unit_in_dwp_v2, open_and_init_dwp_file): Use new
	obstack.
	(dw2_get_real_path): Likewise.  Change argument to
	dwarf2_per_objfile.
2020-05-12 15:24:49 -04:00
16 changed files with 1850 additions and 1501 deletions

View File

@@ -583,7 +583,8 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
CORE_ADDR *initial,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
/* We keep a counter so that labels and other objects we create have
unique names. */
@@ -719,7 +720,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
index, not an address. We don't support things like
branching between the address and the TLS op. */
if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
uoffset += per_cu->text_offset ();
uoffset += per_objfile->objfile->text_section_offset ();
push (indent, stream, uoffset);
break;
@@ -896,7 +897,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
sym, pc,
arch, registers_used, addr_size,
datastart, datastart + datalen,
NULL, per_cu);
NULL, per_cu, per_objfile);
pushf (indent, stream, "%s + %s", fb_name, hex_string (offset));
}
@@ -1077,7 +1078,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream,
sym, pc, arch, registers_used,
addr_size,
cfa_start, cfa_end,
&text_offset, per_cu);
&text_offset, per_cu, per_objfile);
pushf (indent, stream, "%s", cfa_name);
}
}
@@ -1123,11 +1124,12 @@ compile_dwarf_expr_to_c (string_file *stream, const char *result_name,
struct gdbarch *arch, unsigned char *registers_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
do_compile_dwarf_expr_to_c (2, stream, GCC_UINTPTR, result_name, sym, pc,
arch, registers_used, addr_size, op_ptr, op_end,
NULL, per_cu);
NULL, per_cu, per_objfile);
}
/* See compile.h. */
@@ -1140,9 +1142,11 @@ compile_dwarf_bounds_to_c (string_file *stream,
struct gdbarch *arch, unsigned char *registers_used,
unsigned int addr_size,
const gdb_byte *op_ptr, const gdb_byte *op_end,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
do_compile_dwarf_expr_to_c (2, stream, "unsigned long ", result_name,
sym, pc, arch, registers_used,
addr_size, op_ptr, op_end, NULL, per_cu);
addr_size, op_ptr, op_end, NULL, per_cu,
per_objfile);
}

View File

@@ -21,6 +21,7 @@
struct ui_file;
struct gdbarch;
struct dwarf2_per_cu_data;
struct dwarf2_per_objfile;
struct symbol;
struct dynamic_prop;
@@ -53,6 +54,9 @@ extern void eval_compile_command (struct command_line *cmd,
OPT_PTR and OP_END are the bounds of the DWARF expression.
PER_CU is the per-CU object used for looking up various other
things.
PER_OBJFILE is the per-objfile object also used for looking up various other
things. */
extern void compile_dwarf_expr_to_c (string_file *stream,
@@ -64,7 +68,8 @@ extern void compile_dwarf_expr_to_c (string_file *stream,
unsigned int addr_size,
const gdb_byte *op_ptr,
const gdb_byte *op_end,
struct dwarf2_per_cu_data *per_cu);
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
/* Compile a DWARF bounds expression to C, suitable for use by the
compiler.
@@ -88,6 +93,9 @@ extern void compile_dwarf_expr_to_c (string_file *stream,
OPT_PTR and OP_END are the bounds of the DWARF expression.
PER_CU is the per-CU object used for looking up various other
things.
PER_OBJFILE is the per-objfile object also used for looking up various other
things. */
extern void compile_dwarf_bounds_to_c (string_file *stream,
@@ -99,7 +107,8 @@ extern void compile_dwarf_bounds_to_c (string_file *stream,
unsigned int addr_size,
const gdb_byte *op_ptr,
const gdb_byte *op_end,
struct dwarf2_per_cu_data *per_cu);
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
extern void compile_print_value (struct value *val, void *data_voidp);

View File

@@ -27,6 +27,7 @@
#include "dwarf2.h"
#include "dwarf2/expr.h"
#include "dwarf2/loc.h"
#include "dwarf2/read.h"
#include "gdbsupport/underlying.h"
#include "gdbarch.h"
@@ -88,17 +89,17 @@ dwarf_expr_context::address_type () const
/* Create a new context for the expression evaluator. */
dwarf_expr_context::dwarf_expr_context ()
dwarf_expr_context::dwarf_expr_context (dwarf2_per_objfile *per_objfile)
: gdbarch (NULL),
addr_size (0),
ref_addr_size (0),
offset (0),
recursion_depth (0),
max_recursion_depth (0x100),
location (DWARF_VALUE_MEMORY),
len (0),
data (NULL),
initialized (0)
initialized (0),
per_objfile (per_objfile)
{
}
@@ -631,7 +632,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
index, not an address. We don't support things like
branching between the address and the TLS op. */
if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
result += this->offset;
result += this->per_objfile->objfile->text_section_offset ();
result_val = value_from_ulongest (address_type, result);
break;
@@ -639,7 +640,7 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr,
case DW_OP_GNU_addr_index:
op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
result = this->get_addr_index (uoffset);
result += this->offset;
result += this->per_objfile->objfile->text_section_offset ();
result_val = value_from_ulongest (address_type, result);
break;
case DW_OP_GNU_const_index:

View File

@@ -25,6 +25,8 @@
#include "leb128.h"
#include "gdbtypes.h"
struct dwarf2_per_objfile;
/* The location of a value. */
enum dwarf_value_location
{
@@ -117,7 +119,7 @@ struct dwarf_stack_value
its current state and its callbacks. */
struct dwarf_expr_context
{
dwarf_expr_context ();
dwarf_expr_context (dwarf2_per_objfile *per_objfile);
virtual ~dwarf_expr_context () = default;
void push_address (CORE_ADDR value, bool in_stack_memory);
@@ -139,10 +141,6 @@ struct dwarf_expr_context
context and operations depending on DW_FORM_ref_addr are not allowed. */
int ref_addr_size;
/* Offset used to relocate DW_OP_addr, DW_OP_addrx, and
DW_OP_GNU_addr_index arguments. */
CORE_ADDR offset;
/* The current depth of dwarf expression recursion, via DW_OP_call*,
DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum
depth we'll tolerate before raising an error. */
@@ -185,6 +183,9 @@ struct dwarf_expr_context
two cases need to be handled separately.) */
std::vector<dwarf_expr_piece> pieces;
/* We evaluate the expression in the context of this objfile. */
dwarf2_per_objfile *per_objfile;
/* Return the value of register number REGNUM (a DWARF register number),
read as an address. */
virtual CORE_ADDR read_addr_from_reg (int regnum) = 0;

View File

@@ -166,8 +166,8 @@ struct comp_unit
auto_obstack obstack;
};
static struct dwarf2_fde *dwarf2_frame_find_fde (CORE_ADDR *pc,
CORE_ADDR *out_offset);
static struct dwarf2_fde *dwarf2_frame_find_fde
(CORE_ADDR *pc, dwarf2_per_objfile **out_per_objfile);
static int dwarf2_frame_adjust_regnum (struct gdbarch *gdbarch, int regnum,
int eh_frame_p);
@@ -237,7 +237,11 @@ register %s (#%d) at %s"),
class dwarf_expr_executor : public dwarf_expr_context
{
public:
public:
dwarf_expr_executor (dwarf2_per_objfile *per_objfile)
: dwarf_expr_context (per_objfile)
{}
struct frame_info *this_frame;
@@ -311,19 +315,18 @@ class dwarf_expr_executor : public dwarf_expr_context
static CORE_ADDR
execute_stack_op (const gdb_byte *exp, ULONGEST len, int addr_size,
CORE_ADDR offset, struct frame_info *this_frame,
CORE_ADDR initial, int initial_in_stack_memory)
struct frame_info *this_frame, CORE_ADDR initial,
int initial_in_stack_memory, dwarf2_per_objfile *per_objfile)
{
CORE_ADDR result;
dwarf_expr_executor ctx;
dwarf_expr_executor ctx (per_objfile);
scoped_value_mark free_values;
ctx.this_frame = this_frame;
ctx.gdbarch = get_frame_arch (this_frame);
ctx.addr_size = addr_size;
ctx.ref_addr_size = -1;
ctx.offset = offset;
ctx.push_address (initial, initial_in_stack_memory);
ctx.eval (exp, len);
@@ -883,14 +886,16 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
const gdb_byte **cfa_end_out)
{
struct dwarf2_fde *fde;
CORE_ADDR text_offset;
dwarf2_per_objfile *per_objfile;
CORE_ADDR pc1 = pc;
/* Find the correct FDE. */
fde = dwarf2_frame_find_fde (&pc1, &text_offset);
fde = dwarf2_frame_find_fde (&pc1, &per_objfile);
if (fde == NULL)
error (_("Could not compute CFA; needed to translate this expression"));
gdb_assert (per_objfile != nullptr);
dwarf2_frame_state fs (pc1, fde->cie);
/* Check for "quirks" - known bugs in producers. */
@@ -898,14 +903,15 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
/* First decode all the insns in the CIE. */
execute_cfa_program (fde, fde->cie->initial_instructions,
fde->cie->end, gdbarch, pc, &fs, text_offset);
fde->cie->end, gdbarch, pc, &fs,
per_objfile->objfile->text_section_offset ());
/* Save the initialized register set. */
fs.initial = fs.regs;
/* Then decode the insns in the FDE up to our target PC. */
execute_cfa_program (fde, fde->instructions, fde->end, gdbarch, pc, &fs,
text_offset);
per_objfile->objfile->text_section_offset ());
/* Calculate the CFA. */
switch (fs.regs.cfa_how)
@@ -923,7 +929,7 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc,
}
case CFA_EXP:
*text_offset_out = text_offset;
*text_offset_out = per_objfile->objfile->text_section_offset ();
*cfa_start_out = fs.regs.cfa_exp;
*cfa_end_out = fs.regs.cfa_exp + fs.regs.cfa_exp_len;
return 0;
@@ -956,8 +962,8 @@ struct dwarf2_frame_cache
/* Target address size in bytes. */
int addr_size;
/* The .text offset. */
CORE_ADDR text_offset;
/* The dwarf2_per_objfile from which this frame description came. */
dwarf2_per_objfile *per_objfile;
/* If not NULL then this frame is the bottom frame of a TAILCALL_FRAME
sequence. If NULL then it is a normal case with no TAILCALL_FRAME
@@ -1003,8 +1009,9 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
CORE_ADDR pc1 = get_frame_address_in_block (this_frame);
/* Find the correct FDE. */
fde = dwarf2_frame_find_fde (&pc1, &cache->text_offset);
fde = dwarf2_frame_find_fde (&pc1, &cache->per_objfile);
gdb_assert (fde != NULL);
gdb_assert (cache->per_objfile != nullptr);
/* Allocate and initialize the frame state. */
struct dwarf2_frame_state fs (pc1, fde->cie);
@@ -1018,7 +1025,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
execute_cfa_program (fde, fde->cie->initial_instructions,
fde->cie->end, gdbarch,
get_frame_address_in_block (this_frame), &fs,
cache->text_offset);
cache->per_objfile->objfile->text_section_offset ());
/* Save the initialized register set. */
fs.initial = fs.regs;
@@ -1034,8 +1041,9 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
&& entry_pc < fde->initial_location + fde->address_range)
{
/* Decode the insns in the FDE up to the entry PC. */
instr = execute_cfa_program (fde, fde->instructions, fde->end, gdbarch,
entry_pc, &fs, cache->text_offset);
instr = execute_cfa_program
(fde, fde->instructions, fde->end, gdbarch, entry_pc, &fs,
cache->per_objfile->objfile->text_section_offset ());
if (fs.regs.cfa_how == CFA_REG_OFFSET
&& (dwarf_reg_to_regnum (gdbarch, fs.regs.cfa_reg)
@@ -1051,7 +1059,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
/* Then decode the insns in the FDE up to our target PC. */
execute_cfa_program (fde, instr, fde->end, gdbarch,
get_frame_address_in_block (this_frame), &fs,
cache->text_offset);
cache->per_objfile->objfile->text_section_offset ());
try
{
@@ -1069,8 +1077,8 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
case CFA_EXP:
cache->cfa =
execute_stack_op (fs.regs.cfa_exp, fs.regs.cfa_exp_len,
cache->addr_size, cache->text_offset,
this_frame, 0, 0);
cache->addr_size, this_frame, 0, 0,
cache->per_objfile);
break;
default:
@@ -1270,8 +1278,9 @@ dwarf2_frame_prev_register (struct frame_info *this_frame, void **this_cache,
case DWARF2_FRAME_REG_SAVED_EXP:
addr = execute_stack_op (cache->reg[regnum].loc.exp.start,
cache->reg[regnum].loc.exp.len,
cache->addr_size, cache->text_offset,
this_frame, cache->cfa, 1);
cache->addr_size,
this_frame, cache->cfa, 1,
cache->per_objfile);
return frame_unwind_got_memory (this_frame, regnum, addr);
case DWARF2_FRAME_REG_SAVED_VAL_OFFSET:
@@ -1281,8 +1290,9 @@ dwarf2_frame_prev_register (struct frame_info *this_frame, void **this_cache,
case DWARF2_FRAME_REG_SAVED_VAL_EXP:
addr = execute_stack_op (cache->reg[regnum].loc.exp.start,
cache->reg[regnum].loc.exp.len,
cache->addr_size, cache->text_offset,
this_frame, cache->cfa, 1);
cache->addr_size,
this_frame, cache->cfa, 1,
cache->per_objfile);
return frame_unwind_got_constant (this_frame, regnum, addr);
case DWARF2_FRAME_REG_UNSPECIFIED:
@@ -1650,7 +1660,7 @@ set_comp_unit (struct objfile *objfile, struct comp_unit *unit)
initial location associated with it into *PC. */
static struct dwarf2_fde *
dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
dwarf2_frame_find_fde (CORE_ADDR *pc, dwarf2_per_objfile **out_per_objfile)
{
for (objfile *objfile : current_program_space->objfiles ())
{
@@ -1682,8 +1692,9 @@ dwarf2_frame_find_fde (CORE_ADDR *pc, CORE_ADDR *out_offset)
if (it != fde_table->end ())
{
*pc = (*it)->initial_location + offset;
if (out_offset)
*out_offset = offset;
if (out_per_objfile != nullptr)
*out_per_objfile = get_dwarf2_per_objfile (objfile);
return *it;
}
}

View File

@@ -108,7 +108,7 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile)
/* Get build id of dwz file, if present. */
gdb::optional<std::string> dwz_build_id_str;
const dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
const dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
const char *dwz_build_id_ptr = NULL;
if (dwz != nullptr)

View File

@@ -961,17 +961,17 @@ private:
: m_abfd (dwarf2_per_objfile->objfile->obfd),
m_dwarf2_per_objfile (dwarf2_per_objfile)
{
dwarf2_per_objfile->str.read (dwarf2_per_objfile->objfile);
if (dwarf2_per_objfile->str.buffer == NULL)
dwarf2_per_objfile->per_bfd->str.read (dwarf2_per_objfile->objfile);
if (dwarf2_per_objfile->per_bfd->str.buffer == NULL)
return;
for (const gdb_byte *data = dwarf2_per_objfile->str.buffer;
data < (dwarf2_per_objfile->str.buffer
+ dwarf2_per_objfile->str.size);)
for (const gdb_byte *data = dwarf2_per_objfile->per_bfd->str.buffer;
data < (dwarf2_per_objfile->per_bfd->str.buffer
+ dwarf2_per_objfile->per_bfd->str.size);)
{
const char *const s = reinterpret_cast<const char *> (data);
const auto insertpair
= m_str_table.emplace (c_str_view (s),
data - dwarf2_per_objfile->str.buffer);
data - dwarf2_per_objfile->per_bfd->str.buffer);
if (!insertpair.second)
complaint (_("Duplicate string \"%s\" in "
".debug_str section [in module %s]"),
@@ -988,7 +988,7 @@ private:
const auto it = m_str_table.find (c_str_view (s));
if (it != m_str_table.end ())
return it->second;
const size_t offset = (m_dwarf2_per_objfile->str.size
const size_t offset = (m_dwarf2_per_objfile->per_bfd->str.size
+ m_str_add_buf.size ());
m_str_table.emplace (c_str_view (s), offset);
m_str_add_buf.append_cstr0 (s);
@@ -1296,12 +1296,12 @@ private:
static bool
check_dwarf64_offsets (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
if (to_underlying (per_cu->sect_off) >= (static_cast<uint64_t> (1) << 32))
return true;
}
for (const signatured_type *sigtype : dwarf2_per_objfile->all_type_units)
for (const signatured_type *sigtype : dwarf2_per_objfile->per_bfd->all_type_units)
{
const dwarf2_per_cu_data &per_cu = sigtype->per_cu;
@@ -1321,7 +1321,7 @@ static size_t
psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
size_t psyms_count = 0;
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
{
partial_symtab *psymtab = per_cu->v.psymtab;
@@ -1414,7 +1414,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
in the index file). This will later be needed to write the address
table. */
psym_index_map cu_index_htab;
cu_index_htab.reserve (dwarf2_per_objfile->all_comp_units.size ());
cu_index_htab.reserve (dwarf2_per_objfile->per_bfd->all_comp_units.size ());
/* The CU list is already sorted, so we don't need to do additional
work here. Also, the debug_types entries do not appear in
@@ -1422,10 +1422,10 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
std::unordered_set<partial_symbol *> psyms_seen
(psyms_seen_size (dwarf2_per_objfile));
for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
for (int i = 0; i < dwarf2_per_objfile->per_bfd->all_comp_units.size (); ++i)
{
struct dwarf2_per_cu_data *per_cu
= dwarf2_per_objfile->all_comp_units[i];
= dwarf2_per_objfile->per_bfd->all_comp_units[i];
partial_symtab *psymtab = per_cu->v.psymtab;
if (psymtab != NULL)
@@ -1453,15 +1453,15 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
/* Write out the .debug_type entries, if any. */
data_buf types_cu_list;
if (dwarf2_per_objfile->signatured_types)
if (dwarf2_per_objfile->per_bfd->signatured_types)
{
signatured_type_index_data sig_data (types_cu_list,
psyms_seen);
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.get (),
sig_data.cu_index = dwarf2_per_objfile->per_bfd->all_comp_units.size ();
htab_traverse_noresize (dwarf2_per_objfile->per_bfd->signatured_types.get (),
write_one_signatured_type, &sig_data);
}
@@ -1505,9 +1505,9 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
dwarf5_byte_order);
std::unordered_set<partial_symbol *>
psyms_seen (psyms_seen_size (dwarf2_per_objfile));
for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
for (int i = 0; i < dwarf2_per_objfile->per_bfd->all_comp_units.size (); ++i)
{
const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i];
const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->all_comp_units[i];
partial_symtab *psymtab = per_cu->v.psymtab;
/* CU of a shared file from 'dwz -m' may be unused by this main
@@ -1525,7 +1525,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
/* Write out the .debug_type entries, if any. */
data_buf types_cu_list;
if (dwarf2_per_objfile->signatured_types)
if (dwarf2_per_objfile->per_bfd->signatured_types)
{
debug_names::write_one_signatured_type_data sig_data (nametable,
signatured_type_index_data (types_cu_list, psyms_seen));
@@ -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.get (),
htab_traverse_noresize (dwarf2_per_objfile->per_bfd->signatured_types.get (),
debug_names::write_one_signatured_type,
&sig_data);
}
@@ -1574,12 +1574,12 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
/* comp_unit_count - The number of CUs in the CU list. */
header.append_uint (4, dwarf5_byte_order,
dwarf2_per_objfile->all_comp_units.size ());
dwarf2_per_objfile->per_bfd->all_comp_units.size ());
/* local_type_unit_count - The number of TUs in the local TU
list. */
header.append_uint (4, dwarf5_byte_order,
dwarf2_per_objfile->all_type_units.size ());
dwarf2_per_objfile->per_bfd->all_type_units.size ());
/* foreign_type_unit_count - The number of TUs in the foreign TU
list. */
@@ -1676,10 +1676,10 @@ write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
if (dwarf2_per_objfile->using_index)
if (dwarf2_per_objfile->per_bfd->using_index)
error (_("Cannot use an index to create the index"));
if (dwarf2_per_objfile->types.size () > 1)
if (dwarf2_per_objfile->per_bfd->types.size () > 1)
error (_("Cannot make an index when the file has multiple .debug_types sections"));
if (!objfile->partial_symtabs->psymtabs
@@ -1761,7 +1761,8 @@ save_gdb_index_command (const char *arg, int from_tty)
try
{
const char *basename = lbasename (objfile_name (objfile));
const dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
const dwz_file *dwz
= dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
const char *dwz_basename = NULL;
if (dwz != NULL)

View File

@@ -47,23 +47,22 @@
#include "gdbsupport/underlying.h"
#include "gdbsupport/byte-vector.h"
static struct value *dwarf2_evaluate_loc_desc_full (struct type *type,
struct frame_info *frame,
const gdb_byte *data,
size_t size,
struct dwarf2_per_cu_data *per_cu,
struct type *subobj_type,
LONGEST subobj_byte_offset);
static struct value *dwarf2_evaluate_loc_desc_full
(struct type *type, struct frame_info *frame, const gdb_byte *data,
size_t size, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile,
struct type *subobj_type, LONGEST subobj_byte_offset);
static struct call_site_parameter *dwarf_expr_reg_to_entry_parameter
(struct frame_info *frame,
enum call_site_parameter_kind kind,
union call_site_parameter_u kind_u,
struct dwarf2_per_cu_data **per_cu_return);
dwarf2_per_cu_data **per_cu_return,
dwarf2_per_objfile **per_objfile_return);
static struct value *indirect_synthetic_pointer
(sect_offset die, LONGEST byte_offset,
struct dwarf2_per_cu_data *per_cu,
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
struct frame_info *frame,
struct type *type, bool resolve_abstract_p = false);
@@ -163,7 +162,8 @@ decode_debug_loc_addresses (const gdb_byte *loc_ptr, const gdb_byte *buf_end,
The result indicates the kind of entry found. */
static enum debug_loc_kind
decode_debug_loclists_addresses (struct dwarf2_per_cu_data *per_cu,
decode_debug_loclists_addresses (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
const gdb_byte *loc_ptr,
const gdb_byte *buf_end,
const gdb_byte **new_ptr,
@@ -184,14 +184,14 @@ decode_debug_loclists_addresses (struct dwarf2_per_cu_data *per_cu,
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64);
if (loc_ptr == NULL)
return DEBUG_LOC_BUFFER_OVERFLOW;
*high = dwarf2_read_addr_index (per_cu, u64);
*high = dwarf2_read_addr_index (per_cu, per_objfile, u64);
*new_ptr = loc_ptr;
return DEBUG_LOC_BASE_ADDRESS;
case DW_LLE_startx_length:
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64);
if (loc_ptr == NULL)
return DEBUG_LOC_BUFFER_OVERFLOW;
*low = dwarf2_read_addr_index (per_cu, u64);
*low = dwarf2_read_addr_index (per_cu, per_objfile, u64);
*high = *low;
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &u64);
if (loc_ptr == NULL)
@@ -253,7 +253,8 @@ decode_debug_loclists_addresses (struct dwarf2_per_cu_data *per_cu,
The result indicates the kind of entry found. */
static enum debug_loc_kind
decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu,
decode_debug_loc_dwo_addresses (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
const gdb_byte *loc_ptr,
const gdb_byte *buf_end,
const gdb_byte **new_ptr,
@@ -275,25 +276,25 @@ decode_debug_loc_dwo_addresses (struct dwarf2_per_cu_data *per_cu,
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &high_index);
if (loc_ptr == NULL)
return DEBUG_LOC_BUFFER_OVERFLOW;
*high = dwarf2_read_addr_index (per_cu, high_index);
*high = dwarf2_read_addr_index (per_cu, per_objfile, high_index);
*new_ptr = loc_ptr;
return DEBUG_LOC_BASE_ADDRESS;
case DW_LLE_GNU_start_end_entry:
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index);
if (loc_ptr == NULL)
return DEBUG_LOC_BUFFER_OVERFLOW;
*low = dwarf2_read_addr_index (per_cu, low_index);
*low = dwarf2_read_addr_index (per_cu, per_objfile, low_index);
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &high_index);
if (loc_ptr == NULL)
return DEBUG_LOC_BUFFER_OVERFLOW;
*high = dwarf2_read_addr_index (per_cu, high_index);
*high = dwarf2_read_addr_index (per_cu, per_objfile, high_index);
*new_ptr = loc_ptr;
return DEBUG_LOC_START_END;
case DW_LLE_GNU_start_length_entry:
loc_ptr = gdb_read_uleb128 (loc_ptr, buf_end, &low_index);
if (loc_ptr == NULL)
return DEBUG_LOC_BUFFER_OVERFLOW;
*low = dwarf2_read_addr_index (per_cu, low_index);
*low = dwarf2_read_addr_index (per_cu, per_objfile, low_index);
if (loc_ptr + 4 > buf_end)
return DEBUG_LOC_BUFFER_OVERFLOW;
*high = *low;
@@ -317,13 +318,14 @@ const gdb_byte *
dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
size_t *locexpr_length, CORE_ADDR pc)
{
struct objfile *objfile = baton->per_cu->objfile ();
dwarf2_per_objfile *per_objfile = baton->per_objfile;
struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = baton->per_cu->addr_size ();
int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
/* Adjust base_address for relocatable objects. */
CORE_ADDR base_offset = baton->per_cu->text_offset ();
CORE_ADDR base_offset = baton->per_objfile->objfile->text_section_offset ();
CORE_ADDR base_address = baton->base_address + base_offset;
const gdb_byte *loc_ptr, *buf_end;
@@ -339,6 +341,7 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
if (baton->per_cu->version () < 5 && baton->from_dwo)
kind = decode_debug_loc_dwo_addresses (baton->per_cu,
baton->per_objfile,
loc_ptr, buf_end, &new_ptr,
&low, &high, byte_order);
else if (baton->per_cu->version () < 5)
@@ -348,6 +351,7 @@ dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
signed_addr_p);
else
kind = decode_debug_loclists_addresses (baton->per_cu,
baton->per_objfile,
loc_ptr, buf_end, &new_ptr,
&low, &high, byte_order,
addr_size, signed_addr_p);
@@ -470,7 +474,7 @@ locexpr_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location
(framefunc, get_frame_pc (frame), &start, &length);
result = dwarf2_evaluate_loc_desc (type, frame, start, length,
dlbaton->per_cu);
dlbaton->per_cu, dlbaton->per_objfile);
/* The DW_AT_frame_base attribute contains a location description which
computes the base address itself. However, the call to
@@ -527,7 +531,7 @@ loclist_get_frame_base (struct symbol *framefunc, struct frame_info *frame)
SYMBOL_BLOCK_OPS (framefunc)->find_frame_base_location
(framefunc, get_frame_pc (frame), &start, &length);
result = dwarf2_evaluate_loc_desc (type, frame, start, length,
dlbaton->per_cu);
dlbaton->per_cu, dlbaton->per_objfile);
/* The DW_AT_frame_base attribute contains a location description which
computes the base address itself. However, the call to
@@ -576,11 +580,11 @@ get_frame_pc_for_per_cu_dwarf_call (void *baton)
static void
per_cu_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile)
{
struct dwarf2_locexpr_baton block;
block = dwarf2_fetch_die_loc_cu_off (die_offset, per_cu,
block = dwarf2_fetch_die_loc_cu_off (die_offset, per_cu, per_objfile,
get_frame_pc_for_per_cu_dwarf_call,
ctx);
@@ -596,9 +600,11 @@ per_cu_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset,
static struct value *
sect_variable_value (struct dwarf_expr_context *ctx, sect_offset sect_off,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
struct type *die_type = dwarf2_fetch_die_type_sect_off (sect_off, per_cu);
struct type *die_type
= dwarf2_fetch_die_type_sect_off (sect_off, per_cu, per_objfile);
if (die_type == NULL)
error (_("Bad DW_OP_GNU_variable_value DIE."));
@@ -611,12 +617,16 @@ sect_variable_value (struct dwarf_expr_context *ctx, sect_offset sect_off,
struct type *type = lookup_pointer_type (die_type);
struct frame_info *frame = get_selected_frame (_("No frame selected."));
return indirect_synthetic_pointer (sect_off, 0, per_cu, frame, type, true);
return indirect_synthetic_pointer (sect_off, 0, per_cu, per_objfile, frame,
type, true);
}
class dwarf_evaluate_loc_desc : public dwarf_expr_context
{
public:
public:
dwarf_evaluate_loc_desc (dwarf2_per_objfile *per_objfile)
: dwarf_expr_context (per_objfile)
{}
struct frame_info *frame;
struct dwarf2_per_cu_data *per_cu;
@@ -642,9 +652,7 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
current thread's thread-local storage with offset OFFSET. */
CORE_ADDR get_tls_address (CORE_ADDR offset) override
{
struct objfile *objfile = per_cu->objfile ();
return target_translate_tls_address (objfile, offset);
return target_translate_tls_address (per_objfile->objfile, offset);
}
/* Helper interface of per_cu_dwarf_call for
@@ -652,7 +660,7 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
void dwarf_call (cu_offset die_offset) override
{
per_cu_dwarf_call (this, die_offset, per_cu);
per_cu_dwarf_call (this, die_offset, per_cu, per_objfile);
}
/* Helper interface of sect_variable_value for
@@ -660,12 +668,12 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
struct value *dwarf_variable_value (sect_offset sect_off) override
{
return sect_variable_value (this, sect_off, per_cu);
return sect_variable_value (this, sect_off, per_cu, per_objfile);
}
struct type *get_base_type (cu_offset die_offset, int size) override
{
struct type *result = dwarf2_get_die_type (die_offset, per_cu);
struct type *result = dwarf2_get_die_type (die_offset, per_cu, per_objfile);
if (result == NULL)
error (_("Could not find type for DW_OP_const_type"));
if (size != 0 && TYPE_LENGTH (result) != size)
@@ -678,7 +686,7 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
CORE_ADDR get_addr_index (unsigned int index) override
{
return dwarf2_read_addr_index (per_cu, index);
return dwarf2_read_addr_index (per_cu, per_objfile, index);
}
/* Callback function for get_object_address. Return the address of the VLA
@@ -704,7 +712,8 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
int deref_size) override
{
struct frame_info *caller_frame;
struct dwarf2_per_cu_data *caller_per_cu;
dwarf2_per_cu_data *caller_per_cu;
dwarf2_per_objfile *caller_per_objfile;
struct call_site_parameter *parameter;
const gdb_byte *data_src;
size_t size;
@@ -712,10 +721,13 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
caller_frame = get_prev_frame (frame);
parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u,
&caller_per_cu);
&caller_per_cu,
&caller_per_objfile);
data_src = deref_size == -1 ? parameter->value : parameter->data_value;
size = deref_size == -1 ? parameter->value_size : parameter->data_value_size;
gdb_assert (this->per_objfile == caller_per_objfile);
/* DEREF_SIZE size is not verified here. */
if (data_src == NULL)
throw_error (NO_ENTRY_VALUE_ERROR,
@@ -729,11 +741,9 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context
(CORE_ADDR) 0);
scoped_restore save_arch = make_scoped_restore (&this->gdbarch);
this->gdbarch = per_cu->objfile ()->arch ();
this->gdbarch = this->per_objfile->objfile->arch ();
scoped_restore save_addr_size = make_scoped_restore (&this->addr_size);
this->addr_size = per_cu->addr_size ();
scoped_restore save_offset = make_scoped_restore (&this->offset);
this->offset = per_cu->text_offset ();
this->eval (data_src, size);
}
@@ -859,7 +869,8 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
caller_core_addr_type = builtin_type (caller_arch)->builtin_func_ptr;
val = dwarf2_evaluate_loc_desc (caller_core_addr_type, caller_frame,
dwarf_block->data, dwarf_block->size,
dwarf_block->per_cu);
dwarf_block->per_cu,
dwarf_block->per_objfile);
/* DW_AT_call_target is a DWARF expression, not a DWARF location. */
if (VALUE_LVAL (val) == lval_memory)
return value_address (val);
@@ -1280,7 +1291,8 @@ static struct call_site_parameter *
dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
enum call_site_parameter_kind kind,
union call_site_parameter_u kind_u,
struct dwarf2_per_cu_data **per_cu_return)
dwarf2_per_cu_data **per_cu_return,
dwarf2_per_objfile **per_objfile_return)
{
CORE_ADDR func_addr, caller_pc;
struct gdbarch *gdbarch;
@@ -1371,6 +1383,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
}
*per_cu_return = call_site->per_cu;
*per_objfile_return = call_site->per_objfile;
return parameter;
}
@@ -1388,7 +1401,8 @@ static struct value *
dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
CORE_ADDR deref_size, struct type *type,
struct frame_info *caller_frame,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
const gdb_byte *data_src;
gdb_byte *data;
@@ -1409,7 +1423,8 @@ dwarf_entry_parameter_to_value (struct call_site_parameter *parameter,
memcpy (data, data_src, size);
data[size] = DW_OP_stack_value;
return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu);
return dwarf2_evaluate_loc_desc (type, caller_frame, data, size + 1, per_cu,
per_objfile);
}
/* VALUE must be of type lval_computed with entry_data_value_funcs. Perform
@@ -1483,14 +1498,17 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
struct frame_info *caller_frame = get_prev_frame (frame);
struct value *outer_val, *target_val, *val;
struct call_site_parameter *parameter;
struct dwarf2_per_cu_data *caller_per_cu;
dwarf2_per_cu_data *caller_per_cu;
dwarf2_per_objfile *caller_per_objfile;
parameter = dwarf_expr_reg_to_entry_parameter (frame, kind, kind_u,
&caller_per_cu);
&caller_per_cu,
&caller_per_objfile);
outer_val = dwarf_entry_parameter_to_value (parameter, -1 /* deref_size */,
type, caller_frame,
caller_per_cu);
caller_per_cu,
caller_per_objfile);
/* Check if DW_AT_call_data_value cannot be used. If it should be
used and it is not available do not fall back to OUTER_VAL - dereferencing
@@ -1504,7 +1522,8 @@ value_of_dwarf_reg_entry (struct type *type, struct frame_info *frame,
target_val = dwarf_entry_parameter_to_value (parameter,
TYPE_LENGTH (target_type),
target_type, caller_frame,
caller_per_cu);
caller_per_cu,
caller_per_objfile);
val = allocate_computed_value (type, &entry_data_value_funcs,
release_value (target_val).release ());
@@ -1552,6 +1571,9 @@ struct piece_closure
/* Reference count. */
int refc = 0;
/* The objfile from which this closure's expression came. */
dwarf2_per_objfile *per_objfile = nullptr;
/* The CU from which this closure's expression came. */
struct dwarf2_per_cu_data *per_cu = NULL;
@@ -1567,13 +1589,16 @@ struct piece_closure
PIECES. */
static struct piece_closure *
allocate_piece_closure (struct dwarf2_per_cu_data *per_cu,
allocate_piece_closure (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
std::vector<dwarf_expr_piece> &&pieces,
struct frame_info *frame)
{
struct piece_closure *c = new piece_closure;
c->refc = 1;
/* We must capture this here due to sharing of DWARF state. */
c->per_objfile = per_objfile;
c->per_cu = per_cu;
c->pieces = std::move (pieces);
if (frame == NULL)
@@ -1815,8 +1840,7 @@ rw_pieced_value (struct value *v, struct value *from)
break;
}
struct objfile *objfile = c->per_cu->objfile ();
struct gdbarch *objfile_gdbarch = objfile->arch ();
gdbarch *objfile_gdbarch = c->per_objfile->objfile->arch ();
ULONGEST stack_value_size_bits
= 8 * TYPE_LENGTH (value_type (p->v.value));
@@ -1951,7 +1975,8 @@ get_frame_address_in_block_wrapper (void *baton)
static struct value *
fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
struct dwarf2_per_cu_data *per_cu,
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
struct type *type)
{
struct value *result = NULL;
@@ -1959,7 +1984,8 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
LONGEST len;
auto_obstack temp_obstack;
bytes = dwarf2_fetch_constant_bytes (die, per_cu, &temp_obstack, &len);
bytes = dwarf2_fetch_constant_bytes (die, per_cu, per_objfile,
&temp_obstack, &len);
if (bytes != NULL)
{
@@ -1982,18 +2008,20 @@ fetch_const_value_from_synthetic_pointer (sect_offset die, LONGEST byte_offset,
static struct value *
indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset,
struct dwarf2_per_cu_data *per_cu,
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
struct frame_info *frame, struct type *type,
bool resolve_abstract_p)
{
/* Fetch the location expression of the DIE we're pointing to. */
struct dwarf2_locexpr_baton baton
= dwarf2_fetch_die_loc_sect_off (die, per_cu,
= dwarf2_fetch_die_loc_sect_off (die, per_cu, per_objfile,
get_frame_address_in_block_wrapper, frame,
resolve_abstract_p);
/* Get type of pointed-to DIE. */
struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu);
struct type *orig_type = dwarf2_fetch_die_type_sect_off (die, per_cu,
per_objfile);
if (orig_type == NULL)
invalid_synthetic_pointer ();
@@ -2003,11 +2031,12 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset,
if (baton.data != NULL)
return dwarf2_evaluate_loc_desc_full (orig_type, frame, baton.data,
baton.size, baton.per_cu,
baton.per_objfile,
TYPE_TARGET_TYPE (type),
byte_offset);
else
return fetch_const_value_from_synthetic_pointer (die, byte_offset, per_cu,
type);
per_objfile, type);
}
/* An implementation of an lval_funcs method to indirect through a
@@ -2084,7 +2113,7 @@ indirect_pieced_value (struct value *value)
return indirect_synthetic_pointer (piece->v.ptr.die_sect_off,
byte_offset, c->per_cu,
frame, type);
c->per_objfile, frame, type);
}
/* Implementation of the coerce_ref method of lval_funcs for synthetic C++
@@ -2111,7 +2140,7 @@ coerce_pieced_ref (const struct value *value)
return indirect_synthetic_pointer
(closure->pieces[0].v.ptr.die_sect_off,
closure->pieces[0].v.ptr.offset,
closure->per_cu, frame, type);
closure->per_cu, closure->per_objfile, frame, type);
}
else
{
@@ -2167,12 +2196,12 @@ static const struct lval_funcs pieced_value_funcs = {
static struct value *
dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
const gdb_byte *data, size_t size,
struct dwarf2_per_cu_data *per_cu,
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
struct type *subobj_type,
LONGEST subobj_byte_offset)
{
struct value *retval;
struct objfile *objfile = per_cu->objfile ();
if (subobj_type == NULL)
{
@@ -2185,17 +2214,16 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
if (size == 0)
return allocate_optimized_out_value (subobj_type);
dwarf_evaluate_loc_desc ctx;
dwarf_evaluate_loc_desc ctx (per_objfile);
ctx.frame = frame;
ctx.per_cu = per_cu;
ctx.obj_address = 0;
scoped_value_mark free_values;
ctx.gdbarch = objfile->arch ();
ctx.gdbarch = per_objfile->objfile->arch ();
ctx.addr_size = per_cu->addr_size ();
ctx.ref_addr_size = per_cu->ref_addr_size ();
ctx.offset = per_cu->text_offset ();
try
{
@@ -2234,7 +2262,8 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
if (bit_size > 8 * TYPE_LENGTH (type))
invalid_synthetic_pointer ();
c = allocate_piece_closure (per_cu, std::move (ctx.pieces), frame);
c = allocate_piece_closure (per_cu, per_objfile, std::move (ctx.pieces),
frame);
/* We must clean up the value chain after creating the piece
closure but before allocating the result. */
free_values.free_to_mark ();
@@ -2315,7 +2344,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
size_t n = TYPE_LENGTH (value_type (value));
size_t len = TYPE_LENGTH (subobj_type);
size_t max = TYPE_LENGTH (type);
struct gdbarch *objfile_gdbarch = objfile->arch ();
gdbarch *objfile_gdbarch = per_objfile->objfile->arch ();
if (subobj_byte_offset + len > max)
invalid_synthetic_pointer ();
@@ -2378,10 +2407,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
struct value *
dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
const gdb_byte *data, size_t size,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
return dwarf2_evaluate_loc_desc_full (type, frame, data, size, per_cu,
NULL, 0);
per_objfile, NULL, 0);
}
/* A specialization of dwarf_evaluate_loc_desc that is used by
@@ -2392,6 +2422,10 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
struct evaluate_for_locexpr_baton : public dwarf_evaluate_loc_desc
{
evaluate_for_locexpr_baton (dwarf2_per_objfile *per_objfile)
: dwarf_evaluate_loc_desc (per_objfile)
{}
/* The data that was passed in. */
gdb::array_view<const gdb_byte> data_view;
@@ -2437,12 +2471,11 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
CORE_ADDR *valp,
bool push_initial_value)
{
struct objfile *objfile;
if (dlbaton == NULL || dlbaton->size == 0)
return 0;
evaluate_for_locexpr_baton ctx;
dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
evaluate_for_locexpr_baton ctx (per_objfile);
ctx.frame = frame;
ctx.per_cu = dlbaton->per_cu;
@@ -2454,12 +2487,9 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
ctx.data_view = addr_stack->valaddr;
}
objfile = dlbaton->per_cu->objfile ();
ctx.gdbarch = objfile->arch ();
ctx.gdbarch = per_objfile->objfile->arch ();
ctx.addr_size = dlbaton->per_cu->addr_size ();
ctx.ref_addr_size = dlbaton->per_cu->ref_addr_size ();
ctx.offset = dlbaton->per_cu->text_offset ();
if (push_initial_value)
ctx.push_address (ctx.obj_address, false);
@@ -2582,7 +2612,8 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop,
if (data != NULL)
{
val = dwarf2_evaluate_loc_desc (baton->property_type, frame, data,
size, baton->loclist.per_cu);
size, baton->loclist.per_cu,
baton->loclist.per_objfile);
if (!value_optimized_out (val))
{
*value = value_as_address (val);
@@ -2642,13 +2673,15 @@ dwarf2_compile_property_to_c (string_file *stream,
= (struct dwarf2_property_baton *) prop->data.baton;
const gdb_byte *data;
size_t size;
struct dwarf2_per_cu_data *per_cu;
dwarf2_per_cu_data *per_cu;
dwarf2_per_objfile *per_objfile;
if (prop->kind == PROP_LOCEXPR)
{
data = baton->locexpr.data;
size = baton->locexpr.size;
per_cu = baton->locexpr.per_cu;
per_objfile = baton->locexpr.per_objfile;
}
else
{
@@ -2656,12 +2689,13 @@ dwarf2_compile_property_to_c (string_file *stream,
data = dwarf2_find_location_expression (&baton->loclist, &size, pc);
per_cu = baton->loclist.per_cu;
per_objfile = baton->loclist.per_objfile;
}
compile_dwarf_bounds_to_c (stream, result_name, prop, sym, pc,
gdbarch, registers_used,
per_cu->addr_size (),
data, data + size, per_cu);
data, data + size, per_cu, per_objfile);
}
@@ -2669,7 +2703,10 @@ dwarf2_compile_property_to_c (string_file *stream,
class symbol_needs_eval_context : public dwarf_expr_context
{
public:
public:
symbol_needs_eval_context (dwarf2_per_objfile *per_objfile)
: dwarf_expr_context (per_objfile)
{}
enum symbol_needs_kind needs;
struct dwarf2_per_cu_data *per_cu;
@@ -2733,7 +2770,7 @@ class symbol_needs_eval_context : public dwarf_expr_context
void dwarf_call (cu_offset die_offset) override
{
per_cu_dwarf_call (this, die_offset, per_cu);
per_cu_dwarf_call (this, die_offset, per_cu, per_objfile);
}
/* Helper interface of sect_variable_value for
@@ -2741,7 +2778,7 @@ class symbol_needs_eval_context : public dwarf_expr_context
struct value *dwarf_variable_value (sect_offset sect_off) override
{
return sect_variable_value (this, sect_off, per_cu);
return sect_variable_value (this, sect_off, per_cu, per_objfile);
}
/* DW_OP_entry_value accesses require a caller, therefore a
@@ -2779,21 +2816,20 @@ class symbol_needs_eval_context : public dwarf_expr_context
static enum symbol_needs_kind
dwarf2_loc_desc_get_symbol_read_needs (const gdb_byte *data, size_t size,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
int in_reg;
struct objfile *objfile = per_cu->objfile ();
scoped_value_mark free_values;
symbol_needs_eval_context ctx;
symbol_needs_eval_context ctx (per_objfile);
ctx.needs = SYMBOL_NEEDS_NONE;
ctx.per_cu = per_cu;
ctx.gdbarch = objfile->arch ();
ctx.gdbarch = per_objfile->objfile->arch ();
ctx.addr_size = per_cu->addr_size ();
ctx.ref_addr_size = per_cu->ref_addr_size ();
ctx.offset = per_cu->text_offset ();
ctx.eval (data, size);
@@ -2947,7 +2983,8 @@ static void
dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
unsigned int addr_size, const gdb_byte *op_ptr,
const gdb_byte *op_end,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
gdbarch *arch = expr->gdbarch;
std::vector<int> dw_labels, patches;
@@ -3034,7 +3071,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
index, not an address. We don't support things like
branching between the address and the TLS op. */
if (op_ptr >= op_end || *op_ptr != DW_OP_GNU_push_tls_address)
uoffset += per_cu->text_offset ();
uoffset += per_objfile->objfile->text_section_offset ();
ax_const_l (expr, uoffset);
break;
@@ -3225,7 +3262,8 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
dwarf2_compile_expr_to_ax (expr, loc, addr_size, datastart,
datastart + datalen, per_cu);
datastart + datalen, per_cu,
per_objfile);
if (loc->kind == axs_lvalue_register)
require_rvalue (expr, loc);
@@ -3451,7 +3489,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
/* Another expression. */
ax_const_l (expr, text_offset);
dwarf2_compile_expr_to_ax (expr, loc, addr_size, cfa_start,
cfa_end, per_cu);
cfa_end, per_cu, per_objfile);
}
loc->kind = axs_lvalue_memory;
@@ -3569,14 +3607,15 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
op_ptr += size;
cu_offset cuoffset = (cu_offset) uoffset;
block = dwarf2_fetch_die_loc_cu_off (cuoffset, per_cu,
block = dwarf2_fetch_die_loc_cu_off (cuoffset, per_cu, per_objfile,
get_ax_pc, expr);
/* DW_OP_call_ref is currently not supported. */
gdb_assert (block.per_cu == per_cu);
dwarf2_compile_expr_to_ax (expr, loc, addr_size, block.data,
block.data + block.size, per_cu);
block.data + block.size, per_cu,
per_objfile);
}
break;
@@ -3612,7 +3651,8 @@ locexpr_read_variable (struct symbol *symbol, struct frame_info *frame)
struct value *val;
val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, dlbaton->data,
dlbaton->size, dlbaton->per_cu);
dlbaton->size, dlbaton->per_cu,
dlbaton->per_objfile);
return val;
}
@@ -3641,7 +3681,8 @@ locexpr_get_symbol_read_needs (struct symbol *symbol)
= (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
return dwarf2_loc_desc_get_symbol_read_needs (dlbaton->data, dlbaton->size,
dlbaton->per_cu);
dlbaton->per_cu,
dlbaton->per_objfile);
}
/* Return true if DATA points to the end of a piece. END is one past
@@ -3683,11 +3724,12 @@ locexpr_regname (struct gdbarch *gdbarch, int dwarf_regnum)
static const gdb_byte *
locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream,
CORE_ADDR addr, struct objfile *objfile,
struct dwarf2_per_cu_data *per_cu,
CORE_ADDR addr, dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
const gdb_byte *data, const gdb_byte *end,
unsigned int addr_size)
{
objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
size_t leb128_size;
@@ -3826,7 +3868,7 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream,
uint64_t offset;
data = safe_read_uleb128 (data + 1, end, &offset);
offset = dwarf2_read_addr_index (per_cu, offset);
offset = dwarf2_read_addr_index (per_cu, per_objfile, offset);
fprintf_filtered (stream,
_("a thread-local variable at offset 0x%s "
"in the thread-local storage for `%s'"),
@@ -3859,7 +3901,8 @@ disassemble_dwarf_expression (struct ui_file *stream,
int offset_size, const gdb_byte *start,
const gdb_byte *data, const gdb_byte *end,
int indent, int all,
struct dwarf2_per_cu_data *per_cu)
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
while (data < end
&& (all
@@ -4119,7 +4162,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
data = safe_read_uleb128 (data, end, &ul);
cu_offset offset = (cu_offset) ul;
type = dwarf2_get_die_type (offset, per_cu);
type = dwarf2_get_die_type (offset, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]> %d",
@@ -4135,7 +4178,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
data = safe_read_uleb128 (data, end, &ul);
cu_offset type_die = (cu_offset) ul;
type = dwarf2_get_die_type (type_die, per_cu);
type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]>",
@@ -4159,7 +4202,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
data = safe_read_uleb128 (data, end, &ul);
cu_offset type_die = (cu_offset) ul;
type = dwarf2_get_die_type (type_die, per_cu);
type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]> [$%s]",
@@ -4182,7 +4225,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
{
struct type *type;
type = dwarf2_get_die_type (type_die, per_cu);
type = dwarf2_get_die_type (type_die, per_cu, per_objfile);
fprintf_filtered (stream, "<");
type_print (type, "", stream, -1);
fprintf_filtered (stream, " [0x%s]>",
@@ -4197,7 +4240,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
fputc_filtered ('\n', stream);
disassemble_dwarf_expression (stream, arch, addr_size, offset_size,
start, data, data + ul, indent + 2,
all, per_cu);
all, per_cu, per_objfile);
data += ul;
continue;
@@ -4210,12 +4253,12 @@ disassemble_dwarf_expression (struct ui_file *stream,
case DW_OP_addrx:
case DW_OP_GNU_addr_index:
data = safe_read_uleb128 (data, end, &ul);
ul = dwarf2_read_addr_index (per_cu, ul);
ul = dwarf2_read_addr_index (per_cu, per_objfile, ul);
fprintf_filtered (stream, " 0x%s", phex_nz (ul, addr_size));
break;
case DW_OP_GNU_const_index:
data = safe_read_uleb128 (data, end, &ul);
ul = dwarf2_read_addr_index (per_cu, ul);
ul = dwarf2_read_addr_index (per_cu, per_objfile, ul);
fprintf_filtered (stream, " %s", pulongest (ul));
break;
@@ -4252,11 +4295,13 @@ static void
locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr,
struct ui_file *stream,
const gdb_byte *data, size_t size,
struct objfile *objfile, unsigned int addr_size,
int offset_size, struct dwarf2_per_cu_data *per_cu)
unsigned int addr_size,
int offset_size, dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile)
{
const gdb_byte *end = data + size;
int first_piece = 1, bad = 0;
objfile *objfile = per_objfile->objfile;
while (data < end)
{
@@ -4271,7 +4316,7 @@ locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr,
if (!dwarf_always_disassemble)
{
data = locexpr_describe_location_piece (symbol, stream,
addr, objfile, per_cu,
addr, per_cu, per_objfile,
data, end, addr_size);
/* If we printed anything, or if we have an empty piece,
then don't disassemble. */
@@ -4288,7 +4333,7 @@ locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr,
addr_size, offset_size, data,
data, end, 0,
dwarf_always_disassemble,
per_cu);
per_cu, per_objfile);
}
if (data < end)
@@ -4348,14 +4393,13 @@ locexpr_describe_location (struct symbol *symbol, CORE_ADDR addr,
{
struct dwarf2_locexpr_baton *dlbaton
= (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
struct objfile *objfile = dlbaton->per_cu->objfile ();
unsigned int addr_size = dlbaton->per_cu->addr_size ();
int offset_size = dlbaton->per_cu->offset_size ();
locexpr_describe_location_1 (symbol, addr, stream,
dlbaton->data, dlbaton->size,
objfile, addr_size, offset_size,
dlbaton->per_cu);
addr_size, offset_size,
dlbaton->per_cu, dlbaton->per_objfile);
}
/* Describe the location of SYMBOL as an agent value in VALUE, generating
@@ -4373,7 +4417,8 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax,
value->optimized_out = 1;
else
dwarf2_compile_expr_to_ax (ax, value, addr_size, dlbaton->data,
dlbaton->data + dlbaton->size, dlbaton->per_cu);
dlbaton->data + dlbaton->size, dlbaton->per_cu,
dlbaton->per_objfile);
}
/* symbol_computed_ops 'generate_c_location' method. */
@@ -4394,7 +4439,7 @@ locexpr_generate_c_location (struct symbol *sym, string_file *stream,
compile_dwarf_expr_to_c (stream, result_name,
sym, pc, gdbarch, registers_used, addr_size,
dlbaton->data, dlbaton->data + dlbaton->size,
dlbaton->per_cu);
dlbaton->per_cu, dlbaton->per_objfile);
}
/* The set of location functions used with the DWARF-2 expression
@@ -4427,7 +4472,7 @@ loclist_read_variable (struct symbol *symbol, struct frame_info *frame)
data = dwarf2_find_location_expression (dlbaton, &size, pc);
val = dwarf2_evaluate_loc_desc (SYMBOL_TYPE (symbol), frame, data, size,
dlbaton->per_cu);
dlbaton->per_cu, dlbaton->per_objfile);
return val;
}
@@ -4485,14 +4530,15 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
struct dwarf2_loclist_baton *dlbaton
= (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
const gdb_byte *loc_ptr, *buf_end;
struct objfile *objfile = dlbaton->per_cu->objfile ();
dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = dlbaton->per_cu->addr_size ();
int offset_size = dlbaton->per_cu->offset_size ();
int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd);
/* Adjust base_address for relocatable objects. */
CORE_ADDR base_offset = dlbaton->per_cu->text_offset ();
CORE_ADDR base_offset = objfile->text_section_offset ();
CORE_ADDR base_address = dlbaton->base_address + base_offset;
int done = 0;
@@ -4511,6 +4557,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
if (dlbaton->per_cu->version () < 5 && dlbaton->from_dwo)
kind = decode_debug_loc_dwo_addresses (dlbaton->per_cu,
dlbaton->per_objfile,
loc_ptr, buf_end, &new_ptr,
&low, &high, byte_order);
else if (dlbaton->per_cu->version () < 5)
@@ -4520,6 +4567,7 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
signed_addr_p);
else
kind = decode_debug_loclists_addresses (dlbaton->per_cu,
dlbaton->per_objfile,
loc_ptr, buf_end, &new_ptr,
&low, &high, byte_order,
addr_size, signed_addr_p);
@@ -4572,8 +4620,8 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
/* Now describe this particular location. */
locexpr_describe_location_1 (symbol, low, stream, loc_ptr, length,
objfile, addr_size, offset_size,
dlbaton->per_cu);
addr_size, offset_size,
dlbaton->per_cu, dlbaton->per_objfile);
fprintf_filtered (stream, "\n");
@@ -4598,7 +4646,7 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax,
value->optimized_out = 1;
else
dwarf2_compile_expr_to_ax (ax, value, addr_size, data, data + size,
dlbaton->per_cu);
dlbaton->per_cu, dlbaton->per_objfile);
}
/* symbol_computed_ops 'generate_c_location' method. */
@@ -4622,7 +4670,8 @@ loclist_generate_c_location (struct symbol *sym, string_file *stream,
compile_dwarf_expr_to_c (stream, result_name,
sym, pc, gdbarch, registers_used, addr_size,
data, data + size,
dlbaton->per_cu);
dlbaton->per_cu,
dlbaton->per_objfile);
}
/* The set of location functions used with the DWARF-2 expression

View File

@@ -23,7 +23,7 @@
#include "dwarf2/expr.h"
struct symbol_computed_ops;
struct objfile;
struct dwarf2_per_objfile;
struct dwarf2_per_cu_data;
struct dwarf2_loclist_baton;
struct agent_expr;
@@ -61,7 +61,8 @@ struct value *dwarf2_evaluate_loc_desc (struct type *type,
struct frame_info *frame,
const gdb_byte *data,
size_t size,
struct dwarf2_per_cu_data *per_cu);
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
/* A chain of addresses that might be needed to resolve a dynamic
property. */
@@ -146,6 +147,9 @@ struct dwarf2_locexpr_baton
directly. */
bool is_reference;
/* The objfile that was used when creating this. */
dwarf2_per_objfile *per_objfile;
/* The compilation unit containing the symbol whose location
we're computing. */
struct dwarf2_per_cu_data *per_cu;
@@ -163,6 +167,9 @@ struct dwarf2_loclist_baton
/* Length of the location list. */
size_t size;
/* The objfile that was used when creating this. */
dwarf2_per_objfile *per_objfile;
/* The compilation unit containing the symbol whose location
we're computing. */
struct dwarf2_per_cu_data *per_cu;

View File

@@ -507,14 +507,14 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
|| section_is_dwz)
{
struct dwz_file *dwz
= dwarf2_get_dwz_file (dwarf2_per_objfile);
= dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
body = dwz->read_string (objfile, str_offset);
}
else
body = dwarf2_per_objfile->str.read_string (objfile,
str_offset,
"DW_FORM_strp");
body = dwarf2_per_objfile->per_bfd->str.read_string (objfile,
str_offset,
"DW_FORM_strp");
}
is_define = (macinfo_type == DW_MACRO_define
@@ -644,7 +644,8 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (macinfo_type == DW_MACRO_import_sup)
{
struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
struct dwz_file *dwz
= dwarf2_get_dwz_file (dwarf2_per_objfile->per_bfd);
dwz->macro.read (objfile);

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,7 @@
#include <queue>
#include <unordered_map>
#include "dwarf2/comp-unit.h"
#include "dwarf2/index-cache.h"
#include "dwarf2/section.h"
#include "filename-seen-cache.h"
@@ -42,18 +43,22 @@ struct tu_stats
int nr_all_type_units_reallocs;
};
struct dwarf2_cu;
struct dwarf2_debug_sections;
struct dwarf2_per_cu_data;
struct mapped_index;
struct mapped_debug_names;
struct signatured_type;
struct type_unit_group;
/* One item on the queue of compilation units to read in full symbols
for. */
struct dwarf2_queue_item
{
dwarf2_queue_item (dwarf2_per_cu_data *cu, enum language lang)
dwarf2_queue_item (dwarf2_per_cu_data *cu, dwarf2_per_objfile *per_objfile,
enum language lang)
: per_cu (cu),
per_objfile (per_objfile),
pretend_language (lang)
{
}
@@ -62,36 +67,39 @@ struct dwarf2_queue_item
DISABLE_COPY_AND_ASSIGN (dwarf2_queue_item);
struct dwarf2_per_cu_data *per_cu;
dwarf2_per_cu_data *per_cu;
dwarf2_per_objfile *per_objfile;
enum language pretend_language;
};
/* Collection of data recorded per objfile.
This hangs off of dwarf2_objfile_data_key. */
/* Some DWARF data can be shared across objfiles who share the same BFD,
this data is stored in this object.
struct dwarf2_per_objfile
Two dwarf2_per_objfile objects representing objfiles sharing the same BFD
will point to the same instance of dwarf2_per_bfd, unless the BFD requires
relocation. */
struct dwarf2_per_bfd
{
/* Construct a dwarf2_per_objfile for OBJFILE. NAMES points to the
/* Construct a dwarf2_per_bfd for OBFD. NAMES points to the
dwarf2 section names, or is NULL if the standard ELF names are
used. CAN_COPY is true for formats where symbol
interposition is possible and so symbol values must follow copy
relocation rules. */
dwarf2_per_objfile (struct objfile *objfile,
const dwarf2_debug_sections *names,
bool can_copy);
dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, bool can_copy);
~dwarf2_per_objfile ();
~dwarf2_per_bfd ();
DISABLE_COPY_AND_ASSIGN (dwarf2_per_objfile);
DISABLE_COPY_AND_ASSIGN (dwarf2_per_bfd);
/* Return the CU/TU given its index.
This is intended for loops like:
for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+ dwarf2_per_objfile->n_type_units); ++i)
for (i = 0; i < (dwarf2_per_bfd->n_comp_units
+ dwarf2_per_bfd->n_type_units); ++i)
{
dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->get_cutu (i);
dwarf2_per_cu_data *per_cu = dwarf2_per_bfd->get_cutu (i);
...;
}
@@ -108,15 +116,20 @@ struct dwarf2_per_objfile
TU. */
signatured_type *get_tu (int index);
/* Free all cached compilation units. */
void free_cached_comp_units ();
/* A convenience function to allocate a dwarf2_per_cu_data. The
returned object has its "index" field set properly. The object
is allocated on the dwarf2_per_bfd obstack. */
dwarf2_per_cu_data *allocate_per_cu ();
/* Return pointer to string at .debug_line_str offset as read from BUF.
BUF is assumed to be in a compilation unit described by CU_HEADER.
Return *BYTES_READ_PTR count of bytes read from BUF. */
const char *read_line_string (const gdb_byte *buf,
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr);
/* A convenience function to allocate a signatured_type. The
returned object has its "index" field set properly. The object
is allocated on the dwarf2_per_bfd obstack. */
signatured_type *allocate_signatured_type ();
/* Return the number of partial symtabs allocated with allocate_per_cu
and allocate_signatured_type so far. */
int num_psymtabs () const
{ return m_num_psymtabs; }
private:
/* This function is mapped across the sections and remembers the
@@ -126,6 +139,14 @@ private:
const dwarf2_debug_sections &names);
public:
/* The corresponding BFD. */
bfd *obfd;
/* Objects that can be shared across objfiles are stored in this
obstack or on the psymtab obstack, while objects that are
objfile-specific are stored on the objfile obstack. */
auto_obstack obstack;
dwarf2_section_info info {};
dwarf2_section_info abbrev {};
dwarf2_section_info line {};
@@ -147,9 +168,6 @@ public:
std::vector<dwarf2_section_info> types;
/* Back link. */
struct objfile *objfile = NULL;
/* Table of all the compilation units. This is used to locate
the target compilation unit of a particular reference. */
std::vector<dwarf2_per_cu_data *> all_comp_units;
@@ -169,10 +187,6 @@ public:
are doing. */
struct tu_stats tu_stats {};
/* A chain of compilation units that are currently read in, so that
they can be freed later. */
dwarf2_per_cu_data *read_in_chain = NULL;
/* A table mapping DW_AT_dwo_name values to struct dwo_file objects.
This is NULL if the table hasn't been allocated yet. */
htab_up dwo_files;
@@ -217,11 +231,6 @@ public:
symbols. */
bool reading_partial_symbols = false;
/* Table mapping type DIEs to their struct type *.
This is NULL if not allocated yet.
The mapping is done via (CU/TU + DIE offset) -> type. */
htab_up die_type_hash;
/* The CUs we recently read. */
std::vector<dwarf2_per_cu_data *> just_read_cus;
@@ -244,6 +253,146 @@ public:
/* CUs that are queued to be read. */
std::queue<dwarf2_queue_item> queue;
/* We keep a separate reference to the partial symtabs, in case we
are sharing them between objfiles. This is only set after
partial symbols have been read the first time. */
std::shared_ptr<psymtab_storage> partial_symtabs;
private:
/* The total number of per_cu and signatured_type objects that have
been created so far for this reader. */
size_t m_num_psymtabs = 0;
};
/* This is the per-objfile data associated with a type_unit_group. */
struct type_unit_group_unshareable
{
/* The compunit symtab.
Type units in a group needn't all be defined in the same source file,
so we create an essentially anonymous symtab as the compunit symtab. */
struct compunit_symtab *compunit_symtab = nullptr;
/* The number of symtabs from the line header.
The value here must match line_header.num_file_names. */
unsigned int num_symtabs = 0;
/* The symbol tables for this TU (obtained from the files listed in
DW_AT_stmt_list).
WARNING: The order of entries here must match the order of entries
in the line header. After the first TU using this type_unit_group, the
line header for the subsequent TUs is recreated from this. This is done
because we need to use the same symtabs for each TU using the same
DW_AT_stmt_list value. Also note that symtabs may be repeated here,
there's no guarantee the line header doesn't have duplicate entries. */
struct symtab **symtabs = nullptr;
};
/* Collection of data recorded per objfile.
This hangs off of dwarf2_objfile_data_key.
Some DWARF data cannot (currently) be shared across objfiles. Such
data is stored in this object. */
struct dwarf2_per_objfile
{
dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd)
: objfile (objfile), per_bfd (per_bfd)
{}
~dwarf2_per_objfile ();
/* Return pointer to string at .debug_line_str offset as read from BUF.
BUF is assumed to be in a compilation unit described by CU_HEADER.
Return *BYTES_READ_PTR count of bytes read from BUF. */
const char *read_line_string (const gdb_byte *buf,
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr);
/* Resize the M_SYMTABS vector to the needed size (the number of partial
symtabs allocated by the per-bfd). */
void resize_symtabs ()
{
/* The symtabs vector should only grow, not shrink. */
gdb_assert (per_bfd->num_psymtabs () >= m_symtabs.size ());
m_symtabs.resize (per_bfd->num_psymtabs ());
}
/* Return true if the symtab corresponding to PER_CU has been set,
false otherwise. */
bool symtab_set_p (const dwarf2_per_cu_data *per_cu) const;
/* Return the compunit_symtab associated to PER_CU, if it has been created. */
compunit_symtab *get_symtab (const dwarf2_per_cu_data *per_cu) const;
/* Set the compunit_symtab associated to PER_CU. */
void set_symtab (const dwarf2_per_cu_data *per_cu, compunit_symtab *symtab);
/* Get the type_unit_group_unshareable corresponding to TU_GROUP. If one
does not exist, create it. */
type_unit_group_unshareable *get_type_unit_group_unshareable
(type_unit_group *tu_group);
struct type *get_type_for_signatured_type (signatured_type *sig_type) const;
void set_type_for_signatured_type (signatured_type *sig_type,
struct type *type);
/* Find an integer type SIZE_IN_BYTES bytes in size and return it.
UNSIGNED_P controls if the integer is unsigned or not. */
struct type *int_type (int size_in_bytes, bool unsigned_p) const;
/* Get the dwarf2_cu matching PER_CU for this objfile. */
dwarf2_cu *get_cu (dwarf2_per_cu_data *per_cu);
/* Set the dwarf2_cu matching PER_CU for this objfile. */
void set_cu (dwarf2_per_cu_data *per_cu, dwarf2_cu *cu);
/* Remove/free the dwarf2_cu matching PER_CU for this objfile. */
void remove_cu (dwarf2_per_cu_data *per_cu);
/* Free all cached compilation units. */
void remove_all_cus ();
/* Increase the age counter on each CU compilation unit and free
any that are too old. */
void age_comp_units ();
/* Back link. */
struct objfile *objfile;
/* Pointer to the data that is (possibly) shared between this objfile and
other objfiles backed by the same BFD. */
struct dwarf2_per_bfd *per_bfd;
/* Table mapping type DIEs to their struct type *.
This is nullptr if not allocated yet.
The mapping is done via (CU/TU + DIE offset) -> type. */
htab_up die_type_hash;
private:
/* Hold the corresponding compunit_symtab for each CU or TU. This
is indexed by dwarf2_per_cu_data::index. A NULL value means
that the CU/TU has not been expanded yet. */
std::vector<compunit_symtab *> m_symtabs;
/* Map from a type unit group to the corresponding unshared
structure. */
typedef std::unique_ptr<type_unit_group_unshareable>
type_unit_group_unshareable_up;
std::unordered_map<type_unit_group *, type_unit_group_unshareable_up>
m_type_units;
/* Map from signatured types to the corresponding struct type. */
std::unordered_map<signatured_type *, struct type *> m_type_map;
/* Map from the objfile-independent dwarf2_per_cu_data instances to the
corresponding objfile-dependent dwarf2_cu instances. */
std::unordered_map<dwarf2_per_cu_data *, dwarf2_cu *> m_dwarf2_cus;
};
/* Get the dwarf2_per_objfile associated to OBJFILE. */
@@ -251,17 +400,19 @@ public:
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
/* A partial symtab specialized for DWARF. */
struct dwarf2_psymtab : public standard_psymtab
struct dwarf2_psymtab : public partial_symtab
{
dwarf2_psymtab (const char *filename, struct objfile *objfile,
dwarf2_per_cu_data *per_cu)
: standard_psymtab (filename, objfile, 0),
: partial_symtab (filename, objfile, 0),
per_cu_data (per_cu)
{
}
void read_symtab (struct objfile *) override;
void expand_psymtab (struct objfile *) override;
bool readin_p (struct objfile *) const override;
compunit_symtab *get_compunit_symtab (struct objfile *) const override;
struct dwarf2_per_cu_data *per_cu_data;
};
@@ -317,26 +468,39 @@ struct dwarf2_per_cu_data
This flag is only valid if is_debug_types is true. */
unsigned int tu_read : 1;
/* Our index in the unshared "symtabs" vector. */
unsigned index;
/* The section this CU/TU lives in.
If the DIE refers to a DWO file, this is always the original die,
not the DWO file. */
struct dwarf2_section_info *section;
/* Set to non-NULL iff this CU is currently loaded. When it gets freed out
of the CU cache it gets reset to NULL again. This is left as NULL for
dummy CUs (a CU header, but nothing else). */
struct dwarf2_cu *cu;
/* The unit type of this CU. */
enum dwarf_unit_type unit_type;
/* The language of this CU. */
enum language lang;
/* The corresponding dwarf2_per_objfile. */
struct dwarf2_per_objfile *dwarf2_per_objfile;
/* Backlink to the owner of this. */
dwarf2_per_bfd *per_bfd;
/* When dwarf2_per_objfile->using_index is true, the 'quick' field
/* DWARF header of this CU. Note that dwarf2_cu reads its own version of the
header, which may differ from this one, since it may pass rcuh_kind::TYPE
to read_comp_unit_head, whereas for dwarf2_per_cu_data we always pass
rcuh_kind::COMPILE.
Don't access this field directly, use the get_header method instead. It
should be private, but we can't make it private at the moment. */
mutable comp_unit_head m_header;
/* True if HEADER has been read in.
Don't access this field directly. It should be private, but we can't make
it private at the moment. */
mutable bool m_header_read_in;
/* When dwarf2_per_bfd::using_index is true, the 'quick' field
is active. Otherwise, the 'psymtab' field is active. */
union
{
@@ -405,10 +569,8 @@ struct dwarf2_per_cu_data
imported_symtabs = nullptr;
}
/* Return the OBJFILE associated with this compilation unit. If
this compilation unit came from a separate debuginfo file, then
the master objfile is returned. */
struct objfile *objfile () const;
/* Get the header of this per_cu, reading it if necessary. */
const comp_unit_head *get_header () const;
/* Return the address size given in the compilation unit header for
this CU. */
@@ -422,26 +584,6 @@ struct dwarf2_per_cu_data
header for this CU. */
int ref_addr_size () const;
/* Return the text offset of the CU. The returned offset comes from
this CU's objfile. If this objfile came from a separate
debuginfo file, then the offset may be different from the
corresponding offset in the parent objfile. */
CORE_ADDR text_offset () const;
/* Return a type that is a generic pointer type, the size of which
matches the address size given in the compilation unit header for
this CU. */
struct type *addr_type () const;
/* Find an integer type SIZE_IN_BYTES bytes in size and return it.
UNSIGNED_P controls if the integer is unsigned or not. */
struct type *int_type (int size_in_bytes, bool unsigned_p) const;
/* Find an integer type the same size as the address size given in
the compilation unit header for this CU. UNSIGNED_P controls if
the integer is unsigned or not. */
struct type *addr_sized_int_type (bool unsigned_p) const;
/* Return DWARF version number of this CU. */
short version () const
{
@@ -485,11 +627,6 @@ struct signatured_type
can share them. This points to the containing symtab. */
struct type_unit_group *type_unit_group;
/* The type.
The first time we encounter this type we fully read it in and install it
in the symbol tables. Subsequent times we only need the type. */
struct type *type;
/* Containing DWO unit.
This field is valid iff per_cu.reading_dwo_directly. */
struct dwo_unit *dwo_unit;
@@ -499,14 +636,14 @@ struct signatured_type
there is no .gnu_debugaltlink section in the file. Error if there
is such a section but the file cannot be found. */
extern struct dwz_file *dwarf2_get_dwz_file
(struct dwarf2_per_objfile *dwarf2_per_objfile);
extern dwz_file *dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd);
/* Return the type of the DIE at DIE_OFFSET in the CU named by
PER_CU. */
struct type *dwarf2_get_die_type (cu_offset die_offset,
struct dwarf2_per_cu_data *per_cu);
dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
/* Given an index in .debug_addr, fetch the value.
NOTE: This can be called during dwarf expression evaluation,
@@ -514,6 +651,7 @@ struct type *dwarf2_get_die_type (cu_offset die_offset,
may no longer exist. */
CORE_ADDR dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *dwarf2_per_objfile,
unsigned int addr_index);
/* Return DWARF block referenced by DW_AT_location of DIE at SECT_OFF at PER_CU.
@@ -523,6 +661,7 @@ CORE_ADDR dwarf2_read_addr_index (dwarf2_per_cu_data *per_cu,
struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off
(sect_offset sect_off, dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
CORE_ADDR (*get_frame_pc) (void *baton),
void *baton, bool resolve_abstract_p = false);
@@ -531,6 +670,7 @@ struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_sect_off
struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off
(cu_offset offset_in_cu, dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
CORE_ADDR (*get_frame_pc) (void *baton),
void *baton);
@@ -540,14 +680,16 @@ struct dwarf2_locexpr_baton dwarf2_fetch_die_loc_cu_off
does not have a DW_AT_const_value, return NULL. */
extern const gdb_byte *dwarf2_fetch_constant_bytes
(sect_offset sect_off, dwarf2_per_cu_data *per_cu, obstack *obstack,
(sect_offset sect_off, dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile, obstack *obstack,
LONGEST *len);
/* Return the type of the die at SECT_OFF in PER_CU. Return NULL if no
valid type for this die is found. */
struct type *dwarf2_fetch_die_type_sect_off
(sect_offset sect_off, dwarf2_per_cu_data *per_cu);
(sect_offset sect_off, dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile);
/* When non-zero, dump line number entries as they are read in. */
extern unsigned int dwarf_line_debug;

View File

@@ -58,6 +58,8 @@ struct field;
struct block;
struct value_print_options;
struct language_defn;
struct dwarf2_per_cu_data;
struct dwarf2_per_objfile;
/* These declarations are DWARF-specific as some of the gdbtypes.h data types
are already DWARF-specific. */
@@ -1333,7 +1335,11 @@ struct call_site
/* * CU of the function where the call is located. It gets used
for DWARF blocks execution in the parameter array below. */
struct dwarf2_per_cu_data *per_cu;
dwarf2_per_cu_data *per_cu;
/* objfile of the function where the call is located. */
dwarf2_per_objfile *per_objfile;
/* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */

View File

@@ -576,7 +576,7 @@ public:
/* The partial symbol tables. */
std::unique_ptr<psymtab_storage> partial_symtabs;
std::shared_ptr<psymtab_storage> partial_symtabs;
/* The object file's BFD. Can be null if the objfile contains only
minimal symbols, e.g. the run time common symbols for SunOS4. */

View File

@@ -147,13 +147,16 @@ struct partial_symtab
void expand_dependencies (struct objfile *);
/* Return true if the symtab corresponding to this psymtab has been
readin. */
virtual bool readin_p () const = 0;
read in in the context of this objfile. */
virtual bool readin_p (struct objfile *) const = 0;
/* Return a pointer to the compunit allocated for this source file.
Return nullptr if !readin or if there was no symtab. */
virtual struct compunit_symtab *get_compunit_symtab () const = 0;
/* Return a pointer to the compunit allocated for this source file
in the context of this objfile.
Return nullptr if the compunit was not read in or if there was no
symtab. */
virtual struct compunit_symtab *get_compunit_symtab
(struct objfile *) const = 0;
/* Return the raw low text address of this partial_symtab. */
CORE_ADDR raw_text_low () const
@@ -319,14 +322,12 @@ struct standard_psymtab : public partial_symtab
{
}
bool readin_p () const override
bool readin_p (struct objfile *) const override
{
return readin;
}
/* Return a pointer to the compunit allocated for this source file.
Return nullptr if !readin or if there was no symtab. */
struct compunit_symtab *get_compunit_symtab () const override
struct compunit_symtab *get_compunit_symtab (struct objfile *) const override
{
return compunit_symtab;
}

View File

@@ -132,7 +132,7 @@ partial_map_expand_apply (struct objfile *objfile,
gdb_assert (pst->user == NULL);
/* Don't visit already-expanded psymtabs. */
if (pst->readin_p ())
if (pst->readin_p (objfile))
return 0;
/* This may expand more than one symtab, and we want to iterate over
@@ -384,7 +384,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
msymbol);
if (ps != NULL)
{
if (warn_if_readin && ps->readin_p ())
if (warn_if_readin && ps->readin_p (objfile))
/* Might want to error() here (in case symtab is corrupt and
will cause a core dump), but maybe we can successfully
continue, so let's not. */
@@ -392,7 +392,7 @@ psym_find_pc_sect_compunit_symtab (struct objfile *objfile,
(Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
paddress (objfile->arch (), pc));
psymtab_to_symtab (objfile, ps);
return ps->get_compunit_symtab ();
return ps->get_compunit_symtab (objfile);
}
return NULL;
}
@@ -485,9 +485,9 @@ psym_lookup_symbol (struct objfile *objfile,
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
if (!ps->readin_p () && lookup_partial_symbol (objfile, ps,
psym_lookup_name,
psymtab_index, domain))
if (!ps->readin_p (objfile)
&& lookup_partial_symbol (objfile, ps, psym_lookup_name,
psymtab_index, domain))
{
struct symbol *sym, *with_opaque = NULL;
struct compunit_symtab *stab = psymtab_to_symtab (objfile, ps);
@@ -535,7 +535,7 @@ psym_lookup_global_symbol_language (struct objfile *objfile, const char *name,
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
struct partial_symbol *psym;
if (ps->readin_p ())
if (ps->readin_p (objfile))
continue;
psym = lookup_partial_symbol (objfile, ps, lookup_name, 1, domain);
@@ -748,11 +748,11 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
pst = pst->user;
/* If it's been looked up before, return it. */
if (pst->get_compunit_symtab ())
return pst->get_compunit_symtab ();
if (pst->get_compunit_symtab (objfile))
return pst->get_compunit_symtab (objfile);
/* If it has not yet been read in, read it. */
if (!pst->readin_p ())
if (!pst->readin_p (objfile))
{
scoped_restore decrementer = increment_reading_symtab ();
@@ -766,7 +766,7 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
pst->read_symtab (objfile);
}
return pst->get_compunit_symtab ();
return pst->get_compunit_symtab (objfile);
}
/* Psymtab version of find_last_source_symtab. See its definition in
@@ -789,7 +789,7 @@ psym_find_last_source_symtab (struct objfile *ofp)
if (cs_pst)
{
if (cs_pst->readin_p ())
if (cs_pst->readin_p (ofp))
{
internal_error (__FILE__, __LINE__,
_("select_source_symtab: "
@@ -946,11 +946,11 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
gdb_print_host_address (objfile, outfile);
fprintf_filtered (outfile, ")\n");
if (psymtab->readin_p ())
if (psymtab->readin_p (objfile))
{
fprintf_filtered (outfile,
" Full symtab was read (at ");
gdb_print_host_address (psymtab->get_compunit_symtab (), outfile);
gdb_print_host_address (psymtab->get_compunit_symtab (objfile), outfile);
fprintf_filtered (outfile, ")\n");
}
@@ -1004,7 +1004,7 @@ psym_print_stats (struct objfile *objfile)
i = 0;
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
if (!ps->readin_p ())
if (!ps->readin_p (objfile))
i++;
}
printf_filtered (_(" Number of psym tables (not yet expanded): %d\n"), i);
@@ -1047,7 +1047,7 @@ psym_expand_symtabs_for_function (struct objfile *objfile,
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
if (ps->readin_p ())
if (ps->readin_p (objfile))
continue;
if ((lookup_partial_symbol (objfile, ps, lookup_name, 1, VAR_DOMAIN)
@@ -1102,7 +1102,7 @@ psym_map_symbol_filenames (struct objfile *objfile,
{
const char *fullname;
if (ps->readin_p ())
if (ps->readin_p (objfile))
continue;
/* We can skip shared psymtabs here, because any file name will be
@@ -1182,7 +1182,7 @@ psym_map_matching_symbols
for (partial_symtab *ps : require_partial_symbols (objfile, true))
{
QUIT;
if (ps->readin_p ()
if (ps->readin_p (objfile)
|| match_partial_symbol (objfile, ps, global, name, domain,
ordered_compare))
{
@@ -1315,7 +1315,7 @@ psym_expand_symtabs_matching
{
QUIT;
if (ps->readin_p ())
if (ps->readin_p (objfile))
continue;
/* We skip shared psymtabs because file-matching doesn't apply
@@ -1717,7 +1717,7 @@ partial_symtab::expand_dependencies (struct objfile *objfile)
{
for (int i = 0; i < number_of_dependencies; ++i)
{
if (!dependencies[i]->readin_p ()
if (!dependencies[i]->readin_p (objfile)
&& dependencies[i]->user == NULL)
{
/* Inform about additional files to be read in. */
@@ -2028,7 +2028,7 @@ maintenance_info_psymtabs (const char *regexp, int from_tty)
host_address_to_string (psymtab));
printf_filtered (" readin %s\n",
psymtab->readin_p () ? "yes" : "no");
psymtab->readin_p (objfile) ? "yes" : "no");
printf_filtered (" fullname %s\n",
psymtab->fullname
? psymtab->fullname : "(null)");
@@ -2124,7 +2124,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
/* We don't call psymtab_to_symtab here because that may cause symtab
expansion. When debugging a problem it helps if checkers leave
things unchanged. */
cust = ps->get_compunit_symtab ();
cust = ps->get_compunit_symtab (objfile);
/* First do some checks that don't require the associated symtab. */
if (ps->text_high (objfile) < ps->text_low (objfile))