Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
Change-Id: I8dc26d4db021e0b9e9306eb033965b2704bba87c
|
|
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.
Change-Id: I3db2a780f0e2157d52ce6939f478558ffe20abcf
|
|
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.
Change-Id: Ibd7bbc443df8b9b8b6f96ff18e93a60ee721b85f
|
|
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.
Change-Id: I1e1c1870820aec23701edc9c3994612da5781c23
|
|
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.
Change-Id: Ifb23f55dda93c499aae57b6a9aff9c6ff9d2f45f
|
|
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.
Change-Id: I4ba0a393e64a14489ef061261a3dede1509d055b
|
|
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.
Change-Id: I00f44e88295f70ae805a4b18e8144ca92154612e
|
|
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.
Change-Id: I248300822a09bae8470b65a7122d04fb9cb2b5bc
|
|
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.
Change-Id: I8fd0da7371f65baea1ea7787aad08e10453bc565
|
|
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.
Change-Id: I3589777ed3579bcabafd2ba859d27babe4502bfb
|
|
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.
gdb/ChangeLog:
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
Change-Id: Iec53d96e0b70a57d8b68408febdac3c6c3d4854b
|
|
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.
Change-Id: I7de7b5d1ce7494aa73bfcf15f719d3c5c46e138c
|
|
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.
gdb/ChangeLog:
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,
handle_data_member_location): Set per_objfile member.
* dwarf2/loc.h (struct dwarf2_locexpr_baton) <per_objfile>: New
member.
(struct dwarf2_loclist_baton) <per_objfile>: New member.
Change-Id: If3aaa6a0f544be86710157c3adb68fde24d80037
|
|
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.
gdb/ChangeLog:
* 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.
Change-Id: I7733479a38ce82a5015cb184c8acce5f8bbf2e69
|
|
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.
gdb/ChangeLog:
* 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.
Change-Id: I3f0b26787c3e78f7fb78b9fc011d91fb8690f3a0
|
|
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.
gdb/ChangeLog:
* 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.
Change-Id: Icdec7be7c4d9f33d1dce4f807284f3077f7d3f03
|
|
Replace all uses of it by type::field.
Note that since type::field returns a reference to the field, some spots
are used to assign the whole field structure. See ctfread.c, function
attach_fields_to_type, for example. This is the same as was happening
with the macro, so I don't think it's a problem, but if anybody sees a
really nicer way to do this, now could be a good time to implement it.
gdb/ChangeLog:
* gdbtypes.h (TYPE_FIELD): Remove. Replace all uses with
type::field.
|
|
Remove all uses of the `TYPE_FIELDS` macro. Replace them with either:
1) type::fields, to obtain a pointer to the fields array (same as
TYPE_FIELDS yields)
2) type::field, a new convenience method that obtains a reference to one
of the type's field by index. It is meant to replace
TYPE_FIELDS (type)[idx]
with
type->field (idx)
gdb/ChangeLog:
* gdbtypes.h (struct type) <field>: New method.
(TYPE_FIELDS): Remove, replace all uses with either type::fields
or type::field.
Change-Id: I49fba10114417deb502060c6156aa5f7fc62462f
|
|
Add the `fields` and `set_fields` methods on `struct type`, in order to
remove the `TYPE_FIELDS` macro. In this patch, the `TYPE_FIELDS` macro
is changed to the `type::fields`, so all the call sites that use it to
set the fields array are changed to use `type::set_fields`. The next
patch will remove `TYPE_FIELDS` entirely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <fields, set_fields>: New methods.
(TYPE_FIELDS): Use type::fields. Change all call sites that
modify the propery to use type::set_fields instead.
Change-Id: I05174ce68f2ce3fccdf5d8b469ff141f14886b33
|
|
Remove `TYPE_NFIELDS`, changing all the call sites to use
`type::num_fields` directly. This is quite a big diff, but this was
mostly done using sed and coccinelle. A few call sites were done by
hand.
gdb/ChangeLog:
* gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use
type::num_fields instead.
Change-Id: Ib73be4c36f9e770e0f729bac3b5257d7cb2f9591
|
|
Add the `num_fields` and `set_num_fields` methods on `struct type`, in
order to remove the `TYPE_NFIELDS` macro. In this patch, the
`TYPE_NFIELDS` macro is changed to use `type::num_fields`, so all the
call sites that are used to set the number of fields are changed to use
`type::set_num_fields`. The next patch will remove `TYPE_NFIELDS`
completely.
I think that in the future, we should consider making the interface of
`struct type` better. For example, right now it's possible for the
number of fields property and the actual number of fields set to be out
of sync. However, I want to keep the existing behavior in this patch,
just translate from macros to methods.
gdb/ChangeLog:
* gdbtypes.h (struct type) <num_fields, set_num_fields>: New
methods.
(TYPE_NFIELDS): Use type::num_fields. Change all call sites
that modify the number of fields to use type::set_num_fields
instead.
Change-Id: I5ad9de5be4097feaf942d111077434bf91d13dc5
|
|
When running test-case gdb.base/with.exp with target board cc-with-gdb-index,
we have:
...
(gdb) PASS: gdb.base/with.exp: basics: show language
with language ada -- print g_s^M
'g_s' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/with.exp: basics: with language ada -- print g_s
...
This is due to this bit in dw2_map_matching_symbols:
...
if (dwarf2_per_objfile->index_table != nullptr)
{
/* Ada currently doesn't support .gdb_index (see PR24713). We can get
here though if the current language is Ada for a non-Ada objfile
using GNU index. As Ada does not look for non-Ada symbols this
function should just return. */
return;
}
...
While the reasoning in the comment may be sound from language perspective, it
does introduce an inconsistency in gdb behaviour between:
- having a .gdb_index section, and
- having a .gdb_names section, or a partial symtab, or -readnow.
Fix the inconsistency by completing implementation of
dw2_map_matching_symbols.
Tested on x86_64-linux, both with native and target board
cc-with-debug-index.
gdb/ChangeLog:
2020-05-20 Tom de Vries <tdevries@suse.de>
PR symtab/25833
* dwarf2/read.c (dw2_map_matching_symbols): Handle .gdb_index.
gdb/testsuite/ChangeLog:
2020-05-20 Tom de Vries <tdevries@suse.de>
PR symtab/25833
* gdb.base/with-mf-inc.c: New test.
* gdb.base/with-mf-main.c: New test.
* gdb.base/with-mf.exp: New file.
|
|
This patch makes gdb use the inline accessor for all bfd->filename
read accesses.
* coff-pe-read.c (read_pe_exported_syms): Use bfd_get_filename
rather than accessing bfd->filename directly.
* dtrace-probe.c (dtrace_static_probe_ops::get_probes): Likewise,
and use bfd_section_name.
* dwarf2/frame.c (decode_frame_entry): Likewise.
* exec.c (exec_set_section_address): Likewise.
* solib-aix.c (solib_aix_bfd_open): Likewise.
* stap-probe.c (get_stap_base_address): Likewise.
* symfile.c (reread_symbols): Likewise.
|
|
Found by inspection, so I don't have a test for it (I don't think it
would be easy to have this bug cause a failure reliably).
We allocate space for N fields into `new_fields`, then memcpy N fields
at `new_fields + 1`. This overflows the allocated buffer by one field.
Fix it by allocating `N + 1` fields.
gdb/ChangeLog:
* dwarf2/read.c (quirk_rust_enum): Allocate enough fields.
|
|
A following patch will add one more defaulted parameter.
gdb/ChangeLog:
2020-05-19 Pedro Alves <palves@redhat.com>
* gdb_bfd.h: (gdb_bfd_open): Default to 'fd' parameter to -1.
Adjust all callers.
|
|
Remove `TYPE_NAME`, changing all the call sites to use `type::name`
directly. This is quite a big diff, but this was mostly done using sed
and coccinelle. A few call sites were done by hand.
gdb/ChangeLog:
* gdbtypes.h (TYPE_NAME): Remove. Change all cal sites to use
type::name instead.
|
|
Add the `name` and `set_name` methods on `struct type`, in order to
remove the `TYPE_NAME` macro. In this patch, the `TYPE_NAME` macro is
changed to use `type::name`, so all the call sites that are used to set
the type name are changed to use `type::set_name`. The next patch will
remove `TYPE_NAME` completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <name, set_name>: New methods.
(TYPE_CODE): Use type::name. Change all call sites used to set
the name to use type::set_name instead.
|
|
This removes allocate_symbol, allocate_template_symbol, and
initialize_objfile_symbol in favor of changing the default values for
symbol members, and updating the one per-arch caller.
gdb/ChangeLog
2020-05-15 Tom Tromey <tom@tromey.com>
* language.c (language_alloc_type_symbol): Set
SYMBOL_SECTION.
* symtab.c (initialize_objfile_symbol): Remove.
(allocate_symbol): Remove.
(allocate_template_symbol): Remove.
* dwarf2/read.c (fixup_go_packaging): Use "new".
(new_symbol): Use "new".
(read_variable): Don't call initialize_objfile_symbol. Use
"new".
(read_func_scope): Use "new".
* xcoffread.c (process_xcoff_symbol): Don't call
initialize_objfile_symbol.
(SYMBOL_DUP): Remove.
* coffread.c (process_coff_symbol, coff_read_enum_type): Use
"new".
* symtab.h (allocate_symbol, initialize_objfile_symbol)
(allocate_template_symbol): Don't declare.
(struct symbol): Add copy constructor. Change defaults.
* jit.c (finalize_symtab): Use "new".
* ctfread.c (ctf_add_enum_member_cb, new_symbol, ctf_add_var_cb):
Use "new".
* stabsread.c (patch_block_stabs, define_symbol, read_enum_type)
(common_block_end): Use "new".
* mdebugread.c (parse_symbol): Use "new".
(new_symbol): Likewise.
|
|
cmd_show_list function implements the 'show' command.
cmd_show_list output is inconsistent: it sometimes shows a prefix
and sometimes does not.
For example, in the below, you see that there is a prefix before
each value, except for 'enabled'.
(gdb) show style
style address background: The "address" style background color is: none
style address foreground: The "address" style foreground color is: blue
style address intensity: The "address" style display intensity is: normal
enabled: CLI output styling is enabled.
style filename background: The "filename" style background color is: none
...
There are other inconsistencies or bugs e.g. in
the below we see twice insn-number-max, once with a prefix
and once without prefix : last line, just before the value of
instruction-history-size which is itself without prefix.
(gdb) show record
record btrace bts buffer-size: The record/replay bts buffer size is 65536.
record btrace cpu: btrace cpu is 'auto'.
record btrace pt buffer-size: The record/replay pt buffer size is 16384.
record btrace replay-memory-access: Replay memory access is read-only.
record full insn-number-max: Record/replay buffer limit is 200000.
record full memory-query: Whether query if PREC cannot record memory change of next instruction is off.
record full stop-at-limit: Whether record/replay stops when record/replay buffer becomes full is on.
function-call-history-size: Number of functions to print in "record function-call-history" is 10.
insn-number-max: instruction-history-size: Number of instructions to print in "record instruction-history" is 10.
(gdb)
Also, some values are output several times due to some aliases, so avoid outputting duplicated
values by skipping all aliases.
Now that the command structure has a correct 'back-pointer' from a command
to its prefix command, we can simplify cmd_show_list by removing its prefix argument
and at the same time fix the output inconsistencies and bugs.
gdb/ChangeLog
2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-setshow.h (cmd_show_list): Remove prefix argument.
* cli/cli-decode.c (do_show_prefix_cmd): Likewise.
* command.h (cmd_show_list): Likewise.
* dwarf2/index-cache.c (show_index_cache_command): Likewise.
* cli/cli-setshow.c (cmd_show_list): Use the prefix to produce the output. Skip aliases.
gdb/testsuite/ChangeLog
2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/default.exp: Update output following fixes.
|
|
Remove TYPE_CODE, changing all the call sites to use type::code
directly. This is quite a big diff, but this was mostly done using sed
and coccinelle. A few call sites were done by hand.
gdb/ChangeLog:
* gdbtypes.h (TYPE_CODE): Remove. Change all call sites to use
type::code instead.
|
|
Add the code and set_code methods on code, in order to remove the
TYPE_CODE macro. In this patch, the TYPE_CODE macro is changed to use
type::code, so all the call sites that are used to set the type code are
changed to use type::set_code. The next patch will remove TYPE_CODE
completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <code, set_code>: New methods.
(TYPE_CODE): Use type::code. Change all call sites used to set
the code to use type::set_code instead.
|
|
When running test-case gdb.fortran/info-modules.exp with target board
debug-names, I run into:
...
FAIL: gdb.fortran/info-modules.exp: info modules: check for entry \
'info-types-2.f90', '18', 'mod2'
...
In more detail, comparing the behaviour of the executable without and with
.debug_names section, we have:
...
-$ gdb -batch info-modules -ex "info modules"
+$ gdb -batch info-modules.debugnames -ex "info modules"
All defined modules:
-File /data/gdb_versions/devel/src/gdb/testsuite/gdb.fortran/info-types-2.f90:
-18: mod2
-
File /data/gdb_versions/devel/src/gdb/testsuite/gdb.fortran/info-types.f90:
16: mod1
...
This is due to the fact that the .debug_names section does not contain
DW_TAG_module entries.
Fix this in debug_names::psymbol_tag.
Build and tested on x86_64-linux with target board debug-names.
gdb/ChangeLog:
2020-05-11 Tom de Vries <tdevries@suse.de>
* dwarf2/index-write.c (debug_names::psymbol_tag): Handle
MODULE_DOMAIN.
|
|
Consider the following two-file test-case:
...
$ cat main.c
extern int foo (void);
int
main (void)
{
int sum, a, b;
sum = a + b + foo ();
return sum;
}
$ cat foo.c
int
foo (void)
{
return 3;
}
...
Compiled like this:
...
$ clang-10 -gdwarf-5 -gpubnames -c main.c
$ clang-10 -gdwarf-5 -c foo.c
$ clang-10 -gdwarf-5 -gpubnames main.o foo.o
...
When loading this exec into gdb, we run into this assert:
...
$ gdb a.out
Reading symbols from a.out...
warning: Section .debug_aranges in a.out entry at offset 0 \
debug_info_offset 0 does not exists, ignoring .debug_aranges.
src/gdb/dwarf2/read.c:6949: \
internal-error: cutu_reader::cutu_reader(dwarf2_per_cu_data*, \
abbrev_table*, int, bool): \
Assertion `this_cu->length == cu->header.get_length ()' failed.
...
The problem is that the determined length of the CU:
...
(gdb) p /x this_cu->length
$4 = 0x26a
...
does not match the actual length:
...
(gdb) p /x cu->header.get_length ()
$5 = 0x59
...
The length of the CU is determined in create_cus_from_debug_names_list, and
set based on this list in the .debug_names section:
...
Compilation Unit offsets [
CU[0]: 0x000000c7
]
...
and it is assumed that this is a complete list, so the size of the CU is
calculated using the end of the .debug_section at 0x331, making it 0x331 -
0xc7 == 0x26a.
However, the CU list is not complete:
...
$ llvm-dwarfdump -debug-info a.out \
| grep "Compile Unit" \
| sed 's/Compile Unit.*//'
0x00000000:
0x0000002e:
0x000000a5:
0x000000c7:
0x00000120:
0x00000157:
0x0000030f:
...
In particular, because the CU for foo.c is there at 0x120 (the rest of the CUs
is due to openSUSE having debug info for various linked in objects).
Fix the assert by not assuming to know the length of CUs in
create_cus_from_debug_names_list (if the .debug_names is not produced by GDB),
and setting it to 0, and setting it later to the actual length.
Note that this does not fix the .debug_aranges warning, that's PR25969.
Build and tested on x86_64-linux, with native and debug-names.
gdb/ChangeLog:
2020-05-11 Tom de Vries <tdevries@suse.de>
PR symtab/25941
* dwarf2/read.c (create_cus_from_debug_names_list): Initialize CUs
with length 0, if not gdb-produced.
(cutu_reader::cutu_reader): Set CU length to actual length if 0.
gdb/testsuite/ChangeLog:
2020-05-11 Tom de Vries <tdevries@suse.de>
PR symtab/25941
* gdb.dwarf2/clang-debug-names.exp.in: New include exp file, factored
out of ...
* gdb.dwarf2/clang-debug-names.exp: ... here.
* gdb.dwarf2/clang-debug-names-2.exp: New file. Include
clang-debug-names.exp.in.
* gdb.dwarf2/clang-debug-names-2-foo.c: New test.
* gdb.dwarf2/clang-debug-names-2.c: New test.
|
|
.debug_names form
Following complaint is observed with the executable compiled with -gdwarf-5
and -gpubnames flags - "During symbol reading: Unsupported .debug_names form
DW_FORM_ref4". This is the form corresponding to DW_IDX_die_offset attribute.
This patch fixes this complaint. Tested with clang 10.0.0. Test case used -
int main()
{
int sum,a,b;
sum = a + b;
return sum;
}
clang -gdwarf-5 -gpubnames test.c -o test.out
gdb -q test.out -ex "set complaints 1" -ex "start"
Reading symbols from test.out...
During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \
[in module test.out]
Temporary breakpoint 1 at 0x400484
Starting program: test.out
During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \
[in module test.out]
During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \
[in module test.out]
During symbol reading: Unsupported .debug_names form DW_FORM_ref4 \
[in module test.out]
gdb/dwarf2/ChangeLog:
2020-05-09 Nitika Achra <Nitika.Achra@amd.com>
PR symtab/25952
* read.c (dw2_debug_names_iterator::next): Handle DW_FORM_ref*
and DW_IDX_die_offset. If there is no compilation unit attribute in
the index entry, then there is a single CU. Return the CU at O index
of compilation unit vector.
gdb/testsuite/ChangeLog:
2020-05-09 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/clang-debug-names.exp: Remove PR25952 kfail.
|
|
A customer reported a crash in the DWARF reader.
Investigation showed that the crash occurred in an unusual scenario: a
function was lexically scoped within some other function -- but the
inner function inlined the outer function and referred to its DIE via
DW_AT_abstract_origin. With the executable in question,
inherit_abstract_dies could eventually call read_lexical_block_scope,
which in turn could recurse into process_die, to process a DIE that
was already being read, triggering an assert.
This came up once before; see:
https://www.sourceware.org/ml/gdb-patches/2014-02/msg00652.html
However, in this case, I don't have an easy way to reproduce. So,
there is no test case.
I did experiment with the failing executable. This patch fixes the
bug and doesn't seem to cause other issues. For example, I can still
set breakpoints on the relevant functions.
gdb/ChangeLog
2020-05-08 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (read_lexical_block_scope): Don't process a DIE
already being processed.
|
|
I noticed that cp_canonicalize_string and friends copy a
unique_xmalloc_ptr to a std::string. However, this copy isn't
genuinely needed anywhere, and it serves to slow down DWARF psymbol
reading.
This patch removes the copy and updates the callers to adapt.
This speeds up the reader from 1.906 seconds (mean of 10 runs, of gdb
on a copy of itself) to 1.888 seconds (mean of 10 runs, on the same
copy as the first trial).
gdb/ChangeLog
2020-05-08 Tom Tromey <tom@tromey.com>
* symtab.h (class demangle_result_storage) <set_malloc_ptr>: New
overload.
<swap_string, m_string>: Remove.
* symtab.c (demangle_for_lookup, completion_list_add_symbol):
Update.
* stabsread.c (define_symbol, read_type): Update.
* linespec.c (find_linespec_symbols): Update.
* gnu-v3-abi.c (gnuv3_get_typeid): Update.
* dwarf2/read.c (dwarf2_canonicalize_name): Update.
* dbxread.c (read_dbx_symtab): Update.
* cp-support.h (cp_canonicalize_string_full)
(cp_canonicalize_string, cp_canonicalize_string_no_typedefs):
Return unique_xmalloc_ptr.
* cp-support.c (inspect_type): Update.
(cp_canonicalize_string_full): Return unique_xmalloc_ptr.
(cp_canonicalize_string_no_typedefs, cp_canonicalize_string):
Likewise.
* c-typeprint.c (print_name_maybe_canonical): Update.
* break-catch-throw.c (check_status_exception_catchpoint):
Update.
|
|
Move add_dyn_prop, currently a free function, to be a method of struct
type.
gdb/ChangeLog:
* gdbtypes.h (struct type) <add_dyn_prop>: New method.
(add_dyn_prop): Remove. Update all users to use
type::add_dyn_prop.
* gdbtypes.c (add_dyn_prop): Rename to...
(type::add_dyn_prop): ... this.
|
|
I looked at all the calls to add_prefix_cmd, and replaced them with
calls to add_basic_prefix_cmd or add_show_prefix_cmd when appropriate.
This makes gdb's command language a bit more regular. I don't think
there's a significant downside.
Note that this patch removes a couple of tests. The removed ones are
completely redundant.
gdb/ChangeLog
2020-05-03 Tom Tromey <tom@tromey.com>
* breakpoint.c (catch_command, tcatch_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(set_breakpoint_cmd, show_breakpoint_cmd): Remove
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Remove.
(add_internal_problem_command): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (set_mipsfpu_command): Remove.
(_initialize_mips_tdep): Use add_basic_prefix_cmd.
* dwarf2/index-cache.c (set_index_cache_command): Remove.
(_initialize_index_cache): Use add_basic_prefix_cmd.
* memattr.c (dummy_cmd): Remove.
(_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd.
* tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove.
(_initialize_tui_win): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-logging.c (set_logging_command): Remove.
(_initialize_cli_logging): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_logging_command): Remove.
* target.c (target_command): Remove.
(add_target): Use add_basic_prefix_cmd.
gdb/testsuite/ChangeLog
2020-05-03 Tom Tromey <tom@tromey.com>
* gdb.base/sepdebug.exp: Remove "catch" test.
* gdb.base/break.exp: Remove "catch" test.
* gdb.base/default.exp: Update expected output.
|
|
This reverts commit 84ed7a472551bce1ac58e0eced619433fabc956c.
The problem that the commit attempts to address has already been fixed in
commit 770479f223e "gdb: Fix toplevel types with -fdebug-types-section".
The commit itself is superfluous because it sets list_in_scope at a point that
it's already set (by start_symtab).
|
|
* dwarf2/read.c (setup_type_unit_groups): Set list_in_scope.
|
|
PR ada/25875 concerns a gdb crash when gdb.ada/arr_enum_idx_w_gap.exp
is run using the .debug_types board.
The problem turns out to be caused by weird compiler output. In this
test, the compiler emits a top-level type that refers to an
enumeration type which is nested in a function. However, this
function is just a declaration.
This results in gdb calling read_enumeration_type for the enum type,
but process_enumeration_scope is never called, yielding an enum with
no fields. This causes the crash.
This patch fixes the problem by arranging to create the enum fields in
read_enumeration_type.
Tested on x86-64 Fedora 30.
gdb/ChangeLog
2020-04-29 Tom Tromey <tromey@adacore.com>
PR ada/25875:
* dwarf2/read.c (update_enumeration_type_from_children): Compute
type fields here.
(read_enumeration_type): Call
update_enumeration_type_from_children later. Update comments.
(process_enumeration_scope): Don't create type fields.
|
|
When debugging a program compiled with -fdebug-types-section,
only the first top-level type in each file is visible to gdb.
The problem was caused by moving the assignment to list_in_scope
from process_full_comp_unit and process_full_type_unit to
start_symtab. This was fine for process_full_comp_unit, because
symtabs and comp units are one-to-one. But there can be many type
units per symtab (one for each type), and we only call start_symtab
for the first one. This adds the necessary assignments on the paths
where start_symtab is not called.
gdb/Changelog:
2020-04-28 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dwarf2read.c: Add missing assingments to list_in_scope when
start_symtab was already called.
gdb/testsuite/Changelog:
2020-04-28 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dw4-toplevel-types.exp: Test for top level types.
* dw4-toplevel-types.cc: Test for top level types.
|
|
When building with g++ 4.8, we get this error (just an excerpt, because
g++ outputs a very long error message):
CXX dwarf2/read.o
...
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:14616:31: required from here
/usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of incomplete type ‘struct std::hash<sect_offset>’
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2,
This is the same problem and fix as in commit f23f598e28ad ("[gdb] Fix
build breaker with gcc 4.8"). Pass an explicit hash function rather
than relying on the default std::hash<sect_offset>.
gdb/ChangeLog:
PR gdb/25881
* dwarf2/read.c (offset_map_type): Use
gdb:hash_enum<sect_offset> as hash function.
|
|
Consider a test-case with sources 36.c:
...
struct s { int i; };
extern void f (void);
int main (void) {
struct s a;
f ();
return 0;
}
...
and 36b.c:
...
struct s { int j; };
void f (void) {
struct s b;
}
...
compiled like this:
...
$ gcc 36.c 36b.c -g
...
It contains DWARF like this:
...
<0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d8> DW_AT_name : 36.c
<1><f4>: Abbrev Number: 2 (DW_TAG_structure_type)
<f5> DW_AT_name : s
<2><fe>: Abbrev Number: 3 (DW_TAG_member)
<ff> DW_AT_name : i
<1><110>: Abbrev Number: 5 (DW_TAG_subprogram)
<111> DW_AT_name : main
<2><12d>: Abbrev Number: 6 (DW_TAG_variable)
<12e> DW_AT_name : a
<132> DW_AT_type : <0xf4>
<0><146>: Abbrev Number: 1 (DW_TAG_compile_unit)
<14c> DW_AT_name : 36b.c
<1><168>: Abbrev Number: 2 (DW_TAG_structure_type)
<169> DW_AT_name : s
<2><172>: Abbrev Number: 3 (DW_TAG_member)
<173> DW_AT_name : j
<1><184>: Abbrev Number: 5 (DW_TAG_subprogram)
<185> DW_AT_name : f
<2><19b>: Abbrev Number: 6 (DW_TAG_variable)
<19c> DW_AT_name : b
<1a0> DW_AT_type : <0x168>
...
And when printing "struct s", we get first a random one (with int j), and then
context-specific ones (with int i in main, and int j in f):
...
$ gdb -batch a.out \
-ex "ptype struct s" \
-ex start \
-ex "ptype struct s" \
-ex "break f" -ex continue \
-ex "ptype struct s" \
| grep "int [ij];"
int j;
int i;
int j;
...
Same for -readnow.
However, if we use -fdebug-types-section:
...
$ gcc 36.c 36b.c -g -fdebug-types-section
...
we get:
...
$ gdb ... | grep "int [ij];"
int j;
int i;
int i;
$ gdb -readnow ... | grep "int [ij];"
int j;
int j;
int j;
...
This is due to the fact that both "struct s" DIEs have been moved to the
.debug_types section:
...
Compilation Unit @ offset 0x0:
Signature: 0xfd1462823bb6f7b7
<0><17>: Abbrev Number: 1 (DW_TAG_type_unit)
<1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
<1e> DW_AT_name : s
<2><27>: Abbrev Number: 3 (DW_TAG_member)
<28> DW_AT_name : i
Compilation Unit @ offset 0x3a:
Signature: 0x534310fbefba324d
<0><51>: Abbrev Number: 1 (DW_TAG_type_unit)
<1><57>: Abbrev Number: 2 (DW_TAG_structure_type)
<58> DW_AT_name : s
<2><61>: Abbrev Number: 3 (DW_TAG_member)
<62> DW_AT_name : j
...
and there's no longer a "struct s" DIE in the 36.c and
and 36b.c CUs to specify which "struct s" belongs in the CU. This is gcc
PR90232.
However, using a tentative patch for gcc that adds these DIEs (according to
DWARF standard: If the complete declaration of a type has been placed in a
separate type unit, an incomplete declaration of that type in the compilation
unit may provide the unique 64-bit signature of the type using a
DW_AT_signature attribute):
...
<0><d2>: Abbrev Number: 5 (DW_TAG_compile_unit)
<d8> DW_AT_name : 36.c
+ <1><f4>: Abbrev Number: 6 (DW_TAG_structure_type)
+ <f5> DW_AT_name : s
+ <f7> DW_AT_signature : signature: 0xfd1462823bb6f7b7
+ <ff> DW_AT_declaration : 1
<0><13c>: Abbrev Number: 5 (DW_TAG_compile_unit)
<142> DW_AT_name : 36b.c
+ <1><15e>: Abbrev Number: 6 (DW_TAG_structure_type)
+ <15f> DW_AT_name : s
+ <161> DW_AT_signature : signature: 0x534310fbefba324d
+ <169> DW_AT_declaration : 1
...
still does not help, because they're declarations, so new_symbol is not called
for them in process_structure_scope.
Fix this by calling new_symbol for these decls.
Build and tested on x86_64-linux.
Also tested with target board enabling by default -fdebug-types-section
-gdwarf-4, and with gcc with aforementioned tentative patch. In this
configuration, the patch reduces number of FAILs from 2888 to 238.
gdb/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (process_structure_scope): Add symbol for struct decl
with DW_AT_signature.
gdb/testsuite/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/main-foo.c: New test.
* gdb.dwarf2/struct-with-sig.exp: New file.
|
|
Commit 5939967b355ba6a940887d19847b7893a4506067 fixed inline
frame unwinding breakage for some targets (aarch64, riscv, s390...)
but regressed a few amd64 testcases related to tailcalls.
Given the following example situation...
Frame #-1 - sentinel frame
Frame # 0 - inline frame
Frame # 1 - normal frame
... suppose we're at level #1 and call into dwarf2_tailcall_sniffer_first.
We'll attempt to fetch PC, which used to be done via the gdbarch_unwind_pc call
(before 5939967b355ba6a940887d19847b7893a4506067), but now it is being handled
by the get_frame_register function.
gdbarch_unwind_pc will attempt to use frame #1's cache to retrieve information
about the PC. Here's where different architectures behave differently.
x86_64 will find a dwarf rule to retrieve PC from memory, at a CFA + offset
location. So the PC value is readily available and there is no need to
create a lazy value.
For aarch64 (and others), GCC doesn't emit an explicit location for PC, so we
eventually will find that PC is DWARF2_FRAME_REG_UNSPECIFIED. This is known
and is handled by GDB by assuming GCC really meant DWARF2_FRAME_REG_SAME_VALUE.
This means we'll attempt to fetch the register value from frame #0, via a call
to frame_unwind_got_register, which will trigger the creation of a lazy value
that requires a valid frame id for frame #0.
We don't have a valid id for frame #0 yet, so we assert.
Given the above, the following patch attempts to handle the situation without
being too hacky. We verify if the next frame is an inline frame and if its
frame id has been computed already. If it hasn't been computed yet, then we
use the safer get_frame_register function, otherwise we use the regular
gdbarch_unwind_pc hook.
gdb/ChangeLog:
2020-04-27 Luis Machado <luis.machado@linaro.org>
* dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first): Handle
problematic inline frame unwinding situation.
* frame.c (frame_id_computed_p): New function.
* frame.h (frame_id_computed_p): New prototype.
|
|
PR rust/25025 notes that some Rust test cases fail.
Debugging gdb revealed that the Rust compiler emits different linkage
names that demangle to the same result. Enabling complaints when
reading the test case is enough to show it:
During symbol reading: Computed physname <generics::identity<f64>> does not match demangled <generics::identity> (from linkage <_ZN8generics8identity17h8540b320af6656d6E>) - DIE at 0x424 [in module /home/tromey/gdb/build/gdb/testsuite/outputs/gdb.rust/generics/generics]
During symbol reading: Computed physname <generics::identity<u32>> does not match demangled <generics::identity> (from linkage <_ZN8generics8identity17hae302fad0c33bd7dE>) - DIE at 0x459 [in module /home/tromey/gdb/build/gdb/testsuite/outputs/gdb.rust/generics/generics]
...
This patch changes the DWARF reader to prefer the computed physname,
rather than the output of the demangler, for Rust. This fixes the
bug.
gdb/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
PR rust/25025:
* dwarf2/read.c (dwarf2_physname): Do not demangle for Rust.
|
|
The DWARF reader has had some odd code since the "physname" patches landed.
In particular, these patches caused PR symtab/12707; namely, they made
it so "set print demangle off" no longer works.
This patch attempts to fix the problem. It arranges to store the
linkage name on the symbol if it exists, and it changes the DWARF
reader so that the demangled name is no longer (usually) stored in the
symbol's "linkage name" field.
c-linkage-name.exp needed a tweak, because it started working
correctly. This conforms to what I think ought to happen, so this
seems like an improvement here.
compile-object-load.c needed a small change to use
symbol_matches_search_name rather than directly examining the linkage
name. Looking directly at the name does the wrong thing for C++.
There is still some name-related confusion in the DWARF reader:
* "physname" often refers to the logical name and not what I would
consider to be the "physical" name;
* dwarf2_full_name, dwarf2_name, and dwarf2_physname all exist and
return different strings -- but this seems like at least one name
too many. For example, Fortran requires dwarf2_full_name, but other
languages do not.
* To my surprise, dwarf2_physname prefers the form emitted by the
demangler over the one that it computes. This seems backward to me,
given that the partial symbol reader prefers the opposite, and it
seems to me that this choice may perform better as well.
I didn't attempt to clean up these things. It would be good to do,
but whenever I contemplate it I get caught up in dreams of truly
rewriting the DWARF reader instead.
gdb/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
PR symtab/12707:
* dwarf2/read.c (add_partial_symbol): Use the linkage name if it
exists.
(new_symbol): Likewise.
* compile/compile-object-load.c (get_out_value_type): Use
symbol_matches_search_name.
gdb/testsuite/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
PR symtab/12707:
* gdb.python/py-symbol.exp: Update expected results for
linkage_name test.
* gdb.cp/print-demangle.exp: New file.
* gdb.base/c-linkage-name.exp: Fix test.
* gdb.guile/scm-symbol.exp: Update expected results for
linkage_name test.
|
|
As mentioned in another thread, there's currently no need to call
compute_and_set_names for partial symbols. Because the DWARF partial
symbol reader constructs demangled names, this call can only demangle
a name by mistake.
So, this patch changes the DWARF reader to simply set the linkage name
on the new symbol. This is equivalent to what was done before. There
should be no user-visible change from this patch, aside from gdb
speeding up a bit.
... there *should* be, but this regressed
dw2-namespaceless-anonymous.exp. However, upon examination, I think
that test is incorrect. It puts a mangled name into DW_AT_name, and
it puts the variable at the top level, not in a namespace. This isn't
what C++ compilers ought to do. So, this patch also updates the test
case.
gdb/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (add_partial_symbol): Do not call
compute_and_set_names.
gdb/testsuite/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
* gdb.dwarf2/dw2-namespaceless-anonymous.S: Remove.
* gdb.dwarf2/dw2-namespaceless-anonymous.c: New file.
* gdb.dwarf2/dw2-namespaceless-anonymous.exp: Use DWARF
assembler.
|
|
This changes the DWARF reader to use the new add_psymbol_to_list
overload. There should be no visible changes due to this patch.
gdb/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (add_partial_symbol): Use new add_psymbol_to_list
overload.
|
|
The full DIE reader checks that an attribute has a "string" form in
some spots, but the partial DIE reader does not. This patch brings
the two readers in sync for one specific case, namely when examining
the linkage name. This avoids regressions in an existing DWARF test
case.
A full fix for this problem would be preferable. An accessor like
DW_STRING should always check the form. However, I haven't attempted
that in this series.
Also the fact that the partial and full readers can disagree like this
is a design flaw.
gdb/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (partial_die_info::read) <case
DW_AT_linkage_name>: Use value_as_string.
(dwarf2_string_attr): Use value_as_string.
* dwarf2/attribute.h (struct attribute) <value_as_string>: Declare
method.
* dwarf2/attribute.c (attribute::value_as_string): New method.
|