binutils-gdb.git
4 years agoPort gas/config/* to str_htab.
Martin Liska [Tue, 18 Aug 2020 08:57:21 +0000 (10:57 +0200)]
Port gas/config/* to str_htab.

* config/obj-coff-seh.c (seh_hash_insert): Port to use new
str_htab type.
(seh_hash_find): Likewise.
(seh_hash_find_or_make): Likewise.
* config/obj-coff.c (tag_init): Likewise.
(tag_insert): Likewise.
(tag_find): Likewise.
* config/obj-elf.c (struct group_list): Likewise.
(build_additional_section_info): Likewise.
(free_section_idx): Likewise.
(elf_adjust_symtab): Likewise.
(elf_frob_file_after_relocs): Likewise.
* config/tc-aarch64.c (INSN_SIZE): Likewise.
(parse_reg): Likewise.
(insert_reg_alias): Likewise.
(create_register_alias): Likewise.
(s_unreq): Likewise.
(parse_shift): Likewise.
(parse_pldop): Likewise.
(parse_barrier): Likewise.
(parse_barrier_psb): Likewise.
(parse_bti_operand): Likewise.
(parse_sys_reg): Likewise.
(parse_sys_ins_reg): Likewise.
(lookup_mnemonic): Likewise.
(opcode_lookup): Likewise.
(parse_operands): Likewise.
(checked_hash_insert): Likewise.
(sysreg_hash_insert): Likewise.
(fill_instruction_hash_table): Likewise.
(md_begin): Likewise.
* config/tc-alpha.c (struct alpha_reloc_tag): Likewise.
(get_alpha_reloc_tag): Likewise.
(assemble_tokens_to_insn): Likewise.
(assemble_tokens): Likewise.
(md_begin): Likewise.
* config/tc-arc.c (arc_find_opcode): Likewise.
(arc_insert_opcode): Likewise.
(find_opcode_match): Likewise.
(declare_register): Likewise.
(declare_addrtype): Likewise.
(md_begin): Likewise.
(arc_parse_name): Likewise.
(tc_arc_regname_to_dw2regnum): Likewise.
(arc_extcorereg): Likewise.
* config/tc-arm.c (MVE_BAD_QREG): Likewise.
(arm_reg_parse_multi): Likewise.
(parse_reloc): Likewise.
(insert_reg_alias): Likewise.
(create_register_alias): Likewise.
(s_unreq): Likewise.
(parse_shift): Likewise.
(parse_psr): Likewise.
(parse_cond): Likewise.
(parse_barrier): Likewise.
(do_vfp_nsyn_opcode): Likewise.
(opcode_lookup): Likewise.
(arm_tc_equal_in_insn): Likewise.
(md_begin): Likewise.
* config/tc-avr.c (md_begin): Likewise.
(avr_ldi_expression): Likewise.
(md_assemble): Likewise.
(avr_update_gccisr): Likewise.
(avr_emit_insn): Likewise.
* config/tc-cr16.c (get_register): Likewise.
(get_register_pair): Likewise.
(get_index_register): Likewise.
(get_index_register_pair): Likewise.
(get_pregister): Likewise.
(get_pregisterp): Likewise.
(initialise_reg_hash_table): Likewise.
(md_begin): Likewise.
(cr16_assemble): Likewise.
(md_assemble): Likewise.
* config/tc-cris.c (cris_insn_first_word_frag): Likewise.
(md_begin): Likewise.
(cris_process_instruction): Likewise.
* config/tc-crx.c (get_register): Likewise.
(get_copregister): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-csky.c (md_begin): Likewise.
(parse_opcode): Likewise.
(get_operand_value): Likewise.
(v1_work_jbsr): Likewise.
(v2_work_rotlc): Likewise.
(v2_work_bgeni): Likewise.
(v2_work_not): Likewise.
* config/tc-d10v.c (sizeof): Likewise.
(md_begin): Likewise.
(do_assemble): Likewise.
(md_apply_fix): Likewise.
* config/tc-d30v.c (sizeof): Likewise.
(md_begin): Likewise.
(do_assemble): Likewise.
* config/tc-dlx.c (RELOC_DLX_VTENTRY): Likewise.
(md_begin): Likewise.
(machine_ip): Likewise.
* config/tc-ft32.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-h8300.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-hppa.c (pa_ip): Likewise.
(md_begin): Likewise.
* config/tc-i386.c (md_begin): Likewise.
(i386_print_statistics): Likewise.
(parse_insn): Likewise.
(process_operands): Likewise.
(i386_index_check): Likewise.
(parse_real_register): Likewise.
* config/tc-ia64.c (dot_rot): Likewise.
(dot_entry): Likewise.
(declare_register): Likewise.
(md_begin): Likewise.
(ia64_parse_name): Likewise.
(md_assemble): Likewise.
(dot_alias): Likewise.
(do_alias): Likewise.
(ia64_adjust_symtab): Likewise.
(do_secalias): Likewise.
(ia64_frob_file): Likewise.
* config/tc-m68hc11.c (m68hc11_print_statistics): Likewise.
(md_begin): Likewise.
(print_insn_format): Likewise.
(md_assemble): Likewise.
* config/tc-m68k.c (tc_gen_reloc): Likewise.
(m68k_ip): Likewise.
(md_begin): Likewise.
* config/tc-mcore.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-microblaze.c (md_begin): Likewise.
(md_assemble): Likewise.
(md_apply_fix): Likewise.
* config/tc-mips.c (nopic_need_relax): Likewise.
(md_begin): Likewise.
(macro_build): Likewise.
(mips16_macro_build): Likewise.
(mips_lookup_insn): Likewise.
(mips_ip): Likewise.
(mips16_ip): Likewise.
* config/tc-mmix.c (sizeof): Likewise.
(mmix_md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-mn10200.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-mn10300.c (HAVE_AM30): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-moxie.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-msp430.c (md_begin): Likewise.
(msp430_operands): Likewise.
(md_assemble): Likewise.
* config/tc-nds32.c (PV_DONT_CARE): Likewise.
(builtin_isreg): Likewise.
(builtin_regnum): Likewise.
(nds32_init_nds32_pseudo_opcodes): Likewise.
(nds32_lookup_pseudo_opcode): Likewise.
(nds32_relax_hint): Likewise.
(md_begin): Likewise.
(nds32_find_reloc_table): Likewise.
(nds32_elf_append_relax_relocs_traverse): Likewise.
(nds32_relax_branch_instructions): Likewise.
(md_convert_frag): Likewise.
(nds32_elf_analysis_relax_hint): Likewise.
(tc_nds32_regname_to_dw2regnum): Likewise.
* config/tc-nios2.c (nios2_opcode_lookup): Likewise.
(nios2_reg_lookup): Likewise.
(nios2_ps_lookup): Likewise.
(md_begin): Likewise.
* config/tc-ns32k.c (struct hash_control): Likewise.
(parse): Likewise.
(md_begin): Likewise.
* config/tc-pdp11.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-pj.c (fake_opcode): Likewise.
(alias): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-ppc.c (ppc_setup_opcodes): Likewise.
(md_assemble): Likewise.
* config/tc-pru.c (pru_opcode_lookup): Likewise.
(pru_reg_lookup): Likewise.
(md_begin): Likewise.
(md_end): Likewise.
* config/tc-riscv.c (init_ext_version_hash): Likewise.
(riscv_get_default_ext_version): Likewise.
(riscv_set_arch): Likewise.
(init_opcode_names_hash): Likewise.
(opcode_name_lookup): Likewise.
(enum reg_class): Likewise.
(hash_reg_name): Likewise.
(riscv_init_csr_hash): Likewise.
(reg_csr_lookup_internal): Likewise.
(reg_lookup_internal): Likewise.
(init_opcode_hash): Likewise.
(md_begin): Likewise.
(DECLARE_CSR): Likewise.
(macro_build): Likewise.
(riscv_ip): Likewise.
* config/tc-s390.c (register_name): Likewise.
(s390_setup_opcodes): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
(s390_insn): Likewise.
* config/tc-score.c (struct s3_reg_map): Likewise.
(s3_score_reg_parse): Likewise.
(s3_dependency_type_from_insn): Likewise.
(s3_parse_16_32_inst): Likewise.
(s3_parse_48_inst): Likewise.
(s3_insert_reg): Likewise.
(s3_build_reg_hsh): Likewise.
(s3_build_score_ops_hsh): Likewise.
(s3_build_dependency_insn_hsh): Likewise.
(s3_begin): Likewise.
* config/tc-score7.c (struct s7_reg_map): Likewise.
(s7_score_reg_parse): Likewise.
(s7_dependency_type_from_insn): Likewise.
(s7_parse_16_32_inst): Likewise.
(s7_build_score_ops_hsh): Likewise.
(s7_build_dependency_insn_hsh): Likewise.
(s7_insert_reg): Likewise.
(s7_build_reg_hsh): Likewise.
(s7_begin): Likewise.
* config/tc-sh.c (EMPTY): Likewise.
(md_begin): Likewise.
(find_cooked_opcode): Likewise.
* config/tc-sparc.c (md_begin): Likewise.
(sparc_ip): Likewise.
* config/tc-spu.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-tic30.c (md_begin): Likewise.
(tic30_operand): Likewise.
(tic30_parallel_insn): Likewise.
(md_assemble): Likewise.
* config/tc-tic4x.c (TIC4X_ALT_SYNTAX): Likewise.
(tic4x_asg): Likewise.
(tic4x_inst_insert): Likewise.
(tic4x_inst_add): Likewise.
(md_begin): Likewise.
(tic4x_operand_parse): Likewise.
(md_assemble): Likewise.
* config/tc-tic54x.c (MAX_SUBSYM_HASH): Likewise.
(stag_add_field_symbols): Likewise.
(tic54x_endstruct): Likewise.
(tic54x_tag): Likewise.
(tic54x_remove_local_label): Likewise.
(tic54x_clear_local_labels): Likewise.
(tic54x_var): Likewise.
(tic54x_macro_start): Likewise.
(tic54x_macro_info): Likewise.
(tic54x_macro_end): Likewise.
(subsym_isreg): Likewise.
(subsym_structsz): Likewise.
(md_begin): Likewise.
(is_mmreg): Likewise.
(is_type): Likewise.
(encode_condition): Likewise.
(encode_cc3): Likewise.
(encode_cc2): Likewise.
(encode_operand): Likewise.
(tic54x_parse_insn): Likewise.
(tic54x_parse_parallel_insn_firstline): Likewise.
(subsym_create_or_replace): Likewise.
(subsym_lookup): Likewise.
(subsym_substitute): Likewise.
(tic54x_undefined_symbol): Likewise.
* config/tc-tic6x.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-tilegx.c (O_hw2_last_plt): Likewise.
(INSERT_SPECIAL_OP): Likewise.
(md_begin): Likewise.
(tilegx_parse_name): Likewise.
(parse_reg_expression): Likewise.
(md_assemble): Likewise.
* config/tc-tilepro.c (O_tls_ie_load): Likewise.
(INSERT_SPECIAL_OP): Likewise.
(tilepro_parse_name): Likewise.
(parse_reg_expression): Likewise.
(md_assemble): Likewise.
* config/tc-v850.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-vax.c (md_ri_to_chars): Likewise.
(vip_begin): Likewise.
(vip): Likewise.
(main): Likewise.
(md_begin): Likewise.
* config/tc-wasm32.c (md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-xgate.c (xgate_parse_operand): Likewise.
(md_begin): Likewise.
(md_assemble): Likewise.
* config/tc-z8k.c (md_begin): Likewise.
(md_assemble): Likewise.

4 years agoPort dw2gencfi.c to str_htab.
Martin Liska [Tue, 18 Aug 2020 08:51:28 +0000 (10:51 +0200)]
Port dw2gencfi.c to str_htab.

* dw2gencfi.c (dwcfi_hash_insert): Use htab_t and str_hash_*
functions.
(dwcfi_hash_find): Likewise.
(dwcfi_hash_find_or_make): Likewise.

4 years agoPort ecoff.c to str_hash.
Martin Liska [Tue, 18 Aug 2020 08:49:16 +0000 (10:49 +0200)]
Port ecoff.c to str_hash.

* ecoff.c (INIT_VARRAY): Use htab_t.
(add_string): Likewise.
(ecoff_read_begin_hook): Use new str_htab_create.
(get_tag): Use htab_t.
(add_file): Likewise.

4 years agoAdd new string hash table based on htab_t.
Martin Liska [Tue, 18 Aug 2020 08:49:16 +0000 (10:49 +0200)]
Add new string hash table based on htab_t.

* hash.h (struct string_tuple): New.
(hash_string_tuple): Likewise.
(eq_string_tuple): Likewise.
(string_tuple_alloc): Likewise.
(str_hash_find): Likewise.
(str_hash_find_n): Likewise.
(str_hash_delete): Likewise.
(str_hash_insert): Likewise.
(str_htab_create): Likewise.

4 years agoUse libiberty hash in gas/symbols.c.
Martin Liska [Sat, 15 Aug 2020 17:48:17 +0000 (19:48 +0200)]
Use libiberty hash in gas/symbols.c.

* symbols.c (struct symbol_entry): New.
(hash_symbol_entry): Likewise.
(eq_symbol_entry): Likewise.
(symbol_entry_alloc): Likewise.
(symbol_entry_find): Likewise.
(local_symbol_make): Use htab hash table.
(local_symbol_convert): Likewise.
(symbol_table_insert): Likewise.
(symbol_find_exact_noref): Likewise.
(resolve_local_symbol): Likewise.
(resolve_local_symbol_values): Likewise.
(symbol_begin): Likewise.
(symbol_print_statistics): Likewise.

4 years agoUse libiberty hash in gas/read.c.
Martin Liska [Sat, 15 Aug 2020 17:47:35 +0000 (19:47 +0200)]
Use libiberty hash in gas/read.c.

* read.c (struct po_entry): New.
(hash_po_entry): Likewise.
(eq_po_entry): Likewise.
(po_entry_alloc): Likewise.
(po_entry_find): Likewise.
(pop_insert): Likewise.
(pobegin): Use htab hash table.
(read_a_source_file): Likewise.
(s_macro): Likewise.
(read_print_statistics): Likewise.
* config/tc-m68k.c (m68k_conditional_pseudoop): Add const qualifier.
* config/tc-m68k.h (m68k_conditional_pseudoop): Likewise.

4 years agoUse libiberty hash in gas/macro.c.
Martin Liska [Sat, 15 Aug 2020 17:47:01 +0000 (19:47 +0200)]
Use libiberty hash in gas/macro.c.

* config/tc-iq2000.c (iq2000_add_macro): Use htab hash table.
* macro.c (struct hash_control): Use htab.
(macro_init): Likewise.
(do_formals): Likewise.
(free_macro): Likewise.
(define_macro): Likewise.
(sub_actual): Likewise.
(macro_expand_body): Likewise.
(macro_expand): Likewise.
(check_macro): Likewise.
(delete_macro): Likewise.
(expand_irp): Likewise.
* macro.h (struct macro_hash_entry): New struct.
(hash_macro_entry): New.
(eq_macro_entry): Likewise.
(macro_entry_alloc): Likewise.
(macro_entry_find): Likewise.
(struct formal_hash_entry): Likewise.
(hash_formal_entry): Likewise.
(eq_formal_entry): Likewise.
(formal_entry_alloc): Likewise.
(formal_entry_find): Likewise.

4 years agogas/hash.c: add new functions
Martin Liska [Sat, 15 Aug 2020 17:46:33 +0000 (19:46 +0200)]
gas/hash.c: add new functions

The first of a patch series deleting the gas/hash.c hash table
implementation and instead using libiberty/hashtab.c hash tables in
gas.

* as.h: Include hashtab.h.
* hash.c (htab_insert): New.
(htab_print_statistics): Likewise.
* hash.h (htab_insert): Likewise.
(htab_print_statistics): Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 20 Aug 2020 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoPR26349, FAIL: binutils-all/pr25543 on hpux
Alan Modra [Wed, 19 Aug 2020 08:49:38 +0000 (18:19 +0930)]
PR26349, FAIL: binutils-all/pr25543 on hpux

The 't' length modifier isn't in SUSv2, unsurprisingly %tx isn't
recognized by older printf implementations.  So even though 't' is
correct for ptrdiff_t we can't use it.  Also, _bfd_int64_high and
_bfd_int64_low disappeared in 2008.

PR 26349
* readelf.c (dump_relocations): Use BFD_VMA_FMT to print offset
and info fields.
(dump_section_as_strings): Don't use %tx to display offset.

4 years agogdb: add linux_nat_debug_printf macro
Simon Marchi [Wed, 19 Aug 2020 02:49:54 +0000 (22:49 -0400)]
gdb: add linux_nat_debug_printf macro

The debug prints inside linux-nat.c almost all have a prefix that
indicate in which function they are located.  This prefix is an
abbreviation of the function name.  For example, this print is in the
`linux_nat_post_attach_wait` function:

    if (debug_linux_nat)
      fprintf_unfiltered (gdb_stdlog,
                          "LNPAW: Attaching to a stopped process\n");

Over time, the code has changed, things were moved, and many of these
prefixes are not accurate anymore.  Also, unless you know the
linux-nat.c file by heart, it's a bit cryptic what LLR, LNW, RSRL, etc,
all mean.

To address both of these issues, I suggest adding this macro for
printing debug statements, which automatically includes the function
name.  It also includes the `[linux-nat]` prefix to clarify which part
of GDB printed this (I think that, ideally, all debug prints would
include such a tag).

The `__func__` magic symbol is used to get the function name.
Unfortunately, in the case of methods, it only contains the method name,
not the class name.  So we'll get "wait", where I would have liked to
get "linux_nat_target::wait".  But at least with the `[linux-nat]` tag
in the front, it's not really ambiguous.

I've made the macro automatically include the trailing newline, because
it wouldn't make sense to call it twice to print two parts of one line,
the `[linux-nat]` tag would be printed in the middle.

An advantage of this (IMO) is that it's less verbose, we don't have to
check for `if (debug_linux_nat)` everywhere.

Another advantage is that it's easier to customize the output later,
without having to touch all call sites.

Here's an example of what it looks like in the end:

    [linux-nat] linux_nat_wait_1: enter
    [linux-nat] wait: [process -1], [TARGET_WNOHANG]

gdb/ChangeLog:

* linux-nat.c (linux_nat_debug_printf): New function.
(linux_nat_debug_printf_1): New macro.  Use throughout the file.

Change-Id: Ifcea3255b91400d3ad093cd0b75d3fac241cb998

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 19 Aug 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoCorrect vcmpsq, vcmpuq and xvtlsbb BF field
Alan Modra [Tue, 18 Aug 2020 23:17:35 +0000 (08:47 +0930)]
Correct vcmpsq, vcmpuq and xvtlsbb BF field

These shouldn't be optional.  The record form of vector instructions
set CR6, giving an expectation that omitting BF should be the same as
specifying CR6.

opcodes/
* ppc-opc.c (powerpc_opcodes): Replace OBF with BF for vcmpsq,
vcmpuq and xvtlsbb.
gas/
* testsuite/gas/ppc/int128.s: Correct vcmpuq.
* testsuite/gas/ppc/int128.d: Update.
* testsuite/gas/ppc/xvtlsbb.d: Update.

4 years agogdb/Makefile.in: Add DEBUGINFOD_CFLAGS, DEBUGINFOD_LIBS variables.
Aaron Merey [Tue, 18 Aug 2020 22:02:26 +0000 (18:02 -0400)]
gdb/Makefile.in: Add DEBUGINFOD_CFLAGS, DEBUGINFOD_LIBS variables.

Introduce Makefile variables DEBUGINFOD_CFLAGS and DEBUGINFOD_LIBS
that map to the configuration variables of the same names.

Replace @DEBUGINFOD_LIBS@ with $(DEBUGINFOD_LIBS) in the definition
of CLIBS in order to conform to the usage of other *_LIBS variables
in Makefile.in.

Add DEBUGINFOD_CFLAGS to INTERNAL_CFLAGS_BASE. This fixes an issue
where GDB would fail to find debuginfod.h if it was not installed
in a default location searched by the compiler.

gdb/ChangeLog:

* Makefile.in (DEBUGINFOD_CFLAGS, DEBUGINFOD_LIBS): New variables.
(INTERNAL_CFLAGS_BASE): Add DEBUGINFOD_CFLAGS.
(CLIBS): Add DEBUGINFOD_LIBS.

4 years agoAdd ChangeLog entries for previous commit.
Peter Bergner [Tue, 18 Aug 2020 17:48:42 +0000 (12:48 -0500)]
Add ChangeLog entries for previous commit.

4 years agoPowerPC: Rename xvcvbf16sp to xvcvbf16spn
Peter Bergner [Tue, 18 Aug 2020 17:42:31 +0000 (12:42 -0500)]
PowerPC: Rename xvcvbf16sp to xvcvbf16spn

The xvcvbf16sp mnemonic has been renamed to xvcvbf16spn, to be consistent
with the other non-signaling conversion instructions which all end with "n".

opcodes/
* ppc-opc.c (powerpc_opcodes) <xvcvbf16sp>: Rename from this...
<xvcvbf16spn>: ...to this.

gas/
* testsuite/gas/ppc/vsx4.s: Update test to use new mnemonic.
* testsuite/gas/ppc/vsx4.d: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 18 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: fix IA64 build failure of linux-nat
Sergei Trofimovich [Tue, 19 May 2020 21:19:45 +0000 (22:19 +0100)]
gdb: fix IA64 build failure of linux-nat

On IA64 built failed as:

```
ia64-linux-nat.c:352:29: error: 'gdbarch_num_regs' was not declared in this scope
  352 |   if (regno < 0 || regno >= gdbarch_num_regs (gdbarch))
      |                             ^~~~~~~~~~~~~~~~
```

The fix includes "gdbarch.h" header where symbol is declared.

* ia64-linux-nat.c: Include "gdbarch.h" to declare used
'gdbarch_num_regs'.

Signed-off-by: Sergei Trofimovich <siarheit@google.com>
4 years agoUpdate xfail pattern in gdb.rust/simple.exp
Tom Tromey [Mon, 17 Aug 2020 16:45:49 +0000 (10:45 -0600)]
Update xfail pattern in gdb.rust/simple.exp

In PR rust/26197, Tom de Vries notes that the variant part rewrite
caused some regressions for the Rust compiler he has.  This compiler
is unusual in that it combines a relatively recent rustc with a
relatively old LLVM -- so variant parts are not emitted using DWARF.

Most of the bugs in that PR were already fixed by earlier patches, but
some lingered.  After some research we found that some of these never
did work -- which is consistent with the investigations we did into
the debug info -- but instead were xfail'd.  This patch updates the
xfails to cope with the new output.  (After this, just one failure
remains.)

Tom de Vries tested this using his rustc and suggested a fix that
appears in this version.

gdb/testsuite/ChangeLog
2020-08-17  Tom de Vries  <tdevries@suse.de>
    Tom Tromey  <tromey@adacore.com>

PR rust/26197:
* gdb.rust/simple.exp (xfail_pattern): Update for new failure.

4 years agoFix MI crash with Ada string access
Tom Tromey [Mon, 17 Aug 2020 15:21:40 +0000 (09:21 -0600)]
Fix MI crash with Ada string access

I happened to notice that using -var-create at a certain spot in an
Ada program caused a crash.  This happens because
ada_get_decoded_value can return NULL -- in particular, deeper in the
code it can hit this return in ada_type_of_array:

      descriptor = desc_bounds (arr);
      if (value_as_long (descriptor) == 0)
        return NULL;

This patch avoids the crash by handling this NULL return.

gdb/ChangeLog
2020-08-17  Tom Tromey  <tromey@adacore.com>

* ada-varobj.c (ada_varobj_decode_var): Handle case where
ada_get_decoded_value returns NULL.

gdb/testsuite/ChangeLog
2020-08-17  Tom Tromey  <tromey@adacore.com>

* gdb.ada/mi_var_access.exp: New file.
* gdb.ada/mi_var_access/mi_access.adb: New file.
* gdb.ada/mi_var_access/pck.adb: New file.
* gdb.ada/mi_var_access/pck.ads: New file.

4 years agoConvert CORE_ADDR to Python using gdb_py_object_from_ulongest
Tom Tromey [Mon, 17 Aug 2020 14:50:35 +0000 (08:50 -0600)]
Convert CORE_ADDR to Python using gdb_py_object_from_ulongest

An internal test failed on a riscv64-elf cross build because
Inferior.search_memory returned a negative value.  I tracked this down
to to use of PyLong_FromLong in infpy_search_memory.  Then, I looked
at other conversions of CORE_ADDR to Python and fixed these as well.

I don't think there is a good way to write a test for this.

gdb/ChangeLog
2020-08-17  Tom Tromey  <tromey@adacore.com>

* python/py-inferior.c (infpy_search_memory): Use
gdb_py_object_from_ulongest.
* python/py-infevents.c (create_inferior_call_event_object)
(create_memory_changed_event_object): Use
gdb_py_object_from_ulongest.
* python/py-linetable.c (ltpy_entry_get_pc): Use
gdb_py_object_from_ulongest.

4 years agogdb: fix wrong indentation in symbol_needs_eval_context
Simon Marchi [Mon, 17 Aug 2020 10:02:24 +0000 (06:02 -0400)]
gdb: fix wrong indentation in symbol_needs_eval_context

gdb/ChangeLog:

* loc.c (class symbol_needs_eval_context): Fix indentation.

Change-Id: Ibf4e6a9ca9573b498737a61db116ee10b287b7f5

4 years agogdb: use bool in dwarf2_loc_desc_get_symbol_read_needs
Simon Marchi [Mon, 17 Aug 2020 09:57:16 +0000 (05:57 -0400)]
gdb: use bool in dwarf2_loc_desc_get_symbol_read_needs

This variable is really a boolean, so use the bool type.

gdb/ChangeLog:

* dwarf2/loc.c (dwarf2_loc_desc_get_symbol_read_needs): Use
bool.

Change-Id: I814a47d1200f3b88722c54c822fd49607a6b77be

4 years agogas: Fix internal error in S_SET_SEGMENT
Alex Coplan [Mon, 17 Aug 2020 13:23:14 +0000 (14:23 +0100)]
gas: Fix internal error in S_SET_SEGMENT

This patch fixes an internal error in GAS when defining a section using
a symbol that has already been named but not defined. For a minimal
reproducer, try the following input:

a=b
.sect a

The problem is that obj_elf_change_section() happily reuses the symbol
"a" created by equals() without clearing the sy_value field: prior to
this patch, it just set bsym. This caused a problem when attempting to
resolve the section symbol, since resolve_symbol_value() ended up
resolving the symbol as if it were the original symbol created by
equals(), which ends up leaving the section symbol in the undefined
section instead of in section a, hence the call to abort() in
S_SET_SEGMENT().

gas/ChangeLog:

* config/obj-elf.c (obj_elf_change_section): When repurposing an
existing symbol, ensure that we set sy_value as per other (fresh)
section symbols.
* testsuite/gas/elf/elf.exp: Add new test.
* testsuite/gas/elf/section-symbol-redef.d: New test.
* testsuite/gas/elf/section-symbol-redef.s: Input for test.

4 years ago[gdb] Fix printing of unresolved dynamic type
Tom de Vries [Mon, 17 Aug 2020 07:54:37 +0000 (09:54 +0200)]
[gdb] Fix printing of unresolved dynamic type

When debugging gdb in batch mode with executable mixed-lang-stack and doing a
backtrace at breakpt:
...
$ gdb --args gdb \
  -batch \
  outputs/gdb.fortran/mixed-lang-stack/mixed-lang-stack \
  -ex "b breakpt" \
  -ex r \
  -ex bt
...
and stopping at resolve_dynamic_type to print the type:
...
(gdb) b resolve_dynamic_type
Breakpoint 1 at 0x6b020c: file gdbtypes.c, line 2633.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>call recursive_dump_type (type, 0)
>continue
>end
(gdb) run
...
we eventually run into an assert for the dynamic type of "str":
...
Thread 1 "gdb" hit Breakpoint 1, resolve_dynamic_type (type=0x22204f0, \
  valaddr=..., addr=4199408) at gdbtypes.c:2633
2633        = {check_typedef (type), valaddr, addr, NULL};
type node 0x22204f0
name '<NULL>' (0x0)
code 0xd (TYPE_CODE_STRING)
length 0
  ...
    nfields 0 0x22204b0
gdbtypes.h:526: internal-error: LONGEST dynamic_prop::const_val() const: \
  Assertion `m_kind == PROP_CONST' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...
when trying to print the high bound of a TYPE_CODE_RANGE, which has m_kind
PROP_LOCEXPR, while the code in resolve_dynamic_type assumes PROP_CONST.

Fix this by extending the printing of TYPE_CODE_RANGE to allow
PROP_LOCEXPR/PROP_LOCLIST as well, such that we have instead:
...
    nfields 0 0x1fbc020
    low 1  high (dynamic)
...

Tested on x86_64-linux.

gdb/ChangeLog:

2020-08-17  Tom de Vries  <tdevries@suse.de>

PR gdb/26393
* gdbtypes.c (dump_dynamic_prop): New function.
(recursive_dump_type): Use dump_dynamic_prop for TYPE_CODE_RANGE.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 17 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoPowerPC64 inline PLT call tests
Alan Modra [Sun, 16 Aug 2020 13:27:51 +0000 (22:57 +0930)]
PowerPC64 inline PLT call tests

* testsuite/ld-powerpc/inline.s,
* testsuite/ld-powerpc/inline-1.d,
* testsuite/ld-powerpc/inline-2.d,
* testsuite/ld-powerpc/inline-3.d,
* testsuite/ld-powerpc/inline-4.d,
* testsuite/ld-powerpc/inlinepcrel.s,
* testsuite/ld-powerpc/inlinepcrel-1.d,
* testsuite/ld-powerpc/inlinepcrel-2.d,
* testsuite/ld-powerpc/inlinepcrel-3.d: New tests.
* testsuite/ld-powerpc/powerpc.exp: Run them.

4 years agold: Add a PR binutils/26389 test
H.J. Lu [Sun, 16 Aug 2020 12:45:02 +0000 (05:45 -0700)]
ld: Add a PR binutils/26389 test

PR binutils/26389
* testsuite/ld-plugin/lto.exp: Run PR binutils/26389 test.
* testsuite/ld-plugin/pr26389.c: New file.
* testsuite/ld-plugin/pr26389.d: Likewise.

4 years ago[gdb/testsuite] Add gdb.base/eh_return.exp
Tom de Vries [Sun, 16 Aug 2020 11:30:34 +0000 (13:30 +0200)]
[gdb/testsuite] Add gdb.base/eh_return.exp

In PR25350, an internal error was reported:
...
(gdb) break *eh2+0x7e
Breakpoint 1 at 0x13e2: file small.c, line 38.
(gdb) run
Starting program: a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Breakpoint 1, 0x00005555555553e2 in eh2 (
frame.c:558: internal-error: frame_id get_frame_id(frame_info*): \
  Assertion `stashed' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

The internal error does not reproduce after recent commit 547ce8f00b
"[gdb/backtrace] Fix printing of fortran string args".

Add the corresponding test-case as regression test, given that the code is
rather atypical.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-08-16  Tom de Vries  <tdevries@suse.de>

PR gdb/25350
* gdb.base/eh_return.c: New test.
* gdb.base/eh_return.exp: New file.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 16 Aug 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[gdb/testsuite] Fix charlen type in mixed-lang-stack.c
Tom de Vries [Sat, 15 Aug 2020 09:59:18 +0000 (11:59 +0200)]
[gdb/testsuite] Fix charlen type in mixed-lang-stack.c

In gdb.fortran/mixed-lang-stack.f90, we have fortran function mixed_func_1d:
...
subroutine mixed_func_1d(a, b, c, d, str)
  use, intrinsic :: iso_c_binding, only: c_int, c_float, c_double
  use, intrinsic :: iso_c_binding, only: c_float_complex
  implicit none
  integer(c_int) :: a
  real(c_float) :: b
  real(c_double) :: c
  complex(c_float_complex) :: d
  character(len=*) :: str
...
which we declare in C in gdb.fortran/mixed-lang-stack.c like this:
...
extern void mixed_func_1d_ (int *, float *, double *, complex float *,
                            char *, size_t);
...

The fortran string parameter str is passed as a char *, and an additional
argument str_ for the string length.  The type used for the string length
argument is size_t, but for gcc 7 and earlier, the actual type is int
instead ( see
https://gcc.gnu.org/onlinedocs/gfortran/Argument-passing-conventions.html ).

Fix this by declaring the string length type depending on the gcc version:
...
 #if !defined (__GNUC__) || __GNUC__ > 7
 typedef size_t fortran_charlen_t;
 #else
 typedef int fortran_charlen_t;
...

Tested on x86_64-linux, with gcc-7 and gcc-8.

gdb/testsuite/ChangeLog:

2020-08-15  Tom de Vries  <tdevries@suse.de>

* gdb.fortran/mixed-lang-stack.c (fortran_charlen_t): New type.
(mixed_func_1d_): Use fortran_charlen_t in decl.

4 years ago[gdb/backtrace] Fix printing of fortran string args
Tom de Vries [Sat, 15 Aug 2020 08:19:13 +0000 (10:19 +0200)]
[gdb/backtrace] Fix printing of fortran string args

When running test-case gdb.fortran/mixed-lang-stack.exp, it passes, but we
find in gdb.log:
...
 (gdb) bt^M
   ...
 #7  0x000000000040113c in mixed_func_1b (a=1, b=2, c=3, d=(4,5), \
   e=<error reading variable: value requires 140737488341744 bytes, which \
   is more than max-value-size>, g=..., _e=6) at mixed-lang-stack.f90:87^M
...
while a bit later in gdb.log, we have instead for the same frame (after
adding a gdb_test_no_output "set print frame-arguments all" to prevent
getting "e=..."):
...
 (gdb) up^M
 #7  0x000000000040113c in mixed_func_1b (a=1, b=2, c=3, d=(4,5), \
   e='abcdef', g=( a = 1.5, b = 2.5 ), _e=6) at mixed-lang-stack.f90:87^M
...

The difference is that in the latter case, we print the frame while it's
selected, while in the former, it's not.

The problem is that while trying to resolve the dynamic type of e in
resolve_dynamic_type, we call dwarf2_evaluate_property with a frame == NULL
argument, and then use the selected frame as the context in which to evaluate
the dwarf property, effectively evaluating a DW_OP_fbreg operation in the
wrong frame context.

Fix this by temporarily selecting the frame of which we're trying to print the
arguments in print_frame_args, borrowing code from print_frame_local_vars that
was added to fix a similar issue in commit 16c3b12f19 "error/internal-error
printing local variable during "bt full".

Build and tested on x86_64-linux.

gdb/ChangeLog:

2020-08-15  Tom de Vries  <tdevries@suse.de>

PR backtrace/26390
* stack.c (print_frame_args): Temporarily set the selected
frame to FRAME while printing the frame's arguments.

gdb/testsuite/ChangeLog:

2020-08-15  Tom de Vries  <tdevries@suse.de>

PR backtrace/26390
* gdb.fortran/mixed-lang-stack.exp: Call bt with -frame-arguments all.
Update expected pattern.

4 years agoSet SEC_SMALL_DATA on small common
Alan Modra [Sat, 15 Aug 2020 04:34:43 +0000 (14:04 +0930)]
Set SEC_SMALL_DATA on small common

Unlike the previous patch setting SEC_SMALL_DATA during
elf_backend_symbol_processing, this patch is mostly cosmetic.

* elf32-frv.c (elf32_frv_add_symbol_hook): Set SEC_SMALL_DATA on
small common section.
* elf32-m32r.c (m32r_elf_add_symbol_hook): Likewise.
* elf32-microblaze.c (microblaze_elf_add_symbol_hook): Likewise.
* elf32-nds32.c (nds32_elf_add_symbol_hook): Likewise.
* elf32-nios2.c (nios2_elf_add_symbol_hook): Likewise.
* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
* elf32-score.c (s3_bfd_score_elf_add_symbol_hook): Likewise.
* elf32-score7.c (s7_bfd_score_elf_add_symbol_hook): Likewise.
* elf32-tic6x.c (elf32_tic6x_add_symbol_hook): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
(v850_elf_add_symbol_hook): Likewise.
* elf64-alpha.c (elf64_alpha_add_symbol_hook): Likewise.
* elf64-ia64-vms.c (elf64_ia64_add_symbol_hook): Likewise.
* elfnn-ia64.c (elfNN_ia64_add_symbol_hook): Likewise.
* elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Likewise.

4 years agoPR26389, nm prints "c" for a common symbol with -flto and -fcommon
Alan Modra [Sat, 15 Aug 2020 00:12:44 +0000 (09:42 +0930)]
PR26389, nm prints "c" for a common symbol with -flto and -fcommon

git commit 49d9fd42acef chose to make nm print 'C' for the normal
common section, and 'c' for other commons.  This was an attempt to
make common symbols in .scommon and other small common sections show
a 'c' type without a section name comparison, but it failed for
nm --plugin on lto objects where normal common symbols are stashed in
a "plug" section.  It's also wrong for large common symbols.  So
instead set SEC_SMALL_DATA on sections created for small commons, and
key off that flag to show 'c' type.  If your ELF target doesn't have
an elf_backend_symbol_processing function, then you won't see 'c' for
symbols in .scommon.

Note that due to bfd_decode_symclass decoding common symbols without
a chance for coff_section_type to treat .scommon specially, then
having .scommon in the array of special sections handled by
coff_section_type prior to 49d9fd42acef was entirely ineffective.
That fact escaped me when writing 49d9fd42acef.  Unless .scommon
didn't have SEC_IS_COMMON set, which would be a little weird.

PR 26389
* syms.c (bfd_decode_symclass): Choose 'c' for commons only when
SEC_SMALL_DATA.
* elf32-m32r.c (_bfd_m32r_elf_symbol_processing): Set SEC_SMALL_DATA
on small common section.
* elf32-score.c (s3_bfd_score_elf_symbol_processing): Likewise.
* elf32-score7.c (s7_bfd_score_elf_symbol_processing): Likewise.
* elf32-tic6x.c (elf32_tic6x_symbol_processing): Likewise.
* elf32-v850.c (v850_elf_symbol_processing): Likewise.
* elfxx-mips.c (_bfd_mips_elf_symbol_processing): Likewise.
* ecoff.c (ecoff_set_symbol_info, ecoff_link_add_externals): Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 15 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[PowerPC] Always clear watchpoint with PTRACE_SET_DEBUGREG
Pedro Franco de Carvalho [Fri, 14 Aug 2020 18:41:14 +0000 (15:41 -0300)]
[PowerPC] Always clear watchpoint with PTRACE_SET_DEBUGREG

This patches changes low_prepare_to_resume in the ppc linux native target
to always clear the watchpoint when the old PTRACE_SET_DEBUGREG interface
is used, even if another watchpoint GDB requested to the target is
written right after using the same call.

The reason for this is that there were some older kernel versions for
which overwriting a watchpoint with PTRACE_SET_DEBUGREG would not
re-activate the watchpoint if it was previouly disabled following a hit.
This happened when the kernel was configured with CONFIG_HW_BREAKPOINT on
and uses perf events to install watchpoints.

Previously, the ppc linux native target would immediately remove or
insert watchpoints following a request from the upper layers.  This was
changed in commit 227c0bf4b3dd0cf65dceb58e729e9da81b38b5a7 to fix other
issues, which caused watchpoint requests to be applied to the inferior
only in low_prepare_to_resume, right before the inferior is resumed.

Usually, but maybe not always, after a hit, GDB will remove the
watchpoint, resume the inferior for a single-step, possibly report the
watchpoint hit to the user, and then re-insert the watchpoint before the
inferior is next resumed.  In this case there would be no problems, but
since I can't guarantee that there aren't other paths in GDB that allow
the user to set a new watchpoint after the first one hit, and after its
deletion by GDB, but before the inferior is resumed, there is a chance
that PTRACE_SET_DEBUGREG could be called directly without the watchpoint
first having been cleared, which could cause a false negative with the
older kernel versions.

This issue would affect kernel versions starting from this commit:

5aae8a53708025d4e718f0d2e7c2f766779ddc71

Up to the fix in this commit:

a53fd61ac2f411745471c1c877d5e072fbbf0e5c

gdb/ChangeLog:

PR breakpoints/26385
* ppc-linux-nat.c (ppc_linux_nat_target::low_prepare_to_resume):
Always clear watchpoint with PTRACE_SET_DEBUGREG.

4 years ago[PowerPC] Use < 0 and >= 0 for watchpoint ptrace calls
Pedro Franco de Carvalho [Fri, 14 Aug 2020 18:41:13 +0000 (15:41 -0300)]
[PowerPC] Use < 0 and >= 0 for watchpoint ptrace calls

In commit 227c0bf4b3dd0cf65dceb58e729e9da81b38b5a7, which fixed some
watchpoint bugs, I compared the return value of some ptrace calls with ==
-1 and != -1.  Althought this should be correct, since the rest of the
file uses < 0 and >= 0, I have modified this for consistency.

gdb/ChangeLog:

* ppc-linux-nat.c (ppc_linux_dreg_interface::detect)
(ppc_linux_nat_target::low_prepare_to_resume): Use ptrace () < 0
and >= to check return value instead of == -1 and != -1.

4 years agogdb: add gdb_argv::as_array_view method
Simon Marchi [Fri, 14 Aug 2020 16:27:22 +0000 (12:27 -0400)]
gdb: add gdb_argv::as_array_view method

Introduce the gdb_argv::as_array_view method, as a way to easily pass
the parsed arguments array to a function taking an array view.  There is
currently one caller where we can use this (which prompted the
suggestion to implement this method).

Add some selftests for the new method, which at the same time test a
little bit gdb_argv.  As far as I know, it's not tested currently.

gdb/ChangeLog:

* utils.h (class gdb_argv) <as_array_view>: New method.
* utils.c (gdb_argv_as_array_view_test): New.
(_initialize_utils): Register selftest.
* maint.c (maintenance_selftest): Use the new method.

Change-Id: I0645037613ed6549aabe60f14a36f3494513b177

4 years agoAllow larger bfd_default_hash_table_size
Alan Modra [Fri, 14 Aug 2020 08:15:13 +0000 (17:45 +0930)]
Allow larger bfd_default_hash_table_size

* hash.c (bfd_hash_set_default_size): Use higher_prime_number
rather than another copy of primes.  Increase maximum default
size allowed.

4 years agoPR26388, objdump debug dump memory leaks
Alan Modra [Fri, 14 Aug 2020 10:49:39 +0000 (20:19 +0930)]
PR26388, objdump debug dump memory leaks

num_debug_info_entries is used not just as a count but also as a flag
(DEBUG_INFO_UNAVAILABLE) after some errors.  That means
num_debug_info_entries can't be used when cleaning up malloc'd info.

PR 26388
* dwarf.c (free_debug_memory): Free alloc_num_debug_info_entries
of debug_information.  Correct test of max_loc_offsets and
max_range_lists.
* rddbg.c (read_debugging_info): Free dhandle on error.

4 years agoReadelf demangling test typo
Alan Modra [Fri, 14 Aug 2020 00:00:22 +0000 (09:30 +0930)]
Readelf demangling test typo

Using floating point data results in cris failing the test.

* testsuite/binutils-all/mangled.s: Use dc.a rather than dc.d.

4 years agoAArch64: Relax thumb-plt testcases regexpr.
Tamar Christina [Fri, 14 Aug 2020 06:51:03 +0000 (07:51 +0100)]
AArch64: Relax thumb-plt testcases regexpr.

The regexpr in these two files are a bit strict in that they don't account for
the slight changes in tags in certain arm targets which cause our address
offsets to change.   This changes the tests to allow slight movement in
locations while still strictly checking the rest.

ld/ChangeLog:

2020-08-03  Tamar Christina  <tamar.christina@arm.com>

* testsuite/ld-arm/thumb-plt-got.d: Relax regexpr.
* testsuite/ld-arm/thumb-plt.d: Likewise.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 14 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: Implement native dumpcore function for NetBSD
Kamil Rytarowski [Thu, 13 Aug 2020 17:29:13 +0000 (19:29 +0200)]
gdb: Implement native dumpcore function for NetBSD

Define supports_dumpcore and dumpcore for NetBSD, that wraps
the ptrace(2) call with the PT_DUMPCORE operation.

gdb/ChangeLog:

       * nbsd-nat.h (nbsd_nat_target::supports_dumpcore)
       (nbsd_nat_target::dumpcore): New declarations.
       * nbsd-nat.c (nbsd_nat_target::supports_dumpcore)
       (nbsd_nat_target::dumpcore): New functions.

4 years agogdb: Implement native dumpcore function
Kamil Rytarowski [Tue, 28 Jul 2020 15:29:35 +0000 (17:29 +0200)]
gdb: Implement native dumpcore function

Add new API for systems with native kernel support for dumping
a process on demand. Wire it into the gdb's gcore functionality.

gdb/ChangeLog:

       * target.h (supports_dumpcore, dumpcore): New
       function declarations.
       * target.c (supports_dumpcore, dumpcore): New
       functions.
       * target-delegates.c: Rebuild.
       * gcore.c (gcore_command): Use target_supports_dumpcore ()
       and target_dumpcore ().

4 years agodebuginfod-support.c: Replace globals with user_data
Aaron Merey [Thu, 13 Aug 2020 21:47:05 +0000 (17:47 -0400)]
debuginfod-support.c: Replace globals with user_data

Store query information in user_data struct instead of global variables.

gdb/ChangeLog:

* debuginfod-support.c: Replace global variables with user_data.

4 years agoAdd skip_fortran_tests to more Fortran testcases
Pedro Alves [Thu, 13 Aug 2020 16:41:28 +0000 (17:41 +0100)]
Add skip_fortran_tests to more Fortran testcases

This adds missing skip_fortran_tests checks to Fortran testcases,
using the exact same pattern the existing files that do check it use.

gdb/testsuite/ChangeLog:

* gdb.fortran/complex.exp: Check skip_fortran_tests.
* gdb.fortran/library-module.exp: Likewise.
* gdb.fortran/logical.exp: Likewise.
* gdb.fortran/module.exp: Likewise.
* gdb.fortran/print_type.exp: Likewise.
* gdb.fortran/vla-alloc-assoc.exp: Likewise.
* gdb.fortran/vla-datatypes.exp: Likewise.
* gdb.fortran/vla-history.exp: Likewise.
* gdb.fortran/vla-ptr-info.exp: Likewise.
* gdb.fortran/vla-ptype-sub.exp: Likewise.
* gdb.fortran/vla-ptype.exp: Likewise.
* gdb.fortran/vla-sizeof.exp: Likewise.
* gdb.fortran/vla-type.exp: Likewise.
* gdb.fortran/vla-value-sub-arbitrary.exp: Likewise.
* gdb.fortran/vla-value-sub-finish.exp: Likewise.
* gdb.fortran/vla-value-sub.exp: Likewise.
* gdb.fortran/vla-value.exp: Likewise.

4 years agoAdd skip_ada_tests to more Ada testcases
Pedro Alves [Thu, 13 Aug 2020 16:34:21 +0000 (17:34 +0100)]
Add skip_ada_tests to more Ada testcases

This adds missing skip_ada_tests checks to Ada testcases, using the
exact same pattern the existing files that do check it use.

gdb/testsuite/ChangeLog:

* gdb.ada/access_tagged_param.exp: Check skip_ada_tests.
* gdb.ada/access_to_packed_array.exp: Likewise.
* gdb.ada/access_to_unbounded_array.exp: Likewise.
* gdb.ada/addr_arith.exp: Likewise.
* gdb.ada/arr_acc_idx_w_gap.exp: Likewise.
* gdb.ada/arr_arr.exp: Likewise.
* gdb.ada/arr_enum_idx_w_gap.exp: Likewise.
* gdb.ada/array_bounds.exp: Likewise.
* gdb.ada/array_of_variable_length.exp: Likewise.
* gdb.ada/array_ptr_renaming.exp: Likewise.
* gdb.ada/array_subscript_addr.exp: Likewise.
* gdb.ada/arraydim.exp: Likewise.
* gdb.ada/arrayparam.exp: Likewise.
* gdb.ada/arrayptr.exp: Likewise.
* gdb.ada/assign_1.exp: Likewise.
* gdb.ada/assign_arr.exp: Likewise.
* gdb.ada/atomic_enum.exp: Likewise.
* gdb.ada/attr_ref_and_charlit.exp: Likewise.
* gdb.ada/bad-task-bp-keyword.exp: Likewise.
* gdb.ada/bias.exp: Likewise.
* gdb.ada/boolean_expr.exp: Likewise.
* gdb.ada/bp_c_mixed_case.exp: Likewise.
* gdb.ada/bp_enum_homonym.exp: Likewise.
* gdb.ada/bp_inlined_func.exp: Likewise.
* gdb.ada/bp_on_var.exp: Likewise.
* gdb.ada/bp_range_type.exp: Likewise.
* gdb.ada/bp_reset.exp: Likewise.
* gdb.ada/call_pn.exp: Likewise.
* gdb.ada/catch_assert_if.exp: Likewise.
* gdb.ada/catch_ex.exp: Likewise.
* gdb.ada/catch_ex_std.exp: Likewise.
* gdb.ada/char_enum.exp: Likewise.
* gdb.ada/char_param.exp: Likewise.
* gdb.ada/complete.exp: Likewise.
* gdb.ada/cond_lang.exp: Likewise.
* gdb.ada/convvar_comp.exp: Likewise.
* gdb.ada/dgopt.exp: Likewise.
* gdb.ada/disc_arr_bound.exp: Likewise.
* gdb.ada/display_nested.exp: Likewise.
* gdb.ada/dot_all.exp: Likewise.
* gdb.ada/dyn_loc.exp: Likewise.
* gdb.ada/dyn_stride.exp: Likewise.
* gdb.ada/excep_handle.exp: Likewise.
* gdb.ada/expr_delims.exp: Likewise.
* gdb.ada/expr_with_funcall.exp: Likewise.
* gdb.ada/exprs.exp: Likewise.
* gdb.ada/fin_fun_out.exp: Likewise.
* gdb.ada/fixed_cmp.exp: Likewise.
* gdb.ada/formatted_ref.exp: Likewise.
* gdb.ada/frame_arg_lang.exp: Likewise.
* gdb.ada/frame_args.exp: Likewise.
* gdb.ada/fullname_bp.exp: Likewise.
* gdb.ada/fun_addr.exp: Likewise.
* gdb.ada/fun_in_declare.exp: Likewise.
* gdb.ada/fun_overload_menu.exp: Likewise.
* gdb.ada/fun_renaming.exp: Likewise.
* gdb.ada/funcall_char.exp: Likewise.
* gdb.ada/funcall_param.exp: Likewise.
* gdb.ada/funcall_ptr.exp: Likewise.
* gdb.ada/funcall_ref.exp: Likewise.
* gdb.ada/homonym.exp: Likewise.
* gdb.ada/info_addr_mixed_case.exp: Likewise.
* gdb.ada/info_auto_lang.exp: Likewise.
* gdb.ada/info_exc.exp: Likewise.
* gdb.ada/info_types.exp: Likewise.
* gdb.ada/int_deref.exp: Likewise.
* gdb.ada/interface.exp: Likewise.
* gdb.ada/iwide.exp: Likewise.
* gdb.ada/lang_switch.exp: Likewise.
* gdb.ada/length_cond.exp: Likewise.
* gdb.ada/maint_with_ada.exp: Likewise.
* gdb.ada/mi_catch_assert.exp: Likewise.
* gdb.ada/mi_catch_ex.exp: Likewise.
* gdb.ada/mi_catch_ex_hand.exp: Likewise.
* gdb.ada/mi_dyn_arr.exp: Likewise.
* gdb.ada/mi_ex_cond.exp: Likewise.
* gdb.ada/mi_exc_info.exp: Likewise.
* gdb.ada/mi_interface.exp: Likewise.
* gdb.ada/mi_prot.exp: Likewise.
* gdb.ada/mi_ref_changeable.exp: Likewise.
* gdb.ada/mi_string_access.exp: Likewise.
* gdb.ada/mi_task_arg.exp: Likewise.
* gdb.ada/mi_task_info.exp: Likewise.
* gdb.ada/mi_var_array.exp: Likewise.
* gdb.ada/mi_var_union.exp: Likewise.
* gdb.ada/mi_variant.exp: Likewise.
* gdb.ada/minsyms.exp: Likewise.
* gdb.ada/mod_from_name.exp: Likewise.
* gdb.ada/nested.exp: Likewise.
* gdb.ada/null_array.exp: Likewise.
* gdb.ada/optim_drec.exp: Likewise.
* gdb.ada/out_of_line_in_inlined.exp: Likewise.
* gdb.ada/packed_array_assign.exp: Likewise.
* gdb.ada/packed_tagged.exp: Likewise.
* gdb.ada/pp-rec-component.exp: Likewise.
* gdb.ada/print_chars.exp: Likewise.
* gdb.ada/print_pc.exp: Likewise.
* gdb.ada/ptr_typedef.exp: Likewise.
* gdb.ada/ptype_arith_binop.exp: Likewise.
* gdb.ada/ptype_array.exp: Likewise.
* gdb.ada/ptype_field.exp: Likewise.
* gdb.ada/ptype_tagged_param.exp: Likewise.
* gdb.ada/ptype_union.exp: Likewise.
* gdb.ada/py_range.exp: Likewise.
* gdb.ada/py_taft.exp: Likewise.
* gdb.ada/rdv_wait.exp: Likewise.
* gdb.ada/rec_comp.exp: Likewise.
* gdb.ada/rec_return.exp: Likewise.
* gdb.ada/ref_param.exp: Likewise.
* gdb.ada/ref_tick_size.exp: Likewise.
* gdb.ada/rename_subscript_param.exp: Likewise.
* gdb.ada/repeat_dyn.exp: Likewise.
* gdb.ada/same_component_name.exp: Likewise.
* gdb.ada/same_enum.exp: Likewise.
* gdb.ada/scalar_storage.exp: Likewise.
* gdb.ada/set_wstr.exp: Likewise.
* gdb.ada/small_reg_param.exp: Likewise.
* gdb.ada/str_binop_equal.exp: Likewise.
* gdb.ada/str_ref_cmp.exp: Likewise.
* gdb.ada/str_uninit.exp: Likewise.
* gdb.ada/sub_variant.exp: Likewise.
* gdb.ada/sym_print_name.exp: Likewise.
* gdb.ada/taft_type.exp: Likewise.
* gdb.ada/tagged.exp: Likewise.
* gdb.ada/tagged_access.exp: Likewise.
* gdb.ada/task_bp.exp: Likewise.
* gdb.ada/task_switch_in_core.exp: Likewise.
* gdb.ada/tasks.exp: Likewise.
* gdb.ada/tick_last_segv.exp: Likewise.
* gdb.ada/tick_length_array_enum_idx.exp: Likewise.
* gdb.ada/type_coercion.exp: Likewise.
* gdb.ada/unc_arr_ptr_in_var_rec.exp: Likewise.
* gdb.ada/unchecked_union.exp: Likewise.
* gdb.ada/uninitialized_vars.exp: Likewise.
* gdb.ada/var_arr_attrs.exp: Likewise.
* gdb.ada/var_arr_typedef.exp: Likewise.
* gdb.ada/var_rec_arr.exp: Likewise.
* gdb.ada/variant-record.exp: Likewise.
* gdb.ada/variant.exp: Likewise.
* gdb.ada/variant_record_packed_array.exp: Likewise.
* gdb.ada/varsize_limit.exp: Likewise.
* gdb.ada/whatis_array_val.exp: Likewise.
* gdb.ada/widewide.exp: Likewise.
* gdb.ada/win_fu_syms.exp: Likewise.

4 years ago[ARM, sim] Fix build failure with -Werror (PR26365)
Luis Machado [Thu, 13 Aug 2020 13:32:52 +0000 (10:32 -0300)]
[ARM, sim] Fix build failure with -Werror (PR26365)

There is a bit of a situation in the ARM sim with regards to the handling
of argv. sim_open () gets a const char **argv, but ARM's sim_open gets
clever and decides to modify argv in place via sim_target_parse_command_line.
I'm not sure why.

In any case, here's a fix that makes the code modify a copy of argv instead.

sim/arm/ChangeLog:

2020-08-13  Luis Machado  <luis.machado@linaro.org>

PR sim/26365

* wrapper.c (sim_target_parse_command_line): Free discarded argv
entries.
(sim_open): Use a duplicate of argv instead of the original argv.

4 years agogdb: allow specifying multiple filters when running selftests
Simon Marchi [Thu, 13 Aug 2020 11:55:48 +0000 (07:55 -0400)]
gdb: allow specifying multiple filters when running selftests

I found myself wanting to run a few specific selftests while developing.
I thought it would be nice to be able to provide multiple test names
when running `maintenant selftests`.  The arguments to that command is
currently interpreted as a single filter (not split by spaces), it now
becomes a list a filters, split by spaces.  A test is executed when it
matches at least one filter.

Here's an example of the result in GDB:

    (gdb) maintenance selftest xml
    Running selftest xml_escape_text.
    Running selftest xml_escape_text_append.
    Ran 2 unit tests, 0 failed
    (gdb) maintenance selftest xml unord
    Running selftest unordered_remove.
    Running selftest xml_escape_text.
    Running selftest xml_escape_text_append.
    Ran 3 unit tests, 0 failed
    (gdb) maintenance selftest xml unord foobar
    Running selftest unordered_remove.
    Running selftest xml_escape_text.
    Running selftest xml_escape_text_append.
    Ran 3 unit tests, 0 failed

Since the selftest machinery is also shared with gdbserver, I also
adapted gdbserver.  It accepts a `--selftest` switch, which accepts an
optional filter argument.  I made it so you can now pass `--selftest`
multiple time to add filters.

It's not so useful right now though: there's only a single selftest
right now in GDB and it's for an architecture I can't compile.  So I
tested by adding dummy tests, here's an example of the result:

    $ ./gdbserver --selftest=foo
    Running selftest foo.
    foo
    Running selftest foobar.
    foobar
    Ran 2 unit tests, 0 failed
    $ ./gdbserver --selftest=foo --selftest=bar
    Running selftest bar.
    bar
    Running selftest foo.
    foo
    Running selftest foobar.
    foobar
    Ran 3 unit tests, 0 failed

gdbsupport/ChangeLog:

* selftest.h (run_tests): Change parameter to array_view.
* selftest.c (run_tests): Change parameter to array_view and use
it.

gdb/ChangeLog:

* maint.c (maintenance_selftest): Split args and pass array_view
to run_tests.

gdbserver/ChangeLog:

* server.cc (captured_main): Accept multiple `--selftest=`
options.  Pass all `--selftest=` arguments to run_tests.

Change-Id: I422bd49f08ea8095ae174c5d66a2dd502a59613a

4 years agoFix an internal compiler error when attempting to create a second $GDB_DEBUG$ section.
Nick Clifton [Thu, 13 Aug 2020 10:50:13 +0000 (11:50 +0100)]
Fix an internal compiler error when attempting to create a second $GDB_DEBUG$ section.

PR 26359
* config/obj-som.c (obj_som_init_stab_section): Do nothing if the
$GDB_DEBUG$ section has already been created.

4 years agoObsolete ia64
Alan Modra [Thu, 13 Aug 2020 04:43:43 +0000 (14:13 +0930)]
Obsolete ia64

* config.bfd: Obsolete ia64*-*-*.

4 years agoObsolete arm-symbianelf
Alan Modra [Thu, 13 Aug 2020 00:28:13 +0000 (09:58 +0930)]
Obsolete arm-symbianelf

* config.bfd: Obsolete arm*-*-symbianelf*.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 13 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoPowerPC64 --no-pcrel-optimize
Alan Modra [Wed, 12 Aug 2020 14:01:28 +0000 (23:31 +0930)]
PowerPC64 --no-pcrel-optimize

This new option effectively ignores R_PPC64_PCREL_OPT, disabling the
optimization of instructions marked by that relocation.  The patch
also disables GOT indirect to GOT/TOC pointer relative code editing
when --no-toc-optimize.

bfd/
* elf64-ppc.h (struct ppc64_elf_params): Add no_pcrel_opt.
* elf64-ppc.c (ppc64_elf_relocate_section): Disable GOT reloc
optimizations when --no-toc-optimize.  Disable R_PPC64_PCREL_OPT
optimization when --no-pcrel-optimize.
ld/
* emultempl/ppc64elf.em (params): Init new field.
(enum ppc64_opt): Add OPTION_NO_PCREL_OPT.
(PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS),
(PARSE_AND_LIST_ARGS_CASES): Support --no-pcrel-optimize.

4 years agoPR26348, Malloc error in write_zeros
Alan Modra [Wed, 12 Aug 2020 10:48:43 +0000 (20:18 +0930)]
PR26348, Malloc error in write_zeros

This adds a few more sanity checks on ELF objects, and a BFD flag to
disable objcopy and strip when fuzzed input files belong in the "too
hard" basket.

bfd/
PR 26348
* bfd.c (struct bfd): Add read_only.
* elfcode.h (elf_swap_shdr_in): Test both sh_offset and sh_size.
Set read_only on warning.
(elf_object_p): Sanity check program header alignment.  Set
read_only on warning.
* bfd-in2.h: Regenerate.
binutils/
PR 26348
* objcopy.c (copy_object): Report file name with endian error.
Error and return on abfd->read_only.

4 years agoFix malloc allocation size sanity check
Luis Machado [Wed, 12 Aug 2020 20:02:32 +0000 (17:02 -0300)]
Fix malloc allocation size sanity check

During debugging of PR26362, it was noticed that the malloc size check
in check_type_length_before_alloc wasn't detecting an allocation attempt
of a huge amount of bytes, making GDB run into an internal error.

This happens because we're using an int to store a type's length. When the
type length is large enough, the int will overflow and the max_value_size
check won't work anymore.

The following patch fixes this by making the length variable a ULONGEST.

Printing statements were also updated to show the correct number of bytes.

gdb/ChangeLog:

2020-08-12  Luis Machado  <luis.machado@linaro.org>

* value.c (check_type_length_before_alloc): Use ULONGEST to store a
type's length.
Use %s and pulongest to print the length.

4 years agoMove multi-target NEWS entry to GDB 10 features
Pedro Alves [Wed, 12 Aug 2020 18:46:13 +0000 (19:46 +0100)]
Move multi-target NEWS entry to GDB 10 features

Simon noticed that I managed to put this in the "Changes in GDB 9"
section by mistake instead of in the "Changes since GDB 9" section
where it belongs.

gdb/ChangeLog:

* NEWS: Move "Multi-target debugging support" item to the
"Changes since GDB 9" section.

4 years agogdb.base/corefile.exp regression for unix/-m32 on x86_64 (PR 26336)
Pedro Alves [Wed, 12 Aug 2020 18:31:19 +0000 (19:31 +0100)]
gdb.base/corefile.exp regression for unix/-m32 on x86_64 (PR 26336)

gdb.base/corefile.exp is showing an unexpected failure and an
unresolved testcase when testing against unix/-m32:

 (gdb) PASS: gdb.base/corefile.exp: attach: sanity check we see the core file
 attach 15741
 gdb/dwarf2-frame.c:1009: internal-error: dwarf2_frame_cache* dwarf2_frame_cache(frame_info*, void**): Assertion `fde != NULL' failed.
 A problem internal to GDB has been detected,
 further debugging may prove unreliable.
 Quit this debugging session? (y or n) FAIL: gdb.base/corefile.exp: attach: with core (GDB internal error)
 Resyncing due to internal error.

This regressed with:

 From 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2 Mon Sep 17 00:00:00 2001
 From: Pedro Alves <palves@redhat.com>
 Date: Fri, 10 Jan 2020 20:06:08 +0000
 Subject: [PATCH] Multi-target support

The assertion is here:

 #0  internal_error (file=0xbffffccb0 <error: Cannot access memory at address 0xbffffccb0>, line=0, fmt=0x555556327320 "en_US.UTF-8") at sr
 c/gdbsupport/errors.cc:51
 #1  0x00005555557d4e45 in dwarf2_frame_cache (this_frame=0x55555672f950, this_cache=0x55555672f968) at src/gdb/dwarf2/frame.c:1013
 #2  0x00005555557d5886 in dwarf2_frame_this_id (this_frame=0x55555672f950, this_cache=0x55555672f968, this_id=0x55555672f9b0) at src/gdb/d
 warf2/frame.c:1226
 #3  0x00005555558b184e in compute_frame_id (fi=0x55555672f950) at src/gdb/frame.c:558
 #4  0x00005555558b19b2 in get_frame_id (fi=0x55555672f950) at src/gdb/frame.c:588
 #5  0x0000555555bda338 in scoped_restore_current_thread::scoped_restore_current_thread (this=0x7fffffffd0d8) at src/gdb/thread.c:1458
 #6  0x00005555556ce41f in scoped_restore_current_pspace_and_thread::scoped_restore_current_pspace_and_thread (During symbol reading: .debug_line address at offset 0x1db2d3
 is 0 [in module /home/pedro/gdb/cascais-builds/binutils-gdb/gdb/gdb]
 this=0x7fffffffd0d0) at src/gdb/progspace-and-thread.h:29
 #7  0x0000555555898ea6 in remove_target_sections (owner=0x555556935550) at src/gdb/exec.c:798
 #8  0x0000555555b700b6 in symfile_free_objfile (objfile=0x555556935550) at src/gdb/symfile.c:3742
 #9  0x000055555565050e in std::_Function_handler<void (objfile*), void (*)(objfile*)>::_M_invoke(std::_Any_data const&, objfile*&&) (__functor=..., __args#0=@0x7fffffffd190
 : 0x555556935550) at /usr/include/c++/9/bits/std_function.h:300
 #10 0x0000555555a3053d in std::function<void (objfile*)>::operator()(objfile*) const (this=0x555556752a20, __args#0=0x555556935550) at /usr/include/c++/9/bits/std_function.
 h:688
 #11 0x0000555555a2ff01 in gdb::observers::observable<objfile*>::notify (this=0x5555562eaa80 <gdb::observers::free_objfile>, args#0=0x555556935550) at /net/cascais.nfs/gdb/b
 inutils-gdb/src/gdb/../gdbsupport/observable.h:106
 #12 0x0000555555a2c56a in objfile::~objfile (this=0x555556935550, __in_chrg=<optimized out>) at src/gdb/objfiles.c:521
 #13 0x0000555555a31d46 in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x555556c1f6f0) at /usr/include/c++/9/bits/shared_ptr_base.h:377
 #14 0x00005555556d3444 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x555556c1f6f0) at /usr/include/c++/9/bits/shared_ptr_base.h:155
 #15 0x00005555556cec77 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x555556b99ee8, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:730
 #16 0x0000555555a2f8da in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x555556b99ee0, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr_base.h:1169
 #17 0x0000555555a2f8fa in std::shared_ptr<objfile>::~shared_ptr (this=0x555556b99ee0, __in_chrg=<optimized out>) at /usr/include/c++/9/bits/shared_ptr.h:103
 #18 0x0000555555a63fba in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x55555679f0c0, __p=0x555556b99ee0) at /usr/include/c++/9/ext/new_allocator.h:153
 #19 0x0000555555a638fb in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=..., __p=0x555556b99ee0) at /usr/include/c++/9/bits/alloc_traits.h:497
 #20 0x0000555555a6351c in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x55555679f0c0, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556935550}) at /usr/include/c++/9/bits/stl_list.h:1921
 #21 0x0000555555a62dab in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x55555679f0c0, __position=std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x555556935550}) at /usr/include/c++/9/bits/list.tcc:158
 #22 0x0000555555a614dd in program_space::remove_objfile (this=0x55555679f080, objfile=0x555556935550) at src/gdb/progspace.c:207
 #23 0x0000555555a2c4dc in objfile::unlink (this=0x555556935550) at src/gdb/objfiles.c:497
 #24 0x0000555555a2da65 in objfile_purge_solibs () at src/gdb/objfiles.c:904
 #25 0x0000555555b3af74 in no_shared_libraries (ignored=0x0, from_tty=1) at src/gdb/solib.c:1236
 #26 0x0000555555bbafc7 in target_pre_inferior (from_tty=1) at src/gdb/target.c:1900
 #27 0x0000555555940afb in attach_command (args=0x5555563277c7 "15741", from_tty=1) at src/gdb/infcmd.c:2582
 ...

The problem is that the multi-target commit added a
scoped_restore_current_thread to remove_target_sections (frame #7
above).  scoped_restore_current_thread's ctor fetches the selected
frame's frame id.  If the frame had not had its frame id computed yet,
it is computed then (frame #4 above).  Because it has been determined
earlier that the frame's unwinder is the DWARF unwinder, we end up
here:

 static struct dwarf2_frame_cache *
 dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
 ...
   /* Find the correct FDE.  */
   fde = dwarf2_frame_find_fde (&pc1, &cache->per_objfile);
   gdb_assert (fde != NULL);

And, that assertion fails.  The assertion is reasonable, because the
DWARF unwinder only claims the frame if it managed to find the FDE
earlier (in dwarf2_frame_sniffer).

(unix/-m32 is thus really a red herring here -- it's just that on
x86_64 -m64, the frame is not claimed by the DWARF unwinder.)

The reason the assertion is failing, is because the objfile that
contains the FDE has been removed from the objfiles list already when
we get here (frame #22 above).  This suggests that the fix should be
to invalidate DWARF frames when their objfile is removed.  Or to keep
it simple and safe, invalidate the frame cache when an objfile is
removed.  That is what this commit does.

OOC, I checked why is it that when you unload a file with plain "(gdb)
file", we don't hit the assertion.  It must be because we're already
flushing the frame cache somewhere else in that case.  And indeed, we
flush the frame cache here:

 (gdb) bt
 #0  reinit_frame_cache () at src/gdb/frame.c:1857
 #1  0x0000555555ad1ad6 in registers_changed_ptid (target=0x0, ptid=...) at src/gdb/regcache.c:470
 #2  0x0000555555ad1b58 in registers_changed () at src/gdb/regcache.c:485
 #3  0x00005555558d095e in set_target_gdbarch (new_gdbarch=0x555556d5f5b0) at src/gdb/gdbarch.c:5528
 #4  0x0000555555677175 in set_gdbarch_from_file (abfd=0x0) at src/gdb/arch-utils.c:601
 #5  0x0000555555897c6b in exec_file_attach (filename=0x0, from_tty=1) at src/gdb/exec.c:409
 #6  0x000055555589852d in exec_file_command (args=0x0, from_tty=1) at src/gdb/exec.c:571
 #7  0x00005555558985a1 in file_command (arg=0x0, from_tty=1) at src/gdb/exec.c:583
 #8  0x000055555572b55f in do_const_cfunc (c=0x55555672e200, args=0x0, from_tty=1) at src/gdb/cli/cli-decode.c:95
 #9  0x000055555572f3d3 in cmd_func (cmd=0x55555672e200, args=0x0, from_tty=1) at src/gdb/cli/cli-decode.c:2181
 #10 0x0000555555be1ecc in execute_command (p=0x555556327804 "", from_tty=1) at src/gdb/top.c:668
 #11 0x0000555555895427 in command_handler (command=0x555556327800 "file") at src/gdb/event-top.c:588
 #12 0x00005555558958af in command_line_handler (rl=...) at src/gdb/event-top.c:773
 #13 0x0000555555894b3e in gdb_rl_callback_handler (rl=0x55555a09e240 "file") at src/gdb/event-top.c:219
 #14 0x0000555555ccfeec in rl_callback_read_char () at src/readline/readline/callback.c:281
 #15 0x000055555589495a in gdb_rl_callback_read_char_wrapper_noexcept () at src/gdb/event-top.c:177
 #16 0x0000555555894a08 in gdb_rl_callback_read_char_wrapper (client_data=0x555556327520) at src/gdb/event-top.c:194
 #17 0x00005555558952a5 in stdin_event_handler (error=0, client_data=0x555556327520) at src/gdb/event-top.c:516
 #18 0x0000555555e027d6 in handle_file_event (file_ptr=0x555558d20840, ready_mask=1) at src/gdbsupport/event-loop.cc:548
 #19 0x0000555555e02d88 in gdb_wait_for_event (block=1) at src/gdbsupport/event-loop.cc:673
 #20 0x0000555555e01c42 in gdb_do_one_event () at src/gdbsupport/event-loop.cc:215
 #21 0x00005555559c47c2 in start_event_loop () at src/gdb/main.c:356
 #22 0x00005555559c490d in captured_command_loop () at src/gdb/main.c:416
 #23 0x00005555559c6217 in captured_main (data=0x7fffffffdc00) at src/gdb/main.c:1253
 #24 0x00005555559c6289 in gdb_main (args=0x7fffffffdc00) at src/gdb/main.c:1268
 #25 0x0000555555621756 in main (argc=3, argv=0x7fffffffdd18) at src/gdb/gdb.c:32

gdb/ChangeLog:

PR gdb/26336
* progspace.c (program_space::remove_objfile): Invalidate the
frame cache.

4 years ago[PATCH] gas: arm: Fix IT-predicated MVE vcvt
Joe Ramsay [Wed, 12 Aug 2020 15:44:54 +0000 (16:44 +0100)]
[PATCH] gas: arm: Fix IT-predicated MVE vcvt

* config/tc-arm.c (do_neon_cvt_1): Parse vcvtne as vcvt-ne for
NS_FD shape when MVE is present
* testsuite/gas/arm/mve-vcvtne-it-bad.d: New test.
* testsuite/gas/arm/mve-vcvtne-it-bad.l: New test.
* testsuite/gas/arm/mve-vcvtne-it-bad.s: New test.
* testsuite/gas/arm/mve-vcvtne-it.d: New test.
* testsuite/gas/arm/mve-vcvtne-it.s: New test.

4 years agoFix signedness comparison warning in elfcore_grok_win32pstatus()
Jon Turney [Wed, 12 Aug 2020 15:34:47 +0000 (16:34 +0100)]
Fix signedness comparison warning in elfcore_grok_win32pstatus()

bfd/ChangeLog:

2020-08-12  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Use unsigned int for
win32pstatus note type to avoid signedness comparison warning.

4 years agoTwo fixes in dwarf-mode.el
Tom Tromey [Wed, 12 Aug 2020 14:41:03 +0000 (08:41 -0600)]
Two fixes in dwarf-mode.el

This fixes a couple of small problems in dwarf-mode.el.

First, I noticed that for an attribute like:

 <2><136c>: Abbrev Number: 11 (DW_TAG_member)
    <136d>   DW_AT_name        : t

... the "t" would not be font-locked using the function name face.
The problem here is that the regexp assumed the indirect string
format, like:

    <12ac>   DW_AT_name        : (indirect string, offset: 0x1b40): whatever

Here the fix is to adjust the regexp to match both formats.

Second, when following a DIE reference, point could end up on an
attribute instead.  This happens when there is a zero-length attribute
with the same "offset" as the following DIE, like:

    <12c5>   DW_AT_GNU_all_call_sites: 1
 <2><12c5>: Abbrev Number: 5 (DW_TAG_formal_parameter)

Here the fix is to search for the DIE by looking for the depth ("<2>"
in the example) as well.

I've bumped the internal version number to make it simpler to install
this using the Emacs package facility.

binutils/ChangeLog
2020-08-12  Tom Tromey  <tromey@adacore.com>

* dwarf-mode.el (Version): Now 1.6.
(dwarf-die-button-action): Tighten DIE reference regexp.
(dwarf-font-lock-keywords): Update name regexp.

4 years agoOnly warn about malformed win32pstatus notes
Jon Turney [Fri, 17 Jul 2020 14:25:47 +0000 (15:25 +0100)]
Only warn about malformed win32pstatus notes

bfd/ChangeLog:

2020-07-21  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Warn on malformed
win32pstatus notes, and return TRUE so we continue rather than
stopping as if it was an error.

4 years agoAdd handling for 64-bit module addresses in Cygwin core dumps
Jon Turney [Mon, 29 Jun 2020 16:11:51 +0000 (17:11 +0100)]
Add handling for 64-bit module addresses in Cygwin core dumps

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Handle NOTE_INFO_MODULE64.

4 years agoRefine size constraints applied to win32pstatus ELF notes
Jon Turney [Wed, 1 Jul 2020 15:18:23 +0000 (16:18 +0100)]
Refine size constraints applied to win32pstatus ELF notes

Don't reject any win32pstatus notes smaller than minimum size for a
NOTE_INFO_THREAD.

This only happens to work because the Cygwin dumper tool currently
writes all these notes as the largest size of the union, (which wastes
lots of space in the core dump).

Instead, apply the appropriate size constraint for each win32pstatus
note type.

bfd/ChangeLog:

2020-07-11  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Don't apply size constraint
for NOTE_INFO_THREAD to all win32pstatus ELF notes, instead apply
appropriate size constraint for each win32pstatus note type.

4 years agoDon't hardcode CONTEXT size for a NOTE_INFO_THREAD win32pstatus note
Jon Turney [Mon, 29 Jun 2020 16:15:02 +0000 (17:15 +0100)]
Don't hardcode CONTEXT size for a NOTE_INFO_THREAD win32pstatus note

Don't hardcode the size of the Win32 API thread CONTEXT type read from a
NOTE_INFO_THREAD win32pstatus note (since it's different on different
architectures).

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Don't hardcode the size of
the Win32 API thread CONTEXT type read from a NOTE_INFO_THREAD
win32pstatus note.

4 years agoDefine constants for win32pstatus ELF notes
Jon Turney [Sat, 11 Jul 2020 13:02:17 +0000 (14:02 +0100)]
Define constants for win32pstatus ELF notes

Define constants for win32pstatus ELF notes, as they were prior to
4a6636fb, and say what specifies them.

bfd/ChangeLog:

2020-07-11  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (NOTE_INFO{_PROCESS,_THREAD,_MODULE}): Define.
(elfcore_grok_win32pstatus): Use.

4 years agoRead tid from correct offset in win32pstatus NOTE_INFO_THREAD
Jon Turney [Mon, 29 Jun 2020 14:54:41 +0000 (15:54 +0100)]
Read tid from correct offset in win32pstatus NOTE_INFO_THREAD

Fix the offset used to read the tid from a win32pstatus ELF note.

This probably meant that registers were only being correctly recovered
from the core dump for the current thread.

It looks like this has beeen incorrect since 4a6636fb.

Also fix offsets used in NOTE_INFO_PROCESS (which is not actually
generated by the Cygwin dumper tool).

Also improve comment.

bfd/ChangeLog:

2020-07-01  Jon Turney  <jon.turney@dronecode.org.uk>

* elf.c (elfcore_grok_win32pstatus): Fix the offset used to read
the tid from a win32pstatus NOTE_INFO_THREAD ELF note.  Fix
offsets used to read NOTE_INFO_PROCESS.

4 years agoFix duplicate label in gdb.dwarf2/dw2-op-out-param.S
Gary Benson [Wed, 12 Aug 2020 13:48:55 +0000 (14:48 +0100)]
Fix duplicate label in gdb.dwarf2/dw2-op-out-param.S

gdb.dwarf2/dw2-op-out-param.S contained a duplicate label, and failed
to build with clang with the following error:

 gdb compile failed, /gdbtest/src/gdb/testsuite/gdb.dwarf2/dw2-op-out-param.S:163:1:
       error: invalid symbol redefinition
 .Ltext5:
 ^

This commit renames the two labels as .Ltext5a and .Ltext5b, and
updates all references appropriately.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-op-out-param.S (.Ltext5): Fix duplicate label.

4 years agoaarch64: Add support for MPAM system registers
Alex Coplan [Wed, 12 Aug 2020 12:49:54 +0000 (13:49 +0100)]
aarch64: Add support for MPAM system registers

This patch adds support for the system registers introduced in the
Armv8-A MPAM extension.

See https://developer.arm.com/documentation/ddi0598/latest for the
Arm ARM supplement documenting this extension.

gas/ChangeLog:

* testsuite/gas/aarch64/mpam-bad.d: New test.
* testsuite/gas/aarch64/mpam-bad.l: Error output.
* testsuite/gas/aarch64/mpam-bad.s: Input.
* testsuite/gas/aarch64/mpam.d: New test.
* testsuite/gas/aarch64/mpam.s: Input.

opcodes/ChangeLog:

* aarch64-opc.c (aarch64_sys_regs): Add MPAM registers.

4 years agoThe description for -mno-csr-check talks about "cheching" rather than "checking".
Nick Clifton [Wed, 12 Aug 2020 12:47:04 +0000 (13:47 +0100)]
The description for -mno-csr-check talks about "cheching" rather than "checking".

PR 26346
* doc/c-riscv.texi (RISC-V-Options): Fix typo in the description
of the -mno-csr-check option.

4 years agoAdd demangling support to readelf.
Nick Clifton [Wed, 12 Aug 2020 12:31:59 +0000 (13:31 +0100)]
Add demangling support to readelf.

PR binutils/26331
* readelf.c (do_demangle): New option flag.
(print_symbol): If do_demangle is enabled, demangle the symbol.
(enum long_option_values): New enum to hold long option values.
(options): Add demangle, no-demangle, recursion-limit and
no-recursion-limit options.  Alpha sort the table.
(usage): Describe the new options.
(parse_args): Handle the new options.
* NEWS: Mention the new feature.
* doc/binutils.texi: Document the new feature.
* testsuite/binutils-all/readelf.exp: Test the new feature.
* testsuite/binutils-all/mangled.s: New file - assembler source.
* testsuite/binutils-all/readelf.demangled: New file - expected
output from readelf.

4 years agoUpdated Serbian and Russian translations for various sub-directories
Nick Clifton [Wed, 12 Aug 2020 10:25:38 +0000 (11:25 +0100)]
Updated Serbian and Russian translations for various sub-directories

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 12 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoPowerPC CELL cctp*
Alan Modra [Tue, 11 Aug 2020 07:50:04 +0000 (17:20 +0930)]
PowerPC CELL cctp*

* ppc-opc.c (powerpc_opcodes): Move cctpl, cctpm and cctph.

4 years ago[gdb/build] Mark ms1 as deleted in MAINTAINERS
Tom de Vries [Tue, 11 Aug 2020 09:07:54 +0000 (11:07 +0200)]
[gdb/build] Mark ms1 as deleted in MAINTAINERS

When running gdb/gdb_mbuild.sh, we run into:
...
ms1-elf ...
... src/configure --target=ms1-elf --enable-gdb-build-warnings=,-Werror \
  --enable-sim-build-warnings=,-Werror
... make -k -j 5 ms1-elf
ms1-elf: compile failed
...

In mbuild/ms1-elf/Build.log we find:
...
*** Configuration mt-unknown-elf is obsolete.
*** Support has been REMOVED.
make: *** [Makefile:10995: configure-gdb] Error 1
...

The support for ms1-elf, aka mt-elf, has been removed since commit dc71152484
"Remove mt port" in Jan 2018.  Make this official in the MAINTAINERS file.

Tested using gdb/gdb_mbuild.sh.

gdb/ChangeLog:

2020-08-11  Tom de Vries  <tdevries@suse.de>

* MAINTAINERS: Mark ms1 as deleted.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 11 Aug 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agoaarch64: Don't assert on long sysreg names
Alex Coplan [Mon, 10 Aug 2020 16:44:02 +0000 (17:44 +0100)]
aarch64: Don't assert on long sysreg names

This patch fixes an assertion failure on long system register operands
in the AArch64 backend. See the new testcase for an input which
reproduces the issue.

gas/ChangeLog:

* config/tc-aarch64.c (parse_sys_reg): Don't assert when parsing
a long system register.
(parse_sys_ins_reg): Likewise.
(sysreg_hash_insert): New.
(md_begin): Use sysreg_hash_insert() to ensure all system
registers are no longer than the maximum length at startup.
* testsuite/gas/aarch64/invalid-sysreg-assert.d: New test.
* testsuite/gas/aarch64/invalid-sysreg-assert.l: Error output.
* testsuite/gas/aarch64/invalid-sysreg-assert.s: Input.

include/ChangeLog:

* opcode/aarch64.h (AARCH64_MAX_SYSREG_NAME_LEN): New.

4 years agoRemove spurious text in changelog entry
Nick Clifton [Mon, 10 Aug 2020 16:24:45 +0000 (17:24 +0100)]
Remove spurious text in changelog entry

4 years agoImprove the documentation of the linker's --relax option.
Nick Clifton [Mon, 10 Aug 2020 15:35:57 +0000 (16:35 +0100)]
Improve the documentation of the linker's --relax option.

PR ld/21351
* ld.texi: Clarify the behaviour of the --relax and --no-relax
options on systems that do not support them.

4 years ago[sim] Fix mbuild build breaker in sim-cpu.c
Tom de Vries [Mon, 10 Aug 2020 15:26:09 +0000 (17:26 +0200)]
[sim] Fix mbuild build breaker in sim-cpu.c

When running gdb/gdb_mbuild.sh, I run into:
...
src/sim/aarch64/../common/sim-cpu.c: In function 'sim_cpu_free':
src/sim/aarch64/../common/sim-cpu.c:64:3: error: implicit declaration of \
  function 'free' [-Werror=implicit-function-declaration]
   free (cpu);
   ^~~~
src/sim/aarch64/../common/sim-cpu.c:64:3: error: incompatible implicit \
  declaration of built-in function 'free' [-Werror]
src/sim/aarch64/../common/sim-cpu.c:64:3: note: include '<stdlib.h>' or \
  provide a declaration of 'free'
...

Fix this by adding "#include <stdlib.h>".

Tested by gdb/gdb_mbuild.sh -e aarch64-elf.

sim/common/ChangeLog:

2020-08-10  Tom de Vries  <tdevries@suse.de>

* sim-cpu.c: Include stdlib.h for free.

4 years ago[aarch64] GAS doesn't validate the architecture version for any tlbi registers. ...
Przemyslaw Wirkus [Mon, 10 Aug 2020 15:20:17 +0000 (16:20 +0100)]
[aarch64] GAS doesn't validate the architecture version for any tlbi registers.  Fixed with this patch.

* gas/config/tc-aarch64.c (parse_sys_reg): Call to
aarch64_sys_ins_reg_supported_p instead of aarch64_sys_reg_supported_p.
(parse_sys_ins_reg): Add aarch64_sys_reg_deprecated_p check.
* include/opcode/aarch64.h (aarch64_sys_reg_deprecated_p): Functions
paramaters changed.
(aarch64_sys_reg_supported_p): Function removed.
(aarch64_sys_ins_reg_supported_p): Functions paramaters changed.
* opcodes/aarch64-opc.c (aarch64_print_operand):
(aarch64_sys_reg_deprecated_p): Functions paramaters changed.
(aarch64_sys_reg_supported_p): Function removed.
(aarch64_sys_ins_reg_supported_p): Functions paramaters changed.
(aarch64_sys_ins_reg_supported_p): Merged aarch64_sys_reg_supported_p
into this function.
* gas/testsuite/gas/aarch64/illegal-sysreg-5.d: New test.
* gas/testsuite/gas/aarch64/illegal-sysreg-5.l: New test.
* gas/testsuite/gas/aarch64/sysreg-5.s: New test.

4 years ago[AArch64] Improve prologue handling (and fix PR26310)
Luis Machado [Mon, 10 Aug 2020 14:56:19 +0000 (11:56 -0300)]
[AArch64] Improve prologue handling (and fix PR26310)

I initially noticed the problem with the addition of
gdb.dwarf2/dw2-line-number-zero.exp.  The following failures showed up:

FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar1
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 1st next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar1, 2nd next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: continue to breakpoint: bar2
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 1st next
FAIL: gdb.dwarf2/dw2-line-number-zero.exp: bar2, 2nd next

They happen because AArch64's prologue analyzer skips too many instructions
and ends up indicating a stopping point further into user code.

Dump of assembler code for function bar1:
   0x00000000000006f8 <+0>: stp x29, x30, [sp, #-16]!
   0x00000000000006fc <+4>: mov x29, sp
   0x0000000000000700 <+8>: mov w0, #0x1                    // #1
   0x0000000000000704 <+12>: bl 0x6e4 <foo>
   0x0000000000000708 <+16>: mov w0, #0x2                    // #2

We should've stopped at 0x700, but the analyzer actually skips
that instruction and stops at 0x704.  Then GDB ends up adjusting
the address further, and pushes the stopping point to 0x708 based on the
SAL information.

I'm not sure if this adjustment to 0x708 is correct though, as it ends up
skipping past a branch. But I'm leaving that aside for now.

One other complicating factor is that GCC seems to be hoisting up instructions
from user code, mixing them up with prologue instructions.

The following patch adjusts the heuristics a little bit, and tracks when the
SP and FP get used.  If we notice an instruction that is not supposed to be
in the prologue, and this happens *after* SP/FP adjustments and saving of
registers, we stop the analysis.

This means, for PR26310, that we will now stop at 0x700.

I've also added a few more unit tests to make sure the updated behavior is
validated.

gdb/ChangeLog:

2020-08-10  Luis Machado  <luis.machado@linaro.org>

PR gdb/26310

* aarch64-tdep.c (aarch64_analyze_prologue): Track use of SP/FP and
act accordingly.
(aarch64_analyze_prologue_test): Add more unit tests to exercise
movz/str/stur/stp skipping behavior.

4 years ago[AArch64] Fix incorrectly-defined SVE macro
Luis Machado [Mon, 10 Aug 2020 14:50:53 +0000 (11:50 -0300)]
[AArch64] Fix incorrectly-defined SVE macro

The kernel has fixed this here:

https://lore.kernel.org/patchwork/patch/1029011/

We should do the same for GDB, which is still carrying an incorrect
definition of the macro.  As stated in the kernel patch thread, this doesn't
actually change things because, luckily, the structs are of the same size.

gdb/ChangeLog:

2020-08-10  Luis Machado  <luis.machado@linaro.org>

* nat/aarch64-sve-linux-sigcontext.h (SVE_PT_REGS_OFFSET): Use
struct user_sve_header instead of struct sve_context.

4 years agoImplement missing powerpc mtspr and mfspr extended insns
Alan Modra [Mon, 10 Aug 2020 12:11:36 +0000 (21:41 +0930)]
Implement missing powerpc mtspr and mfspr extended insns

* ppc-opc.c (powerpc_opcodes): Add many mtspr and mfspr extended
instructions.

4 years agoImplement missing powerpc extended mnemonics
Alan Modra [Mon, 10 Aug 2020 05:38:27 +0000 (15:08 +0930)]
Implement missing powerpc extended mnemonics

gas/
* testsuite/gas/ppc/power8.d,
* testsuite/gas/ppc/power8.s: Add miso.
* testsuite/gas/ppc/power9.d,
* testsuite/gas/ppc/power8.s: Add exser, msgsndu, msgclru.
opcodes/
* ppc-opc.c (powerpc_opcodes): Add exser, msgsndu, msgclru.
Enable icbt for power5, miso for power8.

4 years agoPrioritise mtfprd and mtvrd over mtvsrd in PowerPC disassembly
Alan Modra [Mon, 10 Aug 2020 05:37:33 +0000 (15:07 +0930)]
Prioritise mtfprd and mtvrd over mtvsrd in PowerPC disassembly

gas/
* testsuite/gas/ppc/power8.d: Update.
* testsuite/gas/ppc/vsx2.d: Update.
opcodes/
* ppc-opc.c (powerpc_opcodes): Prioritise mtfprd and mtvrd over
mtvsrd, and similarly for mfvsrd.

4 years agoError on lmw, lswi and related PowerPC insns when LE
Alan Modra [Mon, 10 Aug 2020 05:36:43 +0000 (15:06 +0930)]
Error on lmw, lswi and related PowerPC insns when LE

* config/tc-ppc.c (md_assemble): Error for lmw, stmw, lswi, lswx,
stswi, or stswx in little-endian mode.
* testsuite/gas/ppc/476.d,
* testsuite/gas/ppc/476.s: Delete lmw, stmw, lswi, lswx, stswi, stswx.
* testsuite/gas/ppc/a2.d,
* testsuite/gas/ppc/a2.s: Move lmw, stmw, lswi, lswx, stswi, stswx..
* testsuite/gas/ppc/be.d,
* testsuite/gas/ppc/be.s: ..to here, new big-endian only test.
* testsuite/gas/ppc/le_error.d,
* testsuite/gas/ppc/le_error.l: New little-endian test.
* testsuite/gas/ppc/ppc.exp: Run new tests.

4 years agonm: Remove --with-symbol-versions
H.J. Lu [Mon, 10 Aug 2020 12:17:28 +0000 (05:17 -0700)]
nm: Remove --with-symbol-versions

Since

commit 7e6e972f74aeac0ebdbd95a7f905d871cd2581de
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Mar 24 04:23:11 2020 -0700

    bfd: Display symbol version for nm -D

always displays symbol version for nm, remove --with-symbol-versions and
silently accept it for backward compatibility.

binutils/

PR binutils/26302
* nm.c (with_symbol_versions): Removed.
(long_option_values): Add OPTION_WITH_SYMBOL_VERSIONS.
(long_options): Update --with-symbol-versions entry.
(print_symbol): Remove the with_symbol_versions check.
(main): Add OPTION_WITH_SYMBOL_VERSIONS for backward
compatibility.
* doc/binutils.texi: Remove --with-symbol-versions.

ld/

PR binutils/26302
* testsuite/ld-elf/pr26302.nd: New file.
* testsuite/ld-elf/pr26302.ver: Likewise.
* testsuite/ld-elf/pr26302a.c: Likewise.
* testsuite/ld-elf/pr26302b.c: Likewise.
* testsuite/ld-elf/shared.exp: Run binutils/26302 tests.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 10 Aug 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: replace function pointer with `void *` data with function_view
Simon Marchi [Sun, 9 Aug 2020 22:26:48 +0000 (18:26 -0400)]
gdb: replace function pointer with `void *` data with function_view

Replace the function pointer + `void *` parameters of
dwarf2_fetch_die_loc_sect_off and dwarf2_fetch_die_loc_cu_off with a
function_view parameter.  Change call sites to use a lambda function.
This improves type-safety, so reduces the chances of errors.

gdb/ChangeLog:

* read.h (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off): Replace function pointer +
`void *` parameter with function_view.
* read.c (dwarf2_fetch_die_loc_sect_off,
dwarf2_fetch_die_loc_cu_off): Likewise.
* loc.c (get_frame_pc_for_per_cu_dwarf_call): Remove.
(per_cu_dwarf_call): Adjust.
(get_frame_address_in_block_wrapper): Remove.
(indirect_synthetic_pointer): Adjust.
(get_ax_pc): Remove.
(dwarf2_compile_expr_to_ax): Adjust.

Change-Id: Ic9b6ced0c4128f2b75ca62e0ed638b0962a22859

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 9 Aug 2020 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years ago[gdb/build] Fix missing implicit constructor call with gcc 4.8
Tom de Vries [Sat, 8 Aug 2020 21:34:19 +0000 (23:34 +0200)]
[gdb/build] Fix missing implicit constructor call with gcc 4.8

When building gdb on x86_64-linux with --enable-targets riscv64-suse-linux, I
run into:
...
src/gdb/arch/riscv.c:112:45:   required from here
/usr/include/c++/4.8/bits/hashtable_policy.h:195:39: error: no matching \
  function for call to 'std::pair<const riscv_gdbarch_features, const \
  std::unique_ptr<target_desc, target_desc_deleter> >::pair(const \
  riscv_gdbarch_features&, target_desc*&)'
  : _M_v(std::forward<_Args>(__args)...) { }
                                       ^
...
for this code in riscv_lookup_target_description:
...
  /* Add to the cache.  */
  riscv_tdesc_cache.emplace (features, tdesc);
...

Work around this compiler problem (filed as PR gcc/96537), similar to how that
was done in commit 6d0cf4464e "Fix build with gcc-4.8.x":
...
-  riscv_tdesc_cache.emplace (features, tdesc);
+  riscv_tdesc_cache.emplace (features, target_desc_up (tdesc));
...
That is, call the target_desc_up constructor explictly instead of implicitly.

Also, work around a similar issue in get_thread_arch_aspace_regcache.

Build on x86_64-linux with --enable-targets riscv64-suse-linux, and
reg-tested.

gdb/ChangeLog:

2020-08-08  Tom de Vries  <tdevries@suse.de>

PR build/26344
* arch/riscv.c (riscv_lookup_target_description): Use an explicit
constructor.
* regcache.c (get_thread_arch_aspace_regcache): Same.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Aug 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agobpf: add missing tests from previous commits
Jose E. Marchesi [Fri, 7 Aug 2020 18:40:01 +0000 (20:40 +0200)]
bpf: add missing tests from previous commits

2020-08-07  David Faust  <david.faust@oracle.com>

* testsuite/ld-bpf/call-3.s: New file.
* testsuite/ld-bpf/call-3.d: Likewise.

4 years agobpf: fix false overflow in eBPF ELF backend linker
David Faust [Fri, 7 Aug 2020 18:36:47 +0000 (20:36 +0200)]
bpf: fix false overflow in eBPF ELF backend linker

When performing DISP{16,32} relocations, the eBPF ELF backend linker
needs to convert the relocation from an address into a signed number
of 64-bit words (minus one) to jump.

Because of this unsigned-to-signed conversion, special care needs to
be taken when dividing to ensure the sign bits remain correct.
Otherwise, a false relocation overflow error can be triggered.

bfd/ChangeLog

2020-08-07  David Faust  <david.faust@oracle.com>

* elf64-bpf.c (bpf_elf_relocate_section): Ensure signed division for
DISP16 and DISP32 relocations.

ld/ChangeLog

2020-08-07  David Faust  <david.faust@oracle.com>

* testsuite/ld-bpf/call-3.s: New file.
* testsuite/ld-bpf/call-3.d: Likewise.

4 years agogdb: fix whitespace issues in ChangeLog
Simon Marchi [Fri, 7 Aug 2020 15:29:45 +0000 (11:29 -0400)]
gdb: fix whitespace issues in ChangeLog

Change-Id: Iea4bd2096bb994ec4ea9145cbe316aa345e8c6db

4 years agoFix remaining Ravenscar regressions
Tom Tromey [Fri, 7 Aug 2020 16:26:45 +0000 (10:26 -0600)]
Fix remaining Ravenscar regressions

Testing showed a few more Ravenscar regressions arising from upstream.
In particular, gdb now uses the current thread in some places where
inferior_ptid was previously used.  This patch fixes the problem by
arranging to save and restore the thread now.

gdb/ChangeLog
2020-08-07  Tom Tromey  <tromey@adacore.com>

* ravenscar-thread.c
(ravenscar_thread_target::set_base_thread_from_ravenscar_task):
New method.
(ravenscar_thread_target::wait): Check
runtime_initialized.
(ravenscar_thread_target::prepare_to_store)
(ravenscar_thread_target::stopped_by_sw_breakpoint)
(ravenscar_thread_target::stopped_by_hw_breakpoint)
(ravenscar_thread_target::stopped_by_watchpoint)
(ravenscar_thread_target::stopped_data_address)
(ravenscar_thread_target::core_of_thread): Use
scoped_restore_current_thread and
set_base_thread_from_ravenscar_task.

4 years agoSet inferior_ptid in ravenscar_thread_target::update_thread_list
Tom Tromey [Fri, 7 Aug 2020 16:26:45 +0000 (10:26 -0600)]
Set inferior_ptid in ravenscar_thread_target::update_thread_list

Commit 2da4b788f ("Don't write to inferior_ptid in
ravenscar-thread.c") caused a Ravenscar regression (which, FWIW, is
understandable because Ravenscar is difficult to test).  Namely,
ravenscar_thread_target::update_thread_list calls
iterate_over_live_ada_tasks, which calls ada_build_task_list, which
uses target_has_stack -- which relies on inferior_ptid.

This patch changes update_thread_list to ensure that inferior_ptid is
set before making this call.  This avoids various failures on
Ravenscar targets.

gdb/ChangeLog
2020-08-07  Tom Tromey  <tromey@adacore.com>

* ravenscar-thread.c (update_thread_list): Set inferior_ptid.

4 years agoFetch registers from correct thread in ravenscar-thread.c
Tom Tromey [Fri, 7 Aug 2020 16:26:45 +0000 (10:26 -0600)]
Fetch registers from correct thread in ravenscar-thread.c

Fabien also noticed that gdb would not report a stop correctly when
using Ravenscar.  This patch fixes the bug by making a few changes:

* ravenscar_thread_target::wait now updates the inferior ptid before
  updating the thread list.  This ensures that a new thread is
  correctly associated with the underlying CPU.

* The fetch_registers, store_registers, and prepare_to_store methods
  now save and restore the regcache's ptid before doing the operation
  on the underlying live thread.  This ensures that gdb informs the
  remote of a thread it knows about, as opposed to using a Ravenscar
  thread, which probably will not be recognized.

gdb/ChangeLog
2020-08-07  Tom Tromey  <tromey@adacore.com>

* ravenscar-thread.c (ravenscar_thread_target::wait): Call
update_inferior_ptid before update_thread_list.
(temporarily_change_regcache_ptid): New class.
(ravenscar_thread_target::fetch_registers)
(ravenscar_thread_target::store_registers)
(ravenscar_thread_target::prepare_to_store): Use base thread when
forwarding operation.