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.
Change-Id: Id4662828ac3c5bc93fe221df3c9bd9a36a8427ad
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.
Change-Id: I0406a715b0797963bde2bd86237f159cbece5839
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
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
This fixes an instruction mask typo. We should be matching only
ldrd (immediate) and not any other of its variants. As is, it never matches
anything.
With the patch, the instruction mask also allows matching of ldrd (literal),
but the check for SP discards this particular instruction pattern, as it has
a hardcoded PC register.
gdb/ChangeLog:
2020-05-27 Luis Machado <luis.machado@linaro.org>
PR tdep/26000
* arm-tdep.c (thumb_analyze_prologue): Fix instruction matching
for ldrd (immediate).
While doing a testsuite run on aarch64-linux, I noticed a bunch of duplicated
test name results. It annoyed me a little, so I decided to go ahead and fix the
worst offenders.
The following patch brings the duplicate test names down from 461 to 137.
The remaining ones are mostly scattered across the testsuite, with 1 to 3
duplicates per testcase. We can fix those as we go.
gdb/testsuite/ChangeLog:
2020-05-27 Luis Machado <luis.machado@linaro.org>
* gdb.arch/aarch64-sighandler-regs.exp: Fix duplicated test names.
* gdb.arch/aarch64-tagged-pointer.exp: Likewise.
* gdb.arch/arm-disassembler-options.exp: Likewise.
* gdb.arch/arm-disp-step.exp: Likewise.
* gdb.arch/thumb-prologue.exp: Likewise.
* gdb.base/async.exp: Likewise.
* gdb.base/auxv.exp: Likewise.
* gdb.base/complex-parts.exp: Likewise.
* gdb.base/ena-dis-br.exp: Likewise.
* gdb.base/foll-exec.exp: Likewise.
* gdb.base/permissions.exp: Likewise.
* gdb.base/relocate.exp: Likewise.
* gdb.base/return2.exp: Likewise.
* gdb.base/sigbpt.exp: Likewise.
* gdb.base/siginfo-obj.exp: Likewise.
* gdb.cp/converts.exp: Likewise.
* gdb.cp/exceptprint.exp: Likewise.
* gdb.cp/inherit.exp: Likewise.
* gdb.cp/nsnoimports.exp: Likewise.
* gdb.cp/virtbase2.exp: Likewise.
* gdb.mi/mi-var-cmd.exp: Likewise.
* gdb.mi/var-cmd.c: Likewise.
In commit 6031ac352c I added some casts
to explicitly do conversions from unsigned to signed as 32-bit
quantities to address some bugs with different sizes of long and
bfd_signed_vma. Those casts were removed in the rewrite of the
sign-extension logic in commit 1d61b03226,
reintroducing the same bugs. This patch restores the casts.
2020-05-26 Sandra Loosemore <sandra@codesourcery.com>
opcodes/
* nios2-dis.c (nios2_print_insn_arg): Add explicit casts to
extractions of signed fields.
Before this change, "help" was not showing the TUI class.
With this change:
(gdb) help
...
support -- Support facilities.
text-user-interface -- TUI is the GDB text based interface.
tracepoints -- Tracing of program execution without stopping the program.
...
(gdb) help text-user-interface
TUI is the GDB text based interface.
In TUI mode, GDB can display several text windows showing
the source file, the processor registers, the program disassembly, ...
List of commands:
+ -- Scroll window forward.
...
Note that we cannot use "tui" for the fake class command name, as "tui"
is a command.
gdb/ChangeLog
2020-05-26 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* command.h: Add comment giving the name of class_tui.
* cli/cli-cmds.c (_initialize_cli_cmds): If TUI defined,
create the fake command for the help for class_tui.
In Ada, like C, an enum can assign values to the constants. However,
unlike C (or any other language supported by gdb), the enum type can
also be used as the range of an array.
In this case, the user's code references the enum constants, but the
compiler translates these to the position of the constant in the enum.
So for example one might write:
type Enum_With_Gaps is
(
LIT0,
LIT1,
LIT2,
LIT3,
LIT4
);
for Enum_With_Gaps use
(
LIT0 => 3,
LIT1 => 5,
LIT2 => 8,
LIT3 => 13,
LIT4 => 21
);
Then index an array like "array(LIT3)" -- but this will be the 4th
element in an array of 5 elements, not the 13th element in an array of
19 (assuming I did the math right) elements.
gdb supports this to some degree, with the only missing piece being
indexing into such an array. This patch implements this missing
feature, and also fixes an existing bug, which is that in some
situations I believe gdb would mis-compute the resulting array's
length.
The approach taken here is to try to integrate this feature into the
core of gdb. My view is that much of the Ada support should be better
integrated with gdb, rather than being "on the side". This, I think,
would help avoid code duplication at least. So, I try to take steps
toward this goal when possible.
Because other languages generally don't allow the user to specify the
index type of an array, I simply made the core of gdb unconditionally
apply discrete_position when computing the range of such an array.
This is a no-op for ordinary types, but applies the enum
value-to-position transformation for TYPE_CODE_ENUM.
gdb/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_print_array_index): Change type. Call val_atr.
(ada_value_ptr_subscript): Don't call pos_atr on the lower bound.
(val_atr): New function.
(value_val_atr): Use it.
* ada-valprint.c (print_optional_low_bound): Change low bound
handling for enums.
(val_print_packed_array_elements): Don't call discrete_position.
* gdbtypes.c (get_discrete_bounds) <TYPE_CODE_RANGE>: Call
discrete_position for enum types.
* language.c (default_print_array_index): Change type.
* language.h (struct language_defn) <la_print_array_index>: Add
index_type parameter, change type of index_value.
(LA_PRINT_ARRAY_INDEX): Add index_type parameter.
(default_print_array_index): Update.
* valprint.c (maybe_print_array_index): Don't call
value_from_longest. Update.
(value_print_array_elements): Don't call discrete_position.
gdb/testsuite/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* gdb.ada/arr_acc_idx_w_gap.exp: Add tests.
In Ada, the 'val and 'pos attributes can be used to map from an
enumeration constant to its position in the enum and vice versa.
These operators did not work properly when the type in question was a
subrange of an enum type with "holes".
gdb/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* ada-lang.c (value_val_atr): Handle TYPE_CODE_RANGE.
* gdbtypes.c (discrete_position): Handle TYPE_CODE_RANGE.
gdb/testsuite/ChangeLog
2020-05-26 Tom Tromey <tromey@adacore.com>
* gdb.ada/arr_acc_idx_w_gap.exp: Add enum subrange tests.
* gdb.ada/arr_acc_idx_w_gap/enum_with_gap.ads (Enum_Subrange): New
type.
* gdb.ada/arr_acc_idx_w_gap/enum_with_gap_main.adb (V): New
variable.
Reported by sobukus on IRC.
gdb/testsuite/ChangeLog:
2020-05-26 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Use = instead of == for the test command
for portability.
Change-Id: I431ccfa5e5ba15f9af082ffd6aa8cd7046456cd2
Accept vector alignment hints on z13 although they are ignored there.
The advantage is that any binary compiled for architecture level z13 may
run on z14 or later and benefit from vector alignment hints.
gas/ChangeLog:
2020-05-18 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
* testsuite/gas/s390/zarch-z13.d: Add regexp checks for vector
load/store instruction variants with alignment hints.
* testsuite/gas/s390/zarch-z13.s: Emit new vector load/store
instruction variants with alignment hints.
opcodes/ChangeLog:
2020-05-18 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
* s390-opc.txt: Relocate vector load/store instructions with
additional alignment parameter and change architecture level
constraint from z14 to z13.
opcode/crx.h has
typedef enum
{
...
MAX_REG
}
reg;
typedef enum
{
c0 = MAX_REG,
}
copreg;
tc-crx.c has
static int
getreg_image (reg r)
{
...
/* Check whether the register is in registers table. */
if (r < MAX_REG)
rreg = &crx_regtab[r];
/* Check whether the register is in coprocessor registers table. */
else if (r < (int) MAX_COPREG)
rreg = &crx_copregtab[r-MAX_REG];
}
Change getreg_image's argument type to int and replace fragP->fr_literal
with &fragP->fr_literal[0] to silence GCC 10 warning.
PR gas/26044
* config/tc-crx.c (getreg_image): Change argument type to int.
(md_convert_frag): Replace fragP->fr_literal with
&fragP->fr_literal[0].
There's a PR binutils/15646 - "gold-generated .gdb_index has duplicated
symbols that gdb-generated index doesn't", and gdb contains a workaround,
added in commit 8943b87476 "Work around gold/15646".
Add a test-case testing this workaround.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-26 Tom de Vries <tdevries@suse.de>
* gdb.base/gold-gdb-index-2.c: New test.
* gdb.base/gold-gdb-index.c: New test.
* gdb.base/gold-gdb-index.exp: New file.
* gdb.base/gold-gdb-index.h: New test.
Add new target board that uses gold to add a .gdb_index section, enabled by
-ggnu-pubnames.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-25 Tom de Vries <tdevries@suse.de>
* boards/gold-gdb-index.exp: New file.
The AVR architecture is a Harvard one, meaning it has different memory
spaces for code and data. In GDB, this is dealt with by having the data
(SRAM) addresses start at 0x00800000. When interpreting an integer as
an address (converting to a CORE_ADDR), we currently always generate a
data address. This doesn't work for some cases described below, where
the integer is meant to represent a code address.
This patch changes avr_integer_to_address so that it generates the
correct type of address (code or data) based on the passed type.
Using the simavr.exp board, I didn't see any regressions when running
the gdb.base/*.exp tests. A few tests go from fail to pass, but none
from pass to fail. There are a few new fails and unresolved, but it's
just because some tests manage to make more progress before failing in a
different way.
In practice, it fixes disassembling by address, as described in the PR:
- (gdb) disassemble 0x12a,0x12b
- Dump of assembler code from 0x12a to 0x12b:
- 0x0000012a <main+0>: push r28
- End of assembler dump.
+ (gdb) disassemble 0x12a,0x12b
+ Dump of assembler code from 0x80012a to 0x80012b:
+ 0x0080012a: nop
+ End of assembler dump.
And also, setting a breakpoint by address:
- (gdb) p &main
- $1 = (int (*)(void)) 0x12a <main>
- (gdb) b *0x12a
- Breakpoint 1 at 0x80012a
+ (gdb) p &main
+ $1 = (int (*)(void)) 0x12a <main>
+ (gdb) b *0x12a
+ Breakpoint 1 at 0x12a: file test-avr.c, line 3.
+ Note: automatically using hardware breakpoints for read-only addresses.
gdb/ChangeLog:
PR gdb/13519
* avr-tdep.c (avr_integer_to_address): Return data or code
address accordingly to the second 'type' argument of the
function.
Change-Id: Iaea1587d053e86f4ab8aebdcabec8d31a6d262cd
This patch adds a board file for against a simavr target (so, for the
AVR architecture).
simavr, when started with option -g, runs a GDB stub on port 1234. In
the current latest release (1.6), the port is hardcoded to 1234. But in
master, there is the option to choose another port. So while the board
file hardcodes the port today, in the future it should be possible to
let the user choose a port, or automatically select a free port.
It is easy enough to run, make sure you have avr-gcc/avr-g++ and simavr
installed, and as usual just run:
make check RUNTESTFLAGS="--target_board=simavr"
The following environment variables influence the behavior of the board
file:
- SIMAVR_MCU: type of chip to simulate
- SIMAVR_PATH: path to simavr binary (useful if you build your own
simavr or for some reason it is not simply called `simavr`.
As expected, there are a lot of failures. Many tests use some features
not supported by such a target, and I suppose there are real GDB bugs
too. But a lot also passes (including tests that actually run stuff),
so this board file should still help to validate changes to the AVR
architecture support.
These are the results I got of running tests gdb.base/*.exp:
# of expected passes 20926
# of unexpected failures 2257
# of expected failures 14
# of unknown successes 1
# of known failures 13
# of unresolved testcases 592
# of untested testcases 156
# of unsupported tests 30
# of paths in test names 3
# of duplicate test names 56
gdb/testsuite/ChangeLog:
* boards/simavr.exp: New file.
Change-Id: Ib7fa8c4e2e90b08b104bb9b552df37779de3bc21