binutils-gdb/gdb/ChangeLog

1866 lines
65 KiB
Plaintext
Raw Normal View History

Rewrite GNAT-encoded fixed point types in DWARF reader gdb currently supports two different styles of fixed-point. The original style, where fixed point types are "GNAT encoded", is handled primarily in the Ada code. The newer style, encoded using DWARF, is handled by the core of gdb. This patch changes gdb to read the GNAT encodings in the DWARF reader as well. This removes some code and unifies the two paths. As a result, GNAT-encoded fixed-point now works a bit better. One possible drawback of this change is that, if someone uses stabs, then fixed-point might now stop working. I consider stabs to be fully obsolete, though, so I don't intend to address this. gdb/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * ada-lang.c (cast_from_gnat_encoded_fixed_point_type) (cast_to_gnat_encoded_fixed_point_type): Remove. (ada_value_cast, ada_evaluate_subexp): Update. (gnat_encoded_fixed_point_type_info) (ada_is_gnat_encoded_fixed_point_type) (gnat_encoded_fixed_point_delta) (gnat_encoded_fixed_point_scaling_factor): Remove. * ada-lang.h (ada_is_gnat_encoded_fixed_point_type) (gnat_encoded_fixed_point_delta) (gnat_encoded_fixed_point_scaling_factor): Don't declare. * ada-typeprint.c (print_gnat_encoded_fixed_point_type): Remove. (ada_print_type): Update. * ada-valprint.c (ada_value_print_num): Update. * dwarf2/read.c (ada_get_gnat_encoded_number) (ada_get_gnat_encoded_ratio): New functions. (finish_fixed_point_type): Use them. Add parameters. (GNAT_FIXED_POINT_SUFFIX): New define. (gnat_encoded_fixed_point_type_info): New function. (read_base_type): Handle gnat encodings. gdb/testsuite/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * gdb.ada/fixed_points.exp: Remove most special cases for minimal encodings.
2021-03-03 04:08:24 +08:00
2021-03-02 Tom Tromey <tromey@adacore.com>
* ada-lang.c (cast_from_gnat_encoded_fixed_point_type)
(cast_to_gnat_encoded_fixed_point_type): Remove.
(ada_value_cast, ada_evaluate_subexp): Update.
(gnat_encoded_fixed_point_type_info)
(ada_is_gnat_encoded_fixed_point_type)
(gnat_encoded_fixed_point_delta)
(gnat_encoded_fixed_point_scaling_factor): Remove.
* ada-lang.h (ada_is_gnat_encoded_fixed_point_type)
(gnat_encoded_fixed_point_delta)
(gnat_encoded_fixed_point_scaling_factor): Don't declare.
* ada-typeprint.c (print_gnat_encoded_fixed_point_type): Remove.
(ada_print_type): Update.
* ada-valprint.c (ada_value_print_num): Update.
* dwarf2/read.c (ada_get_gnat_encoded_number)
(ada_get_gnat_encoded_ratio): New functions.
(finish_fixed_point_type): Use them. Add parameters.
(GNAT_FIXED_POINT_SUFFIX): New define.
(gnat_encoded_fixed_point_type_info): New function.
(read_base_type): Handle gnat encodings.
2021-03-02 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_fold_name, ada_variant_discrim_name)
(ada_enum_name, scan_discrim_bound, to_fixed_range_type): Use
std::string.
(GROW_VECT): Remove.
(grow_vect): Remove.
2021-03-02 Tom Tromey <tromey@adacore.com>
* ada-lang.h (ada_lookup_symbol_list): Return a vector.
* ada-lang.c (resolve_subexp): Update.
(ada_resolve_function): Accept a vector.
(is_nonfunction, add_defn_to_vec)
(add_symbols_from_enclosing_procs): Likewise.
(num_defns_collected, defns_collected): Remove.
(remove_extra_symbols): Return a vector.
(remove_irrelevant_renamings): Return void.
(ada_add_local_symbols): Accept a vector.
(struct match_data) <obstackp>: Remove.
<resultp>: New member.
(aux_add_nonlocal_symbols): Update.
(ada_add_block_renamings, add_nonlocal_symbols)
(ada_add_all_symbols): Accept a vector.
(ada_lookup_symbol_list_worker, ada_lookup_symbol_list): Return a
vector.
(ada_lookup_symbol): Update.
(ada_add_block_symbols): Accept a vector.
(get_var_value, iterate_over_symbols): Update.
* ada-exp.y (block_lookup, write_var_or_type, write_name_assoc):
Update.
2021-03-02 Tom Tromey <tromey@adacore.com>
* ada-lang.c (resolve_subexp): Use any_of and erase-remove idiom.
2021-03-02 Tom Tromey <tromey@adacore.com>
* ada-lang.c (struct ada_symbol_cache) <cache_space>: Now an
auto_obstack.
<root>: Initialize.
(ada_pspace_data): Remove destructor.
<sym_cache>: Now a unique_ptr.
(ada_init_symbol_cache, ada_free_symbol_cache): Remove.
(ada_get_symbol_cache): Use 'new'.
(ada_clear_symbol_cache): Rewrite.
2021-03-02 Tom Tromey <tromey@adacore.com>
* ada-lang.c (add_nonlocal_symbols): Handle case where objfile->sf
is null.
2021-02-27 Lancelot Six <lsix@lancelotsix.com>
PR gdb/27393
* source.c (add_path): Skip empty dirnames.
2021-02-26 07:00:43 +08:00
2021-02-25 Kevin Buettner <kevinb@redhat.com>
* nat/aarch64-sve-linux-ptrace.h: Add comment regarding
include order for <sys/ptrace.h> and <asm/ptrace.h>.
gdb: relax assertion in target_mourn_inferior As reported in PR 26861, when killing an inferior on macOS, we hit the assert: ../../gdb-10.1/gdb/target.c:2149: internal-error: void target_mourn_inferior(ptid_t): Assertion `ptid == inferior_ptid' failed. This is because darwin_nat_target::kill passes a pid-only ptid to target_mourn_inferior, with the pid of the current inferior: target_mourn_inferior (ptid_t (inf->pid)); ... which doesn't satisfy the assert in target_mourn_inferior: gdb_assert (ptid == inferior_ptid); The reason for this assertion is that target_mourn_inferior is a prototype shared between GDB and GDBserver, so that shared code in gdb/nat (used in both GDB and GDBserver) can call target_mourn_inferior. In GDB's implementation, it is likely that some targets still rely on inferior_ptid being set to "the current thread we are working on". So until targets are completely decoupled from inferior_ptid (at least their mourn_inferior implementations), we need to ensure the passed in ptid matches inferior_ptid, to ensure the calling code called target_mourn_inferior with the right global context. However, I think the assert is a bit too restrictive. The mourn_inferior operation works on an inferior, not a specific thread. And by the time we call mourn_inferior, the threads of the inferior don't exist anymore, the process is gone, so it doesn't really make sense to require inferior_ptid to point a specific thread. I looked at all the target_ops::mourn_inferior implementations, those that read inferior_ptid only care about the pid field, which supports the idea that only the inferior matters. Other implementations look at the current inferior (call `current_inferior ()`). I think it would make sense to change target_mourn_inferior to accept only a pid rather than a ptid. It would then assert that the pid is the same as the current inferior's pid. However, this would be a quite involved change, so I'll keep it for later. To fix the macOS issue immediately, I propose to relax the assert to only compare the pids, as is done in this patch. Another solution would obviously be to make darwin_nat_target::kill pass inferior_ptid to target_mourn_inferior. However, the solution I propose is more in line with where I think we want to go (passing a pid to target_mourn_inferior). gdb/ChangeLog: PR gdb/26861 * target.c (target_mourn_inferior): Only compare pids in target_mourn_inferior. Change-Id: If2439ccc5aa67272ea16148a43c5362ef23fb2b8
2021-02-26 04:52:29 +08:00
2021-02-25 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/26861
* target.c (target_mourn_inferior): Only compare pids in
target_mourn_inferior.
2021-02-25 Jan Matyas <jmatyas@codasip.com>
PR gdb/26819
* remote.c (remote_target::start_remote): Ensure the single
thread, automatically added for remote targets without the
concept of threading, is initially in set to the "resumed"
state.
* remote.c (remote_target::add_current_inferior_and_thread):
Add return value - return the main thread.
2021-02-25 Jan Vrany <jan.vrany@labware.com>
* gdb/mi/mi-interp.c (mi_traceframe_changed): Remove trailing \n from output.
(mi_tsv_created): Likewise.
(mi_tsv_deleted): Likewise.
[gdb/symtab] Fix wrong unit_type Dwarf Error When running test-case gdb.dwarf2/fission-mix.exp using gcc-11 (and using the tentative fix for PR27353 to get past that assertion failure), I run into: ... (gdb) file fission-mix^M Reading symbols from fission-mix...^M Dwarf Error: wrong unit_type in compilation unit header \ (is DW_UT_split_compile (0x05), should be DW_UT_type (0x02)) \ [in module fission-mix2.dwo]^M (No debugging symbols found in fission-mix)^M ... The compilation unit that is complained about is: ... Contents of the .debug_info.dwo section (loaded from fission-mix2.dwo): Compilation Unit @ offset 0x0: Length: 0x57 (32-bit) Version: 5 Unit Type: DW_UT_split_compile (5) Abbrev Offset: 0x0 Pointer Size: 8 DWO ID: 0x3e3930d3cc1805df <0><14>: Abbrev Number: 1 (DW_TAG_compile_unit) ... And the dwarf error is triggered here in read_comp_unit_head: ... case DW_UT_split_compile: if (section_kind != rcuh_kind::COMPILE) error (_("Dwarf Error: wrong unit_type in compilation unit header " "(is %s, should be %s) [in module %s]"), dwarf_unit_type_name (cu_header->unit_type), dwarf_unit_type_name (DW_UT_type), filename); break; ... due to passing rcuh_kind::TYPE here in open_and_init_dwo_file: ... create_debug_type_hash_table (per_objfile, dwo_file.get (), &dwo_file->sections.info, dwo_file->tus, rcuh_kind::TYPE); ... Fix this by changing the section_kind argument to create_debug_type_hash_table to rcuh_kind::COMPILE, to reflect that we're passing &dwo_file->sections.info rather than &dwo_file->sections.types. Tested on x86_64-linux. gdb/ChangeLog: 2021-02-25 Tom de Vries <tdevries@suse.de> PR symtab/27354 * dwarf2/read.c (open_and_init_dwo_file): Use rcuh_kind::COMPILE as section_kind for &dwo_file->sections.info.
2021-02-25 22:41:49 +08:00
2021-02-25 Tom de Vries <tdevries@suse.de>
PR symtab/27354
* dwarf2/read.c (open_and_init_dwo_file): Use rcuh_kind::COMPILE as
section_kind for &dwo_file->sections.info.
gdb/fortran: don't access non-existent type fields When attempting to call a Fortran function for which there is no debug information we currently trigger undefined behaviour in GDB by accessing non-existent type fields. The reason is that in order to prepare the arguments, for a call to a Fortran function, we need to know the type of each argument. If the function being called has no debug information then obviously GDB doesn't know about the argument types and we should either give the user an error or pick a suitable default. What we currently do is just assume the field exist and access undefined memory, which is clearly wrong. The reason GDB needs to know the argument type is to tell if the argument is artificial or not, artificial arguments will be passed by value while non-artificial arguments will be passed by reference. An ideal solution for this problem would be to allow the user to cast the function to the correct type, we already do this to some degree with the return value, for example: (gdb) print some_func_ () 'some_func_' has unknown return type; cast the call to its declared return type (gdb) print (integer) some_func_ () $1 = 1 But if we could extend this to allow casting to the full function type, GDB could figure out from the signature what are real parameters, and what are artificial parameters. Maybe something like this: (gdb) print ((integer () (integer, double)) some_other_func_ (1, 2.3) Alas, right now the Fortran expression parser doesn't seem to support parsing function signatures, and we certainly don't have support for figuring out real vs artificial arguments from a signature. Still, I think we can prevent GDB from accessing undefined memory and provide a reasonable default behaviour. In this commit I: - Only ask if the argument is artificial if the type of the argument is actually known. - Unknown arguments are assumed to be artificial and passed by value (non-artificial arguments are pass by reference). - If an artificial argument is prefixed with '&' by the user then we treat the argument as pass-by-reference. With these three changes we avoid undefined behaviour in GDB, and allow the user, in most cases, to get a reasonably natural default behaviour. gdb/ChangeLog: PR fortran/26155 * f-lang.c (fortran_argument_convert): Delete declaration. (fortran_prepare_argument): New function. (evaluate_subexp_f): Move logic to new function fortran_prepare_argument. gdb/testsuite/ChangeLog: PR fortran/26155 * gdb.fortran/call-no-debug-func.f90: New file. * gdb.fortran/call-no-debug-prog.f90: New file. * gdb.fortran/call-no-debug.exp: New file.
2020-11-13 18:39:23 +08:00
2021-02-25 Andrew Burgess <andrew.burgess@embecosm.com>
PR fortran/26155
* f-lang.c (fortran_argument_convert): Delete declaration.
(fortran_prepare_argument): New function.
(evaluate_subexp_f): Move logic to new function
fortran_prepare_argument.
2021-02-25 Andrew Burgess <andrew.burgess@embecosm.com>
* f-exp.y (f77_keywords): Add 'associated'.
* f-lang.c (fortran_associated): New function.
(evaluate_subexp_f): Handle FORTRAN_ASSOCIATED.
(operator_length_f): Likewise.
(print_unop_or_binop_subexp_f): New function.
(print_subexp_f): Make use of print_unop_or_binop_subexp_f for
FORTRAN_ASSOCIATED, FORTRAN_LBOUND, and FORTRAN_UBOUND.
(dump_subexp_body_f): Handle FORTRAN_ASSOCIATED.
(operator_check_f): Likewise.
* std-operator.def: Add FORTRAN_ASSOCIATED.
2021-02-25 Andrew Burgess <andrew.burgess@embecosm.com>
* f-exp.y (fortran_operators): Add ".xor.".
[gdb/symtab] Handle DW_AT_decl_file with form DW_FORM_implicit_const With test-case gdb.cp/temargs.exp on target board \ unix/gdb:debug_flags=-gdwarf-5 I run into: ... (gdb) info addr I^M ERROR: GDB process no longer exists GDB process exited with wait status 32286 exp19 0 0 CHILDKILLED SIGABRT SIGABRT UNRESOLVED: gdb.cp/temargs.exp: test address of I in templ_m ... This is a regression since commit 529908cbd0a "Remove DW_UNSND". The problem is that this DW_AT_decl_file: ... <1><221>: Abbrev Number: 4 (DW_TAG_structure_type) <222> DW_AT_name : Base<double, 23, (& a_global), &S::f> <226> DW_AT_byte_size : 1 <226> DW_AT_decl_file : 1 <226> DW_AT_decl_line : 30 <227> DW_AT_sibling : <0x299> ... is not read by this code in new_symbol: .... attr = dwarf2_attr (die, inlined_func ? DW_AT_call_file : DW_AT_decl_file, cu); if (attr != nullptr && attr->form_is_unsigned ()) ... because DW_AT_decl_file has form DW_FORM_implicit_const: ... 4 DW_TAG_structure_type [has children] DW_AT_name DW_FORM_strp DW_AT_byte_size DW_FORM_implicit_const: 1 DW_AT_decl_file DW_FORM_implicit_const: 1 DW_AT_decl_line DW_FORM_data1 DW_AT_sibling DW_FORM_ref4 DW_AT value: 0 DW_FORM value: 0 ... which is a signed LEB128, so attr->form_is_unsigned () returns false. Fix this by introducing new functions is_nonnegative and as_nonnegative, and use these instead of form_is_unsigned and as_unsigned. Tested on x86_64-linux. gdb/ChangeLog: 2021-02-24 Tom de Vries <tdevries@suse.de> PR symtab/27336 * dwarf2/attribute.c (attribute::form_is_signed): New function factored out of ... * dwarf2/attribute.h (attribute::as_signed): ... here. (attribute::is_nonnegative, attribute::as_nonnegative): New function. (attribute::form_is_signed): Declare. * dwarf2/read.c (new_symbol): Use is_nonnegative and as_nonnegative for DW_AT_decl_file.
2021-02-25 06:58:42 +08:00
2021-02-24 Tom de Vries <tdevries@suse.de>
PR symtab/27336
* dwarf2/attribute.c (attribute::form_is_signed): New function
factored out of ...
* dwarf2/attribute.h (attribute::as_signed): ... here.
(attribute::is_nonnegative, attribute::as_nonnegative): New function.
(attribute::form_is_signed): Declare.
* dwarf2/read.c (new_symbol): Use is_nonnegative and as_nonnegative
for DW_AT_decl_file.
2021-02-24 Kevin Buettner <kevinb@redhat.com>
* nat/aarch64-linux-hw-point.c: Add comment regarding include
order for <sys/ptrace.h> and <asm/ptrace.h>.
2021-02-24 Kevin Buettner <kevinb@redhat.com>
* nat/aarch64-linux-hw-point.c: Include <asm/ptrace.h> after
<sys/ptrace.h>.
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* exec.c (set_section_command): Move variable declarations into
the function body, and use std::string instead of a fixed size
buffer.
gdb: move get_section_table from exec_target to dummy_target The only target that implements target_ops::get_section_table in a meaningful way is exec_target. This target calls back into the program space to return the current global section_table. The global section table is populated whenever the user provides GDB with an executable, or when a symbol file is loaded, e.g. when a dynamic library is loaded, or when the user does add-symbol-file. I recently ran into a situation where a user, debugging a remote target, was not supplying GDB with a main executable at all. Instead the user attached to the target then did add-symbol-file, and then proceeded to debug the target. This works fine, but it was noticed that even when trust-readonly-sections was on GDB was still accessing the target to get the contents of readonly sections. The problem is that by not providing an executable there was no exec_target in the target stack, and so when GDB calls the target_ops::get_section_table function GDB ends up in dummy_target::get_section_table, which just returns NULL. What I want is that even when GDB doesn't have an exec_target in the target stack, a call to target_ops::get_section_table will still return the section_table from the current program space. When considering how to achieve this my first though was, why is the request for the section table going via the target stack at all? The set of sections loaded is a property of the program space, not the target. This is, after all, why the data is being stored in the program space. So I initially tried changing target_get_section_table so that, instead of calling into the target it just returns current_program_space->target_sections (). This would be fine except for one issue, target_bfd (from bfd-target.c). This code is used from solib-svr4.c to create a temporary target_ops structure that implements two functions target_bfd::xfer_partial and target_bfd::get_section_table. The purpose behind the code is to enable two targets, ppc64 and frv to decode function descriptors from the dynamic linker, based on the non-relocated addresses from within the dynamic linker bfd object. Both of the implemented functions in target_bfd rely on the target_bfd object holding a section table, and the ppc64 target requires that the target_bfd implement ::get_section_table. The frv target doesn't require ::get_section_table, instead it requires the ::xfer_partial. We could in theory change the ppc64 target to use the same approach as frv, however, this would be a bad idea. I believe that the frv target approach is broken. I'll explain: The frv target calls get_target_memory_unsigned to read the function descriptor. The address being read is the non-relocated address read from the dynamic linker in solib-srv4.c:enable_break. Calling get_target_memory_unsigned eventually ends up in target_xfer_partial with an object type of TARGET_OBJECT_RAW_MEMORY. This will then call memory_xfer_check_region. I believe that it is quite possible that a the non-relocated addresses pulled from the dynamic linker could be in a memory region that is not readable, while the relocated addresses are in a readable memory region. If this was ever the case for the frv target then GDB would reject the attempt to read the non-relocated function pointer. In contrast the ppc64 target calls target_section_by_addr, which calls target_get_section_table, which then calls the ::get_section_table function on the target. Thus, when reflecting on target_bfd we see two functions, ::xfer_partial and ::get_section_table. The former is required by the frv target, but that target is (I think) potentially broken. While the latter is required by the ppc64 target, but this forces ::get_section_table to exist as a target_ops member function. So my original plan, have target_get_section_table NOT call a target_ops member function appears to be flawed. My next idea was to remove exec_target::get_section_table, and instead move the implementation into dummy_target::get_section_table. Currently the dummy_target implementation always returns NULL indicating no section table, but plenty of other dummy_target member functions do more than just return null values. So now, dummy_target::get_section_table returns the section table from the current program space. This allows target_bfd to remain unchanged, so ppc64 and frv should not be affected. Making this change removes the requirement for the user to provide an executable, GDB can now always access the section_table, as the dummy_target always exists in the target stack. Finally, there's a test that the target_section table is not empty in the case where the user does add-symbol-file without providing an executable. gdb/ChangeLog: * exec.c (exec_target::get_section_table): Delete member function. (section_table_read_available_memory): Use current_top_target, not just the exec_ops target. * target-delegates.c: Regenerate. * target.c (default_get_section_table): New function. * target.h (target_ops::get_section_table): Change default behaviour to call default_get_section_table. (default_get_section_table): Declare.
2021-02-12 19:39:31 +08:00
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* exec.c (exec_target::get_section_table): Delete member function.
(section_table_read_available_memory): Use current_top_target, not
just the exec_ops target.
* target-delegates.c: Regenerate.
* target.c (default_get_section_table): New function.
* target.h (target_ops::get_section_table): Change default
behaviour to call default_get_section_table.
(default_get_section_table): Declare.
gdb: make the target_sections table private within program_space Following on from earlier commits which made access to the target_sections table more 'const', this commit makes the table private within the program_space class and provides member functions to access the table. Ideally I would have liked for the new target_sections member function (on program_space) to return a 'const' reference to the table within the program_space. Unfortunately, there are two places in solib-*.c, where code outside of the program_space class modifies the target_sections table, and so to support this we need to return a non-const reference. There should be no user visible changes after this commit. gdb/ChangeLog: * exec.c (exec_target::close): Call new clear_target_sections function. (program_space::add_target_sections): Update name of member variable. (program_space::foreach_target_section): New function. (program_space::add_target_sections): Update name of member variable. (program_space::remove_target_sections): Likewise. (exec_one_fork): Use new target_sections member function. (exec_target::get_section_table): Likewise. (exec_target::files_info): Likewise. (set_section_command): Use new foreach_target_section member function. (exec_set_section_address): Likewise. (exec_target::has_memory): Use new target_sections member function. * progspace.h (program_space::clear_target_sections): New member function. (program_space::target_sections): Rename member variable to m_target_sections, replace with a new member function. (program_space::foreach_target_section): Declare new member function. (program_space::m_target_sections): New member variable. * solib-dsbt.c (scan_dyntag): Use new member function. * solib-svr4.c (scan_dyntag): Likewise.
2021-02-12 20:06:15 +08:00
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* exec.c (exec_target::close): Call new clear_target_sections
function.
(program_space::add_target_sections): Update name of member
variable.
(program_space::add_target_sections): Update name of member
variable.
(program_space::remove_target_sections): Likewise.
(exec_one_fork): Use new target_sections member function.
(exec_target::get_section_table): Likewise.
(exec_target::files_info): Likewise.
(set_section_command): Likewise.
(exec_set_section_address): Likewise.
(exec_target::has_memory): Use new target_sections member
function.
* progspace.h (program_space::clear_target_sections): New member
function.
(program_space::target_sections): Rename member variable to
m_target_sections, replace with a new member function.
(program_space::m_target_sections): New member variable.
* solib-dsbt.c (scan_dyntag): Use new member function.
* solib-svr4.c (scan_dyntag): Likewise.
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb/bfd-target.c (class target_bfd) <get_section_table>: Make
return type const.
* gdb/exec.c (struct exec_target) <get_section_table>: Likewise.
(section_table_read_available_memory): Make local const.
(exec_target::xfer_partial): Make local const.
(print_section_info): Make parameter const.
* gdb/exec.h (print_section_info): Likewise.
* gdb/ppc64-tdep.c (ppc64_convert_from_func_ptr_addr): Make local
const.
* gdb/record-btrace.c (record_btrace_target::xfer_partial):
Likewise.
* gdb/remote.c (remote_target::remote_xfer_live_readonly_partial):
Likewise.
* gdb/s390-tdep.c (s390_load): Likewise.
* gdb/solib-dsbt.c (scan_dyntag): Likewise.
* gdb/solib-svr4.c (scan_dyntag): Likewise.
* gdb/target-debug.h (target_debug_print_target_section_table_p):
Rename to...
(target_debug_print_const_target_section_table_p): ...this.
* gdb/target-delegates.c: Regenerate.
* gdb/target.c (target_get_section_table): Make return type const.
(target_section_by_addr): Likewise. Also make some locals const.
(memory_xfer_partial_1): Make some locals const.
* gdb/target.h (struct target_ops) <get_section_table>: Make
return type const.
(target_section_by_addr): Likewise.
(target_get_section_table): Likewise.
gdb: add a new 'maint info target-sections' command We already have a command 'maint info sections', this command prints all sections from all known object files. However, GDB maintains a second section table internally. This section table is used when GDB wants to read directly from an object file rather than actually reading memory on the target. As such only some sections (the allocatable ones) are added to this secondary section table. I recently ran into a situation where some of GDB's optimisations for reading directly from the files were not working. In 'maint info sections' I could see that GDB knew about the object file, and did know about the sections that it _should_ have been reading from. But I couldn't ask GDB which sections it had copied into its secondary section table. This commit adds a new command 'maint info target-sections' that fills this gap. This command lists only those sections that GDB has copied into its secondary table. You'll notice that the testsuite includes a comment indicating that there's a bug in GDB. Normally this is not something I would add to the testsuite, instead we should raise an actual bugzilla bug and then mark an xfail, however, a later patch in this series will remove this comment once the actual bug in GDB is fixed. gdb/ChangeLog: * NEWS: Mention new 'maint info target-sections' command. * maint.c (maintenance_info_target_sections): New function. (_initialize_maint_cmds): Register new command. gdb/doc/ChangeLog: * gdb.texinfo (Files): Document new 'maint info target-sections' command. gdb/testsuite/ChangeLog: * gdb.base/maint-info-sections.exp: Add new tests. (check_maint_info_target_sections_output): New proc.
2021-02-13 00:10:56 +08:00
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* NEWS: Mention new 'maint info target-sections' command.
* maint.c (maintenance_info_target_sections): New function.
(_initialize_maint_cmds): Register new command.
gdb/riscv: select rv32 target by default when requested GDB for RISC-V always uses target descriptions. When the target doesn't provide a target description then a default is selected. Usually this default is selected based on the properties of the executable being debugged. However, when there is no executable being debugged we currently fallback to the riscv:rv64 target description as the default. This leads to strange behaviour like this: $ gdb (gdb) set architecture riscv:rv32 (gdb) p sizeof ($pc) $1 = 8 Despite the users specifically setting the architecture to riscv:rv32 GDB still thinks that the target has riscv:rv64 register sizes. The above is a bit of a contrived situation. I actually ran into this situation while trying to connect to a running riscv:rv32 target without supplying an executable (the target didn't provide a target description). When I tried to set a register on the target I ran into errors because GDB was passing 8 bytes to the target rather than the expected 4. Even when I manually specified the architecture (as above) I couldn't convince GDB to only send 4 bytes. This patch fixes this issue. Now, when we selected a default target description we will make use of the user selected architecture to guide our choice. In the above example we now get: $ gdb (gdb) set architecture riscv:rv32 (gdb) p sizeof ($pc) $1 = 4 And my real world example of connecting to a remote without an executable works fine. I've used the fact that we can ask GDB about $pc even when no executable is loaded as the basis for a test to cover this situation. gdb/ChangeLog: * riscv-tdep.c (riscv_features_from_gdbarch_info): Rename to... (riscv_features_from_bfd): ...this. Change parameter type to 'bfd*', and update as required. (riscv_find_default_target_description): Update call to riscv_features_from_bfd. Select a default xlen based on info.bfd_arch_info. (riscv_gdbarch_init): Update call to riscv_features_from_bfd. gdb/testsuite/ChangeLog: * gdb.arch/riscv-default-tdesc.exp: New file.
2021-02-05 02:34:13 +08:00
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-tdep.c (riscv_features_from_gdbarch_info): Rename to...
(riscv_features_from_bfd): ...this. Change parameter type to
'bfd*', and update as required.
(riscv_find_default_target_description): Update call to
riscv_features_from_bfd. Select a default xlen based on
info.bfd_arch_info.
(riscv_gdbarch_init): Update call to riscv_features_from_bfd.
gdb: call value_ind for pointers to dynamic types in UNOP_IND evaluation When evaluating and expression containing UNOP_IND in mode EVAL_AVOID_SIDE_EFFECTS, GDB currently (mostly) returns the result of a call to value_zero meaning we get back an object with the correct type, but its contents are all zero. If the target type contains fields with dynamic type then in order to resolve these dynamic fields GDB will need to read the value of the field from within the parent object. In this case the field value will be zero as a result of the call to value_zero mentioned above. The idea behind EVAL_AVOID_SIDE_EFFECTS is to avoid the chance that doing something like `ptype` will modify state within the target, for example consider: ptype i++. However, there is already precedence within GDB that sometimes, in order to get accurate type results, we can't avoid reading from the target, even when EVAL_AVOID_SIDE_EFFECTS is in effect. For example I would point to eval.c:evaluate_var_value, the handling of OP_REGISTER, the handling of value_x_unop in many places. I believe the Ada expression evaluator also ignore EVAL_AVOID_SIDE_EFFECTS in some cases. I am therefor proposing that, in the case where a pointer points at a dynamic type, we allow UNOP_IND to perform the actual indirection. This allows accurate types to be displayed in more cases. gdb/ChangeLog: * eval.c (evaluate_subexp_standard): Call value_ind for points to dynamic types in UNOP_IND. gdb/testsuite/ChangeLog: * gdb.fortran/pointer-to-pointer.exp: Additional tests.
2021-01-08 22:00:45 +08:00
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* eval.c (evaluate_subexp_standard): Call value_ind for points to
dynamic types in UNOP_IND.
gdb/dwarf: create and destroy dwarf2_per_bfd's CUs-to-expand queue As described in the log of patch "gdb/dwarf: add assertion in maybe_queue_comp_unit", it would happen that a call to maybe_queue_comp_unit would enqueue a CU in the to-expand queue while nothing up the stack was processing the queue. This is not desirable, as items are then left lingering in the queue when we exit the dwarf2/read code. This is an inconsistent state. The normal case of using the queue is when we go through dw2_do_instantiate_symtab and process_queue. As depended-on CUs are found, they get added to the queue. process_queue expands CUs until the queue is empty. To catch these cases where things are enqueued while nothing up the stack is processing the queue, change dwarf2_per_bfd::queue to be an optional. The optional is instantiated in dwarf2_queue_guard, just before where we call process_queue. In the dwarf2_queue_guard destructor, the optional gets reset. Therefore, the queue object is instantiated only when something up the stack is handling it. If another entry point tries to enqueue a CU for expansion, an assertion will fail and we know we have something to fix. dwarf2_queue_guard sounds like the good place for this, as it's currently responsible for making sure the queue gets cleared if we exit due to an error. This also allows asserting that when age_comp_units or remove_all_cus run, the queue is not instantiated, and gives us one more level of assurance that we won't free the DIEs of a CU that is in the CUs-to-expand queue. gdb/ChangeLog: PR gdb/26828 * dwarf2/read.c (dwarf2_queue_guard) <dwarf2_queue_guard>: Instantiate queue. (~dwarf2_queue_guard): Clear queue. (queue_comp_unit): Assert that queue is instantiated. (process_queue): Adjust. * dwarf2/read.h (struct dwarf2_per_bfd) <queue>: Make optional. Change-Id: I8fe3d77845bb4ad3d309eac906acebe79d9f0a9d
2021-02-24 02:37:44 +08:00
2021-02-23 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/26828
* dwarf2/read.c (dwarf2_queue_guard) <dwarf2_queue_guard>:
Instantiate queue.
(~dwarf2_queue_guard): Clear queue.
(queue_comp_unit): Assert that queue is
instantiated.
(process_queue): Adjust.
* dwarf2/read.h (struct dwarf2_per_bfd) <queue>: Make optional.
gdb/dwarf: don't enqueue CU in maybe_queue_comp_unit if already expanded The previous commit log described how items could be left lingering in the dwarf2_per_bfd::queue and how that could cause trouble. This patch fixes the issue by changing maybe_queue_comp_unit so that it doesn't put a CU in the to-expand queue if that CU is already expanded. This will make it so that when dwarf2_fetch_die_type_sect_off calls follow_die_offset and maybe_queue_comp_unit, it won't enqueue the target CU, because it will see the CU is already expanded. This assumes that if a CU is dwarf2_fetch_die_type_sect_off's target CU, it will have previously been expanded. I think it is the case, but I can't be 100% sure. If that's not true, the assertions added in the following patch will catch it, and it means we'll have to re-think a bit more how things work (it wouldn't be well handled at all today anyway). This fixes something else in maybe_queue_comp_unit that looks wrong. Imagine the DIEs of a CU are loaded in memory, but that CU is not expanded. In that case, maybe_queue_comp_unit will use this early return: /* If the compilation unit is already loaded, just mark it as used. */ dwarf2_cu *cu = per_objfile->get_cu (per_cu); if (cu != nullptr) { cu->last_used = 0; return 0; } ... so the CU won't be queued for expansion. Whether the DIEs of a CU are loaded in memory and whether that CU is expanded are two orthogonal things, but that function appears to mix them. So, move the queuing above that check / early return, so that if the CU's DIEs are loaded in memory but the CU is not expanded yet, it gets enqueued. I tried to improve maybe_queue_comp_unit's documentation to clarify what the return value means. By clarifying this, I noticed that two callers (follow_die_offset and follow_die_sig_1) access the CU's DIEs after calling maybe_queue_comp_unit, only relying on maybe_queue_comp_unit's return value to tell whether DIEs need to be loaded first or not. As explained in the new comment, this is problematic: maybe_queue_comp_unit's return value doesn't tell whether DIEs are currently loaded, it means whether maybe_queue_comp_unit requires the caller to load them. If the CU is already expanded but the DIEs to have been freed, maybe_queue_comp_unit returns 0, meaning "I don't need you to load the DIEs". So if these two functions (follow_die_offset and follow_die_sig_1) need to access the DIEs in any case, for their own usage, they should make sure to load them if they are not loaded already. I therefore added an extra check to the condition they use, making it so they will always load the DIEs if they aren't already. From what I found, other callers don't care for the CU's DIEs, they call maybe_queue_comp_unit to ensure the CU gets expanded eventually, but don't care for it after that. gdb/ChangeLog: PR gdb/26828 * dwarf2/read.c (maybe_queue_comp_unit): Check if CU is expanded to decide whether or not to enqueue it for expansion. (follow_die_offset, follow_die_sig_1): Ensure we load the DIEs after calling maybe_queue_comp_unit. Change-Id: Id98c6b60669f4b4b21b9be16d0518fc62bdf686a
2021-02-24 01:07:10 +08:00
2021-02-23 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/26828
* dwarf2/read.c (maybe_queue_comp_unit): Check if CU is expanded
to decide whether or not to enqueue it for expansion.
(follow_die_offset, follow_die_sig_1): Ensure we load the DIEs
after calling maybe_queue_comp_unit.
2021-02-23 Simon Marchi <simon.marchi@polymtl.ca>
* linux-nat.c (linux_nat_filter_event): Return void.
2021-02-22 Tom Tromey <tromey@adacore.com>
* solib-svr4.c (enable_break): Update.
* bfd-target.c (class target_bfd) <target_bfd>: Change parameter
type.
(target_bfd_reopen): Change parameter type.
* bfd-target.h (target_bfd_reopen): Change parameter type.
2021-02-22 Simon Marchi <simon.marchi@polymtl.ca>
* thread.c (add_thread_silent): Add assert.
(find_thread_ptid): Add assert.
gdb: push target earlier in procfs_target::attach (PR 27435) Since this is a GDB 9 -> 10 regression, I would like to push it to gdb-10-branch. This is a follow-up to: https://sourceware.org/pipermail/gdb-patches/2021-February/176202.html This patch fixes a segfault seen when attaching to a process on Solaris. The steps leading to the segfault are: - procfs_target::attach calls do_attach, at this point the inferior's process slot in the target stack is empty. - do_attach adds a thread with `add_thread (&the_procfs_target, ptid)` - in add_thread_silent, the passed target (&the_procfs_target) is passed to find_inferior_ptid - find_inferior_ptid returns nullptr, as there is no inferior with this ptid that has &the_procfs_target as its process target - the nullptr `inf` is passed to find_thread_ptid, which dereferences it, causing a segfault - back in procfs_target::attach, after do_attach, we push the the_procfs_target on the inferior's target stack, although we never reach this because the segfault happens before. To fix this, I think we need to do the same as is done in inf_ptrace_target::attach: push the target early and unpush it in case the attach fails (and keep it if the attach succeeds). Implement it by moving target_unpush_up to target.h, so it can be re-used here. Make procfs_target::attach use it. Note that just like is mentioned in inf_ptrace_target::attach, we should push the target before calling target_pid_to_str, so that calling target_pid_to_str ends up in procfs_target::pid_to_str. Tested by trying to attach on a process on gcc211 on the gcc compile farm. gdb/ChangeLog: PR gdb/27435 * inf-ptrace.c (struct target_unpusher): Move to target.h. (target_unpush_up): Likewise. * procfs.c (procfs_target::attach): Push target early. Use target_unpush_up to unpush target in case of error. * target.h (struct target_unpusher): Move here. (target_unpush_up): Likewise. Change-Id: I88aff8b20204e1ca1d792e27ac6bc34fc1aa0d52
2021-02-23 00:41:32 +08:00
2021-02-22 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/27435
* inf-ptrace.c (struct target_unpusher): Move to target.h.
(target_unpush_up): Likewise.
* procfs.c (procfs_target::attach): Push target early. Use
target_unpush_up to unpush target in case of error.
* target.h (struct target_unpusher): Move here.
(target_unpush_up): Likewise.
2021-02-19 Kevin Buettner <kevinb@redhat.com>
* nat/amd64-linux-siginfo.c: Include "gdbsupport/common-defs.h"
(which in turn includes <gnulib/config.h>) before include
of <signal.h>.
RISC-V: PR27158, fixed UJ/SB types and added CSS/CL/CS types for .insn. * Renamed obsolete UJ/SB types and RVC types, also added CSS/CL(CS) types, [VALID/EXTRACT/ENCODE macros] BTYPE_IMM: Renamed from SBTYPE_IMM. JTYPE_IMM: Renamed from UJTYPE_IMM. CITYPE_IMM: Renamed from RVC_IMM. CITYPE_LUI_IMM: Renamed from RVC_LUI_IMM. CITYPE_ADDI16SP_IMM: Renamed from RVC_ADDI16SP_IMM. CITYPE_LWSP_IMM: Renamed from RVC_LWSP_IMM. CITYPE_LDSP_IMM: Renamed from RVC_LDSP_IMM. CIWTYPE_IMM: Renamed from RVC_UIMM8. CIWTYPE_ADDI4SPN_IMM: Renamed from RVC_ADDI4SPN_IMM. CSSTYPE_IMM: Added for .insn without special encoding. CSSTYPE_SWSP_IMM: Renamed from RVC_SWSP_IMM. CSSTYPE_SDSP_IMM: Renamed from RVC_SDSP_IMM. CLTYPE_IMM: Added for .insn without special encoding. CLTYPE_LW_IMM: Renamed from RVC_LW_IMM. CLTYPE_LD_IMM: Renamed from RVC_LD_IMM. RVC_SIMM3: Unused and removed. CBTYPE_IMM: Renamed from RVC_B_IMM. CJTYPE_IMM: Renamed from RVC_J_IMM. * Added new operands and removed the unused ones, C5: Unsigned CL(CS) immediate, added for .insn directive. C6: Unsigned CSS immediate, added for .insn directive. Ci: Unused and removed. C<: Unused and removed. bfd/ PR 27158 * elfnn-riscv.c (perform_relocation): Updated encoding macros. (_bfd_riscv_relax_call): Likewise. (_bfd_riscv_relax_lui): Likewise. * elfxx-riscv.c (howto_table): Likewise. gas/ PR 27158 * config/tc-riscv.c (riscv_ip): Updated encoding macros. (md_apply_fix): Likewise. (md_convert_frag_branch): Likewise. (validate_riscv_insn): Likewise. Also arranged operands, including added C5 and C6 operands, and removed unused Ci and C< operands. * doc/c-riscv.texi: Updated and added CSS/CL/CS types. * testsuite/gas/riscv/insn.d: Added CSS/CL/CS instructions. * testsuite/gas/riscv/insn.s: Likewise. gdb/ PR 27158 * riscv-tdep.c (decode_ci_type_insn): Updated encoding macros. (decode_j_type_insn): Likewise. (decode_cj_type_insn): Likewise. (decode_b_type_insn): Likewise. (decode): Likewise. include/ PR 27158 * opcode/riscv.h: Updated encoding macros. opcodes/ PR 27158 * riscv-dis.c (print_insn_args): Updated encoding macros. * riscv-opc.c (MASK_RVC_IMM): defined to ENCODE_CITYPE_IMM. (match_c_addi16sp): Updated encoding macros. (match_c_lui): Likewise. (match_c_lui_with_hint): Likewise. (match_c_addi4spn): Likewise. (match_c_slli): Likewise. (match_slli_as_c_slli): Likewise. (match_c_slli64): Likewise. (match_srxi_as_c_srxi): Likewise. (riscv_insn_types): Added .insn css/cl/cs. sim/ PR 27158 * riscv/sim-main.c (execute_i): Updated encoding macros.
2021-01-26 18:02:38 +08:00
2021-02-19 Nelson Chu <nelson.chu@sifive.com>
PR 27158
* riscv-tdep.c (decode_ci_type_insn): Updated encoding macros.
(decode_j_type_insn): Likewise.
(decode_cj_type_insn): Likewise.
(decode_b_type_insn): Likewise.
(decode): Likewise.
2021-02-18 Tom Tromey <tom@tromey.com>
* expression.h (struct expression) <evaluate>: Declare method.
* eval.c (evaluate_subexp): Simplify.
(expression::evaluate): New method.
(evaluate_expression, evaluate_type): Use expression::evaluate.
Fix completion related libstdc++ assert when using -D_GLIBCXX_DEBUG This commit fixes a libstdc++ assertion failure encountered when running gdb.base/completion.exp. In order to see this problem, GDB must be built with the follow CFLAGS and CXXFLAGS as part of the configure line: CFLAGS='-D_GLIBCXX_DEBUG' CXXFLAGS='-D_GLIBCXX_DEBUG' (Also, this problem was encountered using Fedora rawhide. It might not be reproducible in Fedora versions prior to Fedora 34.) Using the gdb.base/completion.exp test program, the problem can be observed as follows: [kev@rawhide-1 gdb]$ ./gdb -q testsuite/outputs/gdb.base/completion/completion Reading symbols from testsuite/outputs/gdb.base/completion/completion... (gdb) start Temporary breakpoint 1 at 0x401179: file ../../worktree-master/gdb/testsuite/gdb.base/break.c, line 43. Starting program: testsuite/outputs/gdb.base/completion/completion Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd718, envp=0x7fffffffd728) at ../../worktree-master/gdb/testsuite/gdb.base/break.c:43 43 if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ (gdb) p <TAB>/usr/include/c++/11/string_view:211: constexpr const value_type& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; std::basic_string_view<_CharT, _Traits>::const_reference = const char&; std::basic_string_view<_CharT, _Traits>::size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed. Aborted (core dumped) (Note that I added "<TAB>" to make it clear where the tab key was pressed.) gdb/ChangeLog: * ada-lang.c (ada_fold_name): Check for non-empty string prior to accessing it. (ada_lookup_name_info): Likewise.
2021-02-13 08:53:51 +08:00
2021-02-17 Kevin Buettner <kevinb@redhat.com>
* ada-lang.c (ada_fold_name): Check for non-empty string prior
to accessing it.
(ada_lookup_name_info): Likewise.
2021-02-13 Mike Frysinger <vapier@gentoo.org>
* aclocal.m4: Regenerate.
[gdb/threads] Fix lin_thread_get_thread_signals for glibc 2.28 When running test-case gdb.threads/create-fail.exp on openSUSE Factory (with glibc version 2.32) I run into: ... (gdb) continue Continuing. [New Thread 0x7ffff7c83700 (LWP 626354)] [New Thread 0x7ffff7482700 (LWP 626355)] [Thread 0x7ffff7c83700 (LWP 626354) exited] [New Thread 0x7ffff6c81700 (LWP 626356)] [Thread 0x7ffff7482700 (LWP 626355) exited] [New Thread 0x7ffff6480700 (LWP 626357)] [Thread 0x7ffff6c81700 (LWP 626356) exited] [New Thread 0x7ffff5c7f700 (LWP 626358)] [Thread 0x7ffff6480700 (LWP 626357) exited] pthread_create: 22: Invalid argument Thread 6 "create-fail" received signal SIG32, Real-time event 32. [Switching to Thread 0x7ffff5c7f700 (LWP 626358)] 0x00007ffff7d87695 in clone () from /lib64/libc.so.6 (gdb) FAIL: gdb.threads/create-fail.exp: iteration 1: run till end ... The problem is that glibc-internal signal SIGCANCEL is not recognized by gdb. There's code in check_thread_signals that is supposed to take care of that, but it's not working because this code in lin_thread_get_thread_signals has stopped working: ... /* NPTL reserves the first two RT signals, but does not provide any way for the debugger to query the signal numbers - fortunately they don't change. */ sigaddset (set, __SIGRTMIN); sigaddset (set, __SIGRTMIN + 1); ... Since glibc commit d2dc5467c6 "Filter out NPTL internal signals (BZ #22391)" (first released as part of glibc 2.28), a sigaddset with a glibc-internal signal has no other effect than setting errno to EINVALID. Fix this by eliminating the usage of sigset_t in check_thread_signals and lin_thread_get_thread_signals. The same problem was observed on Ubuntu 20.04. Tested on x86_64-linux, openSUSE Factory. Tested on aarch64-linux, Ubuntu 20.04 and Ubuntu 18.04. gdb/ChangeLog: 2021-02-12 Tom de Vries <tdevries@suse.de> PR threads/26228 * linux-nat.c (lin_thread_get_thread_signals): Remove. (lin_thread_signals): New static var. (lin_thread_get_thread_signal_num, lin_thread_get_thread_signal): New function. * linux-nat.h (lin_thread_get_thread_signals): Remove. (lin_thread_get_thread_signal_num, lin_thread_get_thread_signal): Declare. * linux-thread-db.c (check_thread_signals): Use lin_thread_get_thread_signal_num and lin_thread_get_thread_signal.
2021-02-13 03:12:37 +08:00
2021-02-12 Tom de Vries <tdevries@suse.de>
PR threads/26228
* linux-nat.c (lin_thread_get_thread_signals): Remove.
(lin_thread_signals): New static var.
(lin_thread_get_thread_signal_num, lin_thread_get_thread_signal):
New function.
* linux-nat.h (lin_thread_get_thread_signals): Remove.
(lin_thread_get_thread_signal_num, lin_thread_get_thread_signal):
Declare.
* linux-thread-db.c (check_thread_signals): Use
lin_thread_get_thread_signal_num and lin_thread_get_thread_signal.
2021-02-12 Andrew Burgess <andrew.burgess@embecosm.com>
* f-exp.y (f77_keywords): Add allocated.
* f-lang.c (evaluate_subexp_f): Handle UNOP_FORTRAN_ALLOCATED.
(operator_length_f): Likewise.
(print_subexp_f): Likewise.
(dump_subexp_body_f): Likewise.
(operator_check_f): Likewise.
* std-operator.def (UNOP_FORTRAN_ALLOCATED): New operator.
2021-02-11 Tom de Vries <tdevries@suse.de>
PR symtab/27353
* dwarf2/attribute.c (attribute::form_requires_reprocessing):
Return true for DW_FORM_strx.
2021-02-11 Tom Tromey <tromey@adacore.com>
PR gdb/27383:
* parse.c (write_exp_symbol_reference): Write sym.block.
gdb: change 'maint info section' to use command options The 'maintenance info sections' command currently takes a list of filters on the command line. It can also accept the magic string 'ALLOBJ' which acts more like a command line flag, telling the command to print information about all objfiles. The manual has this to say about the options and filters: ... In addition, 'maint info sections' provides the following command options (which may be arbitrarily combined): ... Implying (to me at least) that I can do this: (gdb) maint info sections ALLOBJ READONLY to list all the read-only sections from all currently loaded object files. Unfortunately, this doesn't work. The READONLY filter will work, but ALLOBJ will not be detected correctly. It would be fairly simple to fix the ALLOBJ detection. However, I dislike this mixing of command options (ALLOBJ) with command data (the filters, e.g. READONLY, etc). As this is a maintenance command, so not really intended for end users, I think we can be a little more aggressive in "fixing" the option parsing. So that's what I do in this commit. The ALLOBJ mechanism is replaced with a real command option (-all-objects). The rest of the command operates just as before. The example above would now become: (gdb) maint info sections -all-objects READONLY The manual has been updated, and I added a NEWS entry to document the change. gdb/ChangeLog: * NEWS: Mention changes to 'maint info sections'. * maint.c (match_substring): Return a bool, fix whitespace issue. (struct single_bfd_flag_info): New struct. (bfd_flag_info): New static global. (match_bfd_flags): Return a bool, use bfd_flag_info. (print_bfd_flags): Use bfd_flag_info. (maint_print_section_info): Delete trailing whitespace. (struct maint_info_sections_opts): New struct. (maint_info_sections_option_defs): New static global. (maint_info_sections_completer): New function. (maintenance_info_sections): Use option parsing mechanism. (_initialize_maint_cmds): Register command completer. gdb/doc/ChangeLog: * gdb.texinfo (Files): Update documentation for 'maint info sections'. gdb/testsuite/ChangeLog: * gdb.base/maint-info-sections.exp: Update expected output, and add additional tests. Again.
2021-02-05 21:51:34 +08:00
2021-02-11 Andrew Burgess <andrew.burgess@embecosm.com>
* NEWS: Mention changes to 'maint info sections'.
* maint.c (match_substring): Return a bool, fix whitespace issue.
(struct single_bfd_flag_info): New struct.
(bfd_flag_info): New static global.
(match_bfd_flags): Return a bool, use bfd_flag_info.
(print_bfd_flags): Use bfd_flag_info.
(maint_print_section_info): Delete trailing whitespace.
(struct maint_info_sections_opts): New struct.
(maint_info_sections_option_defs): New static global.
(maint_info_sections_completer): New function.
(maintenance_info_sections): Use option parsing mechanism.
(_initialize_maint_cmds): Update command help text for 'maint info
sections' and register a command completer.
gdb: 'maint info sections' - handle the no executable case The 'maint info sections' command is split into two blocks or work, first if there's an executable then the sections from the executable, and optionally all other loaded object files are printed. Then all the sections from any core file are printed. I ran into a situation where (for various reasons) I wasn't using a main executable. Instead I connected to a remote target and used add-symbol-file. This allowed me to debug an image that was already loaded on the remote system. Unfortunately, when I tried to use 'maint info sections' I saw nothing. The reason is that the loop over all object files is hidden behind a check that we have a main executable. This commit removes this check and merges together some duplicate code. I also (I think) made the output of this command cleaner. Here is the original output of 'maint info sections': Exec file: `/tmp/hello.x', file type elf64-x86-64. [0] 0x004002a8->0x004002c4 at 0x000002a8: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x004002c4->0x004002e8 at 0x000002c4: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... And my modified output: Exec file: `/home/andrew/tmp/hello.x', file type elf64-x86-64. [0] 0x004002a8->0x004002c4 at 0x000002a8: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x004002c4->0x004002e8 at 0x000002c4: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... The forced newline after 'Exec file: ' has been removed. This is now a wrap point (in case the filename is very long). Here is the original output of 'maint info sections ALLOBJ': Exec file: `/tmp/hello.x', file type elf64-x86-64. Object file: /tmp/hello.x [0] 0x004002a8->0x004002c4 at 0x000002a8: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x004002c4->0x004002e8 at 0x000002c4: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... Object file: /lib64/ld-linux-x86-64.so.2 [0] 0x7ffff7fd12a8->0x7ffff7fd12c8 at 0x000002a8: .note.gnu.property ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x7ffff7fd12c8->0x7ffff7fd12ec at 0x000002c8: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... And my modified output: Exec file: `/tmp/hello.x', file type elf64-x86-64. [0] 0x004002a8->0x004002c4 at 0x000002a8: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x004002c4->0x004002e8 at 0x000002c4: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... Object file: `/lib64/ld-linux-x86-64.so.2', file type elf64-x86-64. [0] 0x7ffff7fd12a8->0x7ffff7fd12c8 at 0x000002a8: .note.gnu.property ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x7ffff7fd12c8->0x7ffff7fd12ec at 0x000002c8: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... The executable now only gets a single header line. The header line for the additional object files is no longer indented as it was before, and the line is laid out in a similar style to the main executable line (with quotes and file type information). And of course, the biggest change. If GDB is started with no executable, but then the user does 'add-symbol-file ....' followed by 'maint info sections ALLOBJ', previously they got nothing, now they get: Object file: `/tmp/hello.x', file type elf64-x86-64. [0] 0x004002a8->0x004002c4 at 0x000002a8: .interp ALLOC LOAD READONLY DATA HAS_CONTENTS [1] 0x004002c4->0x004002e8 at 0x000002c4: .note.gnu.build-id ALLOC LOAD READONLY DATA HAS_CONTENTS ... gdb/ChangeLog: * maint.c (print_bfd_section_info_maybe_relocated): Delete, functionality merged into... (maint_print_all_sections): ...this new function. (maintenance_info_sections): Make use of maint_print_all_sections, allow all objects to be printed even where there's no executable. gdb/testsuite/ChangeLog: * gdb.base/maint-info-sections.exp: Update expected output, and add additional tests.
2021-02-05 19:16:31 +08:00
2021-02-11 Andrew Burgess <andrew.burgess@embecosm.com>
* maint.c (print_bfd_section_info_maybe_relocated): Delete,
functionality merged into...
(maint_print_all_sections): ...this new function.
(maintenance_info_sections): Make use of maint_print_all_sections,
allow all objects to be printed even where there's no executable.
2021-02-11 Andrew Burgess <andrew.burgess@embecosm.com>
* breakpoint.c (resolve_sal_pc): Make use of
bound_minimal_symbol::obj_section.
* maint.c (maintenance_translate_address): Likewise.
* minsyms.c (minimal_symbol_upper_bound): Likewise.
* minsyms.h (struct bound_minimal_symbol) <obj_section>: New
member function.
* printcmd.c (info_address_command): Make use of
bound_minimal_symbol::obj_section.
2021-02-11 Alan Modra <amodra@gmail.com>
* arm-symbian-tdep.c: Delete.
* NEWS: Mention arm-symbian removal.
* Makefile.in: Remove arm-symbian-tdep entries.
* configure.tgt: Remove arm*-*-symbianelf*.
* doc/gdb.texinfo: Remove mention of SymbianOS.
* osabi.c (gdb_osabi_names): Remove "Symbian".
* osabi.h (enum gdb_osabi): Remove GDB_OSABI_SYMBIAN.
* testsuite/gdb.base/ending-run.exp: Remove E32Main handling.
* testsuite/gdb.ada/catch_ex_std.exp: Remove arm*-*-symbianelf*
handling.
* testsuite/gdb.base/dup-sect.exp: Likewise.
* testsuite/gdb.base/long_long.exp: Likewise.
* testsuite/gdb.base/solib-weak.exp: Likewise.
* testsuite/gdb.guile/scm-section-script.exp: Likewise.
* testsuite/gdb.python/py-section-script.exp: Likewise.
* testsuite/lib/dwarf.exp: Likewise.
* testsuite/lib/gdb.exp: Likewise.
2021-02-10 Andrew Burgess <andrew.burgess@embecosm.com>
* f-exp.y (UNOP_OR_BINOP_INTRINSIC): New token.
(exp): New pattern using UNOP_OR_BINOP_INTRINSIC.
(one_or_two_args): New pattern.
(f77_keywords): Add lbound and ubound.
* f-lang.c (fortran_bounds_all_dims): New function.
(fortran_bounds_for_dimension): New function.
(evaluate_subexp_f): Handle FORTRAN_LBOUND and FORTRAN_UBOUND.
(operator_length_f): Likewise.
(print_subexp_f): Likewise.
(dump_subexp_body_f): Likewise.
(operator_check_f): Likewise.
* std-operator.def (FORTRAN_LBOUND): Define.
(FORTRAN_UBOUND): Define.
gdb: delete SYMBOL_SECTION and MSYMBOL_SECTION macros Delete two more symbol/section related macros. This time it's SYMBOL_SECTION and MSYMBOL_SECTION. As with general_symbol_info::m_name it is not currently possible to make general_symbol_info::m_section private as general_symbol_info must remain a POD type. But other than failing to make the new m_section private, this change does what you'd expect, adds a get and set member function and updates all users to use the new functions instead of the previous wrapper macros. There should be no user visible change after this commit. gdb/ChangeLog: * coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index and set_section_index member functions where appropriate. * coffread.c (coff_symtab_read): Likewise. (process_coff_symbol): Likewise. * ctfread.c (set_symbol_address): Likewise. * dwarf2/read.c (add_partial_symbol): Likewise. (var_decode_location): Likewise. * language.c: Likewise. * minsyms.c (minimal_symbol_reader::record_full): Likewise. (compact_minimal_symbols): Likewise. (minimal_symbol_upper_bound): Likewise. * objfiles.c (relocate_one_symbol): Likewise. * psympriv.h (partial_symbol::obj_section): Likewise. (partial_symbol::address): Likewise. * psymtab.c (partial_symtab::add_psymbol): Likewise. * stabsread.c (scan_file_globals): Likewise. * symmisc.c (dump_msymbols): Likewise. * symtab.c (general_symbol_info::obj_section): Likewise. (fixup_section): Likewise. (get_msymbol_address): Likewise. * symtab.h (general_symbol_info::section): Rename to... (general_symbol_info::m_section): ...this. (general_symbol_info::set_section_index): New member function. (general_symbol_info::section_index): Likewise. (SYMBOL_SECTION): Delete. (MSYMBOL_VALUE_ADDRESS): Make use of section_index and set_section_index member functions where appropriate. (MSYMBOL_SECTION): Delete. (symbol::symbol): Update to initialize 'm_section'. * xcoffread.c (read_xcoff_symtab): Make use of set_section_index. (process_xcoff_symbol): Likewise.
2021-02-08 05:15:12 +08:00
2021-02-10 Andrew Burgess <andrew.burgess@embecosm.com>
* coff-pe-read.c (add_pe_forwarded_sym): Make use of section_index
and set_section_index member functions where appropriate.
* coffread.c (coff_symtab_read): Likewise.
(process_coff_symbol): Likewise.
* ctfread.c (set_symbol_address): Likewise.
* dwarf2/read.c (add_partial_symbol): Likewise.
(var_decode_location): Likewise.
* language.c: Likewise.
* minsyms.c (minimal_symbol_reader::record_full): Likewise.
(compact_minimal_symbols): Likewise.
(minimal_symbol_upper_bound): Likewise.
* objfiles.c (relocate_one_symbol): Likewise.
* psympriv.h (partial_symbol::obj_section): Likewise.
(partial_symbol::address): Likewise.
* psymtab.c (partial_symtab::add_psymbol): Likewise.
* stabsread.c (scan_file_globals): Likewise.
* symmisc.c (dump_msymbols): Likewise.
* symtab.c (general_symbol_info::obj_section): Likewise.
(fixup_section): Likewise.
(get_msymbol_address): Likewise.
* symtab.h (general_symbol_info::section): Rename to...
(general_symbol_info::m_section): ...this.
(general_symbol_info::set_section_index): New member function.
(general_symbol_info::section_index): Likewise.
(SYMBOL_SECTION): Delete.
(MSYMBOL_VALUE_ADDRESS): Make use of section_index and
set_section_index member functions where appropriate.
(MSYMBOL_SECTION): Delete.
(symbol::symbol): Update to initialize 'm_section'.
* xcoffread.c (read_xcoff_symtab): Make use of set_section_index.
(process_xcoff_symbol): Likewise.
2021-02-10 Andrew Burgess <andrew.burgess@embecosm.com>
* breakpoint.c (resolve_sal_pc): Replace SYMBOL_OBJ_SECTION and
MSYMBOL_OBJ_SECTION.
* findvar.c (language_defn::read_var_value): Likewise.
* infcmd.c (jump_command): Likewise.
* linespec.c (minsym_found): Likewise.
* maint.c (maintenance_translate_address): Likewise.
* minsyms.c (lookup_minimal_symbol_by_pc_section): Likewise.
(minimal_symbol_upper_bound): Likewise.
* parse.c (find_minsym_type_and_address): Likewise.
(operator_check_standard): Likewise.
* printcmd.c (info_address_command): Likewise.
* symmisc.c (dump_msymbols): Likewise.
(print_symbol): Likewise.
* symtab.c (general_symbol_info::obj_section): Define new
function.
(fixup_symbol_section): Replace SYMBOL_OBJ_SECTION.
(find_pc_sect_compunit_symtab): Likewise.
(find_function_start_sal): Likewise.
(skip_prologue_sal): Replace SYMBOL_OBJ_SECTION and
MSYMBOL_OBJ_SECTION.
* symtab.h (struct general_symbol_info) <obj_section>: Declare new
function.
(SYMBOL_OBJ_SECTION): Delete.
(MSYMBOL_OBJ_SECTION): Delete.
2021-02-09 Tom Tromey <tom@tromey.com>
* stap-probe.c (stap_parse_argument_conditionally): Fix typo.
[gdb/symtab] Fix element type modification in read_array_type When running test-case gdb.fortran/function-calls.exp with target board unix/gdb:debug_flags=-gdwarf-5, I run into: ... (gdb) PASS: gdb.fortran/function-calls.exp: \ p derived_types_and_module_calls::pass_cart(c) p derived_types_and_module_calls::pass_cart_nd(c_nd)^M ^M Program received signal SIGSEGV, Segmentation fault.^M 0x0000000000400f73 in derived_types_and_module_calls::pass_cart_nd \ (c=<error reading variable: Cannot access memory at address 0xc>) at \ function-calls.f90:130^M 130 pass_cart_nd = ubound(c%d,1,4)^M The program being debugged was signaled while in a function called from GDB.^M GDB has restored the context to what it was before the call.^M To change this behavior use "set unwindonsignal off".^M Evaluation of the expression containing the function^M (derived_types_and_module_calls::pass_cart_nd) will be abandoned.^M (gdb) FAIL: gdb.fortran/function-calls.exp: p ... The problem originates in read_array_type, when reading a DW_TAG_array_type with a dwarf-5 DW_TAG_generic_subrange child. This is not supported, and the fallout of this is that rather than constructing a new array type, the code proceeds to modify the element type. Fix this conservatively by issuing a complaint and bailing out in read_array_type when not being able to construct an array type, such that we have: ... (gdb) maint expand-symtabs function-calls.f90^M During symbol reading: unable to find array range \ - DIE at 0xe1e [in module function-calls]^M During symbol reading: unable to find array range \ - DIE at 0xe1e [in module function-calls]^M (gdb) KFAIL: gdb.fortran/function-calls.exp: no complaints in srcfile \ (PRMS: symtab/27388) ... Tested on x86_64-linux. gdb/ChangeLog: 2021-02-09 Tom de Vries <tdevries@suse.de> PR symtab/27341 * dwarf2/read.c (read_array_type): Return NULL when not being able to construct an array type. Add assert to ensure that element_type is not being modified. gdb/testsuite/ChangeLog: 2021-02-09 Tom de Vries <tdevries@suse.de> PR symtab/27341 * lib/gdb.exp (with_complaints): New proc, factored out of ... (gdb_load_no_complaints): ... here. * gdb.fortran/function-calls.exp: Add test-case.
2021-02-10 06:28:16 +08:00
2021-02-09 Tom de Vries <tdevries@suse.de>
PR symtab/27341
* dwarf2/read.c (read_array_type): Return NULL when not being able to
construct an array type. Add assert to ensure that element_type is
not being modified.
gdb: revert "gdb: unify parts of the Linux and FreeBSD core dumping code" This reverts commit 82a1fd3a4935fe665cf08bc6820942c4a091184c. It was pointed out: https://sourceware.org/pipermail/gdb-patches/2021-February/175750.html that commit 82a1fd3a4935 caused GDB to have an unconditional dependency on ELF specific parts of BFD. What this means is that if GDB and BFD are built for a non-elf target then there will be undefined symbol references within GDB. The right solution isn't immediately obvious. So rather than rush a fix in I'm reverting this commit for now, and will bring it back once I have a good solution. gdb/ChangeLog: * gcore.c (struct gcore_collect_regset_section_cb_data): Delete. (gcore_collect_regset_section_cb): Delete. (gcore_collect_thread_registers): Delete. (gcore_build_thread_register_notes): Delete. (gcore_find_signalled_thread): Delete. * gcore.h: Remove 'gdbsupport/gdb_signals.h' include and delete 'gdbarch' and 'thread_info' declarations. (gcore_build_thread_register_notes): Delete declaration. (gcore_find_signalled_thread): Likewise. * fbsd-tdep.c: Remove 'gcore.h' include. (struct fbsd_collect_regset_section_cb_data): New struct. (fbsd_collect_regset_section_cb): New function. (fbsd_collect_thread_registers): New function. (struct fbsd_corefile_thread_data): New struct. (fbsd_corefile_thread): New function. (fbsd_make_corefile_notes): Call FreeBSD specific code. * linux-tdep.c: Remove 'gcore.h' include. (struct linux_collect_regset_section_cb_data): New struct. (linux_collect_regset_section_cb): New function. (linux_collect_thread_registers): New function. (linux_corefile_thread): Call Linux specific code. (find_signalled_thread): New function. (linux_make_corefile_notes): Call find_signalled_thread.
2021-02-10 05:41:30 +08:00
2021-02-09 Andrew Burgess <andrew.burgess@embecosm.com>
* gcore.c (struct gcore_collect_regset_section_cb_data): Delete.
(gcore_collect_regset_section_cb): Delete.
(gcore_collect_thread_registers): Delete.
(gcore_build_thread_register_notes): Delete.
(gcore_find_signalled_thread): Delete.
* gcore.h: Remove 'gdbsupport/gdb_signals.h' include and delete
'gdbarch' and 'thread_info' declarations.
(gcore_build_thread_register_notes): Delete declaration.
(gcore_find_signalled_thread): Likewise.
* fbsd-tdep.c: Remove 'gcore.h' include.
(struct fbsd_collect_regset_section_cb_data): New struct.
(fbsd_collect_regset_section_cb): New function.
(fbsd_collect_thread_registers): New function.
(struct fbsd_corefile_thread_data): New struct.
(fbsd_corefile_thread): New function.
(fbsd_make_corefile_notes): Call FreeBSD specific code.
* linux-tdep.c: Remove 'gcore.h' include.
(struct linux_collect_regset_section_cb_data): New struct.
(linux_collect_regset_section_cb): New function.
(linux_collect_thread_registers): New function.
(linux_corefile_thread): Call Linux specific code.
(find_signalled_thread): New function.
(linux_make_corefile_notes): Call find_signalled_thread.
2021-02-09 Tom Tromey <tromey@adacore.com>
* ada-lang.c (coerce_unspec_val_to_type): Avoid making lazy
not_lval value.
* value.c (value_contents_copy_raw): Now static.
* value.h (value_contents_copy_raw): Don't declare.
2021-02-09 Tom Tromey <tromey@adacore.com>
* gdbtypes.c (resolve_dynamic_struct): Handle structure with no
fields.
gdb: Do not interrupt atomic sequences for ARC When stepping over thread-lock related codes (in uClibc), the inferior process gets stuck and never manages to enter the critical section: ------8<------- 1 size_t fwrite(const void * __restrict ptr, size_t size, 2 size_t nmemb, register FILE * __restrict stream) 3 { 4 size_t retval; 5 __STDIO_AUTO_THREADLOCK_VAR; 6 7 > __STDIO_AUTO_THREADLOCK(stream); 8 9 retval = fwrite_unlocked(ptr, size, nmemb, stream); 10 11 __STDIO_AUTO_THREADUNLOCK(stream); 12 13 return retval; 14 } ------>8------- Here, we are at line 7. Using the "next" command leads no where. However, setting a breakpoint on line 9 and issuing "continue" works. Looking at the assembly instructions reveals that we're dealing with the critical section entry code [1] that should never be interrupted, in this case by the debugger's implicit breakpoints: ------8<------- ... 1 add_s r0,r13,0x38 2 mov_s r3,1 3 llock r2,[r0] <-. 4 brne.nt r2,0,14 --. | 5 scond r3,[r0] | | 6 bne -10 --|--' 7 brne_s r2,0,84 <-' ... ------>8------- Lines 3 until 5 (inclusive) are supposed to be executed atomically. Therefore, GDB should never (implicitly) insert a breakpoint on lines 4 and 5, else the program will try to acquire the lock again by jumping back to line 3 and gets stuck in an infinite loop. The solution is to make GDB aware of these patterns so it inserts breakpoints after the sequence -- line 6 in this example. [1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/arc/bits/atomic.h#n46 ------8<------- ({ \ __typeof(oldval) prev; \ \ __asm__ __volatile__( \ "1: llock %0, [%1] \n" \ " brne %0, %2, 2f \n" \ " scond %3, [%1] \n" \ " bnz 1b \n" \ "2: \n" \ : "=&r"(prev) \ : "r"(mem), "ir"(oldval), \ "r"(newval) /* can't be "ir". scond can't take limm for "b" */\ : "cc", "memory"); \ \ prev; \ }) ------>8------- "llock" (Load Locked) loads the 32-bit word pointed by the source operand. If the load is completed without any interruption or exception, the physical address is remembered, in Lock Physical Address (LPA), and the Lock Flag (LF) is set to 1. LF is a non-architecturally visible flag and is cleared whenever an interrupt or exception takes place. LF is also cleared (atomically) whenever another process writes to the LPA. "scond" (Store Conditional) will write to the destination address if and only if the LF is set to 1. When finished, with or without a write, it atomically copies the LF value to ZF (Zero Flag). These two instructions together provide the mechanism for entering a critical section. The code snippet above comes from uClibc: ----------------------- v3 (after Tom's remarks[2]): handle_atomic_sequence() - no need to initialize the std::vector with "{}" - fix typo in comments: "conditial" -> "conditional" - add braces to the body of "if" condition because of the comment line arc_linux_software_single_step() - make the performance slightly more efficient by moving a few variables after the likely "return" point. v2 (after Simon's remarks[3]): - handle_atomic_sequence() gets a copy of an instruction instead of a reference. - handle_atomic_sequence() asserts if the given instruction is an llock. [2] https://sourceware.org/pipermail/gdb-patches/2021-February/175805.html [3] https://sourceware.org/pipermail/gdb-patches/2021-January/175487.html gdb/ChangeLog: PR tdep/27369 * arc-linux-tdep.c (handle_atomic_sequence): New. (arc_linux_software_single_step): Call handle_atomic_sequence().
2019-11-01 00:33:08 +08:00
2021-02-08 Shahab Vahedi <shahab@synopsys.com>
PR tdep/27369
* arc-linux-tdep.c (handle_atomic_sequence): New.
(arc_linux_software_single_step): Call handle_atomic_sequence().
gdb: return true in TuiWindow.is_valid only if TUI is enabled If the user implements a TUI window in Python, and this window responds to GDB events and then redraws its window contents then there is currently an edge case which can lead to problems. The Python API documentation suggests that calling methods like erase or write on a TUI window (from Python code) will raise an exception if the window is not valid. And the description for is_valid says: This method returns True when this window is valid. When the user changes the TUI layout, windows no longer visible in the new layout will be destroyed. At this point, the gdb.TuiWindow will no longer be valid, and methods (and attributes) other than is_valid will throw an exception. From this I, as a user, would expect that if I did 'tui disable' to switch back to CLI mode, then the window would no longer be valid. However, this is not the case. When the TUI is disabled the windows in the TUI are not deleted, they are simply hidden. As such, currently, the is_valid method continues to return true. This means that if the users Python code does something like: def event_handler (e): global tui_window_object if tui_window_object->is_valid (): tui_window_object->erase () tui_window_object->write ("Hello World") gdb.events.stop.connect (event_handler) Then when a stop event arrives GDB will try to draw the TUI window, even when the TUI is disabled. This exposes two bugs. First, is_valid should be returning false in this case, second, if the user forgot to add the is_valid call, then I believe the erase and write calls should be throwing an exception (when the TUI is disabled). The solution to both of these issues is I think bound together, as it depends on having a working 'is_valid' check. There's a rogue assert added into tui-layout.c as part of this commit. While working on this commit I managed to break GDB such that TUI_CMD_WIN was nullptr, this was causing GDB to abort. I'm leaving the assert in as it might help people catch issues in the future. This patch is inspired by the work done here: https://sourceware.org/pipermail/gdb-patches/2020-December/174338.html gdb/ChangeLog: * python/py-tui.c (gdbpy_tui_window) <is_valid>: New member function. (REQUIRE_WINDOW): Call is_valid member function. (REQUIRE_WINDOW_FOR_SETTER): New define. (gdbpy_tui_is_valid): Call is_valid member function. (gdbpy_tui_set_title): Call REQUIRE_WINDOW_FOR_SETTER instead. * tui/tui-data.h (struct tui_win_info) <is_visible>: Check tui_active too. * tui/tui-layout.c (tui_apply_current_layout): Add an assert. * tui/tui.c (tui_enable): Move setting of tui_active earlier in the function. gdb/doc/ChangeLog: * python.texinfo (TUI Windows In Python): Extend description of TuiWindow.is_valid. gdb/testsuite/ChangeLog: * gdb.python/tui-window-disabled.c: New file. * gdb.python/tui-window-disabled.exp: New file. * gdb.python/tui-window-disabled.py: New file.
2021-01-15 18:31:19 +08:00
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* python/py-tui.c (gdbpy_tui_window) <is_valid>: New member
function.
(REQUIRE_WINDOW): Call is_valid member function.
(REQUIRE_WINDOW_FOR_SETTER): New define.
(gdbpy_tui_is_valid): Call is_valid member function.
(gdbpy_tui_set_title): Call REQUIRE_WINDOW_FOR_SETTER instead.
* tui/tui-data.h (struct tui_win_info) <is_visible>: Check
tui_active too.
* tui/tui-layout.c (tui_apply_current_layout): Add an assert.
* tui/tui.c (tui_enable): Move setting of tui_active earlier in
the function.
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* python/py-tui.c (gdbpy_tui_set_title): Check that the new value
for the title is not nullptr.
gdb/tui: don't add windows to global list from tui_layout:window::apply This commit was inspired by this mailing list patch: https://sourceware.org/pipermail/gdb-patches/2021-January/174713.html Currently, calling tui_layout_window::apply will add the window from the layout object to the global tui_windows list. Unfortunately, when the user runs the 'winheight' command, this calls tui_adjust_window_height, which calls the tui_layout_base::adjust_size function, which can then call tui_layout_base::apply. The consequence of this is that when the user does 'winheight' duplicate copies of a window can be added to the global tui_windows list. The original patch fixed this by changing the apply function to only update the global list some of the time. This patch takes a different approach. The apply function no longer updates the global tui_windows list. Instead a new virtual function is added to tui_layout_base which is used to gather all the currently applied windows into a vector. Finally tui_apply_current_layout is updated to make use of this new function to update the tui_windows list. The benefits I see in this approach are, (a) the apply function now no longer touches global state, this solves the immediate problem, and (b) now that tui_windows is updated directly in the function tui_apply_current_layout, we can drop the saved_tui_windows global. gdb/ChangeLog: * tui-layout.c (saved_tui_windows): Delete. (tui_apply_current_layout): Don't make use of saved_tui_windows, call new get_windows member function instead. (tui_get_window_by_name): Check in tui_windows. (tui_layout_window::apply): Don't add to tui_windows. * tui-layout.h (tui_layout_base::get_windows): New member function. (tui_layout_window::get_windows): Likewise. (tui_layout_split::get_windows): Likewise. gdb/testsuite/ChangeLog: * gdb.tui/winheight.exp: Add more tests.
2021-01-25 23:46:58 +08:00
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* tui-layout.c (saved_tui_windows): Delete.
(tui_apply_current_layout): Don't make use of saved_tui_windows,
call new get_windows member function instead.
(tui_get_window_by_name): Check in tui_windows.
(tui_layout_window::apply): Don't add to tui_windows.
* tui-layout.h (tui_layout_base::get_windows): New member function.
(tui_layout_window::get_windows): Likewise.
(tui_layout_split::get_windows): Likewise.
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* tui/tui-layout.c (tui_apply_current_layout): Restore the delete
of the window objects.
gdb/python: reformat an error string While working on another patch I noticed an oddly formatted error message in the Python code. When 'set python print-stack message' is in effect then consider this Python script: class TestCommand (gdb.Command): def __init__ (self): gdb.Command.__init__ (self, "test-cmd", gdb.COMMAND_DATA) def invoke(self, args, from_tty): raise RuntimeError ("bad") TestCommand () And this GDB session: (gdb) source path/to/python/script.py (gdb) test-cmd Python Exception <class 'RuntimeError'> bad: Error occurred in Python: bad The line 'Python Exception <class 'RuntimeError'> bad:' doesn't look terrible in this situation, the colon at the end of the first line makes sense given the second line. However, there are places in GDB where there is no second line printed, for example consider this python script: def stop_listener (e): raise RuntimeError ("bad") gdb.events.stop.connect (stop_listener) Then this GDB session: (gdb) file helloworld.exe (gdb) start Temporary breakpoint 1 at 0x40112a: file hello.c, line 6. Starting program: helloworld.exe Temporary breakpoint 1, main () at hello.c:6 6 printf ("Hello World\n"); Python Exception <class 'RuntimeError'> bad: (gdb) si 0x000000000040112f 6 printf ("Hello World\n"); Python Exception <class 'RuntimeError'> bad: In this case there is no auxiliary information displayed after the warning, and the line ending in the colon looks weird to me. A quick survey of the code seems to indicate that it is not uncommon for there to be no auxiliary information line printed, its not just the one case I found above. I propose that the line that currently looks like this: Python Exception <class 'RuntimeError'> bad: Be reformatted like this: Python Exception <class 'RuntimeError'>: bad I think this looks fine then in either situation. The first now looks like this: (gdb) test-cmd Python Exception <class 'RuntimeError'>: bad Error occurred in Python: bad And the second like this: (gdb) si 0x000000000040112f 6 printf ("Hello World\n"); Python Exception <class 'RuntimeError'>: bad There's just two tests that needed updating. Errors are checked for in many more tests, but most of the time the pattern doesn't care about the colon. gdb/ChangeLog: * python/python.c (gdbpy_print_stack): Reformat an error message. gdb/testsuite/ChangeLog: * gdb.python/py-framefilter.exp: Update expected results. * gdb.python/python.exp: Update expected results.
2021-01-18 18:03:21 +08:00
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* python/python.c (gdbpy_print_stack): Reformat an error message.
gdb/tui: fix issue with handling the return character My initial goal was to fix our gdb/testsuite/lib/tuiterm.exp such that it would correctly support (some limited) scrolling of the command window. What I observe is that when sending commands to the tui command window in a test script with: Term::command "p 1" The command window would be left looking like this: (gdb) (gdb) p 1$1 = 1 (gdb) When I would have expected it to look like this: (gdb) p 1 $1 = 1 (gdb) Obviously a bug in our tuiterm.exp library, right??? Wrong! Turns out there's a bug in GDB. If in GDB I enable the tui and then type (slowly) the 'p 1\r' (the \r is pressing the return key at the end of the string), then you do indeed get the "expected" terminal output. However, if instead I copy the 'p 1\r' string and paste it into the tui in one go then I now see the same corrupted output as we do when using tuiterm.exp. It turns out the problem is that GDB fails when handling lots of input arriving quickly with a \r (or \n) on the end. The reason for this bug is as follows: When the tui is active the terminal is in no-echo mode, so characters sent to the terminal are not echoed out again. This means that when the user types \r, this is not echoed to the terminal. The characters read in are passed to readline and \r indicates that the command line is complete and ready to be processed. However, the \r is not included in readlines command buffer, and is NOT printed by readline when is displays its buffer to the screen. So, in GDB we have to manually spot the \r when it is read in and update the display. Printing a newline character to the output and moving the cursor to the next line. This is done in tui_getc_1. Now readline tries to reduce the number of write calls. So if we very quickly (as in paste in one go) the text 'p 1' to readline (this time with no \r on the end), then readline will fetch the fist character and add it to its internal buffer. But before printing the character out readline checks to see if there's more input incoming. As we pasted multiple characters, then yes, readline sees the ' ' and adds this to its buffer, and finally the '1', this too is added to the buffer. Now if at this point we take a break, readline sees there is no more input available, and so prints its buffer out. Now when we press \r the code in tui_getc_1 kicks in, adds a \n to the output and moves the cursor to the next line. But, if instead we paste 'p 1\r' in one go then readline adds 'p 1' to its buffer as before, but now it sees that there is still more input available. Now it fetches the '\r', but this triggers the newline behaviour, we print '\n' and move to the next line - however readline has not printed its buffer yet! So finally we end up on the next line. There's no more input available so readline prints its buffer, then GDB gets passed the buffer, handles it, and prints the result. The solution I think is to put of our special newline insertion code until we know that readline has finished printing its buffer. Handily we know when this is - the next thing readline does is pass us the command line buffer for processing. So all we need to do is hook in to the command line processing, and before we pass the command line to GDB's internals we do all of the magic print a newline and move the cursor to the next line stuff. Luckily, GDB's interpreter mechanism already provides the hooks we need to do this. So all I do here is move the newline printing code from tui_getc_1 into a new function, setup a new input_handler hook for the tui, and call my new newline printing function. After this I can enable the tui and paste in 'p 1\r' and see the correct output. Also the tuiterm.exp library will now see non-corrupted output. gdb/ChangeLog: * tui/tui-interp.c (tui_command_line_handler): New function. (tui_interp::resume): Register tui_command_line_handler as the input_handler. * tui/tui-io.c (tui_inject_newline_into_command_window): New function. (tui_getc_1): Delete handling of '\n' and '\r'. * tui-io.h (tui_inject_newline_into_command_window): Declare. gdb/testsuite/ChangeLog: * gdb.tui/scroll.exp: Tighten expected results. Remove comment about bug in GDB, update expected results, and add more tests.
2021-01-23 01:40:19 +08:00
2021-02-08 Andrew Burgess <andrew.burgess@embecosm.com>
* tui/tui-interp.c (tui_command_line_handler): New function.
(tui_interp::resume): Register tui_command_line_handler as the
input_handler.
* tui/tui-io.c (tui_inject_newline_into_command_window): New
function.
(tui_getc_1): Delete handling of '\n' and '\r'.
* tui-io.h (tui_inject_newline_into_command_window): Declare.
2021-02-07 Hannes Domani <ssbssa@yahoo.de>
* tui/tui-regs.c (tui_data_window::display_registers_from):
Mark invisible register sub windows.
(tui_data_window::check_register_values): Ignore invisible
register sub windows.
2021-02-07 Hannes Domani <ssbssa@yahoo.de>
* tui/tui-regs.c (tui_data_item_window::rerender): Don't call
n_spaces with a negative value.
2021-02-07 Hannes Domani <ssbssa@yahoo.de>
* tui/tui-regs.c (tui_data_window::display_registers_from):
Add refresh_window call.
2021-02-07 Hannes Domani <ssbssa@yahoo.de>
* python/py-frame.c (frapy_richcompare): Compare frame_id_is_next.
2021-02-05 Simon Marchi <simon.marchi@polymtl.ca>
* symmisc.c (std_in, std_out, std_err): Remove.
(_initialize_symmisc): Don't set std_in, std_out and std_err.
2021-02-05 Tom de Vries <tdevries@suse.de>
PR breakpoints/27330
* breakpoint.c (create_exception_master_breakpoint): Handle case that
glibc object file has debug info.
2021-02-05 Tom de Vries <tdevries@suse.de>
PR symtab/27333
* dwarf2/read.c (process_psymtab_comp_unit): Handle DW_TAG_type_unit.
2021-02-05 Tom de Vries <tdevries@suse.de>
PR breakpoints/27313
* break-catch-syscall.c (catch_syscall_split_args): Reject negative
syscall numbers.
2021-02-05 Tom Tromey <tom@tromey.com>
* compile/compile-c-support.c (get_compile_context)
(c_get_compile_context, cplus_get_compile_context): Change return
type.
* language.c (language_defn::get_compile_instance): New method.
* language.h (language_defn::get_compile_instance): Change return
type. No longer inline.
* c-lang.c (c_language::get_compile_instance): Change return type.
(cplus_language::get_compile_instance): Change return type.
* c-lang.h (c_get_compile_context, cplus_get_compile_context):
Change return type.
* compile/compile.c (compile_to_object): Update.
2021-02-05 Tom Tromey <tom@tromey.com>
* parser-defs.h (write_exp_symbol_reference): Declare.
* parse.c (write_exp_symbol_reference): New function.
* p-exp.y (variable): Use write_exp_symbol_reference.
* m2-exp.y (variable): Use write_exp_symbol_reference.
* f-exp.y (variable): Use write_exp_symbol_reference.
* d-exp.y (PrimaryExpression): Use write_exp_symbol_reference.
* c-exp.y (variable): Use write_exp_symbol_reference.
2021-02-05 Tom de Vries <tdevries@suse.de>
PR exp/27265
* valarith.c (complex_binop): Throw an error if complex type can't
be created.
2021-02-05 Tom de Vries <tdevries@suse.de>
PR symtab/27307
* dwarf2/read.c (create_cus_from_debug_names_list): Add missing
return.
2021-02-05 Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (create_cus_from_debug_names_list): Fix indentation.
2021-02-04 Mike Frysinger <vapier@gentoo.org>
* configure.tgt (riscv*-*-*): Set gdb_sim.
2021-02-04 Simon Marchi <simon.marchi@polymtl.ca>
* target.c (target_is_non_stop_p): Return bool.
* target.h (target_is_non_stop_p): Return bool.
2021-02-04 Simon Marchi <simon.marchi@efficios.com>
* record-full.c (record_full_async_inferior_event_handler):
Don't clear async event handler.
(record_full_base_target::wait): Clear async event handler at
beginning.
2021-02-04 Simon Marchi <simon.marchi@efficios.com>
* record-btrace.c (record_btrace_handle_async_inferior_event):
Don't clear async event handler.
(record_btrace_target::wait): Clear async event handler at
beginning.
gdb: make remote target clear its handler in remote_target::wait The remote target's remote_async_inferior_event_token is a flag that tells when it wants the infrun loop to call its wait method. The flag is cleared in the async_event_handler's callback (remote_async_inferior_event_handler), just before calling inferior_event_handler. However, since inferior_event_handler may actually call another target's wait method, there needs to be code that checks if we need to re-raise the flag. It would be simpler instead for remote_target::wait to clear the flag when it returns an event and there are no more to report after that. If another target's wait method gets called by inferior_event_handler, the remote target's flag will stay naturally stay marked. Note that this is already partially implemented in remote_target::wait, since the remote target may have multiple events to report (and it can only report one at the time): if (target_is_async_p ()) { remote_state *rs = get_remote_state (); /* If there are are events left in the queue tell the event loop to return here. */ if (!rs->stop_reply_queue.empty ()) mark_async_event_handler (rs->remote_async_inferior_event_token); } The code in remote_async_inferior_event_handler also checks for pending events as well, in addition to the stop reply queue, so I've made remote_target::wait check for that as well. I'm not completely sure this is ok, since I don't understand very well how the pending events mechanism works. But I figured it was safer to do this, worst case it just leads to unnecessary calls to remote_target::wait. gdb/ChangeLog: * remote.c (remote_target::wait): Clear async event handler at beginning, mark if needed at the end. (remote_async_inferior_event_handler): Don't set or clear async event handler. Change-Id: I20117f5b5acc8a9972c90f16280249b766c1bf37
2021-02-05 02:34:11 +08:00
2021-02-04 Simon Marchi <simon.marchi@efficios.com>
* remote.c (remote_target::wait): Clear async event handler at
beginning, mark if needed at the end.
(remote_async_inferior_event_handler): Don't set or clear async
event handler.
gdb: make async event handlers clear themselves The `ready` flag of async event handlers is cleared by the async event handler system right before invoking the associated callback, in check_async_event_handlers. This is not ideal with how the infrun subsystem consumes events: all targets' async event handler callbacks essentially just invoke `inferior_event_handler`, which eventually calls `fetch_inferior_event` and `do_target_wait`. `do_target_wait` picks an inferior at random, and thus a target at random (it could be the target whose `ready` flag was cleared, or not), and pulls one event from it. So it's possible that: - the async event handler for a target A is called - we end up consuming an event for target B - all threads of target B are stopped, target_async(0) is called on it, so its async event handler is cleared (e.g. record_btrace_target::async) As a result, target A still has events to report while its async event handler is left unmarked, so these events are not consumed. To counter this, at the end of their async event handler callbacks, targets check if they still have something to report and re-mark their async event handler (e.g. remote_async_inferior_event_handler). The linux_nat target does not suffer from this because it doesn't use an async event handler at the moment. It only uses a pipe registered with the event loop. It is written to in the SIGCHLD handler (and in other spots that want to get target wait method called) and read from in the target's wait method. So if linux_nat happened to be target A in the example above, the pipe would just stay readable, and the event loop would wake up again, until linux_nat's wait method is finally called and consumes the contents of the pipe. I think it would be nicer if targets using async_event_handler worked in a similar way, where the flag would stay set until the target's wait method is actually called. As a first step towards that, this patch moves the responsibility of clearing the ready flags of async event handlers to the invoked callback. All async event handler callbacks are modified to clear their ready flag before doing anything else. So in practice, nothing changes with this patch. It's only the responsibility of clearing the flag that is shifted toward the callee. gdb/ChangeLog: * async-event.h (async_event_handler_func): Add documentation. * async-event.c (check_async_event_handlers): Don't clear async_event_handler ready flag. * infrun.c (infrun_async_inferior_event_handler): Clear ready flag. * record-btrace.c (record_btrace_handle_async_inferior_event): Likewise. * record-full.c (record_full_async_inferior_event_handler): Likewise. * remote-notif.c (remote_async_get_pending_events_handler): Likewise. * remote.c (remote_async_inferior_event_handler): Likewise. Change-Id: I179ef8e99580eae642d332846fd13664dbddc0c1
2021-02-05 02:13:30 +08:00
2021-02-04 Simon Marchi <simon.marchi@efficios.com>
* async-event.h (async_event_handler_func): Add documentation.
* async-event.c (check_async_event_handlers): Don't clear
async_event_handler ready flag.
* infrun.c (infrun_async_inferior_event_handler): Clear ready
flag.
* record-btrace.c (record_btrace_handle_async_inferior_event):
Likewise.
* record-full.c (record_full_async_inferior_event_handler):
Likewise.
* remote-notif.c (remote_async_get_pending_events_handler):
Likewise.
* remote.c (remote_async_inferior_event_handler): Likewise.
2021-02-03 Simon Marchi <simon.marchi@polymtl.ca>
* infrun.c (handle_inferior_event): Move stop_soon variable to
inner scope.
2021-02-03 Pedro Alves <pedro@palves.net>
* infcmd.c (detach_command): Hold strong reference to target, and
if all-stop on entry, restart threads on exit.
* infrun.c (switch_back_to_stepped_thread): Factor out bits to ...
(restart_stepped_thread): ... this new function. Also handle
trap_expected.
(restart_after_all_stop_detach): New function.
* infrun.h (restart_after_all_stop_detach): Declare.
2021-02-03 Pedro Alves <pedro@palves.net>
* infrun.c (struct step_over_info): Initialize fields.
(prepare_for_detach): Handle ongoing in-line step over.
detach and breakpoint removal A following patch will add a testcase that has a number of threads constantly stepping over a breakpoint, and then has GDB detach the process. That testcase sometimes fails with the inferior crashing with SIGTRAP after the detach because of the bug fixed by this patch, when tested with the native target. The problem is that target_detach removes breakpoints from the target immediately, and that does not work with the native GNU/Linux target (and probably no other native target) currently. The test wouldn't fail with this issue when testing against gdbserver, because gdbserver does allow accessing memory while the current thread is running, by transparently pausing all threads temporarily, without GDB noticing. Implementing that in gdbserver was a lot of work, so I'm not looking forward right now to do the same in the native target. Instead, I came up with a simpler solution -- push the breakpoints removal down to the targets. The Linux target conveniently already pauses all threads before detaching them, since PTRACE_DETACH only works with stopped threads, so we move removing breakpoints to after that. Only the remote and GNU/Linux targets support support async execution, so no other target should really need this. gdb/ChangeLog: * linux-nat.c (linux_nat_target::detach): Remove breakpoints here... * remote.c (remote_target::remote_detach_1): ... and here ... * target.c (target_detach): ... instead of here. * target.h (target_ops::detach): Add comment.
2020-12-13 09:35:05 +08:00
2021-02-03 Pedro Alves <pedro@palves.net>
* linux-nat.c (linux_nat_target::detach): Remove breakpoints
here...
* remote.c (remote_target::remote_detach_1): ... and here ...
* target.c (target_detach): ... instead of here.
* target.h (target_ops::detach): Add comment.
prepare_for_detach and ongoing displaced stepping I noticed that "detach" while a program was running sometimes resulted in the process crashing. I tracked it down to this change to prepare_for_detach in commit 187b041e ("gdb: move displaced stepping logic to gdbarch, allow starting concurrent displaced steps"): /* Is any thread of this process displaced stepping? If not, there's nothing else to do. */ - if (displaced->step_thread == nullptr) + if (displaced_step_in_progress (inf)) return; The problem above is that the condition was inadvertently flipped. It should have been: if (!displaced_step_in_progress (inf)) So I fixed it, and wrote a testcase to exercise it. The testcase has a number of threads constantly stepping over a breakpoint, and then GDB detaches the process, while threads are running and stepping over the breakpoint. And then I was surprised that my testcase would hang -- GDB would get stuck in an infinite loop in prepare_for_detach, here: while (displaced_step_in_progress (inf)) { ... What is going on is that since we now have two displaced stepping buffers, as one displaced step finishes, GDB starts another, and there's another one already in progress, and on and on, so the displaced_step_in_progress condition never turns false. This happens because we go via the whole handle_inferior_event, which tries to start new step overs when one finishes. And also because while we remove breakpoints from the target before prepare_for_detach is called, handle_inferior_event ends up calling insert_breakpoints via e.g. keep_going. Thinking through all this, I came to the conclusion that going through the whole handle_inferior_event isn't ideal. A _lot_ is done by that function, e.g., some thread may get a signal which is passed to the inferior, and gdb decides to try to get over the signal handler, which reinstalls breakpoints. Or some process may exit. We can end up reporting these events via normal_stop while detaching, maybe end up running some breakpoint commands, or maybe even something runs an inferior function call. Etc. All this after the user has already declared they don't want to debug the process anymore, by asking to detach. I came to the conclusion that it's better to do the minimal amount of work possible, in a more controlled fashion, without going through handle_inferior_event. So in the new approach implemented by this patch, if there are threads of the inferior that we're detaching in the middle of a displaced step, stop them, and cancel the displaced step. This is basically what stop_all_threads already does, via wait_one and (the now factored out) handle_one, so I'm reusing those. gdb/ChangeLog: * infrun.c (struct wait_one_event): Move higher up. (prepare_for_detach): Abort in-progress displaced steps instead of letting them complete. (handle_one): If the inferior is detaching, don't add the thread back to the global step-over chain. (restart_threads): Don't restart threads if detaching. (handle_signal_stop): Remove inferior::detaching reference.
2020-12-13 09:35:05 +08:00
2021-02-03 Pedro Alves <pedro@palves.net>
* infrun.c (struct wait_one_event): Move higher up.
(prepare_for_detach): Abort in-progress displaced steps instead of
letting them complete.
(handle_one): If the inferior is detaching, don't add the thread
back to the global step-over chain.
(restart_threads): Don't restart threads if detaching.
(handle_signal_stop): Remove inferior::detaching reference.
2021-02-03 Pedro Alves <pedro@palves.net>
* infrun.c (prepare_for_detach): Don't release scoped_restore
before returning.
2021-02-03 Pedro Alves <pedro@palves.net>
* infrun.c (handle_one): New function, factored out from ...
(stop_all_threads): ... here.
Fix a couple vStopped pending ack bugs A following patch will add a testcase that has two processes with threads stepping over a breakpoint continuously, and then detaches from one of the processes while threads are running. The other process continues stepping over its breakpoint. And then the testcase sends a SIGUSR1, expecting that GDB reports it. That would sometimes hang against gdbserver, due to the bugs fixed here. Both bugs are related, in that they're about remote protocol asynchronous Stop notifications. There's a bug in GDB, and another in GDBserver. The GDB bug: - when we detach from a process, the remote target discards any pending RSP notification related to that process, including the in-flight, yet-unacked notification. Discarding the in-flight notification is the problem. Until the in-flight notification is acked with a vStopped packet, the server won't send another %Stop notification. As a result, the debug session gets messed up. In the new testcase's case, GDB would hang inside stop_all_threads, waiting for a stop for one of the process'es threads, which never arrived -- its stop reply was permanently stuck in the stop reply queue, waiting for a vStopped packet that never arrived. In summary: 1. GDBserver sends stop notification about thread X, the remote target receives it and stores it 2. At the same time, GDB detaches thread X's inferior 3. The remote target discards the received stop notification 4. GDBserver waits forever for the ack The GDBserver bug: GDBserver has the opposite bug. It also discards notifications for the process being detached. If that discards the head of the notification queue, when gdb sends an ack, it ends up acking the _next_ notification. Meaning, gdb loses one notification. In the testcase, this results in a similar hang in stop_all_threads. So we have two very similar bugs in GDB and GDBserver, both resulting in a similar symptom. That's why I'm fixing them both at the same time. gdb/ChangeLog: * remote.c (remote_notif_stop_ack): Don't error out on TARGET_WAITKIND_IGNORE; instead, just ignore the notification. (remote_target::discard_pending_stop_replies): Don't delete in-flight notification; instead, clear its contents. gdbserver/ChangeLog: * server.cc (discard_queued_stop_replies): Don't ever discard the notification at the head of the list.
2021-01-06 10:19:38 +08:00
2021-02-03 Pedro Alves <pedro@palves.net>
* remote.c (remote_notif_stop_ack): Don't error out on
TARGET_WAITKIND_IGNORE; instead, just ignore the notification.
(remote_target::discard_pending_stop_replies): Don't delete
in-flight notification; instead, clear its contents.
Fix "target extended-remote" + "maint set target-non-stop" + "attach" With "target extended-remote" + "maint set target-non-stop", attaching hangs like so: (gdb) attach 1244450 Attaching to process 1244450 [New Thread 1244450.1244450] [New Thread 1244450.1244453] [New Thread 1244450.1244454] [New Thread 1244450.1244455] [New Thread 1244450.1244456] [New Thread 1244450.1244457] [New Thread 1244450.1244458] [New Thread 1244450.1244459] [New Thread 1244450.1244461] [New Thread 1244450.1244462] [New Thread 1244450.1244463] * hang * Attaching to the hung GDB shows that GDB is busy in an infinite loop in stop_all_threads: (top-gdb) bt #0 stop_all_threads () at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:4755 #1 0x000055555597b424 in stop_waiting (ecs=0x7fffffffd930) at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:7738 #2 0x0000555555976fba in handle_signal_stop (ecs=0x7fffffffd930) at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:5868 #3 0x0000555555975f6a in handle_inferior_event (ecs=0x7fffffffd930) at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:5527 #4 0x0000555555971da4 in fetch_inferior_event () at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:3910 #5 0x00005555559540b2 in inferior_event_handler (event_type=INF_REG_EVENT) at /home/pedro/gdb/binutils-gdb/src/gdb/inf-loop.c:42 #6 0x000055555597e825 in infrun_async_inferior_event_handler (data=0x0) at /home/pedro/gdb/binutils-gdb/src/gdb/infrun.c:9162 #7 0x0000555555687d1d in check_async_event_handlers () at /home/pedro/gdb/binutils-gdb/src/gdb/async-event.c:328 #8 0x0000555555e48284 in gdb_do_one_event () at /home/pedro/gdb/binutils-gdb/src/gdbsupport/event-loop.cc:216 #9 0x00005555559e7512 in start_event_loop () at /home/pedro/gdb/binutils-gdb/src/gdb/main.c:347 #10 0x00005555559e765d in captured_command_loop () at /home/pedro/gdb/binutils-gdb/src/gdb/main.c:407 #11 0x00005555559e8f80 in captured_main (data=0x7fffffffdb70) at /home/pedro/gdb/binutils-gdb/src/gdb/main.c:1239 #12 0x00005555559e8ff2 in gdb_main (args=0x7fffffffdb70) at /home/pedro/gdb/binutils-gdb/src/gdb/main.c:1254 #13 0x0000555555627c86 in main (argc=12, argv=0x7fffffffdc88) at /home/pedro/gdb/binutils-gdb/src/gdb/gdb.c:32 The problem is that the remote sends stops for all the threads: Packet received: l/home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.threads/attach-non-stop/attach-non-stop Sending packet: $vStopped#55...Packet received: T0006:f06e25edec7f0000;07:f06e25edec7f0000;10:f14190ccf4550000;thread:p12fd22.12fd2f;core:15; Sending packet: $vStopped#55...Packet received: T0006:f0dea5f0ec7f0000;07:f0dea5f0ec7f0000;10:e84190ccf4550000;thread:p12fd22.12fd27;core:4; Sending packet: $vStopped#55...Packet received: T0006:f0ee25f1ec7f0000;07:f0ee25f1ec7f0000;10:f14190ccf4550000;thread:p12fd22.12fd26;core:5; Sending packet: $vStopped#55...Packet received: T0006:f0bea5efec7f0000;07:f0bea5efec7f0000;10:f14190ccf4550000;thread:p12fd22.12fd29;core:1; Sending packet: $vStopped#55...Packet received: T0006:f0ce25f0ec7f0000;07:f0ce25f0ec7f0000;10:e84190ccf4550000;thread:p12fd22.12fd28;core:a; Sending packet: $vStopped#55...Packet received: T0006:f07ea5edec7f0000;07:f07ea5edec7f0000;10:e84190ccf4550000;thread:p12fd22.12fd2e;core:f; Sending packet: $vStopped#55...Packet received: T0006:f0ae25efec7f0000;07:f0ae25efec7f0000;10:df4190ccf4550000;thread:p12fd22.12fd2a;core:6; Sending packet: $vStopped#55...Packet received: T0006:0000000000000000;07:c0e8a381fe7f0000;10:bf43b4f1ec7f0000;thread:p12fd22.12fd22;core:2; Sending packet: $vStopped#55...Packet received: T0006:f0fea5f1ec7f0000;07:f0fea5f1ec7f0000;10:df4190ccf4550000;thread:p12fd22.12fd25;core:8; Sending packet: $vStopped#55...Packet received: T0006:f09ea5eeec7f0000;07:f09ea5eeec7f0000;10:e84190ccf4550000;thread:p12fd22.12fd2b;core:b; Sending packet: $vStopped#55...Packet received: OK But then wait_one never consumes them, always hitting this path: 4473 if (nfds == 0) 4474 { 4475 /* No waitable targets left. All must be stopped. */ 4476 return {NULL, minus_one_ptid, {TARGET_WAITKIND_NO_RESUMED}}; 4477 } Resulting in GDB constanly calling target_stop to stop threads, but the remote target never reporting back the stops to infrun. That TARGET_WAITKIND_NO_RESUMED path shown above is always taken because here, in wait_one too, just above: 4428 for (inferior *inf : all_inferiors ()) 4429 { 4430 process_stratum_target *target = inf->process_target (); 4431 if (target == NULL 4432 || !target->is_async_p () ^^^^^^^^^^^^^^^^^^^^^ 4433 || !target->threads_executing) 4434 continue; ... the remote target is not async. And in turn that happened because extended_remote_target::attach misses enabling async in the target-non-stop path. A testcase exercising this will be added in a following patch. gdb/ChangeLog: * remote.c (extended_remote_target::attach): Set target async in the target-non-stop path too.
2020-12-24 20:26:20 +08:00
2021-02-03 Pedro Alves <pedro@palves.net>
* remote.c (extended_remote_target::attach): Set target async in
the target-non-stop path too.
Fix attaching in non-stop mode (PR gdb/27055) Attaching in non-stop mode currently misbehaves, like so: (gdb) attach 1244450 Attaching to process 1244450 [New LWP 1244453] [New LWP 1244454] [New LWP 1244455] [New LWP 1244456] [New LWP 1244457] [New LWP 1244458] [New LWP 1244459] [New LWP 1244461] [New LWP 1244462] [New LWP 1244463] No unwaited-for children left. At this point, GDB's stopped/running thread state is out of sync with the inferior: (gdb) info threads Id Target Id Frame * 1 LWP 1244450 "attach-non-stop" 0xf1b443bf in ?? () 2 LWP 1244453 "attach-non-stop" (running) 3 LWP 1244454 "attach-non-stop" (running) 4 LWP 1244455 "attach-non-stop" (running) 5 LWP 1244456 "attach-non-stop" (running) 6 LWP 1244457 "attach-non-stop" (running) 7 LWP 1244458 "attach-non-stop" (running) 8 LWP 1244459 "attach-non-stop" (running) 9 LWP 1244461 "attach-non-stop" (running) 10 LWP 1244462 "attach-non-stop" (running) 11 LWP 1244463 "attach-non-stop" (running) (gdb) (gdb) interrupt -a (gdb) *nothing* The problem is that attaching installs an inferior continuation, called when the target reports the initial attach stop, here, in inf-loop.c:inferior_event_handler: /* Do all continuations associated with the whole inferior (not a particular thread). */ if (inferior_ptid != null_ptid) do_all_inferior_continuations (0); However, currently in non-stop mode, inferior_ptid is still null_ptid when we get here. If you try to do "set debug infrun 1" to debug the problem, however, then the attach completes correctly, with GDB reporting a stop for each thread. The bug is that we're missing a switch_to_thread/context_switch call when handling the initial stop, here: if (stop_soon == STOP_QUIETLY_NO_SIGSTOP && (ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_STOP || ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP || ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_0)) { stop_print_frame = true; stop_waiting (ecs); ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0; return; } Note how the STOP_QUIETLY / STOP_QUIETLY_REMOTE case above that does call context_switch. And the reason "set debug infrun 1" "fixes" it, is that the debug path has a switch_to_thread call. This patch fixes it by moving the main context_switch call earlier. It also removes the: if (ecs->ptid != inferior_ptid) check at the same time because: #1 - that is half of what context_switch already does #2 - deprecated_context_hook is only used in Insight, and all it does is set an int. It won't care if we call it when the current thread hasn't actually changed. A testcase exercising this will be added in a following patch. gdb/ChangeLog: PR gdb/27055 * infrun.c (handle_signal_stop): Move main context_switch call earlier, before STOP_QUIETLY_NO_SIGSTOP.
2020-12-23 08:34:54 +08:00
2021-02-03 Pedro Alves <pedro@palves.net>
PR gdb/27055
* infrun.c (handle_signal_stop): Move main context_switch call
earlier, before STOP_QUIETLY_NO_SIGSTOP.
2021-01-07 04:58:04 +08:00
2021-02-02 Lancelot SIX <lsix@lancelotsix.com>
* NEWS (Changed commands): Add entry for the behavior change of
the inferior command.
* inferior.c (inferior_command): When no argument is given to the
inferior command, display info about the currently selected
inferior.
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/read.c (read_loclist_index, read_rnglist_index): Return
a sect_offset.
(read_attribute_reprocess): Adjust.
gdb/dwarf: split dwarf2_cu::ranges_base in two Consider the test case added in this patch. It defines a compilation unit with a DW_AT_rnglists_base attribute (used for attributes of form DW_FORM_rnglistx), but also uses DW_AT_ranges of form DW_FORM_sec_offset: 0x00000027: DW_TAG_compile_unit DW_AT_ranges [DW_FORM_sec_offset] (0x0000004c [0x0000000000005000, 0x0000000000006000)) DW_AT_rnglists_base [DW_FORM_sec_offset] (0x00000044) The DW_AT_rnglists_base does not play a role in reading the DW_AT_ranges of form DW_FORM_sec_offset, but it should also not do any harm. This case is currently not handled correctly by GDB. This is not something that a compiler is likely to emit, but in my opinion there's no reason why GDB should fail reading it. The problem is that in partial_die_info::read and a few other places where the same logic is replicated, the cu->ranges_base value, containing the DW_AT_rnglists_base value, is wrongfully added to the DW_AT_ranges value. It is quite messy how to decide whether cu->ranges_base should be added to the attribute's value or not. But to summarize, the only time we want to add it is when the attribute comes from a pre-DWARF 5 split unit file (a .dwo) [1]. In this case, the DW_AT_ranges attribute from the split unit file will have form DW_FORM_sec_offset, pointing somewhere in the linked file's .debug_ranges section. *But* it's not a "true" DW_FORM_sec_offset, in that it's an offset relative to the beginning of that CU's contribution in the section, not relative to the beginning of the section. So in that case, and only that case, do we want to add the ranges base value, which we found from the DW_AT_GNU_ranges_base attribute on the skeleton unit. Almost all instances of the DW_AT_ranges attribute will be found in the split unit (on DW_TAG_subprogram, for example), and therefore need to have the ranges base added. However, the DW_TAG_compile_unit DIE in the skeleton may also have a DW_AT_ranges attribute. For that one, the ranges base must not be added. Once the DIEs have been loaded in GDB, however, the distinction between what's coming from the skeleton and what's coming from the split unit is not clear. It is all merged in one big happy tree. So how do we know if a given attribute comes from the split unit or not? We use the fact that in pre-DWARF 5 split DWARF, DW_AT_ranges is found on the skeleton's DW_TAG_compile_unit (in the linked file) and never in the split unit's DW_TAG_compile_unit. This is why you have this in partial_die_info::read: int need_ranges_base = (tag != DW_TAG_compile_unit && attr.form != DW_FORM_rnglistx); However, with the corner case described above (where we have a DW_AT_rnglists_base attribute and a DW_AT_ranges attribute of form DW_FORM_sec_offset) the condition gets it wrong when it encounters an attribute like DW_TAG_subprogram with a DW_AT_ranges attribute of DW_FORM_sec_offset form: it thinks that it is necessary to add the base, when it reality it is not. The problem boils down to failing to differentiate these cases: - a DW_AT_ranges attribute of form DW_FORM_sec_offset in a pre-DWARF 5 split unit (in which case we need to add the base) - a DW_AT_ranges attribute of form DW_FORM_sec_offset in a DWARF 5 non-split unit (in which case we must not add the base) What makes it unnecessarily complex is that the cu->ranges_base field is overloaded, used to hold the pre-DWARF 5, non-standard DW_AT_GNU_ranges_base and the DWARF 5 DW_AT_rnglists_base. In reality, these two are called "bases" but are not the same thing. The result is that we need twisted conditions to try to determine whether or not we should add the base to the attribute's value. To fix it, split the field in two distinct fields. I renamed everything related to the "old" ranges base to "gnu_ranges_base", to make it clear that it's about the non-standard, pre-DWARF 5 thing. And everything related to the DWARF 5 thing gets renamed "rnglists". I think it becomes much easier to reason this way. The issue described above gets fixed by the fact that the DW_AT_rnglists_base value does not end up in cu->gnu_ranges_base, so cu->gnu_ranges_base stays 0. The condition to determine whether gnu_ranges_base should be added can therefore be simplified back to: tag != DW_TAG_compile_unit ... as it was before rnglistx support was added. Extend the gdb.dwarf2/rnglists-sec-offset.exp to cover this case. I also extended the test case for loclists similarly, just to see if there would be some similar problem. There wasn't, but I think it's not a bad idea to test that case for loclists as well, so I left it in the patch. [1] https://gcc.gnu.org/wiki/DebugFission gdb/ChangeLog: * dwarf2/die.h (struct die_info) <ranges_base>: Split in... <gnu_ranges_base>: ... this... <rnglists_base>: ... and this. * dwarf2/read.c (struct dwarf2_cu) <ranges_base>: Split in... <gnu_ranges_base>: ... this... <rnglists_base>: ... and this. (read_cutu_die_from_dwo): Adjust (dwarf2_get_pc_bounds): Adjust (dwarf2_record_block_ranges): Adjust. (read_full_die_1): Adjust (partial_die_info::read): Adjust. (read_rnglist_index): Adjust. gdb/testsuite/ChangeLog: * gdb.dwarf2/rnglists-sec-offset.exp: Add test for DW_AT_ranges of DW_FORM_sec_offset form plus DW_AT_rnglists_base attribute. * gdb.dwarf2/loclists-sec-offset.exp: Add test for DW_AT_location of DW_FORM_sec_offset plus DW_AT_loclists_base attribute Change-Id: Icd109038634b75d0e6e9d7d1dcb62fb9eb951d83
2021-02-02 23:41:59 +08:00
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/die.h (struct die_info) <ranges_base>: Split in...
<gnu_ranges_base>: ... this...
<rnglists_base>: ... and this.
* dwarf2/read.c (struct dwarf2_cu) <ranges_base>: Split in...
<gnu_ranges_base>: ... this...
<rnglists_base>: ... and this.
(read_cutu_die_from_dwo): Adjust
(dwarf2_get_pc_bounds): Adjust
(dwarf2_record_block_ranges): Adjust.
(read_full_die_1): Adjust
(partial_die_info::read): Adjust.
(read_rnglist_index): Adjust.
gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index When loading the binary from PR 26813 in GDB, we get: DW_FORM_rnglistx index pointing outside of .debug_rnglists offset array [in module /home/simark/build/binutils-gdb/gdb/MagicPurse] ... and the symbols fail to load. In read_rnglist_index and read_loclist_index, we read the header (documented in sections 7.28 and 7.29 of DWARF 5) of the CU's contribution to the .debug_rnglists / .debug_loclists sections to validate that the index we want to read makes sense. However, we always read the header at the beginning of the section, rather than the header for the contribution from which we want to read the index. To illustrate, here's what the binary from PR 26813 contains. There are two compile units: 0x0000000c: DW_TAG_compile_unit 1 DW_AT_ranges [DW_FORM_rnglistx]: 0x0 DW_AT_rnglists_base [DW_FORM_sec_offset]: 0xC 0x00003ec9: DW_TAG_compile_unit 2 DW_AT_ranges [DW_FORM_rnglistx]: 0xB DW_AT_rnglists_base [DW_FORM_sec_offset]: 0x85 The layout of the .debug_rnglists is the following: [0x00, 0x0B]: header for CU 1's contribution [0x0C, 0x0F]: list of offsets for CU 1 (1 element) [0x10, 0x78]: range lists data for CU 1 [0x79, 0x84]: header for CU 2's contribution [0x85, 0xB4]: list of offsets for CU 2 (12 elements) [0xB5, 0xBD7]: range lists data for CU 2 The DW_AT_rnglists_base attrbute points to the beginning of the list of offsets for that CU, relative to the start of the .debug_rnglists section. That's right after the header for that contribution. When we try to read the DW_AT_ranges attribute for CU 2, read_rnglist_index reads the header for CU 1 instead of the one for CU 2. Since there's only one element in CU 1's offset list, it believes (wrongfully) that the index 0xB is out of range. Fix it by reading the header just before where DW_AT_rnglists_base points to. With this patch, I am able to load GDB built with clang-11 and -gdwarf-5 in itself, with and without -readnow. gdb/ChangeLog: PR gdb/26813 * dwarf2/read.c (read_loclists_rnglists_header): Add header_offset parameter and use it. (read_loclist_index): Read header of the current contribution, not the one at the beginning of the section. (read_rnglist_index): Likewise. Change-Id: Ie53ff8251af8c1556f0a83a31aa8572044b79e3d
2021-02-02 23:40:51 +08:00
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
PR gdb/26813
* dwarf2/read.c (read_loclists_rnglists_header): Add
header_offset parameter and use it.
(read_loclist_index): Read header of the current contribution,
not the one at the beginning of the section.
(read_rnglist_index): Likewise.
gdb/dwarf: few fixes for handling DW_FORM_{rng,loc}listx We hit an assertion when loading the binary from PR 26813. When fixing it, execution goes a up bit further but then hits another assert, and another, and another. With these fours fixes, I am able to load the binary and get to the prompt. An error is shown (index pointing outside of the section), because the DW_FORM_rnglistx attribute is not read correctly, but that one is taken care of by the next patch. The four fixes are: - attribute::form_requires_reprocessing needs to handle forms DW_FORM_rnglistx and DW_FORM_loclistx, because set_unsigned_reprocess is called for them in read_attribute_value. - read_attribute_reprocess must call set_unsigned for them, not set_address. The parameter of set_address is a CORE_ADDR, meaning it's for program addresses. Post-reprocess, DW_FORM_rnglistx and DW_FORM_loclistx are offsets into their respective sections (.debug_rnglists and .debug_loclists). set_unsigned is the current attribute value setter that fits the best. But perhaps we should have a setter that takes a sect_offset? - read_attribute_process must call as_unsigned_reprocess instead of as_unsigned to get the pre-reprocess value, otherwise we hit the assert inside as_unsigned that makes sure the attribute doesn't need reprocessing. - attribute::set_unsigned needs to clear the requires_reprocessing flag, otherwise it stays set when reprocessing DW_FORM_rnglistx and DW_FORM_loclistx attributes. There's another assert that we hit once the next patch is applied, but since it's in the same vein as the changes in this patch, I included it in this patch: - attribute::form_is_unsigned must handle form DW_FORM_loclistx, otherwise we hit the assert when trying to call set_unsigned for an attribute of this form. DW_FORM_rnglistx is already handled. gdb/ChangeLog: PR gdb/26813 * dwarf2/attribute.h (struct attribute) <set_unsigned>: Clear requires_reprocessing flag. * dwarf2/attribute.c (attribute::form_is_unsigned): Handle DW_FORM_loclistx. (attribute::form_requires_reprocessing): Handle DW_FORM_rnglistx and DW_FORM_loclistx. * dwarf2/read.c (read_attribute_reprocess): Use set_unsigned instead of set_address for DW_FORM_loclistx and DW_FORM_rnglistx. Change-Id: I06c156fa3913ca98e4e39085f4ef171645b4bc1e
2021-02-02 23:40:51 +08:00
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
PR gdb/26813
* dwarf2/attribute.h (struct attribute) <set_unsigned>: Clear
requires_reprocessing flag.
* dwarf2/attribute.c (attribute::form_is_unsigned): Handle
DW_FORM_loclistx.
(attribute::form_requires_reprocessing): Handle DW_FORM_rnglistx
and DW_FORM_loclistx.
* dwarf2/read.c (read_attribute_reprocess): Use set_unsigned
instead of set_address for DW_FORM_loclistx and
DW_FORM_rnglistx.
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/read.c (read_loclist_index): Remove bound check for
start of offset.
(read_rnglist_index): Likewise.
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/read.c (read_loclist_index): Add bound check for the end
of the offset.
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/read.c (read_rnglist_index): Fix bound check.
2021-02-02 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/read.c (read_loclist_index): Change complaints into
errors.
[gdb/symtab] Fix assert in write_one_signatured_type When running test-case gdb.dwarf2/fission-reread.exp with target board cc-with-gdb-index, we run into an abort during the generation of the gdb-index by cc-with-tweaks.sh: ... build/gdb/testsuite/cache/gdb.sh: line 1: 27275 Aborted (core dumped) ... This can be reproduced on the command line like this: ... $ gdb -batch ./outputs/gdb.dwarf2/fission-reread/fission-reread \ -ex 'save gdb-index ./outputs/gdb.dwarf2/fission-reread' warning: Could not find DWO TU fission-reread.dwo(0x9022f1ceac7e8b19) \ referenced by TU at offset 0x0 [in module fission-reread] warning: Could not find DWO CU fission-reread.dwo(0x807060504030201) \ referenced by CU at offset 0x561 [in module fission-reread] Aborted (core dumped) ... The abort is a segfault due to a using a nullptr psymtab in write_one_signatured_type. The problem is that we're trying to write index entries for the type unit with signature: ... (gdb) p /x entry->signature $2 = 0x9022f1ceac7e8b19 ... which is a skeleton type unit: ... Contents of the .debug_types section: Compilation Unit @ offset 0x0: Length: 0x4a (32-bit) Version: 4 Abbrev Offset: 0x165 Pointer Size: 4 Signature: 0x9022f1ceac7e8b19 Type Offset: 0x0 <0><17>: Abbrev Number: 2 (DW_TAG_type_unit) <18> DW_AT_comp_dir : /tmp/src/gdb/testsuite <2f> DW_AT_GNU_dwo_name: fission-reread.dwo <42> DW_AT_GNU_pubnames: 0x0 <46> DW_AT_GNU_pubtypes: 0x0 <4a> DW_AT_GNU_addr_base: 0x0 ... referring to a .dwo file, but as the warnings show, the .dwo file is not found. Fix this by skipping the type unit in write_one_signatured_type if psymtab == nullptr. Tested on x86_64-linux. gdb/ChangeLog: 2021-02-02 Tom de Vries <tdevries@suse.de> PR symtab/24620 * dwarf2/index-write.c (write_one_signatured_type): Skip if psymtab == nullptr. gdb/testsuite/ChangeLog: 2021-02-02 Tom de Vries <tdevries@suse.de> PR symtab/24620 * gdb.dwarf2/fission-reread.exp: Add test-case.
2021-02-02 15:37:45 +08:00
2021-02-02 Tom de Vries <tdevries@suse.de>
PR symtab/24620
* dwarf2/index-write.c (write_one_signatured_type): Skip if
psymtab == nullptr.
gdb: unify parts of the Linux and FreeBSD core dumping code While reviewing the Linux and FreeBSD core dumping code within GDB for another patch series, I noticed that the code that collects the registers for each thread and writes these into ELF note format is basically identical between Linux and FreeBSD. This commit merges this code and moves it into the gcore.c file, which seemed like the right place for generic writing a core file code. The function find_signalled_thread is moved from linux-tdep.c despite not being shared. A later commit will make use of this function. There are a couple of minor changes to the FreeBSD target after this commit, but I believe that these are changes for the better: (1) For FreeBSD we always used to record the thread-id in the core file by using ptid_t.lwp (). In contrast the Linux code did this: /* For remote targets the LWP may not be available, so use the TID. */ long lwp = ptid.lwp (); if (lwp == 0) lwp = ptid.tid (); Both target now do this: /* The LWP is often not available for bare metal target, in which case use the tid instead. */ if (ptid.lwp_p ()) lwp = ptid.lwp (); else lwp = ptid.tid (); Which is equivalent for Linux, but is a change for FreeBSD. I think that all this means is that in some cases where GDB might have previously recorded a thread-id of 0 for each thread, we might now get something more useful. (2) When collecting the registers for Linux we collected into a zero initialised buffer. By contrast on FreeBSD the buffer is left uninitialised. In the new code the buffer is always zero initialised. I suspect once the registers are copied into the buffer there's probably no gaps left so this makes no difference, but if it does then using zeros rather than random bits of GDB's memory is probably a good thing. Otherwise, there should be no other user visible changes after this commit. Tested this on x86-64/GNU-Linux and x86-64/FreeBSD-12.2 with no regressions. gdb/ChangeLog: * Makefile.in (HFILES_NO_SRCDIR): Add corefile.h. * gcore.c (struct gcore_collect_regset_section_cb_data): Moved here from linux-tdep.c and given a new name. Minor cleanups. (gcore_collect_regset_section_cb): Likewise. (gcore_collect_thread_registers): Likewise. (gcore_build_thread_register_notes): Likewise. (gcore_find_signalled_thread): Likewise. * gcore.h (gcore_build_thread_register_notes): Declare. (gcore_find_signalled_thread): Declare. * fbsd-tdep.c: Add 'gcore.h' include. (struct fbsd_collect_regset_section_cb_data): Delete. (fbsd_collect_regset_section_cb): Delete. (fbsd_collect_thread_registers): Delete. (struct fbsd_corefile_thread_data): Delete. (fbsd_corefile_thread): Delete. (fbsd_make_corefile_notes): Call gcore_build_thread_register_notes instead of the now deleted FreeBSD code. * linux-tdep.c: Add 'gcore.h' include. (struct linux_collect_regset_section_cb_data): Delete. (linux_collect_regset_section_cb): Delete. (linux_collect_thread_registers): Delete. (linux_corefile_thread): Call gcore_build_thread_register_notes. (find_signalled_thread): Delete. (linux_make_corefile_notes): Call gcore_find_signalled_thread.
2021-01-19 00:00:38 +08:00
2021-02-01 Andrew Burgess <andrew.burgess@embecosm.com>
* Makefile.in (HFILES_NO_SRCDIR): Add corefile.h.
* gcore.c (struct gcore_collect_regset_section_cb_data): Moved
here from linux-tdep.c and given a new name. Minor cleanups.
(gcore_collect_regset_section_cb): Likewise.
(gcore_collect_thread_registers): Likewise.
(gcore_build_thread_register_notes): Likewise.
(gcore_find_signalled_thread): Likewise.
* gcore.h (gcore_build_thread_register_notes): Declare.
(gcore_find_signalled_thread): Declare.
* fbsd-tdep.c: Add 'gcore.h' include.
(struct fbsd_collect_regset_section_cb_data): Delete.
(fbsd_collect_regset_section_cb): Delete.
(fbsd_collect_thread_registers): Delete.
(struct fbsd_corefile_thread_data): Delete.
(fbsd_corefile_thread): Delete.
(fbsd_make_corefile_notes): Call
gcore_build_thread_register_notes instead of the now deleted
FreeBSD code.
* linux-tdep.c: Add 'gcore.h' include.
(struct linux_collect_regset_section_cb_data): Delete.
(linux_collect_regset_section_cb): Delete.
(linux_collect_thread_registers): Delete.
(linux_corefile_thread): Call
gcore_build_thread_register_notes.
(find_signalled_thread): Delete.
(linux_make_corefile_notes): Call gcore_find_signalled_thread.
[gdb/breakpoint] Fix stepping past non-stmt line-table entries Consider the test-case small.c: ... $ cat -n small.c 1 __attribute__ ((noinline, noclone)) 2 int foo (char *c) 3 { 4 asm volatile ("" : : "r" (c) : "memory"); 5 return 1; 6 } 7 8 int main () 9 { 10 char tpl1[20] = "/tmp/test.XXX"; 11 char tpl2[20] = "/tmp/test.XXX"; 12 int fd1 = foo (tpl1); 13 int fd2 = foo (tpl2); 14 if (fd1 == -1) { 15 return 1; 16 } 17 18 return 0; 19 } ... Compiled with gcc-8 and optimization: ... $ gcc-8 -O2 -g small.c ... We step through the calls to foo, but fail to visit line 13: ... 12 int fd1 = foo (tpl1); (gdb) step foo (c=c@entry=0x7fffffffdea0 "/tmp/test.XXX") at small.c:5 5 return 1; (gdb) step foo (c=c@entry=0x7fffffffdec0 "/tmp/test.XXX") at small.c:5 5 return 1; (gdb) step main () at small.c:14 14 if (fd1 == -1) { (gdb) ... This is caused by the following. The calls to foo are implemented by these insns: .... 4003df: 0f 29 04 24 movaps %xmm0,(%rsp) 4003e3: 0f 29 44 24 20 movaps %xmm0,0x20(%rsp) 4003e8: e8 03 01 00 00 callq 4004f0 <foo> 4003ed: 48 8d 7c 24 20 lea 0x20(%rsp),%rdi 4003f2: 89 c2 mov %eax,%edx 4003f4: e8 f7 00 00 00 callq 4004f0 <foo> 4003f9: 31 c0 xor %eax,%eax ... with corresponding line table entries: ... INDEX LINE ADDRESS IS-STMT 8 12 0x00000000004003df Y 9 10 0x00000000004003df 10 11 0x00000000004003e3 11 12 0x00000000004003e8 12 13 0x00000000004003ed 13 12 0x00000000004003f2 14 13 0x00000000004003f4 Y 15 13 0x00000000004003f4 16 14 0x00000000004003f9 Y 17 14 0x00000000004003f9 ... Once we step out of the call to foo at 4003e8, we land at 4003ed, and gdb enters process_event_stop_test to figure out what to do. That entry has is-stmt=n, so it's not the start of a line, so we don't stop there. However, we do update ecs->event_thread->current_line to line 13, because the frame has changed (because we stepped out of the function). Next we land at 4003f2. Again the entry has is-stmt=n, so it's not the start of a line, so we don't stop there. However, because the frame hasn't changed, we don't update update ecs->event_thread->current_line, so it stays 13. Next we land at 4003f4. Now is-stmt=y, so it's the start of a line, and we'd like to stop here. But we don't stop because this test fails: ... if ((ecs->event_thread->suspend.stop_pc == stop_pc_sal.pc) && (ecs->event_thread->current_line != stop_pc_sal.line || ecs->event_thread->current_symtab != stop_pc_sal.symtab)) { ... because ecs->event_thread->current_line == 13 and stop_pc_sal.line == 13. Fix this by resetting ecs->event_thread->current_line to 0 if is-stmt=n and the frame has changed, such that we have: ... 12 int fd1 = foo (tpl1); (gdb) step foo (c=c@entry=0x7fffffffdbc0 "/tmp/test.XXX") at small.c:5 5 return 1; (gdb) step main () at small.c:13 13 int fd2 = foo (tpl2); (gdb) ... Tested on x86_64-linux, with gcc-7 and gcc-8. gdb/ChangeLog: 2021-01-29 Tom de Vries <tdevries@suse.de> PR breakpoints/26063 * infrun.c (process_event_stop_test): Reset ecs->event_thread->current_line to 0 if is-stmt=n and frame has changed. gdb/testsuite/ChangeLog: 2021-01-29 Tom de Vries <tdevries@suse.de> PR breakpoints/26063 * gdb.dwarf2/dw2-step-out-of-function-no-stmt.c: New test. * gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp: New file.
2021-01-29 20:36:52 +08:00
2021-01-29 Tom de Vries <tdevries@suse.de>
PR breakpoints/26063
* infrun.c (process_event_stop_test): Reset
ecs->event_thread->current_line to 0 if is-stmt=n and frame has
changed.
2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
* thread.c (thr_try_catch_cmd): Replace swith_to_thread with an
assert. Extend the header comment.
gdb/tui: remove special handling of locator/status window The locator window, or status window as it is sometimes called is handled differently to all the other windows. The reason for this is that the class representing this window (tui_locator_window) does two jobs, first this class represents a window just like any other that has space on the screen and fills the space with content. The second job is that this class serves as a storage area to hold information about the current location that the TUI windows represent, so the class has members like 'addr' and 'line_no', for example which are used within this class, and others when they want to know which line/address the TUI windows should be showing to the user. Because of this dual purpose we must always have an instance of the tui_locator_window so that there is somewhere to store this location information. The result of this is that the locator window must never be deleted like other windows, which results in some special case code. In this patch I propose splitting the two roles of the tui_locator_window class. The tui_locator_window class will retain just its window drawing parts, and will be treated just like any other window. This should allow all special case code for this window to be deleted. The other role, that of tracking the current tui location will be moved into a new class (tui_location_tracker), of which there will be a single global instance. All of the places where we previously use the locator window to get location information will now be updated to get this from the tui_location_tracker. There should be no user visible changes after this commit. gdb/ChangeLog: * Makefile.in (SUBDIR_TUI_SRCS): Add tui/tui-location.c. (HFILES_NO_SRCDIR): Add tui/tui-location.h. * tui/tui-data.h (TUI_STATUS_WIN): Define. (tui_locator_win_info_ptr): Delete declaration. * tui/tui-disasm.c: Add 'tui/tui-location.h' include. (tui_disasm_window::set_contents): Fetch state from tui_location global. (tui_get_begin_asm_address): Likewise. * tui/tui-layout.c (tui_apply_current_layout): Remove special case for locator window. (get_locator_window): Delete. (initialize_known_windows): Treat locator window just like all the rest. * tui/tui-source.c: Add 'tui/tui-location.h' include. (tui_source_window::set_contents): Fetch state from tui_location global. (tui_source_window::showing_source_p): Likewise. * tui/tui-stack.c: Add 'tui/tui-location.h' include. (_locator): Delete. (tui_locator_win_info_ptr): Delete. (tui_locator_window::make_status_line): Fetch state from tui_location global. (tui_locator_window::rerender): Remove check of 'handle', reindent function body. (tui_locator_window::set_locator_fullname): Delete. (tui_locator_window::set_locator_info): Delete. (tui_update_locator_fullname): Delete. (tui_show_frame_info): Likewise. (tui_show_locator_content): Access window through TUI_STATUS_WIN. * tui/tui-stack.h (tui_locator_window::set_locator_info): Moved to tui/tui-location.h and renamed to tui_location_tracker::set_location. (tui_locator_window::set_locator_fullname): Moved to tui/tui-location.h and renamed to tui_location_tracker::set_fullname. (tui_locator_window::full_name): Delete. (tui_locator_window::proc_name): Delete. (tui_locator_window::line_no): Delete. (tui_locator_window::addr): Delete. (tui_locator_window::gdbarch): Delete. (tui_update_locator_fullname): Delete declaration. * tui/tui-wingeneral.c (tui_refresh_all): Removed special handling for locator window. * tui/tui-winsource.c: Add 'tui/tui-location.h' include. (tui_display_main): Call function on tui_location directly. * tui/tui.h (enum tui_win_type): Add STATUS_WIN. * tui/tui-location.c: New file. * tui/tui-location.h: New file.
2021-01-26 02:43:19 +08:00
2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
* Makefile.in (SUBDIR_TUI_SRCS): Add tui/tui-location.c.
(HFILES_NO_SRCDIR): Add tui/tui-location.h.
* tui/tui-data.h (TUI_STATUS_WIN): Define.
(tui_locator_win_info_ptr): Delete declaration.
* tui/tui-disasm.c: Add 'tui/tui-location.h' include.
(tui_disasm_window::set_contents): Fetch state from tui_location
global.
(tui_get_begin_asm_address): Likewise.
* tui/tui-layout.c (tui_apply_current_layout): Remove special case
for locator window.
(get_locator_window): Delete.
(initialize_known_windows): Treat locator window just like all the
rest.
* tui/tui-source.c: Add 'tui/tui-location.h' include.
(tui_source_window::set_contents): Fetch state from tui_location
global.
(tui_source_window::showing_source_p): Likewise.
* tui/tui-stack.c: Add 'tui/tui-location.h' include.
(_locator): Delete.
(tui_locator_win_info_ptr): Delete.
(tui_locator_window::make_status_line): Fetch state from
tui_location global.
(tui_locator_window::rerender): Remove check of 'handle',
reindent function body.
(tui_locator_window::set_locator_fullname): Delete.
(tui_locator_window::set_locator_info): Delete.
(tui_update_locator_fullname): Delete.
(tui_show_frame_info): Likewise.
(tui_show_locator_content): Access window through TUI_STATUS_WIN.
* tui/tui-stack.h (tui_locator_window::set_locator_info): Moved to
tui/tui-location.h and renamed to
tui_location_tracker::set_location.
(tui_locator_window::set_locator_fullname): Moved to
tui/tui-location.h and renamed to
tui_location_tracker::set_fullname.
(tui_locator_window::full_name): Delete.
(tui_locator_window::proc_name): Delete.
(tui_locator_window::line_no): Delete.
(tui_locator_window::addr): Delete.
(tui_locator_window::gdbarch): Delete.
(tui_update_locator_fullname): Delete declaration.
* tui/tui-wingeneral.c (tui_refresh_all): Removed special handling
for locator window.
* tui/tui-winsource.c: Add 'tui/tui-location.h' include.
(tui_display_main): Call function on tui_location directly.
* tui/tui.h (enum tui_win_type): Add STATUS_WIN.
* tui/tui-location.c: New file.
* tui/tui-location.h: New file.
2021-01-28 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (get_type_arch): Rename to...
(struct type) <arch>: ... this, update all users.
2021-01-28 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (struct type) <arch>: Rename to...
<arch_owner>: ... this, update all users.
<objfile>: Rename to...
<objfile_owner>: ... this, update all users.
2021-01-28 Andrew Burgess <andrew.burgess@embecosm.com>
* gdbcmd.h (execute_command_to_string): Update comment.
* top.c (execute_command_to_string): Update header comment.
[gdb/breakpoints] Fix longjmp master breakpoint with separate debug info When running test-case gdb.base/longjmp.exp with target board unix/-m32, we run into: ... (gdb) next^M Warning:^M Cannot insert breakpoint 0.^M Cannot access memory at address 0x7dbf7353^M ^M __libc_siglongjmp (env=0x804a040 <env>, val=1) at longjmp.c:28^M 28 longjmps++;^M (gdb) FAIL: gdb.base/longjmp.exp: next over longjmp(1) ... The failure to access memory happens in i386_get_longjmp_target and is due to glibc having pointer encryption (aka "pointer mangling" or "pointer guard") of the long jump buffer. This is a known problem. In create_longjmp_master_breakpoint (which attempts to install a master longjmp breakpoint) a preference scheme is present, which installs a probe breakpoint if a libc:longjmp probe is present, and otherwise falls back to setting breakpoints at the names in the longjmp_names array. But in fact, both the probe breakpoint and the longjmp_names breakpoints are set. The latter ones are set when processing libc.so.debug, and the former one when processing libc.so. In other words, this is the longjmp variant of PR26881, which describes the same problem for master exception breakpoints. This problem only triggers when the glibc debug info package is installed, which is not due to the debug info itself in libc.so.debug, but due to the minimal symbols (because create_longjmp_master_breakpoint uses minimal symbols to translate the longjmp_names to addresses). The problem doesn't trigger for -m64, because there tdep->jb_pc_offset is not set. Fix this similar to commit 1940319c0ef (the fix for PR26881): only install longjmp_names breakpoints in libc.so/libc.so.debug if installing the libc:longjmp probe in libc.so failed. Tested on x86_64-linux. gdb/ChangeLog: 2021-01-28 Tom de Vries <tdevries@suse.de> PR breakpoints/27205 * breakpoint.c (create_longjmp_master_breakpoint_probe) (create_longjmp_master_breakpoint_names): New function, factored out of ... (create_longjmp_master_breakpoint): ... here. Only try to install longjmp_names breakpoints in libc.so/libc.so.debug if installing probe breakpoint in libc.so failed.
2021-01-28 17:59:42 +08:00
2021-01-28 Tom de Vries <tdevries@suse.de>
PR breakpoints/27205
* breakpoint.c (create_longjmp_master_breakpoint_probe)
(create_longjmp_master_breakpoint_names): New function, factored out
of ...
(create_longjmp_master_breakpoint): ... here. Only try to install
longjmp_names breakpoints in libc.so/libc.so.debug if installing probe
breakpoint in libc.so failed.
2021-01-27 Lancelot SIX <lsix@lancelotsix.com>
PR gdb/27133
* cli/cli-interp.c (cli_interp_base::set_logging): Ensure the
unique_ptr is released when the wrapped pointer is kept for later
use.
GDB: aarch64: Add ability to displaced step over a BR/BLR instruction Enable displaced stepping over a BR/BLR instruction Displaced stepping over an instruction executes a instruction in a scratch area and then manually fixes up the PC address to leave execution where it would have been if the instruction were in its original location. The BR instruction does not need modification in order to run correctly at a different address, but the displaced step fixup method should not manually adjust the PC since the BR instruction sets that value already. The BLR instruction should also avoid such a fixup, but must also have the link register modified to point to just after the original code location rather than back to the scratch location. This patch adds the above functionality. We add this functionality by modifying aarch64_displaced_step_others rather than by adding a new visitor method to aarch64_insn_visitor. We choose this since it seems that visitor approach is designed specifically for PC relative instructions (which must always be modified when executed in a different location). It seems that the BR and BLR instructions are more like the RET instruction which is already handled specially in aarch64_displaced_step_others. This also means the gdbserver code to relocate an instruction when creating a fast tracepoint does not need to be modified, since nothing special is needed for the BR and BLR instructions there. Regression tests showed nothing untoward on native aarch64 (though it took a while for me to get the testcase to account for PIE). ------##### Original observed (mis)behaviour before was that displaced stepping over a BR or BLR instruction would not execute the function they called. Most easily seen by putting a breakpoint with a condition on such an instruction and a print statement in the functions they called. When run with the breakpoint enabled the function is not called and "numargs called" is not printed. When run with the breakpoint disabled the function is called and the message is printed. --- GDB Session ~ [15:57:14] % gdb ../using-blr Reading symbols from ../using-blr...done. (gdb) disassemble blr_call_value Dump of assembler code for function blr_call_value: ... 0x0000000000400560 <+28>: blr x2 ... 0x00000000004005b8 <+116>: ret End of assembler dump. (gdb) break *0x0000000000400560 Breakpoint 1 at 0x400560: file ../using-blr.c, line 22. (gdb) condition 1 10 == 0 (gdb) run Starting program: /home/matmal01/using-blr [Inferior 1 (process 33279) exited with code 012] (gdb) disable 1 (gdb) run Starting program: /home/matmal01/using-blr numargs called [Inferior 1 (process 33289) exited with code 012] (gdb) Test program: ---- using-blr ---- \#include <stdio.h> typedef int (foo) (int, int); typedef void (bar) (int, int); struct sls_testclass { foo *x; bar *y; int left; int right; }; __attribute__ ((noinline)) int blr_call_value (struct sls_testclass x) { int retval = x.x(x.left, x.right); if (retval % 10) return 100; return 9; } __attribute__ ((noinline)) int blr_call (struct sls_testclass x) { x.y(x.left, x.right); if (x.left % 10) return 100; return 9; } int numargs (__attribute__ ((unused)) int left, __attribute__ ((unused)) int right) { printf("numargs called\n"); return 10; } void altfunc (__attribute__ ((unused)) int left, __attribute__ ((unused)) int right) { printf("altfunc called\n"); } int main(int argc, char **argv) { struct sls_testclass x = { .x = numargs, .y = altfunc, .left = 1, .right = 2 }; if (argc > 2) { blr_call (x); } else blr_call_value (x); return 10; }
2021-01-28 01:09:46 +08:00
2021-01-27 Matthew Malcomson <matthew.malcomson@arm.com>
* aarch64-tdep.c (aarch64_displaced_step_others): Account for
BLR and BR instructions.
* arch/aarch64-insn.h (enum aarch64_opcodes): Add BR opcode.
(enum aarch64_masks): New.
2021-01-26 Tom Tromey <tromey@adacore.com>
* windows-nat.c (DEBUG_EXEC, DEBUG_EVENTS, DEBUG_MEM)
(DEBUG_EXCEPT): Use debug_prefixed_printf_cond.
(windows_init_thread_list, windows_nat::handle_load_dll)
(windows_nat::handle_unload_dll, windows_nat_target::resume)
(windows_nat_target::resume)
(windows_nat_target::get_windows_debug_event)
(windows_nat_target::interrupt, windows_xfer_memory)
(windows_nat_target::close): Update.
* nat/windows-nat.c (DEBUG_EVENTS): Use
debug_prefixed_printf_cond.
(matching_pending_stop, fetch_pending_stop)
(continue_last_debug_event): Update.
2020-12-17 Mihails Strasuns <mihails.strasuns@intel.com>
* linux-tdep.c (linux_make_mappings_corefile_notes): Start using
elfcore_write_file_note.
2021-01-26 Shahab Vahedi <shahab@synopsys.com>
* arc-tdep.c (arc_add_reggroups): New function.
(arc_gdbarch_init): Call arc_add_reggroups.
2021-01-26 Anton Kolesov <anton.kolesov@synopsys.com>
* arc-tdep.c (arc_skip_prologue): Log "pc" address.
2021-01-25 Bernd Edlinger <bernd.edlinger@hotmail.de>
Simon Marchi <simon.marchi@polymtl.ca>
Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (partial_die_info::read): Use as_unsigned () for
DW_AT_ranges.
2021-01-25 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (get_mpz): New function.
(get_dwarf2_rational_constant): Use it.
2021-01-25 Tom Tromey <tromey@adacore.com>
* ada-lang.c (resolve_subexp): Handle array context.
2021-01-23 Tom Tromey <tom@tromey.com>
PR compile/25575
* compile/compile-loc2c.c (note_register): New function.
(pushf_register_address, pushf_register): Use it.
2021-01-23 Tom Tromey <tom@tromey.com>
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Change type of "registers_used".
* dwarf2/loc.h (dwarf2_compile_property_to_c): Update.
* dwarf2/loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Change
type of "registers_used".
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Update.
* compile/compile-loc2c.c (pushf_register_address)
(pushf_register, do_compile_dwarf_expr_to_c)
(compile_dwarf_expr_to_c, compile_dwarf_bounds_to_c): Change type
of "registers_used".
* compile/compile-c.h (generate_c_for_variable_locations):
Update.
* compile/compile-c-symbols.c (generate_vla_size)
(generate_c_for_for_one_variable): Change type of
"registers_used".
(generate_c_for_variable_locations): Return std::vector.
* compile/compile-c-support.c (generate_register_struct): Change
type of "registers_used".
(compute): Update.
2021-01-23 Tom Tromey <tom@tromey.com>
* compile/compile-internal.h (class compile_instance)
<set_arguments>: Change return type.
* compile/compile.c (compile_to_object): Remove call to reset.
(compile_instance::set_arguments): Change return type.
gdb: fix regression in copy_type_recursive Commit 5b7d941b90d1 ("gdb: add owner-related methods to struct type") introduced a regression when running gdb.base/jit-reader-simple.exp and others. A NULL pointer dereference happens here: #3 0x0000557b7e9e8650 in gdbarch_obstack (arch=0x0) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:484 #4 0x0000557b7ea5b138 in copy_type_recursive (objfile=0x614000006640, type=0x62100018da80, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/gdbtypes.c:5537 #5 0x0000557b7ea5dcbb in copy_type_recursive (objfile=0x614000006640, type=0x62100018e200, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/gdbtypes.c:5598 #6 0x0000557b802cef51 in preserve_one_value (value=0x6110000b3640, objfile=0x614000006640, copied_types=0x62100018e280) at /home/simark/src/binutils-gdb/gdb/value.c:2518 #7 0x0000557b802cf787 in preserve_values (objfile=0x614000006640) at /home/simark/src/binutils-gdb/gdb/value.c:2562 #8 0x0000557b7fbaf19b in reread_symbols () at /home/simark/src/binutils-gdb/gdb/symfile.c:2489 #9 0x0000557b7ec65d1d in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at /home/simark/src/binutils-gdb/gdb/infcmd.c:439 #10 0x0000557b7ec67a97 in run_command (args=0x0, from_tty=1) at /home/simark/src/binutils-gdb/gdb/infcmd.c:546 This is inside a TYPE_ALLOC macro. The fact that gdbarch_obstack is called means that the type is flagged as being arch-owned, but arch=0x0 means that type::arch returned NULL, probably meaning that the m_owner field contains NULL. If we look at the code before the problematic patch, in the copy_type_recursive function, we see: if (! TYPE_OBJFILE_OWNED (type)) return type; ... TYPE_OBJFILE_OWNED (new_type) = 0; TYPE_OWNER (new_type).gdbarch = get_type_arch (type); The last two lines were replaced with: new_type->set_owner (type->arch ()); get_type_arch and type->arch isn't the same thing: get_type_arch gets the type's arch owner if it is arch-owned, and gets the objfile's arch if the type is objfile owned. So it always returns non-NULL. type->arch returns the type's arch if the type is arch-owned, else NULL. So since the original type is objfile owned, it effectively made the new type arch-owned (that is good) but set the owner to NULL (that is bad). Fix this by using get_type_arch again there. I spotted one other similar change in lookup_array_range_type, in the original patch. But that one appears to be correct, as it is executed only if the type is arch-owned. Add some asserts in type::set_owner to ensure we never set a NULL owner. That would have helped catch the issue a little bit earlier, so it could help in the future. gdb/ChangeLog: * gdbtypes.c (copy_type_recursive): Use get_type_arch. * gdbtypes.h (struct type) <set_owner>: Add asserts. Change-Id: I5d8bc7bfc83b3abc579be0b5aadeae4241179a00
2021-01-24 06:36:55 +08:00
2021-01-23 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.c (copy_type_recursive): Use get_type_arch.
* gdbtypes.h (struct type) <set_owner>: Add asserts.
2021-01-23 Lancelot SIX <lsix@lancelotsix.com>
* Makefile.in (SELFTESTS_SRCS): Add
unittests/gdb_tilde_expand-selftests.c.
* unittests/gdb_tilde_expand-selftests.c: New file.
gdb: add new version style This commit adds a new 'version' style, which replaces the hard coded styling currently used for GDB's version string. GDB's version number is displayed: 1. In the output of 'show version', and 2. When GDB starts up (without the --quiet option). This new style can only ever affect the first of these two cases as the second case is printed before GDB has processed any initialization files, or processed any GDB commands passed on the command line. However, because the first case exists I think this commit makes sense, it means the style is no longer hard coded into GDB, and we can add some tests that the style can be enabled/disabled correctly. This commit is an alternative to a patch Tom posted here: https://sourceware.org/pipermail/gdb-patches/2020-June/169820.html I've used the style name 'version' instead of 'startup' to reflect what the style is actually used for. If other parts of the startup text end up being highlighted I imagine they would get their own styles based on what is being highlighted. I feel this is more inline with the other style names that are already in use within GDB. I also decoupled adding this style from the idea of startup options, and the possibility of auto-saving startup options. Those ideas can be explored in later patches. This commit should probably be considered only a partial solution to issue PR cli/25956. The colours of the style are no longer hard coded, however, it is still impossible to change the styling of the version string displayed during startup, so in one sense, the styling of that string is still "hard coded". A later patch will hopefully extend GDB to allow it to adjust the version styling before the initial version string is printed. gdb/ChangeLog: PR cli/25956 * cli/cli-style.c: Add 'cli/cli-setshow.h' include. (version_style): Define. (cli_style_option::cli_style_option): Add intensity parameter, and use as appropriate. (_initialize_cli_style): Register version style set/show commands. * cli/cli-style.h (cli_style_option): Add intensity parameter. (version_style): Declare. * top.c (print_gdb_version): Use version_stype, and styled_string to print the GDB version string. gdb/doc/ChangeLog: PR cli/25956 * gdb.texinfo (Output Styling): Document version style. gdb/testsuite/ChangeLog: PR cli/25956 * gdb.base/style.exp (run_style_tests): Add version string test. (test_startup_version_string): Use version style name. * lib/gdb-utils.exp (style): Handle version style name.
2021-01-14 04:08:51 +08:00
2021-01-22 Andrew Burgess <andrew.burgess@embecosm.com>
PR cli/25956
* NEWS: Mention new command.
* cli/cli-style.c: Add 'cli/cli-setshow.h' include.
(version_style): Define.
(cli_style_option::cli_style_option): Add intensity parameter, and
use as appropriate.
(_initialize_cli_style): Register version style set/show commands.
* cli/cli-style.h (cli_style_option): Add intensity parameter.
(version_style): Declare.
* top.c (print_gdb_version): Use version_stype, and styled_string
to print the GDB version string.
gdb: don't print escape characters when a style is disabled While working on another patch I noticed that if I disable a single style with, for example: set style filename background none set style filename foreground none set style filename intensity normal Then in some places escape characters are still injected into the output stream. This is a bit of an edge case, and I can't think when this would actually cause problems, but it still felt like a bit of an annoyance. One place where this does impact is in testing, where it becomes harder to write tight test patterns if it is not obvious when GDB will decide to inject escape sequences. It's especially annoying because depending on how something is printed then GDB might, or might not, add escape characters. So this would not add escape characters if the filename style was disabled: fprintf_filtered (file, "%ps", styled_string (file_name_style.style (), "This is a test")); But this would add escape characters: fprintf_styled (file, file_name_style.style (), "%s", "This is a test"); I tracked this down to some calls to set_output_style in utils.c. Currently some calls to set_output_style (in utils.c) are guarded like this: if (!STYLE.is_default ()) set_output_style (stream, STYLE); But some calls are not. It is the calls that are NOT guarded that cause the extra escape sequences to be emitted. My initial proposal to resolve this issue was simply to ensure that all calls to set_output_style were guarded. The patch I posted for this can be found here: https://sourceware.org/pipermail/gdb-patches/2021-January/175096.html The feedback on this proposal was that it might be better to guard against the escape sequences being emitted at a later lever, right down at emit_style_escape. So this is what this version does. In emit_style_escape we already track the currently applied style, so if the style we are being asked to switch to is the same as the currently applied style then no escape sequence needs to be emitted. Making this change immediately exposed some issues in fputs_maybe_filtered related to line wrapping. The best place to start to understand what's going on with the styling and wrapping is look at the test: gdb.base/style.exp: all styles enabled: frame when width=20 If you run this test and then examine the output in an editor so the escape sequences can be seen you'll see the duplicate escape sequences that are emitted before this patch, the compare to after this patch you'll see the set of escape sequences should be the minimum required. In order to test these changes I have rewritten the gdb.base/style.exp test script. The core of the script is now run multiple times. The first time the test is run things are as they were before, all styles are on. After that the test is rerun multiple times. Each time through a single style is disabled using the 3 explicit set calls listed above. I then repeat all the tests, however, I arrange so that the patterns for the disabled style now require no escape sequences. gdb/ChangeLog: * utils.c (emit_style_escape): Only emit an escape sequence if the requested style is different than the current applied style. (fputs_maybe_filtered): Adjust the juggling of the wrap_style, and current applied_style. (fputs_styled): Remove is_default check. (fputs_styled_unfiltered): Likewise. (vfprintf_styled_no_gdbfmt): Likewise. gdb/testsuite/ChangeLog: * gdb.base/style.exp (limited_style): New proc. (clean_restart_and_disable): New proc. (run_style_tests): New proc. Most of the old tests from this file are now in this proc. (test_startup_version_string): New proc. Reamining test from the old file is in this proc.
2021-01-14 04:08:42 +08:00
2021-01-22 Andrew Burgess <andrew.burgess@embecosm.com>
* utils.c (emit_style_escape): Only emit an escape sequence if the
requested style is different than the current applied style.
(fputs_maybe_filtered): Adjust the juggling of the wrap_style, and
current applied_style.
(fputs_styled): Remove is_default check.
(fputs_styled_unfiltered): Likewise.
(vfprintf_styled_no_gdbfmt): Likewise.
gdb: add remote_debug_printf This is the next in the new-style debug macro series. For this one, I decided to omit the function name from the "Sending packet" / "Packet received" kind of prints, just because it's not very useful in that context and hinders readability more than anything else. This is completely arbitrary. This is with: [remote] putpkt_binary: Sending packet: $qTStatus#49... [remote] getpkt_or_notif_sane_1: Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes:: and without: [remote] Sending packet: $qTStatus#49... [remote] Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes:: A difference is that previously, the query packet and its reply would be printed on the same line, like this: Sending packet: $qTStatus#49...Packet received: T0;tnotrun:0;tframes:0;tcreated:0;tfree:500000;tsize:500000;circular:0;disconn:0;starttime:0;stoptime:0;username:;notes:: Now, they are printed on two lines, since each remote_debug_printf{,_nofunc} prints its own complete message including an end of line. It's probably a matter of taste, but I prefer the two-line version, it's easier to follow, especially when the query packet is long. As a result, lib/range-stepping-support.exp needs to be updated, as it currently expects the vCont packet and the reply to be on the same line. I think it's sufficient in that context to just expect the vCont packet and not the reply, since the goal is just to count how many vCont;r GDB sends. gdb/ChangeLog: * remote.h (remote_debug_printf): New. (remote_debug_printf_nofunc): New. (REMOTE_SCOPED_DEBUG_ENTER_EXIT): New. * remote.c: Use above macros throughout file. gdbsupport/ChangeLog: * common-debug.h (debug_prefixed_printf_cond_nofunc): New. * common-debug.c (debug_prefixed_vprintf): Handle a nullptr func. gdb/testsuite/ChangeLog: * lib/range-stepping-support.exp (exec_cmd_expect_vCont_count): Adjust to "set debug remote" changes. Change-Id: Ica6dead50d3f82e855c7d763f707cef74bed9fee
2021-01-23 01:43:27 +08:00
2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
* remote.h (remote_debug_printf): New.
(remote_debug_printf_nofunc): New.
(REMOTE_SCOPED_DEBUG_ENTER_EXIT): New.
* remote.c: Use above macros throughout file.
2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
* remote.h (remote_debug): Change to bool.
* remote.c (remote_debug): Change to bool.
(_initialize_remote): Adjust.
2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
* target.h (remote_debug): Move to...
* remote.h (remote_debug): ... here.
* top.c (remote_debug): Move to...
* remote.c (remote_debug): ... here.
* remote-sim.c: Include remote.h.
2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
* cli/cli-cmds.c (show_remote_debug): Remove.
(show_remote_timeout): Remove.
(_initialize_cli_cmds): Don't register commands.
* remote.c (show_remote_debug): Move here.
(show_remote_timeout): Move here.
(_initialize_remote): Register commands.
2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (TYPE_OBJFILE): Remove, change all users to use the
type::objfile method instead.
2021-01-22 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (TYPE_OBJFILE_OWNED): Remove, update all users to
use the type::is_objfile_owned method.
2021-01-22 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (TYPE_OBJFILE_OWNED): Adjust.
(TYPE_OWNER): Remove.
(TYPE_OBJFILE): Adjust.
(struct main_type) <flag_objfile_owned>: Rename to...
<m_flag_objfile_owned>: ... this.
<owner>: Rename to...
<m_owner>: ... this.
(struct type) <is_objfile_owned, set_owner, objfile, arch>: New
methods.
(TYPE_ALLOC): Adjust.
* gdbtypes.c (alloc_type): Adjust.
(alloc_type_arch): Adjust.
(alloc_type_copy): Adjust.
(get_type_arch): Adjust.
(smash_type): Adjust.
(lookup_array_range_type): Adjust.
(recursive_dump_type): Adjust.
(copy_type_recursive): Adjust.
* compile/compile-c-types.c (convert_func): Adjust.
(convert_type_basic): Adjust.
* compile/compile-cplus-types.c (compile_cplus_convert_func):
Adjust.
* language.c
(language_arch_info::type_and_symbol::alloc_type_symbol):
Adjust.
2021-01-21 Luis Machado <luis.machado@linaro.org>
* coffread.c (enter_linenos): Passing string to complaint.
* valops.c (value_assign): Make array view.
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
* auto-load.h (debug_auto_load): Move here.
(auto_load_debug_printf): New.
* auto-load.c: Use auto_load_debug_printf.
(debug_auto_load): Move to header.
* linux-thread-db.c (try_thread_db_load): Use
auto_load_debug_printf.
* main.c (captured_main_1): Likewise.
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
* f-valprint.c (f77_array_offset_tbl): Remove.
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
* gdb_bfd.c (bfd_cache_debug_printf): New, use throughout file.
gdb: use interruptible_select when connecting to a remote When GDB is waiting trying to connect to a remote target and it receives a SIGWINCH (terminal gets resized), the blocking system call gets interrupted and we abort. For example, I connect to some port (on which nothing listens): (gdb) tar rem :1234 ... GDB blocks here, resize the terminal ... :1234: Interrupted system call. The backtrace where GDB is blocked while waiting for the connection to establish is: #0 0x00007fe9db805b7b in select () from /usr/lib/libc.so.6 #1 0x000055f2472e9c42 in gdb_select (n=0, readfds=0x0, writefds=0x0, exceptfds=0x0, timeout=0x7ffe8fafe050) at /home/simark/src/binutils-gdb/gdb/posix-hdep.c:31 #2 0x000055f24759c212 in wait_for_connect (sock=-1, polls=0x7ffe8fafe300) at /home/simark/src/binutils-gdb/gdb/ser-tcp.c:147 #3 0x000055f24759d0e8 in net_open (scb=0x62500015b900, name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/ser-tcp.c:356 #4 0x000055f2475a0395 in serial_open_ops_1 (ops=0x55f24892ca60 <tcp_ops>, open_name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/serial.c:244 #5 0x000055f2475a01d6 in serial_open (name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/serial.c:231 #6 0x000055f2474d5274 in remote_serial_open (name=0x6020000601d8 ":1234") at /home/simark/src/binutils-gdb/gdb/remote.c:5019 #7 0x000055f2474d7025 in remote_target::open_1 (name=0x6020000601d8 ":1234", from_tty=1, extended_p=0) at /home/simark/src/binutils-gdb/gdb/remote.c:5571 #8 0x000055f2474d47d5 in remote_target::open (name=0x6020000601d8 ":1234", from_tty=1) at /home/simark/src/binutils-gdb/gdb/remote.c:4898 #9 0x000055f24776379f in open_target (args=0x6020000601d8 ":1234", from_tty=1, command=0x611000042bc0) at /home/simark/src/binutils-gdb/gdb/target.c:242 Fix that by using interruptible_select in wait_for_connect, instead of gdb_select. Resizing the terminal now no longer aborts the connection. It is still possible to interrupt the connection using ctrl-c. gdb/ChangeLog: * ser-tcp.c (wait_for_connect): Use interruptible_select instead of gdb_select. Change-Id: Ie25577bd1e5699e4847b6b53fdfa10b8c0dc5c89
2021-01-22 03:04:52 +08:00
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
* ser-tcp.c (wait_for_connect): Use interruptible_select instead
of gdb_select.
2021-01-21 Hannes Domani <ssbssa@yahoo.de>
PR python/19151
* python/py-breakpoint.c (bppy_get_location): Handle
bp_hardware_breakpoint.
(bppy_init): Likewise.
(gdbpy_breakpoint_created): Likewise.
2021-01-21 Simon Marchi <simon.marchi@polymtl.ca>
* arm-tdep.c (arm_debug_printf): Add and use throughout file.
2021-01-20 Simon Marchi <simon.marchi@polymtl.ca>
* gdb_bfd.c (debug_bfd_cache): Change type to bool.
(_initialize_gdb_bfd): Adjust.
gdb/dwarf: add assertion in maybe_queue_comp_unit The symptom that leads to this is the crash described in PR 26828: /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:23478:25: runtime error: member access within null pointer of type 'struct dwarf2_cu' The line of the crash is the following, in follow_die_offset: if (target_cu != cu) target_cu->ancestor = cu; <--- HERE The line that assign nullptr to `target_cu` is the `per_objfile->get_cu` call after having called maybe_queue_comp_unit: /* If necessary, add it to the queue and load its DIEs. */ if (maybe_queue_comp_unit (cu, per_cu, per_objfile, cu->language)) load_full_comp_unit (per_cu, per_objfile, per_objfile->get_cu (per_cu), false, cu->language); target_cu = per_objfile->get_cu (per_cu); <--- HERE Some background: there is an invariant, documented in maybe_queue_comp_unit's doc, that if a CU is queued for expansion (present in dwarf2_per_bfd::queue), then its DIEs are loaded in memory. "its DIEs are loaded in memory" is a synonym for saying that a dwarf2_cu object exists for this CU. Yet another way to say it is that `per_objfile->get_cu (per_cu)` returns something not nullptr for that CU. The crash documented in PR 26828 triggers some hard-to-reproduce sequence that ends up violating the invariant: - dwarf2_fetch_die_type_sect_off gets called for a DIE in CU A - The DIE in CU A requires some DIE in CU B - follow_die_offset calls maybe_queue_comp_unit. maybe_queue_comp_unit sees CU B is not queued and its DIEs are not loaded, so it enqueues it and returns 1 to its caller - meaning "the DIEs are not loaded, you should load them" - prompting follow_die_offset to load the DIEs by calling load_full_comp_unit - Note that CU B is enqueued by maybe_queue_comp_unit even if it has already been expanded. It's a bit useless (and causes trouble, see next patch), but that's how it works right now. - Since we entered the dwarf2/read code through dwarf2_fetch_die_type_sect_off, nothing processes the queue, so we exit the dwarf2/read code with CU B still lingering in the queue. - dwarf2_fetch_die_type_sect_off gets called for a DIE in CU A, again - The DIE in CU A requires some DIE in CU B, again - This time, maybe_queue_comp_unit sees that CU B is in the queue. Because of the invariant that if a CU is in the queue, its DIEs are loaded in the memory, it returns 0 to its caller, meaning "you don't need to load the DIEs!". - That happens to be true, so everything is fine for now. - Time passes, some things call dwarf2_per_objfile::age_comp_units enough so that CU B's age becomes past the dwarf_max_cache_age threshold. age_comp_units proceeds to free CU B's DIEs. Remember that CU B is still lingering in the queue (oops, the invariant just got violated). - dwarf2_fetch_die_type_sect_off gets called for a DIE in CU A, again - The DIE in CU A requires some DIE in CU B, again - maybe_queue_comp_unit sees that CU B is in the queue, so returns to its caller "you don't need to load the DIEs!". However, we know at this point this is false. - follow_die_offset doesn't load the DIEs and tries to obtain the DIEs for CU B: target_cu = per_objfile->get_cu (per_cu); But since they are not loaded, target_cu is nullptr, and we get the crash mentioned above a few lines after that. This patch adds an assertions in maybe_queue_comp_unit to verify the invariant, to make sure it doesn't return a falsehood to its caller. The current patch doesn't fix the issue (the next patch does), but it makes it so we catch the problem earlier and get this assertion failure instead of a segmentation fault: /home/simark/src/binutils-gdb/gdb/dwarf2/read.c:9100: internal-error: int maybe_queue_comp_unit(dwarf2_cu*, dwarf2_per_cu_data*, dwarf2_per_objfile*, language): Assertion `per_objfile->get_cu (per_cu) != nullptr' failed. gdb/ChangeLog: PR gdb/26828 * dwarf2/read.c (maybe_queue_comp_unit): Add assertion. Change-Id: I4e51bd7bd58773f9fadf480179cbc4bae61508fe
2021-01-21 10:04:43 +08:00
2021-01-20 Simon Marchi <simon.marchi@polymtl.ca>
PR gdb/26828
* dwarf2/read.c (maybe_queue_comp_unit): Add assertion.
2021-01-20 Simon Marchi <simon.marchi@polymtl.ca>
* dwarf2/read.c (follow_die_offset): Add logging.
(dwarf2_per_objfile::age_comp_units): Add logging.
gdb: make some variables static I'm trying to enable clang's -Wmissing-variable-declarations warning. This patch fixes all the obvious spots where we can simply add "static" (at least, found when building on x86-64 Linux). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_linux_record_tdep): Make static. * aarch64-tdep.c (tdesc_aarch64_list, aarch64_prologue_unwind, aarch64_stub_unwind, aarch64_normal_base, ): Make static. * arm-linux-tdep.c (arm_prologue_unwind): Make static. * arm-tdep.c (struct frame_unwind): Make static. * auto-load.c (auto_load_safe_path_vec): Make static. * csky-tdep.c (csky_stub_unwind): Make static. * gdbarch.c (gdbarch_data_registry): Make static. * gnu-v2-abi.c (gnu_v2_abi_ops): Make static. * i386-netbsd-tdep.c (i386nbsd_mc_reg_offset): Make static. * i386-tdep.c (i386_frame_setup_skip_insns, i386_tramp_chain_in_reg_insns, i386_tramp_chain_on_stack_insns): Make static. * infrun.c (observer_mode): Make static. * linux-nat.c (sigchld_action): Make static. * linux-thread-db.c (thread_db_list): Make static. * maint-test-options.c (maintenance_test_options_list): * mep-tdep.c (mep_csr_registers): Make static. * mi/mi-cmds.c (struct mi_cmd_stats): Remove struct type name. (stats): Make static. * nat/linux-osdata.c (struct osdata_type): Make static. * ppc-netbsd-tdep.c (ppcnbsd_reg_offsets): Make static. * progspace.c (last_program_space_num): Make static. * python/py-param.c (struct parm_constant): Remove struct type name. (parm_constants): Make static. * python/py-record-btrace.c (btpy_list_methods): Make static. * python/py-record.c (recpy_gap_type): Make static. * record.c (record_goto_cmdlist): Make static. * regcache.c (regcache_descr_handle): Make static. * registry.h (DEFINE_REGISTRY): Make definition static. * symmisc.c (std_in, std_out, std_err): Make static. * top.c (previous_saved_command_line): Make static. * tracepoint.c (trace_user, trace_notes, trace_stop_notes): Make static. * unittests/command-def-selftests.c (nr_duplicates, nr_invalid_prefixcmd, lists): Make static. * unittests/observable-selftests.c (test_notification): Make static. * unittests/optional/assignment/1.cc (counter): Make static. * unittests/optional/assignment/2.cc (counter): Make static. * unittests/optional/assignment/3.cc (counter): Make static. * unittests/optional/assignment/4.cc (counter): Make static. * unittests/optional/assignment/5.cc (counter): Make static. * unittests/optional/assignment/6.cc (counter): Make static. gdbserver/ChangeLog: * ax.cc (bytecode_address_table): Make static. * debug.cc (debug_file): Make static. * linux-low.cc (stopping_threads): Make static. (step_over_bkpt): Make static. * linux-x86-low.cc (amd64_emit_ops, i386_emit_ops): Make static. * tracepoint.cc (stop_tracing_bkpt, flush_trace_buffer_bkpt, alloced_trace_state_variables, trace_buffer_ctrl, tracing_start_time, tracing_stop_time, tracing_user_name, tracing_notes, tracing_stop_note): Make static. Change-Id: Ic1d8034723b7802502bda23770893be2338ab020
2021-01-21 09:55:05 +08:00
2021-01-20 Simon Marchi <simon.marchi@polymtl.ca>
* aarch64-linux-tdep.c (aarch64_linux_record_tdep): Make static.
* aarch64-tdep.c (tdesc_aarch64_list, aarch64_prologue_unwind,
aarch64_stub_unwind, aarch64_normal_base, ): Make static.
* arm-linux-tdep.c (arm_prologue_unwind): Make static.
* arm-tdep.c (struct frame_unwind): Make static.
* auto-load.c (auto_load_safe_path_vec): Make static.
* csky-tdep.c (csky_stub_unwind): Make static.
* gdbarch.c (gdbarch_data_registry): Make static.
* gnu-v2-abi.c (gnu_v2_abi_ops): Make static.
* i386-netbsd-tdep.c (i386nbsd_mc_reg_offset): Make static.
* i386-tdep.c (i386_frame_setup_skip_insns,
i386_tramp_chain_in_reg_insns, i386_tramp_chain_on_stack_insns):
Make static.
* infrun.c (observer_mode): Make static.
* linux-nat.c (sigchld_action): Make static.
* linux-thread-db.c (thread_db_list): Make static.
* maint-test-options.c (maintenance_test_options_list):
* mep-tdep.c (mep_csr_registers): Make static.
* mi/mi-cmds.c (struct mi_cmd_stats): Remove struct type name.
(stats): Make static.
* nat/linux-osdata.c (struct osdata_type): Make static.
* ppc-netbsd-tdep.c (ppcnbsd_reg_offsets): Make static.
* progspace.c (last_program_space_num): Make static.
* python/py-param.c (struct parm_constant): Remove struct type
name.
(parm_constants): Make static.
* python/py-record-btrace.c (btpy_list_methods): Make static.
* python/py-record.c (recpy_gap_type): Make static.
* record.c (record_goto_cmdlist): Make static.
* regcache.c (regcache_descr_handle): Make static.
* registry.h (DEFINE_REGISTRY): Make definition static.
* symmisc.c (std_in, std_out, std_err): Make static.
* top.c (previous_saved_command_line): Make static.
* tracepoint.c (trace_user, trace_notes, trace_stop_notes): Make
static.
* unittests/command-def-selftests.c (nr_duplicates,
nr_invalid_prefixcmd, lists): Make static.
* unittests/observable-selftests.c (test_notification): Make
static.
* unittests/optional/assignment/1.cc (counter): Make static.
* unittests/optional/assignment/2.cc (counter): Make static.
* unittests/optional/assignment/3.cc (counter): Make static.
* unittests/optional/assignment/4.cc (counter): Make static.
* unittests/optional/assignment/5.cc (counter): Make static.
* unittests/optional/assignment/6.cc (counter): Make static.
2021-01-20 Joel Sherrill <joel@rtems.org>
PR gdb/27219
* remote.c (struct remote_thread_info) <resume_state>: Rename
to...
<get_resume_state>: ... this.
(remote_target::resume): Adjust.
(remote_target::commit_resume): Adjust.
(remote_target::select_thread_for_ambiguous_stop_reply): Adjust.
Fix a few stap parser issues and add a new test for probe expressions The creation of this patch was motivated by Tom's "Change handling of '!' operator in stap probes" patch. While reviewing his patch, I stumbled upon a few issues with the stap expression parser. They are: - As it turns out, even with Tom's patch applied the parser doesn't properly handle the '!' operator. The underlying issue was the fact that stap_parse_argument_conditionally also needed to be patched in order to recognize '!' as an operator that is part of a single operand, and parse it accordingly. - While writing the testcase I'm proposing on this patch, I found that parenthesized sub-expressions were not being parsed correctly when there was another term after them. For example: 1 - (2 + 3) + 4 In this case, the parser was considering "1" to be the left-side of the expression, and "(2 + 3) + 4" to be the right-side. The patch fixes the parser by making it identify whether a parenthesized sub-expression has just been parsed, and act accordingly. I've tested this on my Debian testing amd64, and everything seems OK. gdb/ChangeLog: 2021-01-20 Sergio Durigan Junior <sergiodj@sergiodj.net> Tom Tromey <tom@tromey.com> * stap-probe.c (stap_parse_single_operand): Handle '!' operator. (stap_parse_argument_conditionally): Likewise. Skip spaces after processing open-parenthesis sub-expression. (stap_parse_argument_1): Skip spaces after call to stap_parse_argument_conditionally. Handle case when right-side expression is a parenthesized sub-expression. Skip spaces after call to stap_parse_argument_1. gdb/testsuite/ChangeLog: 2021-01-20 Sergio Durigan Junior <sergiodj@sergiodj.net> * gdb.arch/amd64-stap-expressions.S: New file. * gdb.arch/amd64-stap-expressions.exp: New file.
2021-01-03 15:42:52 +08:00
2021-01-20 Sergio Durigan Junior <sergiodj@sergiodj.net>
Tom Tromey <tom@tromey.com>
* stap-probe.c (stap_parse_single_operand): Handle '!'
operator.
(stap_parse_argument_conditionally): Likewise.
Skip spaces after processing open-parenthesis sub-expression.
(stap_parse_argument_1): Skip spaces after call to
stap_parse_argument_conditionally.
Handle case when right-side expression is a parenthesized
sub-expression.
Skip spaces after call to stap_parse_argument_1.
2021-01-19 Lancelot SIX <lsix@lancelotsix.com>
* top.h (switch_thru_all_uis): Use DISABLE_COPY_AND_ASSIGN.
trad-frame cleanups With the new member functions for struct trad_frame_saved_reg, there is no need to invoke some of the set/get functions anymore. This patch removes those and adjusts all callers. Even though the most natural initial state of a saved register value is UNKNOWN, there are target backends relying on the previous initial state of REALREG set to a register's own number. I noticed this in at least a couple targets: aarch64 and riscv. Because of that, I decided to keep the reset function that sets the set of register values to REALREG. I can't exercise all the targets to make sure the initial state change won't break things, hence why it is risky to change the default. Validated with --enable-targets=all on aarch64-linux Ubuntu 18.04/20.04. gdb/ChangeLog 2021-01-19 Luis Machado <luis.machado@linaro.org> * trad-frame.h (trad_frame_saved_reg) <set_value_bytes>: Allocate memory and save data. (trad_frame_set_value, trad_frame_set_realreg, trad_frame_set_addr) (trad_frame_set_unknown, trad_frame_set_value_bytes) (trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p) (trad_frame_value_bytes_p): Remove. (trad_frame_reset_saved_regs): Adjust documentation. * trad-frame.c (trad_frame_alloc_saved_regs): Initialize via a constructor and reset the state of the registers. (trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p) (trad_frame_value_bytes_p, trad_frame_set_value) (trad_frame_set_realreg, trad_frame_set_addr) (trad_frame_set_unknown, trad_frame_set_value_bytes): Remove. (trad_frame_set_reg_realreg): Update to call member function. (trad_frame_set_reg_addr, trad_frame_set_reg_value_bytes): Likewise. (trad_frame_get_prev_register): Likewise. * aarch64-tdep.c (aarch64_analyze_prologue) (aarch64_analyze_prologue_test, aarch64_make_prologue_cache_1) (aarch64_prologue_prev_register): Update to use member functions. * alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise. * alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise. * arc-tdep.c (arc_print_frame_cache, arc_make_frame_cache): Likewise. * arm-tdep.c (arm_make_prologue_cache, arm_exidx_fill_cache) (arm_make_epilogue_frame_cache): Likewise. * avr-tdep.c (avr_frame_unwind_cache) (avr_frame_prev_register): Likewise. * cris-tdep.c (cris_scan_prologue): Likewise. * csky-tdep.c (csky_frame_unwind_cache): Likewise. * frv-tdep.c (frv_analyze_prologue): Likewise. * hppa-tdep.c (hppa_frame_cache, hppa_fallback_frame_cache): Likewise. * lm32-tdep.c (lm32_frame_cache): Likewise. * m32r-tdep.c (m32r_frame_unwind_cache): Likewise. * m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise. * mips-tdep.c (set_reg_offset, mips_insn16_frame_cache) (mips_micro_frame_cache, mips_insn32_frame_cache): Likewise. (reset_saved_regs): Adjust to set realreg. * riscv-tdep.c (riscv_scan_prologue, riscv_frame_cache): Adjust to call member functions. * rs6000-tdep.c (rs6000_frame_cache, rs6000_epilogue_frame_cache) * s390-tdep.c (s390_prologue_frame_unwind_cache) (s390_backchain_frame_unwind_cache): Likewise. * score-tdep.c (score7_analyze_prologue) (score3_analyze_prologue, score_make_prologue_cache): Likewise. * sparc-netbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise. * sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise. * sparc64-netbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise. * sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise. * tilegx-tdep.c (tilegx_analyze_prologue) (tilegx_frame_cache): Likewise. * v850-tdep.c (v850_frame_cache): Likewise. * vax-tdep.c (vax_frame_cache): Likewise.
2021-01-15 02:43:28 +08:00
2021-01-19 Luis Machado <luis.machado@linaro.org>
* trad-frame.h (trad_frame_saved_reg) <set_value_bytes>: Allocate
memory and save data.
(trad_frame_set_value, trad_frame_set_realreg, trad_frame_set_addr)
(trad_frame_set_unknown, trad_frame_set_value_bytes)
(trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
(trad_frame_value_bytes_p): Remove.
(trad_frame_reset_saved_regs): Adjust documentation.
* trad-frame.c (trad_frame_alloc_saved_regs): Initialize via a
constructor and reset the state of the registers.
(trad_frame_value_p, trad_frame_addr_p, trad_frame_realreg_p)
(trad_frame_value_bytes_p, trad_frame_set_value)
(trad_frame_set_realreg, trad_frame_set_addr)
(trad_frame_set_unknown, trad_frame_set_value_bytes): Remove.
(trad_frame_set_reg_realreg): Update to call member function.
(trad_frame_set_reg_addr, trad_frame_set_reg_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* aarch64-tdep.c (aarch64_analyze_prologue)
(aarch64_analyze_prologue_test, aarch64_make_prologue_cache_1)
(aarch64_prologue_prev_register): Update to use member functions.
* alpha-mdebug-tdep.c (alpha_mdebug_frame_unwind_cache): Likewise.
* alpha-tdep.c (alpha_heuristic_frame_unwind_cache): Likewise.
* arc-tdep.c (arc_print_frame_cache, arc_make_frame_cache): Likewise.
* arm-tdep.c (arm_make_prologue_cache, arm_exidx_fill_cache)
(arm_make_epilogue_frame_cache): Likewise.
* avr-tdep.c (avr_frame_unwind_cache)
(avr_frame_prev_register): Likewise.
* cris-tdep.c (cris_scan_prologue): Likewise.
* csky-tdep.c (csky_frame_unwind_cache): Likewise.
* frv-tdep.c (frv_analyze_prologue): Likewise.
* hppa-tdep.c (hppa_frame_cache, hppa_fallback_frame_cache): Likewise.
* lm32-tdep.c (lm32_frame_cache): Likewise.
* m32r-tdep.c (m32r_frame_unwind_cache): Likewise.
* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
* mips-tdep.c (set_reg_offset, mips_insn16_frame_cache)
(mips_micro_frame_cache, mips_insn32_frame_cache): Likewise.
(reset_saved_regs): Adjust to set realreg.
* riscv-tdep.c (riscv_scan_prologue, riscv_frame_cache): Adjust to
call member functions.
* rs6000-tdep.c (rs6000_frame_cache, rs6000_epilogue_frame_cache)
* s390-tdep.c (s390_prologue_frame_unwind_cache)
(s390_backchain_frame_unwind_cache): Likewise.
* score-tdep.c (score7_analyze_prologue)
(score3_analyze_prologue, score_make_prologue_cache): Likewise.
* sparc-netbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
* sparc-sol2-tdep.c (sparc32_sol2_sigtramp_frame_cache): Likewise.
* sparc64-netbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.
* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_cache): Likewise.
* tilegx-tdep.c (tilegx_analyze_prologue)
(tilegx_frame_cache): Likewise.
* v850-tdep.c (v850_frame_cache): Likewise.
* vax-tdep.c (vax_frame_cache): Likewise.
Convert some frame functions to use gdb::array_view. This patch converts the most obvious functions from gdb/frame.h to use the gdb::array_view abstraction. I've converted the ones that used buffer + length. There are others using only the buffer, with an implicit size. I did not touch those for now. But it would be nice to pass the size for safety. Tested with --enable-targets=all on Ubuntu 18.04/20.04 aarch64-linux. gdb/ChangeLog 2021-01-19 Luis Machado <luis.machado@linaro.org> * frame.h (get_frame_register_bytes): Pass a gdb::array_view instead of buffer + length. (put_frame_register_bytes): Likewise. Adjust documentation. (get_frame_memory): Pass a gdb::array_view instead of buffer + length. (safe_frame_unwind_memory): Likewise. * frame.c (get_frame_register_bytes, put_frame_register_bytes) (get_frame_memory, safe_frame_unwind_memory): Adjust to use gdb::array_view. * amd64-fbsd-tdep.c (amd64fbsd_sigtramp_p): Likewise. * amd64-linux-tdep.c (amd64_linux_sigtramp_start): Likewise. * amd64-obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arc-linux-tdep.c (arc_linux_is_sigtramp): Likewise. * cris-tdep.c (cris_sigtramp_start, cris_rt_sigtramp_start): Likewise. * dwarf2/loc.c (rw_pieced_value): Likewise. * hppa-tdep.c (hppa_frame_cache): Likewise. * i386-fbsd-tdep.c (i386fbsd_sigtramp_p): Likewise. * i386-gnu-tdep.c (i386_gnu_sigtramp_start): Likewise. * i386-linux-tdep.c (i386_linux_sigtramp_start) (i386_linux_rt_sigtramp_start): Likewise. * i386-obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * i386-tdep.c (i386_register_to_value): Likewise. * i387-tdep.c (i387_register_to_value): Likewise. * ia64-tdep.c (ia64_register_to_value): Likewise. * m32r-linux-tdep.c (m32r_linux_sigtramp_start) (m32r_linux_rt_sigtramp_start): Likewise. * m68k-linux-tdep.c (m68k_linux_pc_in_sigtramp): Likewise. * m68k-tdep.c (m68k_register_to_value): Likewise. * mips-tdep.c (mips_register_to_value) (mips_value_to_register): Likewise. * ppc-fbsd-tdep.c (ppcfbsd_sigtramp_frame_sniffer) (ppcfbsd_sigtramp_frame_cache): Likewise. * ppc-obsd-tdep.c (ppcobsd_sigtramp_frame_sniffer) (ppcobsd_sigtramp_frame_cache): Likewise. * rs6000-tdep.c (rs6000_in_function_epilogue_frame_p) (rs6000_register_to_value): Likewise. * tilegx-tdep.c (tilegx_analyze_prologue): Likewise. * tramp-frame.c (tramp_frame_start): Likewise. * valops.c (value_assign): Likewise.
2021-01-16 00:16:04 +08:00
2021-01-19 Luis Machado <luis.machado@linaro.org>
* frame.h (get_frame_register_bytes): Pass a gdb::array_view instead
of buffer + length.
(put_frame_register_bytes): Likewise.
Adjust documentation.
(get_frame_memory): Pass a gdb::array_view instead of buffer + length.
(safe_frame_unwind_memory): Likewise.
* frame.c (get_frame_register_bytes, put_frame_register_bytes)
(get_frame_memory, safe_frame_unwind_memory): Adjust to use
gdb::array_view.
* amd64-fbsd-tdep.c (amd64fbsd_sigtramp_p): Likewise.
* amd64-linux-tdep.c (amd64_linux_sigtramp_start): Likewise.
* amd64-obsd-tdep.c (amd64obsd_sigtramp_p): Likewise.
* arc-linux-tdep.c (arc_linux_is_sigtramp): Likewise.
* cris-tdep.c (cris_sigtramp_start, cris_rt_sigtramp_start): Likewise.
* dwarf2/loc.c (rw_pieced_value): Likewise.
* hppa-tdep.c (hppa_frame_cache): Likewise.
* i386-fbsd-tdep.c (i386fbsd_sigtramp_p): Likewise.
* i386-gnu-tdep.c (i386_gnu_sigtramp_start): Likewise.
* i386-linux-tdep.c (i386_linux_sigtramp_start)
(i386_linux_rt_sigtramp_start): Likewise.
* i386-obsd-tdep.c (i386obsd_sigtramp_p): Likewise.
* i386-tdep.c (i386_register_to_value): Likewise.
* i387-tdep.c (i387_register_to_value): Likewise.
* ia64-tdep.c (ia64_register_to_value): Likewise.
* m32r-linux-tdep.c (m32r_linux_sigtramp_start)
(m32r_linux_rt_sigtramp_start): Likewise.
* m68k-linux-tdep.c (m68k_linux_pc_in_sigtramp): Likewise.
* m68k-tdep.c (m68k_register_to_value): Likewise.
* mips-tdep.c (mips_register_to_value)
(mips_value_to_register): Likewise.
* ppc-fbsd-tdep.c (ppcfbsd_sigtramp_frame_sniffer)
(ppcfbsd_sigtramp_frame_cache): Likewise.
* ppc-obsd-tdep.c (ppcobsd_sigtramp_frame_sniffer)
(ppcobsd_sigtramp_frame_cache): Likewise.
* rs6000-tdep.c (rs6000_in_function_epilogue_frame_p)
(rs6000_register_to_value): Likewise.
* tilegx-tdep.c (tilegx_analyze_prologue): Likewise.
* tramp-frame.c (tramp_frame_start): Likewise.
* valops.c (value_assign): Likewise.
2021-01-19 Luis Machado <luis.machado@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_restore_vreg): Pass in an
array_view.
* trad-frame.c (trad_frame_set_value_bytes): Use gdb::array_view
instead of buffer and size.
(trad_frame_set_reg_value_bytes): Likewise.
* trad-frame.h (trad_frame_set_reg_value_bytes): Likewise.
(trad_frame_set_value_bytes): Likewise.
2021-01-18 Mike Frysinger <vapier@gentoo.org>
* copyright.py (NOT_FSF_LIST): Delete sim/testsuite/sim/bfin/s21.s.
gdb/riscv: use a single regset supply function for riscv fbsd & linux The RISC-V x0 register is hard-coded to zero. As such neither Linux or FreeBSD supply the value of the register x0 in their core dump files. For FreeBSD we take care of this by manually supplying the value of x0 in riscv_fbsd_supply_gregset, however we don't do this for Linux. As a result after loading a core file on Linux we see this behaviour: (gdb) p $x0 $1 = <unavailable> In this commit I make riscv_fbsd_supply_gregset a common function that can be shared between RISC-V for FreeBSD and Linux, this resolves the above issue. There is a similar problem for the two registers `fflags` and `frm`. These two floating point related CSRs are a little weird. They are separate CSRs in the RISC-V specification, but are actually sub-fields of the `fcsr` CSR. As a result neither Linux or FreeBSD supply the `fflags` or `frm` registers as separate fields in their core dumps, and so, after restoring a core dump these register are similarly unavailable. In this commit I supply `fflags` and `frm` by first asking for the value of `fcsr`, extracting the two fields, and using these to supply the values for `fflags` and `frm`. gdb/ChangeLog: * riscv-fbsd-tdep.c (riscv_fbsd_supply_gregset): Delete. (riscv_fbsd_gregset): Use riscv_supply_regset. (riscv_fbsd_fpregset): Likewise. * riscv-linux-tdep.c (riscv_linux_gregset): Likewise. (riscv_linux_fregset): Likewise. * riscv-tdep.c (riscv_supply_regset): Define new function. * riscv-tdep.h (riscv_supply_regset): Declare new function.
2020-12-02 23:10:06 +08:00
2021-01-18 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-fbsd-tdep.c (riscv_fbsd_supply_gregset): Delete.
(riscv_fbsd_gregset): Use riscv_supply_regset.
(riscv_fbsd_fpregset): Likewise.
* riscv-linux-tdep.c (riscv_linux_gregset): Likewise.
(riscv_linux_fregset): Likewise.
* riscv-tdep.c (riscv_supply_regset): Define new function.
* riscv-tdep.h (riscv_supply_regset): Declare new function.
2021-01-18 Tom de Vries <tdevries@suse.de>
PR tdep/27172
* nat/amd64-linux-siginfo.c (cpt_si_lower, cpt_si_upper, SEGV_BNDERR):
New macro.
(compat_siginfo_from_siginfo): Copy cpt_si_lower and cpt_si_upper
for SEGV_BNDERR.
2021-01-18 Simon Marchi <simon.marchi@polymtl.ca>
* remote.c (class remote_target) <remote_hostio_send_command,
remote_hostio_parse_result>: Constify parameter.
(remote_hostio_parse_result): Likewise.
(remote_target::remote_hostio_send_command): Adjust.
(remote_target::remote_hostio_pread_vFile): Adjust.
(remote_target::fileio_readlink): Adjust.
(remote_target::fileio_fstat): Adjust.
2021-01-18 Simon Marchi <simon.marchi@polymtl.ca>
* remote.c (remote_target::start_remote): Move wait_status to
narrower scope.
2021-01-18 Simon Marchi <simon.marchi@polymtl.ca>
* remote.c (class remote_target):
<add_current_inferior_and_thread>: Constify parameter.
(stop_reply_extract_thread): Likewise.
(remote_target::get_current_thread): Likewise.
(remote_target::add_current_inferior_and_thread): Likewise.
2021-01-18 Simon Marchi <simon.marchi@polymtl.ca>
* remote.c (class remote_target)
<remote_unpack_thread_info_response,
parse_threadlist_response>: Constify parameter and/or return
value and or local variable.
(stub_unpack_int): Likewise.
(unpack_nibble): Likewise.
(unpack_byte): Likewise.
(unpack_int): Likewise.
(unpack_string): Likewise.
(unpack_threadid): Likewise.
(remote_target::remote_unpack_thread_info_response): Likewise.
(remote_target::parse_threadlist_response): Likewise.
2021-01-15 Andrew Burgess <andrew.burgess@embecosm.com>
* tui/tui.c (tui_is_window_visible): Compare to nullptr, not 0.
2021-01-14 Lancelot Six <lsix@lancelotsix.com>
* MAINTAINERS (Write After Approval): Add myself.
2021-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de>
* trad-frame.c (trad_frame_alloc_saved_regs): Avoid compile-error
because is_trivially_default_constructible was first implemented with
gcc-5.
[gdb/breakpoint] Handle .plt.sec in in_plt_section Consider the following test-case small.c: ... #include <stdio.h> #include <stdlib.h> #include <string.h> int main (void) { int *p = (int *)malloc (sizeof(int) * 4); memset (p, 0, sizeof(p)); printf ("p[0] = %d; p[3] = %d\n", p[0], p[3]); return 0; } ... On Ubuntu 20.04, we get: ... $ gcc -O0 -g small.c $ gdb -batch a.out -ex start -ex step Temporary breakpoint 1, main () at small.c:6 6 int *p = (int *) malloc(sizeof(int) * 4); p[0] = 0; p[3] = 0 [Inferior 1 (process $dec) exited normally] ... but after switching off the on-by-default fcf-protection, we get the desired behaviour: ... $ gcc -O0 -g small.c -fcf-protection=none $ gdb -batch a.out -ex start -ex step Temporary breakpoint 1, main () at small.c:6 6 int *p = (int *) malloc(sizeof(int) * 4); 7 memset (p, 0, sizeof(p)); ... Using "set debug infrun 1", the first observable difference between the two debug sessions is that with -fcf-protection=none we get: ... [infrun] process_event_stop_test: stepped into dynsym resolve code ... In this case, "in_solib_dynsym_resolve_code (malloc@plt)" returns true because "in_plt_section (malloc@plt)" returns true. With -fcf-protection=full, "in_solib_dynsym_resolve_code (malloc@plt)" returns false because "in_plt_section (malloc@plt)" returns false, because the section name for malloc@plt is .plt.sec instead of .plt, which is not handled in in_plt_section: ... static inline int in_plt_section (CORE_ADDR pc) { return pc_in_section (pc, ".plt"); } ... Fix this by handling .plt.sec in in_plt_section. Tested on x86_64-linux. [ Another requirement to be able to reproduce this is to have a dynamic linker with a "malloc" minimal symbol, which causes find_solib_trampoline_target to find it, such that skip_language_trampoline returns the address for the dynamic linkers malloc. This causes the step machinery to set a breakpoint there, and to continue, expecting to hit it. Obviously, we execute glibc's malloc instead, so the breakpoint is not hit and we continue to program completion. ] gdb/ChangeLog: 2021-01-14 Tom de Vries <tdevries@suse.de> PR breakpoints/27151 * objfiles.h (in_plt_section): Handle .plt.sec.
2021-01-14 17:35:34 +08:00
2021-01-14 Tom de Vries <tdevries@suse.de>
PR breakpoints/27151
* objfiles.h (in_plt_section): Handle .plt.sec.
gdb: better handling of 'S' packets This commit builds on work started in the following two commits: commit 24ed6739b699f329c2c45aedee5f8c7d2f54e493 Date: Thu Jan 30 14:35:40 2020 +0000 gdb/remote: Restore support for 'S' stop reply packet commit cada5fc921e39a1945c422eea055c8b326d8d353 Date: Wed Mar 11 12:30:13 2020 +0000 gdb: Handle W and X remote packets without giving a warning This is related to how GDB handles remote targets that send back 'S' packets. In the first of the above commits we fixed GDB's ability to handle a single process, single threaded target that sends back 'S' packets. Although the 'T' packet would always be preferred to 'S' these days, there's nothing really wrong with 'S' for this situation. The second commit above fixed an oversight in the first commit, a single-process, multi-threaded target can send back a process wide event, for example the process exited event 'W' without including a process-id, this also is fine as there is no ambiguity in this case. In PR gdb/26819 we run into yet another problem with the above commits. In this case we have a single process with two threads, GDB hits a breakpoint in thread 2 and then performs a stepi: (gdb) b main Breakpoint 1 at 0x1212340830: file infinite_loop.S, line 10. (gdb) c Continuing. Thread 2 hit Breakpoint 1, main () at infinite_loop.S:10 10 in infinite_loop.S (gdb) set debug remote 1 (gdb) stepi Sending packet: $vCont;s:2#24...Packet received: S05 ../binutils-gdb/gdb/infrun.c:5807: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed. What happens in this case is that on the RISC-V target displaced stepping is not supported, so when the stepi is issued GDB steps just thread 2. As only a single thread was set running the target decides that is can get away with sending back an 'S' packet without a thread-id. GDB then associates the stop with thread 1 (the first non-exited thread), but as thread 1 was not previously set executing the assertion seen above triggers. As an aside I am surprised that the target sends pack 'S' in this situation. The target is happy to send back 'T' (including thread-id) when multiple threads are set running, so (to me) it would seem easier to just always use the 'T' packet when multiple threads are in use. However, the target only uses 'T' when multiple threads are actually executing, otherwise an 'S' packet it used. Still, when looking at the above situation we can see that GDB should be able to understand which thread the 'S' reply is referring too. The problem is that is that in commit 24ed6739b699 (above) when a stop reply comes in with no thread-id we look for the first non-exited thread and select that as the thread the stop applies too. What we should really do is select the first non-exited, resumed thread, and associate the stop event with this thread. In the above example both thread 1 and 2 are non-exited, but only thread 2 is resumed, so this is what we should use. There's a test for this issue included which works with stock gdbserver by disabling use of the 'T' packet, and enabling 'scheduler-locking' within GDB so only one thread is set running. gdb/ChangeLog: PR gdb/26819 * remote.c (remote_target::select_thread_for_ambiguous_stop_reply): New member function. (remote_target::process_stop_reply): Call select_thread_for_ambiguous_stop_reply. gdb/testsuite/ChangeLog: PR gdb/26819 * gdb.server/stop-reply-no-thread-multi.c: New file. * gdb.server/stop-reply-no-thread-multi.exp: New file. Change-Id: I9b49d76c2a99063dcc76203fa0f5270a72825d15
2021-01-14 09:26:58 +08:00
2021-01-13 Andrew Burgess <andrew.burgess@embecosm.com>
PR gdb/26819
* remote.c
(remote_target::select_thread_for_ambiguous_stop_reply): New
member function.
(remote_target::process_stop_reply): Call
select_thread_for_ambiguous_stop_reply.
2021-01-13 Simon Marchi <simon.marchi@efficios.com>
* record-btrace.c (class record_btrace_target): Remove.
(record_btrace_target::commit_resume): Remove.
* record-full.c (class record_full_target): Remove.
(record_full_target::commit_resume): Remove.
gdb: make the remote target track its own thread resume state The next patch moves the target commit_resume method to be a process_stratum_target-only method. The only non-process targets that currently implement the commit_resume method are the btrace and full record targets. The only reason they need to do so is to prevent a commit resume from reaching the beneath (process) target if they are currently replaying. This is important if a record target is used on top of the remote target (the only process target implementing the commit_resume method). Currently, the remote target checks the `thread_info::executing` flag of a thread to know if it should commit resume that thread: if (!tp->executing || remote_thr->vcont_resumed) continue; The `tp->executing` flag is set by infrun when it has asked the target stack to resume the thread, and therefore if the thread is executing, from its point of view. It _not_ equivalent to whether the remote target was asked to resume this thread. Indeed, if infrun asks the target stack to resume some thread while the record target is replaying, the record target won't forward the resume request the remote target beneath, because we don't actually want to resume the thread on the execution target. But the `tp->executing` flag is still set, because from the point of view of infrun, the thread executes. So, if the commit_resume call wasn't intercepted by the record target as it is today and did reach the remote target, the remote target would say "Oh, this thread should be executing and I haven't vCont-resumed it! I must vCont-resume it!". But that would be wrong, because it was never asked to resume this thread, the resume request did not reach it. This is why the record targets currently need to implement commit_resume: to prevent the beneath target from commit_resuming threads it wasn't asked to resume. Since commit_resume will become a method on process_stratum_target in the following patch, record targets won't have a chance to intercept the calls and that would result in the remote target commit_resuming threads it shouldn't. To avoid this, this patch makes the remote target track its own thread resumption state. That means, tracking which threads it was asked to resume via target_ops::resume. Regardless of the context of this patch, I think this change makes it easier to understand how resume / commit_resume works in the remote target. It makes the target more self-contained, as it only depends on what it gets asked to do via the target methods, and not on tp->executing, which is a flag maintained from the point of view of infrun. I initially made it so this state was only used when the remote target operates in non-stop mode, since commit_resume is only used when the target is non-stop. However, it's more consistent and it can be useful to maintain this state even in all-stop too. In all-stop, receiving a stop notification for one thread means all threads of the target are considered stopped. From the point of view of the remote target, there are three states a thread can be in: 1. not resumed 2. resumed but pending vCont-resume 3. resumed State 2 only exists when the target is non-stop. As of this patch, valid state transitions are: - 1 -> 2 (through the target resume method if in non-stop) - 2 -> 3 (through the target commit_resume method if in non-stop) - 1 -> 3 (through the target resume method if in all-stop) - 3 -> 1 (through a remote stop notification / reporting an event to the event loop) A subsequent patch will make it possible to go from 2 to 1, in case infrun asks to stop a thread that was resumed but not commit-resumed yet. I don't think it can happen as of now. In terms of code, this patch replaces the vcont_resumed field with an enumeration that explicitly represents the three states described above. The last_resume_sig and last_resume_step fields are moved to a structure which is clearly identified as only used when the thread is in the "resumed but pending vCont-resume" state. gdb/ChangeLog: * remote.c (enum class resume_state): New. (struct resumed_pending_vcont_info): New. (struct remote_thread_info) <resume_state, set_not_resumed, set_resumed_pending_vcont, resumed_pending_vcont_info, set_resumed, m_resume_state, m_resumed_pending_vcont_info>: New. <last_resume_step, last_resume_sig, vcont_resumed>: Remove. (remote_target::remote_add_thread): Adjust. (remote_target::process_initial_stop_replies): Adjust. (remote_target::resume): Adjust. (remote_target::commit_resume): Rely on state in remote_thread_info and not on tp->executing. (remote_target::process_stop_reply): Adjust. Change-Id: I10480919ccb4552faa62575e447a36dbe7c2d523
2021-01-14 09:20:43 +08:00
2021-01-13 Simon Marchi <simon.marchi@efficios.com>
* remote.c (enum class resume_state): New.
(struct resumed_pending_vcont_info): New.
(struct remote_thread_info) <resume_state, set_not_resumed,
set_resumed_pending_vcont, resumed_pending_vcont_info,
set_resumed, m_resume_state, m_resumed_pending_vcont_info>:
New.
<last_resume_step, last_resume_sig, vcont_resumed>: Remove.
(remote_target::remote_add_thread): Adjust.
(remote_target::process_initial_stop_replies): Adjust.
(remote_target::resume): Adjust.
(remote_target::commit_resume): Rely on state in
remote_thread_info and not on tp->executing.
(remote_target::process_stop_reply): Adjust.
2021-01-13 Simon Marchi <simon.marchi@polymtl.ca>
* arc-tdep.h (arc_debug_printf): New.
* arc-tdep.c: Use arc_debug_printf.
* arc-linux-nat.c (arc_linux_nat_debug_printf): Add and use.
* arc-linux-tdep.c (arc_linux_debug_printf): Add and use.
* arc-newlib-tdep.c (arc_newlib_debug_printf): Add and use.
2021-01-13 Simon Marchi <simon.marchi@polymtl.ca>
* arc-tdep.h (arc_debug): Change type to bool.
* arc-tdep.c (arc_debug): Change type to bool.
(arc_analyze_prologue): Adjust.
(_initialize_arc_tdep): Use add_setshow_boolean_cmd.
* arc-linux-nat.c (ps_get_thread_area): Adjust.
2021-01-13 Simon Marchi <simon.marchi@polymtl.ca>
* auto-load.c (auto_load_objfile_script_1): Use bool.
(execute_script_contents): Use bool.
2021-01-13 Simon Marchi <simon.marchi@polymtl.ca>
* auto-load.h (auto_load_gdb_scripts_enabled): Return bool, move
comment here.
* auto-load.c (auto_load_gdb_scripts_enabled): Return bool, move
comment to header.
* extension-priv.h (struct extension_language_script_ops)
<auto_load_enabled>: Return bool.
* extension.h (ext_lang_auto_load_enabled): Return bool, move
comment here.
* extension.c (ext_lang_auto_load_enabled): Return bool, move
comment to header.
* guile/guile-header.h (gdbscm_auto_load_enabled): Return bool,
move comment here.
* guile/scm-auto-load.c (gdbscm_auto_load_enabled): Return bool,
move comment to header.
* python/python-header.h (gdbpy_auto_load_enabled): Return bool,
move comment here.
* python/py-auto-load.c (gdbpy_auto_load_enabled): Return bool,
move comment to header.
2021-01-13 Simon Marchi <simon.marchi@polymtl.ca>
* auto-load.h (file_is_auto_load_safe): Change return type to
bool, move comment here.
* auto-load.c (file_is_auto_load_safe): Change return type and
advice_printed to bool. Move comment to header.
2021-01-13 Simon Marchi <simon.marchi@polymtl.ca>
* jit.c (jit_debug_printf): New, use throughout file.
2021-01-12 Simon Marchi <simon.marchi@polymtl.ca>
* infrun.c (normal_stop): Fix indentation.
2021-01-12 Simon Marchi <simon.marchi@polymtl.ca>
* top.h (readnow_symbol_files, readnever_symbol_files): Move
declarations to ...
* symfile.h: ... here.
* symfile.c: Update doc.
2021-01-12 Simon Marchi <simon.marchi@polymtl.ca>
* target.h (baud_rate, serial_parity): Move declarations...
* serial.h: ... here.
* main.c: Include serial.h.
* serial.c (baud_rate, serial_parity): Update doc.
2021-01-12 Simon Marchi <simon.marchi@polymtl.ca>
* top.c (pre_init_ui_hook): Remove.
aarch64: Add support for bfloat16 in gdb. This patch adds support for bfloat16 in AArch64 gdb. Also adds the field "bf" to vector registers h0-h31. Also adds the vector "bf" to h field in vector registers v0-v31. The following is how the vector register h and v looks like. Before this patch: (gdb) p $h0 $1 = {f = 0, u = 0, s = 0} (gdb) p/x $h0 $2 = {f = 0x0, u = 0x0, s = 0x0} (gdb) p $v0.h $3 = {f = {0, 0, 0, 0, 0, 0, 0, 0}, u = {0, 0, 0, 0, 0, 0, 0, 0}, s = {0, 0, 0, 0, 0, 0, 0, 0}} (gdb) p/x $v0.h $4 = {f = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, s = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}} After this patch: (gdb) p $h0 $1 = {bf = 0, f = 0, u = 0, s = 0} (gdb) p/x $h0 $2 = {bf = 0x0, f = 0x0, u = 0x0, s = 0x0} (gdb) p $v0.h $3 = {bf = {0, 0, 0, 0, 0, 0, 0, 0}, f = {0, 0, 0, 0, 0, 0, 0, 0}, u = {0, 0, 0, 0, 0, 0, 0, 0}, s = {0, 0, 0, 0, 0, 0, 0, 0}} (gdb) p/x $v0.h $4 = {bf = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, f = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, u = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, s = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}} gdb/ChangeLog: 2021-01-12 Srinath Parvathaneni <srinath.parvathaneni@arm.com> * aarch64-tdep.c (aarch64_vnh_type): Add "bf" field in h registers. (aarch64_vnv_type): Add "bf" type in h field of v registers. * features/aarch64-fpu.c (create_feature_aarch64_fpu): Regenerated. * features/aarch64-fpu.xml: Add bfloat16 type. gdb/testsuite/ChangeLog: 2021-01-12 Srinath Parvathaneni <srinath.parvathaneni@arm.com> * gdb.arch/aarch64-fp.exp: Modify to test bfloat16 support.
2021-01-12 21:57:23 +08:00
2021-01-12 Srinath Parvathaneni <srinath.parvathaneni@arm.com>
* aarch64-tdep.c (aarch64_vnh_type): Add "bf" field in h registers.
(aarch64_vnv_type): Add "bf" type in h field of v registers.
* features/aarch64-fpu.c (create_feature_aarch64_fpu): Regenerated.
* features/aarch64-fpu.xml: Add bfloat16 type.
2021-01-12 Andrew Burgess <andrew.burgess@embecosm.com>
* expprint.c (dump_subexp_body_standard): Handle OP_BOOL.
2021-01-12 Andrew Burgess <andrew.burgess@embecosm.com>
* f-exp.y (dot_ops): Rename to...
(fortran_operators): ...this. Add a header comment. Add symbol
based operators.
(yylex): Update to use fortran_operators not dot_ops. Remove
special handling for '**', this is now included in
fortran_operators.
2021-01-11 Simon Marchi <simon.marchi@polymtl.ca>
* arch/aarch64-insn.h (aarch64_debug_printf): New.
* arch/aarch64-insn.c: Use aarch64_debug_printf.
* aarch64-tdep.c: Use aarch64_debug_printf.
2021-01-11 Simon Marchi <simon.marchi@polymtl.ca>
* solib-aix.c (solib_aix_debug_printf): New, use throughout
file.
2021-01-11 Simon Marchi <simon.marchi@polymtl.ca>
* jit.c (jit_debug): Change type to bool.
(_initialize_jit): Adjust.
2021-01-09 Tom Tromey <tom@tromey.com>
PR compile/23672
* compile/compile.c (compile_to_object): Avoid crash when
osabi_triplet_regexp returns NULL.
2021-01-09 Tom Tromey <tom@tromey.com>
* tracepoint.h (class collection_list) <append_exp>: Take a
std::string.
* tracepoint.c (collection_list::append_exp): Take a std::string.
(encode_actions_1): Update.
2021-01-08 Tom Tromey <tromey@adacore.com>
* parse.c (parse_expression): Add void_context_p parameter. Use
parse_exp_in_context.
* printcmd.c (print_command_1): Change voidprint to bool. Pass to
parse_expression.
(print_command, call_command): Update.
* expression.h (parse_expression): Add void_context_p parameter.
gdb: user variables with components of dynamic type Consider this Fortran type: type :: some_type integer, allocatable :: array_one (:,:) integer :: a_field integer, allocatable :: array_two (:,:) end type some_type And a variable declared: type(some_type) :: some_var Now within GDB we try this: (gdb) set $a = some_var (gdb) p $a $1 = ( array_one = ../../src/gdb/value.c:3968: internal-error: Unexpected lazy value type. Normally, when an internalvar ($a in this case) is created, it is non-lazy, the value is immediately copied out of the inferior into GDB's memory. When printing the internalvar ($a) GDB will extract each field in turn, so in this case `array_one`. As the original internalvar is non-lazy then the extracted field will also be non-lazy, with its contents immediately copied from the parent internalvar. However, when the field has a dynamic type this is not the case, in value_primitive_field we see that any field with dynamic type is always created lazy. Further, the content of this field will usually not have been captured in the contents buffer of the original value, a field with dynamic location is effectively a pointer value contained within the parent value, with rules in the DWARF for how to dereference the pointer. So, we end up with a lazy lval_internalvar_component representing a field within an lval_internalvar. This eventually ends up in value_fetch_lazy, which currently does not support lval_internalvar_component, and we see the error above. My original plan for how to handle this involved extending value_fetch_lazy to handle lval_internalvar_component. However, when I did this I ran into another error: (gdb) set $a = some_var (gdb) p $a $1 = ( array_one = ((1, 1) (1, 1) (1, 1)), a_field = 5, array_two = ((0, 0, 0) (0, 0, 0)) ) (gdb) p $a%array_one $2 = ((1, 1) (1, 1) (1, 1)) (gdb) p $a%array_one(1,1) ../../src/gdb/value.c:1547: internal-error: void set_value_address(value*, CORE_ADDR): Assertion `value->lval == lval_memory' failed. The problem now is inside set_value_component_location, where we attempt to set the address for a component if the original parent value has a dynamic location. GDB does not expect to ever set the address on anything other than an lval_memory value (which seems reasonable). In order to resolve this issue I initially thought about how an internalvar should "capture" the value of a program variable at the moment the var is created. In an ideal world (I think) GDB would be able to do this even for values with dynamic type. So in our above example doing `set $a = some_var` would capture the content of 'some_var', but also the content of 'array_one', and also 'array_two', even though these content regions are not contained within the region of 'some_var'. Supporting this would require GDB values to be able to carry around multiple non-contiguous regions of memory as content in some way, which sounds like a pretty huge change to a core part of GDB. So, I wondered if there was some other solution that wouldn't require such a huge change. What if values with a dynamic location were though of like points with automatic dereferencing? Given this C structure: struct foo_t { int *val; } struct foo_t my_foo; Then in GDB: (gdb) $a = my_foo We would expect GDB to capture the pointer value in '$a', but not the value pointed at by the pointer. So maybe it's not that unreasonable to think that given a dynamically typed field GDB will capture the address of the content, but not the actual content itself. That's what this patch does. The approach is to catch this case in set_value_component_location. When we create a component location (of an lval_internalvar) that has a dynamic data location, the lval_internalvar_component is changed into an lval_memory. After this, both of the above issues are resolved. In the first case, the lval_memory is still lazy, but value_fetch_lazy knows how to handle that. In the second case, when we access an element of the array we are now accessing an element of an lval_memory, not an lval_internalvar_component, and calling set_value_address on an lval_memory is fine. gdb/ChangeLog: * value.c (set_value_component_location): Adjust the VALUE_LVAL for internalvar components that have a dynamic location. gdb/testsuite/ChangeLog: * gdb.fortran/intvar-dynamic-types.exp: New file. * gdb.fortran/intvar-dynamic-types.f90: New file.
2020-10-22 18:34:52 +08:00
2021-01-08 Andrew Burgess <andrew.burgess@embecosm.com>
* value.c (set_value_component_location): Adjust the VALUE_LVAL
for internalvar components that have a dynamic location.
[gdb] Fix internal-error in process_event_stop_test The function create_exception_master_breakpoint in gdb/breakpoint.c attempts to set a master exception breakpoint in each objfile. It tries this using a libgcc/unwind probe, and if that fails then using the _Unwind_DebugHook symbol: ... for (objfile *objfile : current_program_space->objfiles ()) { /* Try using probes. */ if (/* successful */) continue; /* Try using _Unwind_DebugHook */ } ... The preference scheme works ok both if the objfile has debug info, and if it's stripped. But it doesn't work when the objfile has a .gnu_debuglink to a .debug file (and the .debug file is present). What happens is that: - we first encounter objfile libgcc.debug - we try using probes, and this fails - so we try _Unwind_DebugHook, which succeeds - next we encounter objfile libgcc - we try using probes, and this succeeds. So, we end up with a master exception breakpoint in both libgcc (using probes) and libgcc.debug (using _Unwind_DebugHook). This eventually causes: ... (gdb) PASS: gdb.cp/nextoverthrow.exp: post-check - next over a throw 3 next^M src/gdb/infrun.c:6384: internal-error: \ void process_event_stop_test(execution_control_state*): \ Assertion `ecs->event_thread->control.exception_resume_breakpoint != NULL' \ failed.^M A problem internal to GDB has been detected,^M further debugging may prove unreliable.^M Quit this debugging session? (y or n) FAIL: gdb.cp/nextoverthrow.exp: next past catch (GDB internal error) ... To trigger this internal-error, we need to use gcc-10 or later to compile the test-case, such that it contains the fix for gcc PR97774 - "Incorrect line info for try/catch". Fix this by only trying to install the master exception breakpoint in libgcc.debug using the _Unwind_DebugHook method, if the install using probes in libgcc failed. Tested on x86_64-linux. gdb/ChangeLog: 2021-01-08 Tom de Vries <tdevries@suse.de> PR gdb/26881 * breakpoint.c (create_exception_master_breakpoint_probe) (create_exception_master_breakpoint_hook): Factor out of ... (create_exception_master_breakpoint): ... here. Only try to install the master exception breakpoint in objfile.debug using the _Unwind_DebugHook method, if the install using probes in objfile failed.
2021-01-08 18:11:16 +08:00
2021-01-08 Tom de Vries <tdevries@suse.de>
PR gdb/26881
* breakpoint.c (create_exception_master_breakpoint_probe)
(create_exception_master_breakpoint_hook): Factor out
of ...
(create_exception_master_breakpoint): ... here. Only try to install
the master exception breakpoint in objfile.debug using the
_Unwind_DebugHook method, if the install using probes in objfile
failed.
2021-01-08 Andrew Burgess <andrew.burgess@embecosm.com>
* f-lang.c (fortran_value_subarray): Call value_from_component.
2021-01-07 Mike Frysinger <vapier@gentoo.org>
* remote-sim.c: Include memory-map.h.
(gdbsim_target): Define memory_map override.
(gdbsim_target::memory_map): Define.
2021-01-07 Tom Tromey <tromey@adacore.com>
* ada-lang.c (do_full_match): Conditionally skip "_ada_" prefix.
2021-01-07 Tom Tromey <tromey@adacore.com>
* ada-lang.c (add_component_interval): Start loop using vector's
updated size.
2021-01-06 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_evaluate_subexp) <BINOP_ADD, BINOP_SUB>:
Do not cast result.
* valarith.c (fixed_point_binop): Handle multiplication
and division specially.
* valops.c (value_to_gdb_mpq): New function.
(value_cast_to_fixed_point): Use it.
2021-01-05 Hannes Domani <ssbssa@yahoo.de>
* tui/tui-winsource.c (tui_source_window_base::refresh_window):
Call wnoutrefresh instead of tui_win_info::refresh_window.
2021-01-05 Hannes Domani <ssbssa@yahoo.de>
* tui/tui-source.c (tui_source_window::show_line_number):
Redraw second space after line number.
2021-01-05 Hannes Domani <ssbssa@yahoo.de>
PR tui/26927
* tui/tui-winsource.c (tui_source_window_base::refresh_window):
Fix source pad size in prefresh.
(tui_source_window_base::show_source_content): Grow source pad
if necessary.
2015-06-19 16:24:13 +08:00
2021-01-04 Mike Frysinger <vapier@gentoo.org>
* bfin-tdep.c (bfin_push_dummy_call): Use align_up.
(bfin_frame_align): Use align_down.
2021-01-04 Tom de Vries <tdevries@suse.de>
* buildsym.c (buildsym_compunit::record_line): Filter out end-of-seq
terminators that do not terminate anything.
gdb: introduce scoped debug prints I spent a lot of time reading infrun debug logs recently, and I think they could be made much more readable by being indented, to clearly see what operation is done as part of what other operation. In the current format, there are no visual cues to tell where things start and end, it's just a big flat list. It's also difficult to understand what caused a given operation (e.g. a call to resume_1) to be done. To help with this, I propose to add the new scoped_debug_start_end structure, along with a bunch of macros to make it convenient to use. The idea of scoped_debug_start_end is simply to print a start and end message at construction and destruction. It also increments/decrements a depth counter in order to make debug statements printed during this range use some indentation. Some care is taken to handle the fact that debug can be turned on or off in the middle of such a range. For example, a "set debug foo 1" command in a breakpoint command, or a superior GDB manually changing the debug_foo variable. Two macros are added in gdbsupport/common-debug.h, which are helpers to define module-specific macros: - scoped_debug_start_end: takes a message that is printed both at construction / destruction, with "start: " and "end: " prefixes. - scoped_debug_enter_exit: prints hard-coded "enter" and "exit" messages, to denote the entry and exit of a function. I added some examples in the infrun module to give an idea of how it can be used and what the result looks like. The macros are in capital letters (INFRUN_SCOPED_DEBUG_START_END and INFRUN_SCOPED_DEBUG_ENTER_EXIT) to mimic the existing SCOPE_EXIT, but that can be changed if you prefer something else. Here's an excerpt of the debug statements printed when doing "continue", where a displaced step is started: [infrun] proceed: enter [infrun] proceed: addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT [infrun] global_thread_step_over_chain_enqueue: enqueueing thread Thread 0x7ffff75a5640 (LWP 2289301) in global step over chain [infrun] start_step_over: enter [infrun] start_step_over: stealing global queue of threads to step, length = 1 [infrun] start_step_over: resuming [Thread 0x7ffff75a5640 (LWP 2289301)] for step-over [infrun] resume_1: step=1, signal=GDB_SIGNAL_0, trap_expected=1, current thread [Thread 0x7ffff75a5640 (LWP 2289301)] at 0x5555555551bd [displaced] displaced_step_prepare_throw: displaced-stepping Thread 0x7ffff75a5640 (LWP 2289301) now [displaced] prepare: selected buffer at 0x5555555550c2 [displaced] prepare: saved 0x5555555550c2: 1e fa 31 ed 49 89 d1 5e 48 89 e2 48 83 e4 f0 50 [displaced] amd64_displaced_step_copy_insn: copy 0x5555555551bd->0x5555555550c2: c7 45 fc 00 00 00 00 eb 13 8b 05 d4 2e 00 00 83 [displaced] displaced_step_prepare_throw: prepared successfully thread=Thread 0x7ffff75a5640 (LWP 2289301), original_pc=0x5555555551bd, displaced_pc=0x5555555550c2 [displaced] resume_1: run 0x5555555550c2: c7 45 fc 00 [infrun] infrun_async: enable=1 [infrun] prepare_to_wait: prepare_to_wait [infrun] start_step_over: [Thread 0x7ffff75a5640 (LWP 2289301)] was resumed. [infrun] operator(): step-over queue now empty [infrun] start_step_over: exit [infrun] proceed: start: resuming threads, all-stop-on-top-of-non-stop [infrun] proceed: resuming Thread 0x7ffff7da7740 (LWP 2289296) [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [Thread 0x7ffff7da7740 (LWP 2289296)] at 0x7ffff7f7d9b7 [infrun] prepare_to_wait: prepare_to_wait [infrun] proceed: resuming Thread 0x7ffff7da6640 (LWP 2289300) [infrun] resume_1: thread Thread 0x7ffff7da6640 (LWP 2289300) has pending wait status status->kind = stopped, signal = GDB_SIGNAL_TRAP (currently_stepping=0). [infrun] prepare_to_wait: prepare_to_wait [infrun] proceed: [Thread 0x7ffff75a5640 (LWP 2289301)] resumed [infrun] proceed: resuming Thread 0x7ffff6da4640 (LWP 2289302) [infrun] resume_1: thread Thread 0x7ffff6da4640 (LWP 2289302) has pending wait status status->kind = stopped, signal = GDB_SIGNAL_TRAP (currently_stepping=0). [infrun] prepare_to_wait: prepare_to_wait [infrun] proceed: end: resuming threads, all-stop-on-top-of-non-stop [infrun] proceed: exit We can easily see where the call to `proceed` starts and end. We can also see why there are a bunch of resume_1 calls, it's because we are resuming threads, emulating all-stop on top of a non-stop target. We also see that debug statements nest well with other modules that have been migrated to use the "new" debug statement helpers (because they all use debug_prefixed_vprintf in the end. I think this is desirable, for example we could see the debug statements about reading the DWARF info of a library nested under the debug statements about loading that library. Of course, modules that haven't been migrated to use the "new" helpers will still print without indentations. This will be one good reason to migrate them. I think the runtime cost (when debug statements are disabled) of this is reasonable, given the improvement in readability. There is the cost of the conditionals (like standard debug statements), one more condition (if (m_must_decrement_print_depth)) and the cost of constructing a stack object, which means copying a fews pointers. Adding the print in fetch_inferior_event breaks some tests that use "set debug infrun", because it prints a debug statement after the prompt. I adapted these tests to cope with it, by using the "-prompt" switch of gdb_test_multiple to as if this debug statement is part of the expected prompt. It's unfortunate that we have to do this, but I think the debug print is useful, and I don't want a few tests to get in the way of adding good debug output. gdbsupport/ChangeLog: * common-debug.h (debug_print_depth): New. (struct scoped_debug_start_end): New. (scoped_debug_start_end): New. (scoped_debug_enter_exit): New. * common-debug.cc (debug_prefixed_vprintf): Print indentation. gdb/ChangeLog: * debug.c (debug_print_depth): New. * infrun.h (INFRUN_SCOPED_DEBUG_START_END): New. (INFRUN_SCOPED_DEBUG_ENTER_EXIT): New. * infrun.c (start_step_over): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT. (proceed): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT and INFRUN_SCOPED_DEBUG_START_END. (fetch_inferior_event): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT. gdbserver/ChangeLog: * debug.cc (debug_print_depth): New. gdb/testsuite/ChangeLog: * gdb.base/ui-redirect.exp: Expect infrun debug print after prompt. * gdb.threads/ia64-sigill.exp: Likewise. * gdb.threads/watchthreads-reorder.exp: Likewise. Change-Id: I7c3805e6487807aa63a1bae318876a0c69dce949
2021-01-05 00:56:10 +08:00
2021-01-04 Simon Marchi <simon.marchi@efficios.com>
* debug.c (debug_print_depth): New.
* infrun.h (INFRUN_SCOPED_DEBUG_START_END): New.
(INFRUN_SCOPED_DEBUG_ENTER_EXIT): New.
* infrun.c (start_step_over): Use
INFRUN_SCOPED_DEBUG_ENTER_EXIT.
(proceed): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT and
INFRUN_SCOPED_DEBUG_START_END.
(fetch_inferior_event): Use INFRUN_SCOPED_DEBUG_ENTER_EXIT.
2021-01-04 Simon Marchi <simon.marchi@efficios.com>
* infrun.c (print_target_wait_results): Use infrun_debug_printf.
gdb: make "set debug timestamp" work nice with new debug printouts New in v2: - implement by modifying vprintf_unfiltered rather than debug_prefixed_vprintf. I tried enabling debug timestamps, and realized that it doesn't play well with the revamp of the debug printouts I've been working on: $ ./gdb -q -nx --data-directory=data-directory -ex "set debug infrun" -ex "set debug timestamp" a.out Reading symbols from a.out... (gdb) start Temporary breakpoint 1 at 0x1131: file test.c, line 2. Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out 939897.769338 [infrun] infrun_async: 939897.769383 enable=1 939897.769409 939897.915218 [infrun] proceed: 939897.915281 addr=0x7ffff7fd0100, signal=GDB_SIGNAL_0 939897.915315 939897.915417 [infrun] start_step_over: 939897.915464 stealing global queue of threads to step, length = 0 939897.915502 939897.915567 [infrun] operator(): 939897.915601 step-over queue now empty 939897.915633 939897.915690 [infrun] proceed: 939897.915729 resuming process 636244 939897.915768 939897.915892 [infrun] resume_1: 939897.915954 step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [process 636244] at 0x7ffff7fd0100 939897.915991 939897.916119 [infrun] prepare_to_wait: 939897.916153 prepare_to_wait 939897.916201 939897.916661 [infrun] target_wait (-1.0.0, status) = [infrun] 636244.636244.0 [process 636244], [infrun] status->kind = stopped, signal = GDB_SIGNAL_TRAP 939897.916734 [infrun] handle_inferior_event: 939897.916768 status->kind = stopped, signal = GDB_SIGNAL_TRAP 939897.916799 This is due to debug_prefixed_vprintf being implemented as three separate calls to debug_printf / debug_vprintf. Each call gets its own timestamp and newline, curtesy of vprintf_unfiltered. My first idea was to add a "line_start" parameter to debug_vprintf, allowing the caller to say whether the print is the start of the line. A debug timestamp would only be printed if line_start was true. However, that was much more invasive than the simple fix implemented in this patch. My second idea was to make debug_prefixed_vprintf use string_printf and issue a single call to debug_printf. That would however prevent future use of styling in the debug messages. What is implemented in this patch is the same as is implemented in GDBserver: the timestamp-printing code in GDB tracks whether the last debug output ended with a newline. If so, it prints a timestamp on the next debug output. After the fix, it looks like this: $ ./gdb -q -nx --data-directory=data-directory -ex "set debug infrun" -ex "set debug timestamp" a.out Reading symbols from a.out... (gdb) start Temporary breakpoint 1 at 0x1131: file test.c, line 2. Starting program: /home/smarchi/build/binutils-gdb-all-targets/gdb/a.out 941112.135662 [infrun] infrun_async: enable=1 941112.279930 [infrun] proceed: addr=0x7ffff7fd0100, signal=GDB_SIGNAL_0 941112.280064 [infrun] start_step_over: stealing global queue of threads to step, length = 0 941112.280125 [infrun] operator(): step-over queue now empty 941112.280194 [infrun] proceed: resuming process 646228 941112.280332 [infrun] resume_1: step=0, signal=GDB_SIGNAL_0, trap_expected=0, current thread [process 646228] at 0x7ffff7fd0100 941112.280480 [infrun] prepare_to_wait: prepare_to_wait 941112.281004 [infrun] target_wait (-1.0.0, status) = [infrun] 646228.646228.0 [process 646228], [infrun] status->kind = stopped, signal = GDB_SIGNAL_TRAP 941112.281078 [infrun] handle_inferior_event: status->kind = stopped, signal = GDB_SIGNAL_TRAP gdb/ChangeLog: * utils.c (vfprintf_unfiltered): Print timestamp only when previous debug output ended with a newline. Change-Id: Idcfe3acc7e3d0f526a5f0a43a5e0884bf93c41ae
2021-01-05 00:56:10 +08:00
2021-01-04 Simon Marchi <simon.marchi@efficios.com>
* utils.c (vfprintf_unfiltered): Print timestamp only when
previous debug output ended with a newline.
Refactor struct trad_frame_saved_regs The following patch drops the overloading going on with the trad_frame_saved_reg struct and defines a new struct with a KIND enum and a union of different fields. The new struct looks like this: struct trad_frame_saved_reg { setters/getters ... private: trad_frame_saved_reg_kind m_kind; union { LONGEST value; int realreg; LONGEST addr; const gdb_byte *value_bytes; } m_reg; }; And the enums look like this: /* Describes the kind of encoding a stored register has. */ enum class trad_frame_saved_reg_kind { /* Register value is unknown. */ UNKNOWN = 0, /* Register value is a constant. */ VALUE, /* Register value is in another register. */ REALREG, /* Register value is at an address. */ ADDR, /* Register value is a sequence of bytes. */ VALUE_BYTES }; The patch also adds setters/getters and updates all the users of the old struct. It is worth mentioning that due to the previous overloaded nature of the fields, some tdep files like to store negative offsets and indexes in the ADDR field, so I kept the ADDR as LONGEST instead of CORE_ADDR. Those cases may be better supported by a new enum entry. I have not addressed those cases in this patch to prevent unwanted breakage, given I have no way to test some of the targets. But it would be nice to clean those up eventually. The change to frame-unwind.* is to constify the parameter being passed to the unwinding functions, given we now accept a "const gdb_byte *" for value bytes. Tested on aarch64-linux/Ubuntu 20.04/18.04 and by building GDB with --enable-targets=all. gdb/ChangeLog: 2021-01-04 Luis Machado <luis.machado@linaro.org> Update all users of trad_frame_saved_reg to use the new member functions. Remote all struct keywords from declarations of trad_frame_saved_reg types, except on forward declarations. * aarch64-tdep.c: Update. * alpha-mdebug-tdep.c: Update. * alpha-tdep.c: Update. * arc-tdep.c: Update. * arm-tdep.c: Update. * avr-tdep.c: Update. * cris-tdep.c: Update. * csky-tdep.c: Update. * frv-tdep.c: Update. * hppa-linux-tdep.c: Update. * hppa-tdep.c: Update. * hppa-tdep.h: Update. * lm32-tdep.c: Update. * m32r-linux-tdep.c: Update. * m32r-tdep.c: Update. * m68hc11-tdep.c: Update. * mips-tdep.c: Update. * moxie-tdep.c: Update. * riscv-tdep.c: Update. * rs6000-tdep.c: Update. * s390-linux-tdep.c: Update. * s390-tdep.c: Update. * score-tdep.c: Update. * sparc-netbsd-tdep.c: Update. * sparc-sol2-tdep.c: Update. * sparc64-fbsd-tdep.c: Update. * sparc64-netbsd-tdep.c: Update. * sparc64-obsd-tdep.c: Update. * sparc64-sol2-tdep.c: Update. * tilegx-tdep.c: Update. * v850-tdep.c: Update. * vax-tdep.c: Update. * frame-unwind.c (frame_unwind_got_bytes): Make parameter const. * frame-unwind.h (frame_unwind_got_bytes): Likewise. * trad-frame.c: Update. Remove TF_REG_* enum. (trad_frame_alloc_saved_regs): Add a static assertion to check for a trivially-constructible struct. (trad_frame_reset_saved_regs): Adjust to use member function. (trad_frame_value_p): Likewise. (trad_frame_addr_p): Likewise. (trad_frame_realreg_p): Likewise. (trad_frame_value_bytes_p): Likewise. (trad_frame_set_value): Likewise. (trad_frame_set_realreg): Likewise. (trad_frame_set_addr): Likewise. (trad_frame_set_unknown): Likewise. (trad_frame_set_value_bytes): Likewise. (trad_frame_get_prev_register): Likewise. * trad-frame.h: Update. (trad_frame_saved_reg_kind): New enum. (struct trad_frame_saved_reg) <addr, realreg, data>: Remove. <m_kind, m_reg>: New member fields. <set_value, set_realreg, set_addr, set_unknown, set_value_bytes> <kind, value, realreg, addr, value_bytes, is_value, is_realreg> <is_addr, is_unknown, is_value_bytes>: New member functions.
2020-12-23 04:45:21 +08:00
2021-01-04 Luis Machado <luis.machado@linaro.org>
Update all users of trad_frame_saved_reg to use the new member
functions.
Remote all struct keywords from declarations of trad_frame_saved_reg
types, except on forward declarations.
* aarch64-tdep.c: Update.
* alpha-mdebug-tdep.c: Update.
* alpha-tdep.c: Update.
* arc-tdep.c: Update.
* arm-tdep.c: Update.
* avr-tdep.c: Update.
* cris-tdep.c: Update.
* csky-tdep.c: Update.
* frv-tdep.c: Update.
* hppa-linux-tdep.c: Update.
* hppa-tdep.c: Update.
* hppa-tdep.h: Update.
* lm32-tdep.c: Update.
* m32r-linux-tdep.c: Update.
* m32r-tdep.c: Update.
* m68hc11-tdep.c: Update.
* mips-tdep.c: Update.
* moxie-tdep.c: Update.
* riscv-tdep.c: Update.
* rs6000-tdep.c: Update.
* s390-linux-tdep.c: Update.
* s390-tdep.c: Update.
* score-tdep.c: Update.
* sparc-netbsd-tdep.c: Update.
* sparc-sol2-tdep.c: Update.
* sparc64-fbsd-tdep.c: Update.
* sparc64-netbsd-tdep.c: Update.
* sparc64-obsd-tdep.c: Update.
* sparc64-sol2-tdep.c: Update.
* tilegx-tdep.c: Update.
* v850-tdep.c: Update.
* vax-tdep.c: Update.
* frame-unwind.c (frame_unwind_got_bytes): Make parameter const.
* frame-unwind.h (frame_unwind_got_bytes): Likewise.
* trad-frame.c: Update.
Remove TF_REG_* enum.
(trad_frame_alloc_saved_regs): Add a static assertion to check for
a trivially-constructible struct.
(trad_frame_reset_saved_regs): Adjust to use member function.
(trad_frame_value_p): Likewise.
(trad_frame_addr_p): Likewise.
(trad_frame_realreg_p): Likewise.
(trad_frame_value_bytes_p): Likewise.
(trad_frame_set_value): Likewise.
(trad_frame_set_realreg): Likewise.
(trad_frame_set_addr): Likewise.
(trad_frame_set_unknown): Likewise.
(trad_frame_set_value_bytes): Likewise.
(trad_frame_get_prev_register): Likewise.
* trad-frame.h: Update.
(trad_frame_saved_reg_kind): New enum.
(struct trad_frame_saved_reg) <addr, realreg, data>: Remove.
<m_kind, m_reg>: New member fields.
<set_value, set_realreg, set_addr, set_unknown, set_value_bytes>
<kind, value, realreg, addr, value_bytes, is_value, is_realreg>
<is_addr, is_unknown, is_value_bytes>: New member functions.
2021-01-02 Simon Marchi <simon.marchi@polymtl.ca>
* target-float.c: Fix typos.
2021-01-02 Hannes Domani <ssbssa@yahoo.de>
* gdb-gdb.py.in: Fix main_type.flds_bnds.bounds pretty printer.
2021-01-01 Joel Brobecker <brobecker@adacore.com>
* gdbarch.sh: Update copyright year range.
2021-01-01 Joel Brobecker <brobecker@adacore.com>
Update copyright year range in copyright header of all GDB files.
2021-01-01 Joel Brobecker <brobecker@adacore.com>
* copyright.py (get_update_list): Add "gdbserver" and "gdbsupport"
to the list of directories to update.
2021-01-01 Joel Brobecker <brobecker@adacore.com>
* top.c (print_gdb_version): Update copyright year.
2021-01-01 Joel Brobecker <brobecker@adacore.com>
* config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2020.
For older changes see ChangeLog-2020.
Local Variables:
mode: change-log
left-margin: 8
fill-column: 74
version-control: never
2007-08-10 06:44:38 +08:00
coding: utf-8
End: