binutils-gdb.git
4 years agogold: Update GNU_PROPERTY_X86_XXX macros
H.J. Lu [Tue, 13 Oct 2020 12:20:49 +0000 (05:20 -0700)]
gold: Update GNU_PROPERTY_X86_XXX macros

This patch updates GNU_PROPERTY_X86_XXX macros for gold:

1. GNU_PROPERTY_X86_UINT32_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_AND_LO      0xc0000002
 #define GNU_PROPERTY_X86_UINT32_AND_HI      0xc0007fff

2. GNU_PROPERTY_X86_UINT32_OR_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_LO    0xc0008000
 #define GNU_PROPERTY_X86_UINT32_OR_HI    0xc000ffff

3. GNU_PROPERTY_X86_UINT32_OR_AND_XXX: A 4-byte unsigned integer property.
A bit is set if it is set in any relocatable inputs and the property is
present in all relocatable inputs:

 #define GNU_PROPERTY_X86_UINT32_OR_AND_LO   0xc0010000
 #define GNU_PROPERTY_X86_UINT32_OR_AND_HI   0xc0017fff

4. GNU_PROPERTY_X86_FEATURE_2_NEEDED, GNU_PROPERTY_X86_FEATURE_2_USED
and GNU_PROPERTY_X86_FEATURE_2_XXX bits.

GNU_PROPERTY_X86_FEATURE_1_AND is unchanged.  GNU_PROPERTY_X86_ISA_1_USED
and GNU_PROPERTY_X86_ISA_1_NEEDED are updated to better support targeted
processors since GNU_PROPERTY_X86_ISA_1_?86 aren't isn't very useful.
A new set of GNU_PROPERTY_X86_ISA_1_XXX bits are defined.  The previous
GNU_PROPERTY_X86_ISA_1_XXX macros are deprecated and renamed to
GNU_PROPERTY_X86_COMPAT_ISA_1_XXX and GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.

elfcpp/

* elfcpp.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_USED): This.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED): This.
(GNU_PROPERTY_X86_UINT32_AND_LO): New.
(GNU_PROPERTY_X86_UINT32_AND_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_HI): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_LO): Likewise.
(GNU_PROPERTY_X86_UINT32_OR_AND_HI): Likewise.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): New.
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): Likewise.
(GNU_PROPERTY_X86_FEATURE_1_AND): Updated to
(GNU_PROPERTY_X86_UINT32_AND_LO + 0).
(GNU_PROPERTY_X86_ISA_1_NEEDED): New.  Defined to
GNU_PROPERTY_X86_UINT32_OR_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_NEEDED): New.  Defined to
(GNU_PROPERTY_X86_UINT32_OR_LO + 1).
(GNU_PROPERTY_X86_ISA_1_USED): New.  Defined to
GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2.
(GNU_PROPERTY_X86_FEATURE_2_USED): New.  Defined to
(GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1).

gold/

* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
feature_2_used_, feature_2_needed_ and object_feature_2_used_.
(Target_x86_64::feature_2_used_): New data member.
(Target_x86_64::feature_2_needed_): Likewise.
(Target_x86_64::object_isa_1_used_): Likewise.
(Target_x86_64::record_gnu_property): Support
GNU_PROPERTY_X86_COMPAT_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED,
GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED,
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
(Target_x86_64::merge_gnu_properties): Merge FEATURE_2_USED bits.
Initialize object_feature_2_used_.
(Target_x86_64::do_finalize_gnu_properties): Support
GNU_PROPERTY_X86_FEATURE_2_USED and
GNU_PROPERTY_X86_FEATURE_2_NEEDED.
* testsuite/gnu_property_a.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_b.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_c.S (GNU_PROPERTY_X86_ISA_1_USED): Set
to 0xc0010002.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Set to 0xc0008002.
* testsuite/gnu_property_test.sh: Updated.

4 years agogold: Properly align the NT_GNU_PROPERTY_TYPE_0 note
H.J. Lu [Tue, 13 Oct 2020 12:18:13 +0000 (05:18 -0700)]
gold: Properly align the NT_GNU_PROPERTY_TYPE_0 note

The NT_GNU_PROPERTY_TYPE_0 note should be aligned to 8 bytes for 64-bit
ELF as specified by gABI.  A note section can be only placed in a PT_NOTE
segment with the same alignment.

PR gold/22914
PR gold/23535
* layout.cc (Layout::attach_allocated_section_to_segment): Place
a note section in a PT_NOTE segment with the same alignment.  Set
the alignment of the PT_NOTE segment from the alignment of the
note section.
(Layout::create_note): Align the NT_GNU_PROPERTY_TYPE_0 note to 8
bytes for 64-bit ELF.
(Layout::segment_precedes): Place segments with larger alignments
first.
* output.cc (Output_segment::Output_segment): Initialize align_.
* output.h (Output_segment): Add align, set_align and align_.
* testsuite/Makefile.am (gnu_property_test.stdout): Pass -lhSWn
to $(TEST_READELF).
(gnu_property_test): Pass --build-id to ld.
* testsuite/Makefile.in: Regenerated.
* testsuite/gnu_property_test.sh (check_alignment): New.
Use check_alignment to check the NT_GNU_PROPERTY_TYPE_0 note
alignment.  Verify that there are 2 PT_NOTE segments.

4 years agoGold: Enable safe ICF for shared object on x86-64
H.J. Lu [Tue, 13 Oct 2020 12:10:24 +0000 (05:10 -0700)]
Gold: Enable safe ICF for shared object on x86-64

With

commit 4aebb6312eb5dcd12f2f8420028547584b708907
Author: Rahul Chaudhry <rahulchaudhry@google.com>
Date:   Wed Feb 15 00:37:10 2017 -0800

    Improved support for --icf=safe when used with -pie.

we now check opcode with R_X86_64_PC32 relocation, which tell branches
from other instructions.  We can enable safe ICF for shared object on
x86-64.  Also, global symbols with non-default visibility should be
folded like local symbols.

PR gold/21452
* x86_64.cc (Scan::local_reloc_may_be_function_pointer): Remove
check for shared library.
(Scan::global_reloc_may_be_function_pointer): Remove check for
shared library and symbol visibility.
* testsuite/icf_safe_so_test.cc (bar_static): New function.
(main): Take function address of bar_static and use it.
* testsuite/icf_safe_so_test.sh (arch_specific_safe_fold): Also
check fold on x86-64.  Check bar_static isn't folded.

4 years agoGold: Skip zero-sized sections for ICF
H.J. Lu [Tue, 13 Oct 2020 12:08:25 +0000 (05:08 -0700)]
Gold: Skip zero-sized sections for ICF

Skip zero-sized sections since there is no need to do ICF on them.

* icf.cc (Icf::find_identical_sections): Skip zero-sized sections.

4 years agoNormalize names of the NetBSD files
Kamil Rytarowski [Tue, 6 Oct 2020 19:36:22 +0000 (21:36 +0200)]
Normalize names of the NetBSD files

The files used to be named 'nbsd', which incorrectly reflects
the name of the OS and confuses it with other BSD derived OSes.

gdb/ChangeLog:

        * Makefile.in (ALL_64_TARGET_OBS, ALL_TARGET_OBS)
        HFILES_NO_SRCDIR, ALLDEPFILES): Rename files.
        * alpha-bsd-nat.c: Adjust include.
        * alpha-bsd-tdep.h: Adjust comment.
        * alpha-nbsd-tdep.c: Rename to ...
        * alpha-netbsd-tdep.c: ... this, adjust include.
        * amd64-nbsd-nat.c: Rename to ...
        * amd64-netbsd-nat.c: ... this, adjust include.
        * amd64-nbsd-tdep.c: Rename to ...
        * amd64-netbsd-tdep.c: ... this, adjust include.
        * amd64-tdep.h: Adjust include.
        * arm-nbsd-nat.c: Rename to ...
        * arm-netbsd-nat.c: ... this, adjust include.
        * arm-nbsd-tdep.c: Rename to ...
        * arm-netbsd-tdep.c: ... this, adjust include.
        * arm-nbsd-tdep.h: Rename to ...
        * arm-netbsd-tdep.h: ... this, adjust include.
        * configure.nat: Adjust file lists.
        * configure.tgt: Likewise.
        * hppa-nbsd-nat.c: Rename to ...
        * hppa-netbsd-nat.c: ... this, adjust include.
        * hppa-nbsd-tdep.c: Rename to ...
        * hppa-netbsd-tdep.c: ... this, adjust include.
        * i386-nbsd-nat.c: Rename to ...
        * i386-netbsd-nat.c: ... this, adjust include.
        * i386-nbsd-tdep.c: Rename to ...
        * i386-netbsd-tdep.c: ... this, adjust include.
        * m68k-bsd-nat.c: Adjust include.
        * mips-nbsd-nat.c: Rename to ...
        * mips-netbsd-nat.c: ... this, adjust include.
        * mips-nbsd-tdep.c: Rename to ...
        * mips-netbsd-tdep.c: ... this, adjust include.
        * mips-nbsd-tdep.h: Rename to ...
        * mips-netbsd-tdep.h: ... this.
        * nbsd-nat.c: Rename to ...
        * netbsd-nat.c: ... this, adjust include.
        * nbsd-nat.h: Rename to ...
        * netbsd-nat.h: ... this, adjust include.
        * nbsd-tdep.c: Rename to ...
        * netbsd-tdep.c: ... this, adjust include.
        * nbsd-tdep.h: Rename to ...
        * netbsd-tdep.h: ... this.
        * ppc-nbsd-nat.c: Rename to ...
        * ppc-netbsd-nat.c: ... this, adjust include.
        * ppc-nbsd-tdep.c: Rename to ...
        * ppc-netbsd-tdep.c: ... this, adjust include and comment.
        * ppc-nbsd-tdep.h: Rename to ...
        * ppc-netbsd-tdep.h: ... this.
        * sh-nbsd-nat.c: Rename to ...
        * sh-netbsd-nat.c: ... this, adjust include.
        * sh-nbsd-tdep.c: Rename to ...
        * sh-netbsd-tdep.c: ... this, adjust include.
        * sparc-nbsd-nat.c: Rename to ...
        * sparc-netbsd-nat.c: ... this.
        * sparc-nbsd-tdep.c: Rename to ...
        * sparc-netbsd-tdep.c: ... this, adjust include.
        * sparc64-nbsd-nat.c: Rename to ...
        * sparc64-netbsd-nat.c: ... this.
        * sparc64-nbsd-tdep.c: Rename to ...
        * sparc64-netbsd-tdep.c: ... this, adjust include.
        * sparc64-tdep.h: Adjust comment.
        * vax-bsd-nat.c: Adjust include.
        * vax-nbsd-tdep.c: Rename to ...
        * vax-netbsd-tdep.c: ... this, adjust include.

4 years agoChange target_section_table to std::vector alias
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Change target_section_table to std::vector alias

Because target_section_table only holds a vector, and because it is
used in an "open" way, this patch makes it just be an alias for the
std::vector specialization.  This makes the code less wordy.  If we do
ever want to add more specialized behavior to this type, it's simple
enough to convert it back to a struct with the few needed methods
implied by this change.

gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>

* target.h (struct target_ops) <get_section_table>: Update.
(target_get_section_table): Update.
* target.c (target_get_section_table, target_section_by_addr)
(memory_xfer_partial_1): Update.
* target-section.h (target_section_table): Now an alias.
* target-delegates.c: Rebuild.
* target-debug.h (target_debug_print_target_section_table_p):
Rename from target_debug_print_struct_target_section_table_p.
* symfile.c (build_section_addr_info_from_section_table): Update.
* solib.c (solib_map_sections, solib_contains_address_p): Update.
* solib-svr4.c (scan_dyntag): Update.
* solib-dsbt.c (scan_dyntag): Update.
* remote.c (remote_target::remote_xfer_live_readonly_partial):
Update.
* record-full.c (record_full_core_target::xfer_partial): Update.
* progspace.h (struct program_space) <target_sections>: Update.
* exec.h (print_section_info): Update.
* exec.c (exec_target::close, build_section_table)
(add_target_sections, add_target_sections_of_objfile)
(remove_target_sections, exec_on_vfork)
(section_table_available_memory)
(section_table_xfer_memory_partial)
(exec_target::get_section_table, exec_target::xfer_partial)
(print_section_info, set_section_command)
(exec_set_section_address, exec_target::has_memory): Update.
* corelow.c (core_target::build_file_mappings)
(core_target::xfer_partial, core_target::info_proc_mappings)
(core_target::info_proc_mappings): Update.
* bfd-target.c (class target_bfd): Update

4 years agoRemove clear_section_table
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Remove clear_section_table

The call to clear_section_table in ~program_space is now clearly not
needed -- the section table will clear itself.  This patch removes
this call and then inlines the one remaining call to
clear_section_table.

gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>

* progspace.c (program_space::~program_space): Don't call
clear_section_table.
* exec.h (clear_section_table): Don't declare.
* exec.c (exec_target::close): Update.
(clear_section_table): Remove.

4 years agoSimplify add_target_sections_of_objfile
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Simplify add_target_sections_of_objfile

Now that target_section_table uses std::vector,
add_target_sections_of_objfile does not need to loop twice.  This
patch simplifies this code to have just a single loop.  Also, the
passed-in objfile can never be NULL, so this changes this function to
assert that.

gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>

* exec.c (add_target_sections_of_objfile): Simplify.

4 years agobuild_section_table cannot fail
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
build_section_table cannot fail

I noticed that build_section_table cannot fail.  This patch changes it
to return a target_section_table and then removes the dead code.

gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>

* solib.c (solib_map_sections): Update.
* record-full.c (record_full_core_open_1): Update.
* exec.h (build_section_table): Return a target_section_table.
* exec.c (exec_file_attach): Update.
(build_section_table): Return a target_section_table.
* corelow.c (core_target::core_target): Update.
* bfd-target.c (target_bfd::target_bfd): Update.

4 years agoUse a std::vector in target_section_table
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Use a std::vector in target_section_table

This changes target_section_table to wrap a std::vector.  This
simplifies some code, and also enables the simplifications coming in
the subsequent patches.

Note that for solib, I chose to have it use a pointer to a
target_section_table.  This is more convoluted than would be ideal,
but I didn't want to convert solib to new/delete as a prerequisite for
this series.

gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>

* target.c (target_section_by_addr, memory_xfer_partial_1):
Update.
* target-section.h (struct target_section_table): Use
std::vector.
* symfile.h (build_section_addr_info_from_section_table): Take a
target_section_table.
* symfile.c (build_section_addr_info_from_section_table): Take a
target_section_table.
* solist.h (struct so_list) <sections>: Change type.
<sections_end>: Remove.
* solib.c (solib_map_sections, clear_so, solib_read_symbols)
(solib_contains_address_p): Update.
* solib-svr4.c (scan_dyntag): Update.
* solib-dsbt.c (scan_dyntag): Update.
* remote.c (remote_target::remote_xfer_live_readonly_partial):
Update.
* record-full.c (record_full_core_start, record_full_core_end):
Remove.
(record_full_core_sections): New global.
(record_full_core_open_1, record_full_core_target::xfer_partial):
Update.
* exec.h (build_section_table, section_table_xfer_memory_partial)
(add_target_sections): Take a target_section_table.
* exec.c (exec_file_attach, clear_section_table): Update.
(resize_section_table): Remove.
(build_section_table, add_target_sections): Take a
target_section_table.
(add_target_sections_of_objfile, remove_target_sections)
(exec_on_vfork): Update.
(section_table_available_memory): Take a target_section_table.
(section_table_read_available_memory): Update.
(section_table_xfer_memory_partial): Take a target_section_table.
(print_section_info, set_section_command)
(exec_set_section_address, exec_target::has_memory): Update.
* corelow.c (class core_target) <m_core_section_table,
m_core_file_mappings>: Remove braces.
<~core_target>: Remove.
(core_target::core_target): Update.
(core_target::~core_target): Remove.
(core_target::build_file_mappings)
(core_target::xfer_memory_via_mappings)
(core_target::xfer_partial, core_target::info_proc_mappings):
Update.
* bfd-target.c (target_bfd::xfer_partial): Update.
(target_bfd::target_bfd): Update.
(target_bfd::~target_bfd): Remove.

4 years agoIntroduce target-section.h
Tom Tromey [Mon, 12 Oct 2020 21:53:16 +0000 (15:53 -0600)]
Introduce target-section.h

This introduces a new target-section.h file.  This makes some of the
later patches in this series a bit cleaner, because new includes of
target.h won't be required.  Also I think it's better to have small
header files for each separate data structure.

gdb/ChangeLog
2020-10-12  Tom Tromey  <tom@tromey.com>

* target.h (struct target_section, struct target_section_table):
Move to target-section.h.
* target-section.h: New file.

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

4 years agoPowerPC testsuite fails and duplicates
Alan Modra [Mon, 12 Oct 2020 02:27:58 +0000 (12:57 +1030)]
PowerPC testsuite fails and duplicates

binutils commit 5fbec329ec3 changed disassembly of mfvsrd and mtvsrd
to be consistent with the mfvsrwz and mtvsrw/mtvsrwz, which favour
output of the fp/vr extended mnemonic and regs over the vsx form.
This patch fixes the following, and removes some duplicates.

FAIL: gdb.arch/powerpc-power8.exp: found: mfvsrd  r12,vs62
FAIL: gdb.arch/powerpc-power8.exp: found: mtvsrd  vs48,r11
FAIL: gdb.arch/powerpc-vsx2.exp: found: mfvsrd  r12,vs30
FAIL: gdb.arch/powerpc-vsx2.exp: found: mfvsrd  r12,vs30
FAIL: gdb.arch/powerpc-vsx2.exp: found: mfvsrd  r12,vs62
FAIL: gdb.arch/powerpc-vsx2.exp: found: mfvsrd  r12,vs62
FAIL: gdb.arch/powerpc-vsx2.exp: found: mtvsrd  vs11,r28
FAIL: gdb.arch/powerpc-vsx2.exp: found: mtvsrd  vs11,r28
FAIL: gdb.arch/powerpc-vsx2.exp: found: mtvsrd  vs43,r29
FAIL: gdb.arch/powerpc-vsx2.exp: found: mtvsrd  vs43,r29

* gdb.arch/powerpc-altivec.s,
* gdb.arch/powerpc-power7.s,
* gdb.arch/powerpc-power8.s,
* gdb.arch/powerpc-power9.s,
* gdb.arch/powerpc-vsx.s,
* gdb.arch/powerpc-vsx2.s: Remove duplicate instructions.
* gdb.arch/powerpc-altivec.exp,
* gdb.arch/powerpc-power7.exp,
* gdb.arch/powerpc-power8.exp,
* gdb.arch/powerpc-power9.exp,
* gdb.arch/powerpc-vsx.exp,
* gdb.arch/powerpc-vsx2.exp: Likewise, and update expected
disassembly of mfvsrd/mtvsrd.

4 years agoRe: gdb: Improve formatting of 'show architecture' messages
Alan Modra [Mon, 12 Oct 2020 01:02:21 +0000 (11:32 +1030)]
Re: gdb: Improve formatting of 'show architecture' messages

Commit ccb9eba6a25 updated the testsuite for some targets without
running the testsuite on those targets.  This patch corrects the
update, in most cases just adding the expected full-stop.

On powerpc64le-linux, fixes these:
FAIL: gdb.arch/powerpc-d128-regs.exp: checking for PPC arch
FAIL: gdb.arch/powerpc-disassembler-options.exp: set architecture powerpc:common64
FAIL: gdb.arch/powerpc-disassembler-options.exp: set architecture rs6000:6000
FAIL: gdb.arch/ppc64-symtab-cordic.exp: show architecture

I also verified that arm-linuxeabi and s390x-linux cross-builds now
pass their disassembler-options.exp tests.

* gdb.arch/arm-disassembler-options.exp: Adjust expected
"target architecture" output.
* gdb.arch/powerpc-d128-regs.exp: Likewise.
* gdb.arch/powerpc-disassembler-options.exp: Likewise.
* gdb.arch/ppc64-symtab-cordic.exp: Likewise.
* gdb.arch/s390-disassembler-options.exp: Likewise.

4 years agoReject ambiguous C++ field accesses (PR exp/26602)
Pedro Alves [Fri, 28 Aug 2020 20:10:59 +0000 (21:10 +0100)]
Reject ambiguous C++ field accesses (PR exp/26602)

The gdb.cp/ambiguous.exp testcase had been disabled for many years,
but recently it was re-enabled.  However, it is failing everywhere.
That is because it is testing an old feature that is gone from GDB.

The testcase is expecting to see an ambiguous field warning, like:

 # X is derived from A1 and A2; both A1 and A2 have a member 'x'
 send_gdb "print x.x\n"
 gdb_expect {
    -re "warning: x ambiguous; using X::A2::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print x.x"
    }
    -re "warning: x ambiguous; using X::A1::x. Use a cast to disambiguate.\r\n\\$\[0-9\]* = \[-\]*\[0-9\]*\r\n$gdb_prompt $" {
pass "print x.x"
    }
    -re ".*$gdb_prompt $" { fail "print x.x" }
    timeout { fail "(timeout) print x.x" }
  }

However, GDB just accesses one of the candidates without warning or
error:

 print x.x
 $1 = 1431655296
 (gdb) FAIL: gdb.cp/ambiguous.exp: print x.x

(The weird number is because the testcase does not initialize the
variables.)

The testcase come in originally with the big HP merge:

 +Sun Jan 10 23:44:11 1999  David Taylor  <taylor@texas.cygnus.com>
 +
 +
 +       The following files are part of the HP merge; some had longer
 +       names at HP, but have been renamed to be no more than 14
 +       characters in length.

Looking at the tree back then, we find that warning:

 /* Helper function used by value_struct_elt to recurse through baseclasses.
    Look for a field NAME in ARG1. Adjust the address of ARG1 by OFFSET bytes,
    and search in it assuming it has (class) type TYPE.
    If found, return value, else return NULL.

    If LOOKING_FOR_BASECLASS, then instead of looking for struct fields,
    look for a baseclass named NAME.  */

 static value_ptr
 search_struct_field (name, arg1, offset, type, looking_for_baseclass)
      char *name;
      register value_ptr arg1;
      int offset;
      register struct type *type;
      int looking_for_baseclass;
 {
   int found = 0;
   char found_class[1024];
   value_ptr v;
   struct type *vbase = NULL;

   found_class[0] = '\000';

   v = search_struct_field_aux (name, arg1, offset, type, looking_for_baseclass, &found, found_class, &vbase);
   if (found > 1)
     warning ("%s ambiguous; using %s::%s. Use a cast to disambiguate.",
              name, found_class, name);

   return v;
 }

However, in current GDB, search_struct_field does not handle the
ambiguous field case, nor is that warning found anywhere.  Somehow it
got lost over the years.  That seems like a regression, because the
compiler (as per language rules) rejects the ambiguous accesses as
well.  E.g.:

 gdb.cp/ambiguous.cc:98:5: error: request for member 'x' is ambiguous
    98 |   x.x = 1;
       |     ^
 gdb.cp/ambiguous.cc:10:7: note: candidates are: 'int A2::x'
    10 |   int x;
       |       ^
 gdb.cp/ambiguous.cc:4:7: note:                 'int A1::x'
     4 |   int x;
       |       ^

This patch restores the feature, though implemented differently and
with better user experience, IMHO.  An ambiguous access is now an
error instead of a warning, and also GDB shows you all the candidates,
like:

 (gdb) print x.x
 Request for member 'x' is ambiguous in type 'X'. Candidates are:
   'int A1::x' (X -> A1)
   'int A2::x' (X -> A2)
 (gdb) print j.x
 Request for member 'x' is ambiguous in type 'J'. Candidates are:
   'int A1::x' (J -> K -> A1)
   'int A1::x' (J -> L -> A1)

Users can then fix their commands by casting or by specifying the
baseclass explicitly, like:

 (gdb) p x.A1::x
 $1 = 1
 (gdb) p x.A2::x
 $2 = 2
 (gdb) p ((A1) x).x
 $3 = 1
 (gdb) p ((A2) x).x
 $4 = 2
 (gdb) p j.K::x
 $12 = 1
 (gdb) p j.L::x
 $13 = 2
 (gdb) p j.A1::x
 base class 'A1' is ambiguous in type 'J'

The last error I've not touched; could be improved to also list the
baseclass candidates.

The showing the class "path" for each candidate was inspired by GCC's
output when you try an ambiguous cast:

  gdb.cp/ambiguous.cc:161:8: error: ambiguous conversion from derived class 'const JVA1' to base class 'const A1':
      class JVA1 -> class KV -> class A1
      class JVA1 -> class A1
    (A1) jva1;
 ^~~~

I did not include the "class" word as it seemed unnecessarily
repetitive, but I can include it if people prefer it:

 (gdb) print j.x
 Request for member 'x' is ambiguous in type 'J'. Candidates are:
   'int A1::x' (class J -> class K -> class A1)
   'int A1::x' (class J -> class L -> class A1)

The testcase is adjusted accordingly.  I also took the chance to
modernize it at the same time.

Also, as mentioned above, the testcase doesn't currently initialize
the tested variables.  This patch inializes them all, giving each
field a distinct value, so that we can be sure that GDB is accessing
the right fields / offsets.  The testcase is extended accordingly.

Unfortunately, this exposes a bug, not addressed in this patch.  The
bug is around a class that inherits from A1 directly and also inherits
from two other distinct base classes that inherit virtually from A1 in
turn:

 print jva1.KV::x
 $51 = 1431665544
 (gdb) FAIL: gdb.cp/ambiguous.exp: all fields: print jva1.KV::x
 print jva1.KV::y
 $52 = 21845
 (gdb) FAIL: gdb.cp/ambiguous.exp: all fields: print jva1.KV::y

 (gdb) print /x (KV)jva1
 $4 = {<A1> = <invalid address>, _vptr.KV = 0x555555557b88 <vtable for JVA1+24>, i = 0x457}
 (gdb) print /x (A1)(KV)jva1
 Cannot access memory at address 0x0

Since that's an orthogonal issue, I filed PR c++/26550 and kfailed the
tests that fail because of it.

gdb/ChangeLog:

PR exp/26602
* valops.c (struct struct_field_searcher): New.
(update_search_result): Rename to ...
(struct_field_searcher::update_result): ... this.  Simplify
prototype.  Record all found fields.
(do_search_struct_field): Rename to ...
(struct_field_searcher::search): ... this.  Simplify prototype.
Maintain stack of visited baseclass path.  Call update_result for
fields too.  Keep searching fields in baseclasses instead of
stopping at the first found field.
(search_struct_field): Use struct_field_searcher.  When looking
for fields, report ambiguous access attempts.

gdb/testsuite/ChangeLog:

PR exp/26602
PR c++/26550
* gdb.cp/ambiguous.cc (marker1): Delete.
(main): Initialize all the fields of the locals.  Replace marker1
call with a "set breakpoint here" marker.
* gdb.cp/ambiguous.exp: Modernize.  Use gdb_continue_to_breakpoint
instead of running to marker1.  Add tests printing all the
variables and all the fields of the variables.
(test_ambiguous): New proc, expecting the new GDB output when a
field access is ambiguous.  Change all "warning: X ambiguous"
tests to use it.

4 years agoFix testcases with required but unreferenced functions and variables
Gary Benson [Mon, 12 Oct 2020 09:35:23 +0000 (10:35 +0100)]
Fix testcases with required but unreferenced functions and variables

A number of testcases define variables and/or functions which are
referenced by GDB during the test, but which are not referenced from
within the test executable.  Clang correctly recognizes that these
variables and functions are unused, and optimizes them out, causing
the testcases in question to fail.  This commit adds __attribute__
((used)) in various places to prevent this.

gdb/testsuite/ChangeLog:

* gdb.base/msym-bp.c (foo): Add __attribute__ ((used)).
* gdb.base/msym-bp-2.c (foo): Likewise.
* gdb.base/msym-lang.c (foo): Likewise.
* gdb.base/msym-lang-main.c (foo): Likewise.
* gdb.base/symtab-search-order-1.c (static_global): Likewise.
* gdb.guile/scm-pretty-print.c (eval_func): Likewise.
* gdb.mi/mi-sym-info-1.c (global_f1): Likewise.
* gdb.mi/mi-sym-info-2.c (global_f1, var1, var2): Likewise.
* gdb.multi/watchpoint-multi-exit.c (globalvar): Likewise.
* gdb.python/py-as-string.c (enum_valid, enum_invalid): Likewise.
* gdb.python/py-objfile.c (static_var): Likewise.
* gdb.python/py-symbol.c (rr): Likewise.
* gdb.python/py-symbol-2.c (anon, rr): Likewise.
* gdb.mi/mi-sym-info.exp (lineno1, lineno2): Updated.

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

4 years agogdb: detect main function even when there's no matching msymbol
Andrew Burgess [Thu, 8 Oct 2020 11:28:19 +0000 (12:28 +0100)]
gdb: detect main function even when there's no matching msymbol

Currently, GDB will only stop the backtrace at the main function if
there is a minimal symbol with the matching name.  In Fortran programs
compiled with gfortran this is not the case.  The main function is
present in the DWARF, and as marked as DW_AT_main_subprogram, but
there's no minimal symbol.

This commit extends `inside_main_func` to check the full symbols if no
matching minimal symbol is found.

There's an updated test case that covers this change.

gdb/ChangeLog:

* frame.c (inside_main_func): Check full symbols as well as
minimal symbols.

gdb/testsuite/ChangeLog:

* gdb.fortran/mixed-lang-stack.exp (run_tests): Update expected
output of backtrace.

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

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

4 years agoada-lang.c::advance_wild_match improve doc and parameter+temporaries types
Joel Brobecker [Fri, 9 Oct 2020 20:30:48 +0000 (13:30 -0700)]
ada-lang.c::advance_wild_match improve doc and parameter+temporaries types

This commit fixes the type of one of the parameters as well as a couple
of temporaries.

While at it, the function's description is slightly rewritten to make it
a little clearer what the function does.

gdb/ChangeLog:

        * ada-lang.c (advance_wild_match): Rewrite the function's
        description.  Change the type of target0, t0 and t1 to char.

4 years agoFix bit offset regression
Tom Tromey [Tue, 6 Oct 2020 14:56:54 +0000 (08:56 -0600)]
Fix bit offset regression

The type-safe attribute patch introduced a regression that can occur
when the DW_AT_bit_offset value is negative.  This can happen with
some Ada programs.

This patch fixes the problem.  It also fixes a minor oddity in the
existing scalar storage test -- this test was intended to assign a
smaller number of bits to the field.

2020-10-09  Tom Tromey  <tromey@adacore.com>

* dwarf2/read.c (dwarf2_add_field): Handle signed offsets.

gdb/testsuite/ChangeLog
2020-10-09  Tom Tromey  <tromey@adacore.com>

* gdb.ada/scalar_storage/storage.adb (Another_Range): New type.
(Rec): Add field.  Fix range.
* gdb.ada/scalar_storage.exp: Update.

4 years agoReturn std::string from ada_encode
Tom Tromey [Fri, 9 Oct 2020 14:27:30 +0000 (08:27 -0600)]
Return std::string from ada_encode

This changes ada_encode to return a std::string.  This simplifies it
somewhat, removes a use of GROW_VECT, and is also simpler for callers
to use.

gdb/ChangeLog
2020-10-09  Tom Tromey  <tromey@adacore.com>

* ada-lang.h (ada_encode): Return std::string.
* ada-lang.c (ada_encode_1): Return std::string.
(ada_encode): Likewise.
(type_from_tag, ada_lookup_name_info::ada_lookup_name_info):
Update.
* ada-exp.y (block_lookup, write_var_or_type): Update.

4 years ago[GOLD] Power10 segv due to wild r2
Alan Modra [Fri, 9 Oct 2020 06:26:33 +0000 (16:56 +1030)]
[GOLD] Power10 segv due to wild r2

Calling non-pcrel functions from pcrel code requires a stub to set up
r2.  Gold created the stub, but an "optimisation" made the stub jump
to the function local entry, ie. r2 was not initialised.

This patch fixes that long branch stub problem, and another that might
occur for plt call stubs to local functions.

bfd/
* elf64-ppc.c (write_plt_relocs_for_local_syms): Don't do local
entry offset optimisation.
gold/
* powerpc.cc (Powerpc_relobj::do_relocate_sections): Don't do
local entry offset optimisation for lplt_section.
(Target_powerpc::Branch_info::make_stub): Don't add local
entry offset to long branch dest passed to
add_long_branch_entry.  Do pass st_other bits.
(Stub_table::Branch_stub_ent): Add "other_" field.
(Stub_table::add_long_branch_entry): Add "other" param, and
save.
(Stub_table::branch_stub_size): Adjust long branch offset.
(Stub_table::do_write): Likewise.
(Target_powerpc::Relocate::relocate): Likewise.

4 years ago[GOLD] internal error in relocate, at powerpc.cc:10473
Alan Modra [Fri, 9 Oct 2020 00:29:33 +0000 (10:59 +1030)]
[GOLD] internal error in relocate, at powerpc.cc:10473

GOT relocations can refer directly to a function in a fixed position
executable, unlike ADDR64 which needs a global entry stub, or branch
relocs, which need PLT stubs.

* powerpc.cc (is_got_reloc): New function.
(Target_powerpc::Relocate::relocate): Use it here, exclude GOT
relocs when looking for stubs.

4 years agox86: Support GNU_PROPERTY_X86_ISA_1_V[234] marker
H.J. Lu [Fri, 9 Oct 2020 12:05:57 +0000 (05:05 -0700)]
x86: Support GNU_PROPERTY_X86_ISA_1_V[234] marker

GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA
levels:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250

Update GNU_PROPERTY_X86_ISA_1_XXX macros:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13

in x86 ELF binaries to indicate that micro-architecture ISA levels
required to execute the binary:

 #define GNU_PROPERTY_X86_ISA_1_NEEDED (GNU_PROPERTY_X86_UINT32_OR_LO + 2)
 #define GNU_PROPERTY_X86_ISA_1_USED (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 2)
 #define GNU_PROPERTY_X86_ISA_1_V2 (1U << 0)
 #define GNU_PROPERTY_X86_ISA_1_V3 (1U << 1)
 #define GNU_PROPERTY_X86_ISA_1_V4 (1U << 2)

The previous GNU_PROPERTY_X86_ISA_1_XXX  macros are deprecated and renamed
to GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX.

In addition to EM_X86_64, GNU_PROPERTY_X86_ISA_1_V[234] marker can be used
by ld.so to detect the x86-64-v4 shared library placed in an x86-64-v2
directory by mistake on an x86-64-v2 machine to avoid crashes on x86-64-v4
instructions.

Add -z x86-64-v[234] linker command line option to mark x86-64-v[234]
ISA level as needed.

Also add

 #define GNU_PROPERTY_X86_FEATURE_2_MASK (1U << 11)

for mask registers.

bfd/

PR gas/26703
* elf-linker-x86.h (elf_linker_x86_params): Add isa_level.
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Merge
GNU_PROPERTY_X86_ISA_1_V[234].
(_bfd_x86_elf_link_setup_gnu_properties): Generate
GNU_PROPERTY_X86_ISA_1_V[234] for -z x86-64-v[234].

binutils/

PR gas/26703
* readelf.c (decode_x86_compat_2_isa): New function.
(decode_x86_isa): Updated for new X86_ISA_1_XXX bits.
(decode_x86_feature_1): Handle GNU_PROPERTY_X86_FEATURE_2_MASK.
(print_gnu_property_note): Handle X86_COMPAT_2_ISA_1_USED,
and X86_COMPAT_2_ISA_1_NEEDED.
* testsuite/binutils-all/i386/pr21231b.s: Updated to the current
GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
values.
* testsuite/binutils-all/x86-64/pr21231b.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.s: Likewise.
* testsuite/binutils-all/i386/empty.d: Updated.
* testsuite/binutils-all/i386/ibt.d: Likewise.
* testsuite/binutils-all/i386/pr21231a.d: Likewise.
* testsuite/binutils-all/i386/pr21231b.d: Likewise.
* testsuite/binutils-all/i386/shstk.d: Likewise.
* testsuite/binutils-all/x86-64/empty-x32.d: Likewise.
* testsuite/binutils-all/x86-64/empty.d: Likewise.
* testsuite/binutils-all/x86-64/ibt-x32.d: Likewise.
* testsuite/binutils-all/x86-64/ibt.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231a.d: Likewise.
* testsuite/binutils-all/x86-64/pr21231b.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
* testsuite/binutils-all/x86-64/shstk-x32.d: Likewise.
* testsuite/binutils-all/x86-64/shstk.d: Likewise.

gas/

PR gas/26703
* config/tc-i386.c (xstate): Add xstate_mask.
(md_assemble): Check i.types[j], instead of i.tm.operand_types[j],
for xstate.  Set xstate_mask, instead of xstate_zmm, for RegMask.
(output_insn): Update for GNU_PROPERTY_X86_ISA_1_V[234].  Update
xstate for mask register and VSIB.
* testsuite/gas/i386/i386.exp: Run more GNU_PROPERTY tests.
* testsuite/gas/i386/property-1.s: Updated to the current
GNU_PROPERTY_X86_ISA_1_USED value.
* testsuite/gas/i386/property-2.s: Only keep cmove.
* testsuite/gas/i386/property-3.s: Changed to addsubpd.
* testsuite/gas/i386/property-1.d: Updated.
* testsuite/gas/i386/property-2.d: Likewise.
* testsuite/gas/i386/property-3.d: Likewise.
* testsuite/gas/i386/property-4.d: Likewise.
* testsuite/gas/i386/property-5.d: Likewise.
* testsuite/gas/i386/property-6.d: Likewise.
* testsuite/gas/i386/x86-64-property-1.d: Likewise.
* testsuite/gas/i386/x86-64-property-2.d: Likewise.
* testsuite/gas/i386/x86-64-property-3.d: Likewise.
* testsuite/gas/i386/x86-64-property-4.d: Likewise.
* testsuite/gas/i386/x86-64-property-5.d: Likewise.
* testsuite/gas/i386/x86-64-property-6.d: Likewise.
* testsuite/gas/i386/x86-64-property-7.d: Likewise.
* testsuite/gas/i386/x86-64-property-8.d: Likewise.
* testsuite/gas/i386/x86-64-property-9.d: Likewise.
* testsuite/gas/i386/property-11.d: New file.
* testsuite/gas/i386/property-11.s: Likewise.
* testsuite/gas/i386/property-12.d: Likewise.
* testsuite/gas/i386/property-12.s: Likewise.
* testsuite/gas/i386/property-13.d: Likewise.
* testsuite/gas/i386/property-13.s: Likewise.
* testsuite/gas/i386/x86-64-property-11.d: Likewise.
* testsuite/gas/i386/x86-64-property-12.d: Likewise.
* testsuite/gas/i386/x86-64-property-13.d: Likewise.
* testsuite/gas/i386/x86-64-property-14.d: Likewise.
* testsuite/gas/i386/x86-64-property-14.s: Likewise.

include/

PR gas/26703
* elf/common.h (GNU_PROPERTY_X86_ISA_1_USED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED): This.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED): This.
(GNU_PROPERTY_X86_ISA_1_XXX): Renamed to ...
(GNU_PROPERTY_X86_COMPAT_2_ISA_1_XXX): This.
(GNU_PROPERTY_X86_ISA_1_NEEDED): New.
(GNU_PROPERTY_X86_ISA_1_USED): Likewise.
(GNU_PROPERTY_X86_ISA_1_V2): Likewise.
(GNU_PROPERTY_X86_ISA_1_V3): Likewise.
(GNU_PROPERTY_X86_ISA_1_V4): Likewise.
(GNU_PROPERTY_X86_FEATURE_2_MASK): Likewise.

ld/

PR gas/26703
* NEWS: Mention -z x86-64-v[234].
* ld.texi: Document -z x86-64-v[234].
* emulparams/elf32_x86_64.sh: Use x86-64-level.sh.
* emulparams/elf_i386.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/x86-64-level.sh: New file.
* testsuite/ld-elf/x86-feature-1a.rd: Update.
* testsuite/ld-elf/x86-feature-1b.rd: Likewise.
* testsuite/ld-elf/x86-feature-1c.rd: Likewise.
* testsuite/ld-elf/x86-feature-1d.rd: Likewise.
* testsuite/ld-elf/x86-feature-1e.rd: Likewise.
* testsuite/ld-i386/pr23372c.d: Likewise.
* testsuite/ld-i386/pr23486c.d: Likewise.
* testsuite/ld-i386/pr23486d.d: Likewise.
* testsuite/ld-i386/pr24322a.d: Likewise.
* testsuite/ld-i386/pr24322b.d: Likewise.
* testsuite/ld-i386/property-1a.r: Likewise.
* testsuite/ld-i386/property-2a.r: Likewise.
* testsuite/ld-i386/property-3.r: Likewise.
* testsuite/ld-i386/property-3a.r: Likewise.
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-4a.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-i386/property-5a.r: Likewise.
* testsuite/ld-i386/property-7a.r: Likewise.
* testsuite/ld-i386/property-x86-3.d: Likewise.
* testsuite/ld-i386/property-x86-4a.d: Likewise.
* testsuite/ld-i386/property-x86-5.d: Likewise.
* testsuite/ld-i386/property-x86-cet1.d: Likewise.
* testsuite/ld-i386/property-x86-cet2a.d: Likewise.
* testsuite/ld-i386/property-x86-cet5a.d: Likewise.
* testsuite/ld-i386/property-x86-cet5b.d: Likewise.
* testsuite/ld-i386/property-x86-ibt1a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt1b.d: Likewise.
* testsuite/ld-i386/property-x86-ibt2.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
* testsuite/ld-i386/property-x86-ibt4.d: Likewise.
* testsuite/ld-i386/property-x86-ibt5.d: Likewise.
* testsuite/ld-i386/property-x86-shstk1a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk1b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk2.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
* testsuite/ld-i386/property-x86-shstk4.d: Likewise.
* testsuite/ld-i386/property-x86-shstk5.d: Likewise.
* testsuite/ld-x86-64/pr23372c-x32.d: Likewise.
* testsuite/ld-x86-64/pr23372c.d: Likewise.
* testsuite/ld-x86-64/pr23486c.d: Likewise.
* testsuite/ld-x86-64/pr23486d-x32.d: Likewise.
* testsuite/ld-x86-64/pr23486d.d: Likewise.
* testsuite/ld-x86-64/pr24322a-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322a.d: Likewise.
* testsuite/ld-x86-64/pr24322b-x32.d: Likewise.
* testsuite/ld-x86-64/pr24322b.d: Likewise.
* testsuite/ld-x86-64/pr24458a-x32.d: Likewise.
* testsuite/ld-x86-64/pr24458a.d: Likewise.
* testsuite/ld-x86-64/pr24458b-x32.d: Likewise.
* testsuite/ld-x86-64/pr24458b.d: Likewise.
* testsuite/ld-x86-64/pr24458c-x32.d: Likewise.
* testsuite/ld-x86-64/pr24458c.d: Likewise.
* testsuite/ld-x86-64/property-1a.r: Likewise.
* testsuite/ld-x86-64/property-2a.r: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-3a.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-4a.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.
* testsuite/ld-x86-64/property-5a.r: Likewise.
* testsuite/ld-x86-64/property-7a.r: Likewise.
* testsuite/ld-x86-64/property-x86-3-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-3.d: Likewise.
* testsuite/ld-x86-64/property-x86-4a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-4a.d: Likewise.
* testsuite/ld-x86-64/property-x86-5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-5.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet1-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet1.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet2a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5a.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-cet5b.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt1b.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt2-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt2.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt4-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt4.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-ibt5.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk1b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk2-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk2.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk4-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk4.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk5-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-shstk5.d: Likewise.
* testsuite/ld-i386/i386.exp: Run property-x86-6,
property-x86-isa1, property-x86-isa2 and property-x86-isa3.
* testsuite/ld-i386/property-x86-1.S: Updated to the current
GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED
values.
* testsuite/ld-i386/property-x86-2.S: Likewise.
* testsuite/ld-i386/property-x86-3.s: Likewise.
* testsuite/ld-x86-64/pr23372d.s: Likewise.
* testsuite/ld-x86-64/pr23372e.s: Likewise.
* testsuite/ld-x86-64/pr23372f.s: Likewise.
* testsuite/ld-x86-64/pr23486c.s: Likewise.
* testsuite/ld-x86-64/pr23486d.s: Likewise.
* testsuite/ld-x86-64/property-x86-1.S: Likewise.
* testsuite/ld-x86-64/property-x86-2.S: Likewise.
* testsuite/ld-x86-64/property-x86-3.s: Likewise.
* testsuite/ld-x86-64/property-x86-5a.s: Likewise.
* testsuite/ld-x86-64/property-x86-5b.s: Likewise.
* testsuite/ld-i386/property-x86-6.d: New file.
* testsuite/ld-i386/property-x86-isa1.d: Likewise.
* testsuite/ld-i386/property-x86-isa2.d: Likewise.
* testsuite/ld-i386/property-x86-isa3.d: Likewise.
* testsuite/ld-x86-64/property-x86-6-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-6.d: Likewise.
* testsuite/ld-x86-64/property-x86-6.s: Likewise.
* testsuite/ld-x86-64/property-x86-isa1-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa1.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa1.s: Likewise.
* testsuite/ld-x86-64/property-x86-isa2-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa2.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa3-x32.d: Likewise.
* testsuite/ld-x86-64/property-x86-isa3.d: Likewise.
* testsuite/ld-x86-64/simple.s: Likewise.
* ld/testsuite/ld-x86-64/x86-64.exp: Run property-x86-6,
property-x86-6-x32, property-x86-isa1, property-x86-isa1-x32,
property-x86-isa2, property-x86-isa2-x32, property-x86-isa3-x32
and property-x86-isa3.

4 years agoHandle void results as unformatted prints
Hannes Domani [Thu, 8 Oct 2020 15:38:32 +0000 (17:38 +0200)]
Handle void results as unformatted prints

When printing void results without any format letter, they are output
as expected:
(gdb) p $abcd
$1 = void
(gdb) p (void)10
$2 = void

But if any format letter (besides s) is used, it always outputs zero:
(gdb) p/x $abcd
$3 = 0x0
(gdb) p/x (void)10
$4 = 0x0

So this adds void results to the types handled like unformatted prints.

gdb/ChangeLog:

2020-10-09  Hannes Domani  <ssbssa@yahoo.de>

PR exp/26714
* printcmd.c (print_formatted): Handle void results as
unformatted prints.

gdb/testsuite/ChangeLog:

2020-10-09  Hannes Domani  <ssbssa@yahoo.de>

PR exp/26714
* gdb.base/printcmds.exp: Add tests for void results.

4 years agogdb: Delay releasing target_desc_up in more cases
Andrew Burgess [Thu, 8 Oct 2020 09:44:55 +0000 (10:44 +0100)]
gdb: Delay releasing target_desc_up in more cases

After commit:

  commit 51a948fdf0e14fb69ab9e0c79ae8b2415801f9a3
  Date:   Mon Jul 20 14:18:04 2020 +0100

      gdb: Have allocate_target_description return a unique_ptr

There were a few places where we could (should?) have delayed
releasing the target_desc_up until a little later.  This commit
catches these cases.

In the case of ARC, the target_desc_up is now exposed right out to
gdbserver, which means making a small change there too.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* arch/aarch32.c (aarch32_create_target_description): Release the
target_desc_up as late as possible.
* arch/aarch64.c (aarch64_create_target_description): Likewise.
* arch/amd64.c (amd64_create_target_description): Likewise.
* arch/arc.c (arc_create_target_description): Return a
target_desc_up, don't release it.
* arch/arc.h (arc_create_target_description): Update declaration.
(arc_lookup_target_description): Move target_desc_up into the
cache, and return a borrowed pointer.
* arch/arm.c (arm_create_target_description): Release the
target_desc_up as late as possible.
* arch/i386.c (i386_create_target_description): Likewise.
* arch/riscv.h (riscv_create_target_description): Update
declaration to match definition.
* arch/tic6x.c (tic6x_create_target_description): Release the
target_desc_up as late as possible.

gdbserver/ChangeLog:

* linux-arc-low.cc (arc_linux_read_description): Release the
unique_ptr returned from arc_create_target_description.

4 years agognulib: Ensure all libraries are used when building gdb/gdbserver
Andrew Burgess [Tue, 6 Oct 2020 09:09:06 +0000 (10:09 +0100)]
gnulib: Ensure all libraries are used when building gdb/gdbserver

An issue was reported here related to building GDB on MinGW:

  https://sourceware.org/pipermail/gdb/2020-September/048927.html

It was suggested here:

  https://sourceware.org/pipermail/gdb/2020-September/048931.html

that the solution might be to make use of $(LIB_GETRANDOM), a variable
defined in the gnulib makefile, when linking GDB.

In fact I think the issue is bigger than just LIB_GETRANDOM.  When
using the script binutils-gdb/gnulib/update-gnulib.sh to reimport
gnulib there is a lot of output from gnulib's gnulib-tool.  Part of
that output is this:

  You may need to use the following makefile variables when linking.
  Use them in <program>_LDADD when linking a program, or
  in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.
    $(FREXPL_LIBM)
    $(FREXP_LIBM)
    $(INET_NTOP_LIB)
    $(LIBTHREAD)
    $(LIB_GETLOGIN)
    $(LIB_GETRANDOM)
    $(LIB_HARD_LOCALE)
    $(LIB_MBRTOWC)
    $(LIB_SETLOCALE_NULL)
    $(LTLIBINTL) when linking with libtool, $(LIBINTL) otherwise

What I think this is telling us is that we should be including the
value of all these variables on the link line for gdb and gdbserver.

The problem though is that these variables are define in gnulib's
makefile, but are not (necessarily) defined in GDB's makefile.

One solution would be to recreate the checks that gnulib performs in
order to recreate these variables in both gdb's and gdbserver's
makefile.  Though this shouldn't be too hard, most (if not all) of
these checks are in the form macros defined in m4 files in the gnulib
tree, so we could just reference these as needed.  However, in this
commit I propose a different solution.

Currently, in the top level makefile, we give gdb and gdbserver a
dependency on gnulib.  Once gnulib has finished building gdb and
gdbserver can start, these projects then have a hard coded (relative)
path to the compiled gnulib library in their makefiles.

In this commit I extend the gnulib configure script to install a new
makefile fragment in the gnulib build directory.  This new file will
have the usual variable substitutions applied to it, and so can
include the complete list (see above) of all the extra libraries that
are needed when linking against gnulib.

In fact the new makefile fragment defines three variables, these are:

LIBGNU: The path to the archive containing gnulib.  Can be used as a
       dependency as when this file changes gdb/gdbserver should be
       relinked.

LIBGNU_EXTRA_LIBS: A list of linker -l.... flags that should be
       included in the link line of gdb/gdbserver.  These are
       libraries that $(LIBGNU) depends on.  This list is taken from
       the output of gnulib-tool, which is run by our
       gnulib/update-gnulib.sh script.

INCGNU: A list of -I.... include paths that should be passed to the
       compiler, these are where the gnulib headers can be found.

Now both gdb and gdbserver can include the makefile fragment and make
use of these variables.

The makefile fragment relies on the variable GNULIB_BUILDDIR being
defined.  This is checked for in the fragment, and was already defined
in the makefiles of gdb and gdbserver.

gdb/ChangeLog:

* Makefile.in: Include Makefile.gnulib.inc.  Don't define LIBGNU
or INCGNU.  Make use of LIBGNU_EXTRA_LIBS when linking.

gdbserver/ChangeLog:

* Makefile.in: Include Makefile.gnulib.inc.  Don't define LIBGNU
or INCGNU.  Make use of LIBGNU_EXTRA_LIBS when linking.

gnulib/ChangeLog:

* Makefile.gnulib.inc.in: New file.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Install the new file.

4 years agoNotify observers that directories have changed when using "directory" CLI command
Jan Vrany [Fri, 9 Oct 2020 05:47:30 +0000 (06:47 +0100)]
Notify observers that directories have changed when using "directory" CLI command

gdb/ChangeLog

* source.c (directory_command): Notify observers that "directories"
parameter has changed.

gdb/testsuite/ChangeLog

* gdb.mi/mi-cmd-param-changed.exp: Check that notification is
is emmited for both 'set directories' and 'directory' commands.

4 years agoStyle more output of "disassemble" command
Tom Tromey [Fri, 9 Oct 2020 01:41:45 +0000 (19:41 -0600)]
Style more output of "disassemble" command

I noticed a couple of spots where the "disassemble" could style its
output, but currently does not.  This patch adds styling to the
function name at the start of the disassembly, and any addresses
printed there.

gdb/ChangeLog
2020-10-08  Tom Tromey  <tom@tromey.com>

* cli/cli-cmds.c (print_disassembly): Style function name and
addresses.  Add _() wrappers.

gdb/testsuite/ChangeLog
2020-10-08  Tom Tromey  <tom@tromey.com>

* gdb.base/style.exp: Check that "main"'s name is styled.

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

4 years agogold: Update testsuite/split_[i386|x32|x86_64].sh
H.J. Lu [Thu, 8 Oct 2020 11:54:26 +0000 (04:54 -0700)]
gold: Update testsuite/split_[i386|x32|x86_64].sh

Update testsuite/split_i386.sh, testsuite/split_x32.sh and
testsuite/split_x86_64.sh for

commit f9ff65d4dffbaf342dce7a8760059c27683cd962
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Oct 8 10:27:43 2020 +1030

    [GOLD] Increase --split-stack-adjust-size

* testsuite/split_i386.sh: Updated for --split-stack-adjust-size
default change.
* testsuite/split_x32.sh: Likewise.
* testsuite/split_x86_64.sh: Likewise.

4 years agoUpdate GDB NEWS with ARC support in GDBserver
Shahab Vahedi [Wed, 7 Oct 2020 15:13:33 +0000 (17:13 +0200)]
Update GDB NEWS with ARC support in GDBserver

gdb/ChangeLog:

* NEWS: Mention ARC support in GDBserver.

4 years agogdb: Have allocate_target_description return a unique_ptr
Andrew Burgess [Mon, 20 Jul 2020 13:18:04 +0000 (14:18 +0100)]
gdb: Have allocate_target_description return a unique_ptr

Update allocate_target_description to return a target_desc_up, a
specialisation of unique_ptr.

This commit does not attempt to make use of the unique_ptr in the
best possible way, in almost all cases we immediately release the
pointer from within the unique_ptr and then continue as before.

There are a few places where it was easy to handle the unique_ptr, and
in these cases I've done that.

Everything under gdb/features/* is auto-regenerated.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* arch/aarch32.c (aarch32_create_target_description): Release
unique_ptr returned from allocate_target_description.
* arch/aarch64.c (aarch64_create_target_description): Likewise.
* arch/amd64.c (amd64_create_target_description): Likewise.
* arch/arc.c (arc_create_target_description): Likewise.
* arch/arm.c (arm_create_target_description): Likewise.
* arch/i386.c (i386_create_target_description): Likewise.
* arch/riscv.c (riscv_create_target_description): Update return
type.  Handle allocate_target_description returning a unique_ptr.
(riscv_lookup_target_description): Update to handle unique_ptr.
* arch/tic6x.c (tic6x_create_target_description): Release
unique_ptr returned from allocate_target_description.
* features/microblaze-with-stack-protect.c: Regenerate.
* features/microblaze.c: Regenerate.
* features/mips-dsp-linux.c: Regenerate.
* features/mips-linux.c: Regenerate.
* features/mips64-dsp-linux.c: Regenerate.
* features/mips64-linux.c: Regenerate.
* features/nds32.c: Regenerate.
* features/nios2.c: Regenerate.
* features/or1k.c: Regenerate.
* features/rs6000/powerpc-32.c: Regenerate.
* features/rs6000/powerpc-32l.c: Regenerate.
* features/rs6000/powerpc-403.c: Regenerate.
* features/rs6000/powerpc-403gc.c: Regenerate.
* features/rs6000/powerpc-405.c: Regenerate.
* features/rs6000/powerpc-505.c: Regenerate.
* features/rs6000/powerpc-601.c: Regenerate.
* features/rs6000/powerpc-602.c: Regenerate.
* features/rs6000/powerpc-603.c: Regenerate.
* features/rs6000/powerpc-604.c: Regenerate.
* features/rs6000/powerpc-64.c: Regenerate.
* features/rs6000/powerpc-64l.c: Regenerate.
* features/rs6000/powerpc-7400.c: Regenerate.
* features/rs6000/powerpc-750.c: Regenerate.
* features/rs6000/powerpc-860.c: Regenerate.
* features/rs6000/powerpc-altivec32.c: Regenerate.
* features/rs6000/powerpc-altivec32l.c: Regenerate.
* features/rs6000/powerpc-altivec64.c: Regenerate.
* features/rs6000/powerpc-altivec64l.c: Regenerate.
* features/rs6000/powerpc-e500.c: Regenerate.
* features/rs6000/powerpc-e500l.c: Regenerate.
* features/rs6000/powerpc-isa205-32l.c: Regenerate.
* features/rs6000/powerpc-isa205-64l.c: Regenerate.
* features/rs6000/powerpc-isa205-altivec32l.c: Regenerate.
* features/rs6000/powerpc-isa205-altivec64l.c: Regenerate.
* features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Regenerate.
* features/rs6000/powerpc-isa205-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa205-vsx64l.c: Regenerate.
* features/rs6000/powerpc-isa207-htm-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa207-htm-vsx64l.c: Regenerate.
* features/rs6000/powerpc-isa207-vsx32l.c: Regenerate.
* features/rs6000/powerpc-isa207-vsx64l.c: Regenerate.
* features/rs6000/powerpc-vsx32.c: Regenerate.
* features/rs6000/powerpc-vsx32l.c: Regenerate.
* features/rs6000/powerpc-vsx64.c: Regenerate.
* features/rs6000/powerpc-vsx64l.c: Regenerate.
* features/rs6000/rs6000.c: Regenerate.
* features/rx.c: Regenerate.
* features/s390-gs-linux64.c: Regenerate.
* features/s390-linux32.c: Regenerate.
* features/s390-linux32v1.c: Regenerate.
* features/s390-linux32v2.c: Regenerate.
* features/s390-linux64.c: Regenerate.
* features/s390-linux64v1.c: Regenerate.
* features/s390-linux64v2.c: Regenerate.
* features/s390-te-linux64.c: Regenerate.
* features/s390-tevx-linux64.c: Regenerate.
* features/s390-vx-linux64.c: Regenerate.
* features/s390x-gs-linux64.c: Regenerate.
* features/s390x-linux64.c: Regenerate.
* features/s390x-linux64v1.c: Regenerate.
* features/s390x-linux64v2.c: Regenerate.
* features/s390x-te-linux64.c: Regenerate.
* features/s390x-tevx-linux64.c: Regenerate.
* features/s390x-vx-linux64.c: Regenerate.
* mips-tdep.c (_initialize_mips_tdep): Release unique_ptr returned
from allocate_target_description.
* target-descriptions.c (allocate_target_description): Update
return type.
(print_c_tdesc::visit_pre): Release unique_ptr returned from
allocate_target_description.

gdbserver/ChangeLog:

* linux-low.cc (linux_process_target::handle_extended_wait):
Release the unique_ptr returned from allocate_target_description.
* linux-riscv-low.cc (riscv_target::low_arch_setup): Likewise.
* linux-x86-low.cc (tdesc_amd64_linux_no_xml): Change type.
(tdesc_i386_linux_no_xml): Change type.
(x86_linux_read_description): Borrow pointer from unique_ptr
object.
(x86_target::get_ipa_tdesc_idx): Likewise.
(initialize_low_arch): Likewise.
* tdesc.cc (allocate_target_description): Update return type.

gdbsupport/ChangeLog:

* tdesc.h (allocate_target_description): Update return type.

4 years ago[GOLD] Increase --split-stack-adjust-size
Alan Modra [Wed, 7 Oct 2020 23:57:43 +0000 (10:27 +1030)]
[GOLD] Increase --split-stack-adjust-size

For functions with small (< 256 bytes) stack frames, the current x86
do_calls_non_split ignores --split-stack-adjust-size and, in
combination with __morestack_non_split, supplies a non-split-stack
function with at least 0x100000 (1M) available stack.  On powerpc64, a
default of 0x4000 is not large enough to reliably work with the golang
testsuite.  This increase the default size to the defacto x86 value.

* options.h (split_stack_adjust_size): Default to 0x100000.

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

4 years agox86: Update GNU property tests
H.J. Lu [Tue, 6 Oct 2020 22:51:33 +0000 (15:51 -0700)]
x86: Update GNU property tests

Update property tests for glibc compiled by Fedora binary annotation
plugin for GCC, which may insert additonal GNU properties:

x86 ISA needed: SSE, SSE2

* testsuite/ld-i386/property-3.r: Updated for Fedora binary
annotation plugin for GCC.
* testsuite/ld-i386/property-4.r: Likewise.
* testsuite/ld-i386/property-5.r: Likewise.
* testsuite/ld-x86-64/property-3.r: Likewise.
* testsuite/ld-x86-64/property-4.r: Likewise.
* testsuite/ld-x86-64/property-5.r: Likewise.

4 years agoAdd simple_search_memory unit tests
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Add simple_search_memory unit tests

This adds some unit tests for simple_search_memory.  I tried here to
reproduce some bugs (PR gdb/11158 and PR gdb/17756), but was unable
to.

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

* unittests/search-memory-selftests.c: New file.
* Makefile.in (SELFTESTS_SRCS): Add
unittests/search-memory-selftests.c.

4 years agoDocument inclusive range in help for "find"
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Document inclusive range in help for "find"

PR gdb/16930 points out that the "find" command uses an inclusive
range; but this is not documented in the "help".  This patch updates
the help text.

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

PR gdb/16930:
* findcmd.c (_initialize_mem_search): Mention that the range is
inclusive.

4 years agoRemove some dead code from handle_search_memory
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Remove some dead code from handle_search_memory

handle_search_memory had some code after a call to error.  This code
is dead, and this patch removes it.

gdbserver/ChangeLog
2020-10-07  Tom Tromey  <tromey@adacore.com>

* server.cc (handle_search_memory): Remove dead code.

4 years agoUse simple_search_memory in gdbserver
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Use simple_search_memory in gdbserver

This replaces gdbserver's memory-searching function with
simple_search_memory.

gdbserver/ChangeLog
2020-10-07  Tom Tromey  <tromey@adacore.com>

* server.cc (handle_search_memory_1): Remove.
(handle_search_memory): Use simple_search_memory.

4 years agoMove simple_search_memory to gdbsupport/search.cc
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Move simple_search_memory to gdbsupport/search.cc

This moves the simple_search_memory function to a new file,
gdbsupport/search.cc.  The API is slightly changed to make it more
general.  This generality is useful for wiring it to gdbserver, and
also for unit testing.

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

* target.h (simple_search_memory): Don't declare.
* target.c (simple_search_memory): Move to gdbsupport.
(default_search_memory): Update.
* remote.c (remote_target::search_memory): Update.

gdbsupport/ChangeLog
2020-10-07  Tom Tromey  <tromey@adacore.com>

* Makefile.in: Rebuild.
* Makefile.am (libgdbsupport_a_SOURCES): Add search.cc.
* search.h: New file.
* search.cc: New file.

4 years agoRename some tests in find.exp
Tom Tromey [Wed, 7 Oct 2020 18:07:55 +0000 (12:07 -0600)]
Rename some tests in find.exp

This renames some tests in find.exp, to avoid duplicate test names.

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

* gdb.base/find.exp: Rename some tests.

4 years agogdb: put user-supplied CFLAGS at the end
Simon Marchi [Wed, 7 Oct 2020 17:58:57 +0000 (13:58 -0400)]
gdb: put user-supplied CFLAGS at the end

GDB currently doesn't build cleanly with clang (a -Wdeprecated-copy-dtor
error).  I configured my clang-based GDB build with
CXXFLAGS="-Wno-error=deprecated-copy-dtor", so I can use it despite that
problem.  However, I found that it had no effect.  This is because my
-Wno-error=Wdeprecated-copy-dtor switch is followed by -Werror in the
command line, which switches back all warnings to be errors.

If we want the user-supplied C(XX)FLAGS to be able to override flags
added by our configure script, the user-supplied C(XX)FLAGS should
appear after the configure-supplied flags.

This patch moves the user-supplied CXXFLAGS at the very end of the
compilation command line, which fixes the problem described above.  This
means moving it out of INTERNAL_CFLAGS and inlining it in the users of
INTERNAL_CFLAGS.

I observed the problem when building GDB, but the same problem could
happen with GDBserver, so the change is done there too.

In GDBserver, INTERNAL_CFLAGS is passed when linking

gdb/ChangeLog:

* Makefile.in (COMPILE): Add CXXFLAGS.
(INTERNAL_CFLAGS_BASE): Remove CXXFLAGS.
(check-headers): Add CXXFLAGS.

gdbserver/ChangeLog:

* Makefile.in (COMPILE): Add CXXFLAGS.
(INTERNAL_CFLAGS_BASE): Remove CXXFLAGS.
(gdbserver$(EXEEXT)): Add CXXFLAGS.
(gdbreplay$(EXEEXT)): Add CXXFLAGS.
($(IPA_LIB)): Add CXXFLAGS.
(IPAGENT_COMPILE): Add CXXFLAGS.

Change-Id: I00e054506695e0e9536095c6d14827e48abd8f69

4 years agoAdd Makefile.in entry for "Add NetBSD/aarch64 gdbserver support"
Kamil Rytarowski [Wed, 7 Oct 2020 17:38:46 +0000 (19:38 +0200)]
Add Makefile.in entry for "Add NetBSD/aarch64 gdbserver support"

The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.

gdbserver/ChangeLog:

         * netbsd-aarch64-low.cc: Add.
         * Makefile.in (SFILES): Register "netbsd-aarch64-low.c".
         * configure.srv: Add aarch64*-*-netbsd*.

4 years agogdb: Correct the ChageLog entry
Shahab Vahedi [Wed, 7 Oct 2020 16:20:45 +0000 (18:20 +0200)]
gdb: Correct the ChageLog entry

Becausae of a copy/paste, I've put myself as the author of the
following patch which was not true:

6d2d7c5668f gdbserver: Add GNU/Linux support for ARC

This change will place the correct date and author in the ChangeLog.

4 years agoarc: Add support for Linux coredump files
Anton Kolesov [Mon, 30 Jan 2017 15:32:10 +0000 (18:32 +0300)]
arc: Add support for Linux coredump files

With the implemenations in this patch, ARC gdb can handle
coredump related matters.  The binutils counter part of
this patch has already been pushed [1].

v2 [2]:
- arc_linux_collect_gregset: Use "reg <= ARC_LAST_REGNUM" instead of
  "reg < ARC_LAST_REGNUM" for the condition check of the for-loop.
- arc-linux-tdep.c: Use "ARC_LAST_REGNUM < ARRAY_SIZE (...)" instead of
  "ARC_LAST_REGNUM <= ARRAY_SIZE (...)" for the "asserts".
- Use "buf + arc_linux_core_reg_offsets[ARC_ERET_REGNUM]" instead of
  "buf + REG_OFF (6)".
- Fix a few typos/indentation.

v3 [3]:
- Use gdb_assert_not_reached(text) instead of gdb_assert (!text).
- Remove unnecessary braces in the for loop.

[1] arc: Add support for ARC HS extra registers in core files
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=2745674244d6aecddcf636475034bdb9c0a6b4a0

[2] First remarks
https://sourceware.org/pipermail/gdb-patches/2020-September/171912.html

[3] Second remarks
https://sourceware.org/pipermail/gdb-patches/2020-October/172302.html

gdb/ChangeLog:

* arc-linux-tdep.h: New file.
* arc-linux-tdep.c (arc_linux_core_reg_offsets,
arc_linux_supply_gregset, arc_linux_supply_v2_regset,
arc_linux_collect_gregset, arc_linux_collect_v2_regset,
arc_linux_gregset, arc_linux_v2_regset,
arc_linux_iterate_over_regset_sections,
arc_linux_core_read_description): Implement.
(arc_linux_init_osabi): Set iterate_over_regset_sections.
* arc-tdep.h (ARC_OFFSET_NO_REGISTER): Declare.
        (arc_gdbarch_features_create): Add.
* arc-tdep.c (arc_gdbarch_features_create): Not static anymore.

4 years agogdbserver: Add GNU/Linux support for ARC
Anton Kolesov [Wed, 6 Jul 2016 17:30:29 +0000 (20:30 +0300)]
gdbserver: Add GNU/Linux support for ARC

This gdbserver implementation supports ARC ABI v3 and v4 (older ARC ABI
versions are not supported by other modern GNU tools or Linux itself).
Gdbserver supports inspection of ARC HS registers R30, R58 and R59 - feature
that has been added to Linux 4.12.  Whether gdbserver build will actually
support this feature depends on the version of Linux headers used to build
the server.

v2 [1]:
- Use "this->read_memory ()" instead of "the_target->read_memory ()".
- Remove the unnecessary "arch-arc.o:" target from the "Makefile.in".
- Got rid of "ntohs()" function and added lots of comments about
  endianness.
- Clarify why "pc" value is read from and saved to different fields
  in user regs struct.
- In function "is_reg_name_available_p()", use a range-based iterator
  to loop over the registers.
- Removed mentioning of issue number that was not related to sourceware.
- A few typo's fixed.

[1] Remarks
https://sourceware.org/pipermail/gdb-patches/2020-September/171911.html
https://sourceware.org/pipermail/gdb-patches/2020-September/171919.html

gdbserver/ChangeLog:

* configure.srv: Support ARC architecture.
* Makefile.in: Add linux-arc-low.cc and arch/arc.o.
* linux-arc-low.cc: New file.

4 years agoarc: Rename "arc_gdbarch_features" struct
Shahab Vahedi [Mon, 5 Oct 2020 15:10:47 +0000 (17:10 +0200)]
arc: Rename "arc_gdbarch_features" struct

"arc_gdbarch_features" is a data structure containing information
about the ARC architecture: ISA version, register size, etc.
This name is misleading, because although it carries the phrase
"gdbarch", it has nothing to do with the type/interface in GDB.
Traditionaly, "gdbarch" structures are only used for that purpose.
To rectify this, this patch changes the name to "arc_arch_features".

gdb/ChangeLog:

* arch/arc.h: Rename "arc_gdbarch_features" to
"arc_arch_features".
* arc-tdep.h: Likewise.
* arc-tdep.c: Likewise.

4 years agoStop passing netbsd_process_target to local functions
Kamil Rytarowski [Wed, 7 Oct 2020 14:32:11 +0000 (16:32 +0200)]
Stop passing netbsd_process_target to local functions

Switch from target->read_memory to netbsd_nat::read_memory and
cleanup the code.

No functional change.

gdbserver/ChangeLog:

        * netbsd-low.cc (get_dynamic, get_r_debug, read_one_ptr)
        (netbsd_qxfer_libraries_svr4): Remove "target" argument and update.
        (netbsd_process_target::qxfer_libraries_svr4): Update.

4 years agogdb/infcmd: remove redundant clear_proceed_status call
Tankut Baris Aktemur [Wed, 7 Oct 2020 14:55:52 +0000 (16:55 +0200)]
gdb/infcmd: remove redundant clear_proceed_status call

In `attach_command`, there is a call to `init_wait_for_inferior`
followed by a call to `clear_proceed_status`.  However,
`init_wait_for_inferior` already calls `clear_proceed_status`.  Remove
the redundant call.

Regression-tested on X86_64 Linux.

gdb/ChangeLog:
2020-10-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* infcmd.c (attach_command): Remove the redundant call to
`clear_proceed_status`.

4 years agoCorrect logical error in NetBSD's read_memory and write_memory
Kamil Rytarowski [Wed, 7 Oct 2020 13:12:59 +0000 (15:12 +0200)]
Correct logical error in NetBSD's read_memory and write_memory

In case of repeated ptrace PT_IO call and returning the value of
transferred bytes equal to 0, do not return without setting
xfered_len.

gdb/ChangeLog:

        * nat/netbsd-nat.c (write_memory, read_memory): Update.

4 years agoFix whitespace formatting
Kamil Rytarowski [Fri, 2 Oct 2020 01:57:16 +0000 (03:57 +0200)]
Fix whitespace formatting

gdbserver/ChangeLog:

        * netbsd-low.cc: Fix whitespace formatting.
        * netbsd-amd64-low.cc: Likewise.

4 years agoAdd common write_memory and read_memory NetBSD routines
Kamil Rytarowski [Wed, 7 Oct 2020 03:57:52 +0000 (05:57 +0200)]
Add common write_memory and read_memory NetBSD routines

Instead of sharing the native-only code with all BSDs with slightly
different semantics of the kernels, share the NetBSD-only behavior beteen
the NetBSD native and gdbserver setup.

NetBSD does not differentiate the address space I and D in the
operations (contrary to OpenBSD). NetBSD handles EACCES that integrates
with NetBSD specific PaX MPROTECT error handling.

Add a verbose message in the native client that an operation could be
cancelled due to PaX MPROTECT setup.

gdb/ChangeLog:

       * nat/netbsd-nat.c (write_memory, read_memory): Add.
       * nat/netbsd-nat.h (write_memory, read_memory): Likewise.
       * nbsd-nat.c (nbsd_nat_target::xfer_partial): Update.

gdbserver/ChangeLog:

       * netbsd-low.cc (netbsd_process_target::read_memory)
       (netbsd_process_target::write_memory): Update.

4 years agoAdd ChangeLog for "Add NetBSD/aarch64 gdbserver support"
Kamil Rytarowski [Wed, 7 Oct 2020 12:47:27 +0000 (14:47 +0200)]
Add ChangeLog for "Add NetBSD/aarch64 gdbserver support"

The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.

gdbserver/ChangeLog:

         * netbsd-aarch64-low.cc: Add.
         * Makefile.in (SFILES): Register "netbsd-aarch64-low.c".
         * configure.srv: Add aarch64*-*-netbsd*.

4 years agoAdd NetBSD/aarch64 gdbserver support
Kamil Rytarowski [Tue, 6 Oct 2020 16:10:26 +0000 (18:10 +0200)]
Add NetBSD/aarch64 gdbserver support

The support is on par with NetBSD/amd64, thus GPR works,
single step and software breakpoint are operational, and the
SVR4 r_debug integration is functional.

gdbserver/ChangeLog:

         * netbsd-aarch64-low.cc: Add.
         * Makefile.in (SFILES): Register "netbsd-aarch64-low.c".
         * configure.srv: Add aarch64*-*-netbsd*.

4 years agogdb: make signal_catch_counts a static array
Simon Marchi [Wed, 7 Oct 2020 12:13:44 +0000 (08:13 -0400)]
gdb: make signal_catch_counts a static array

I noticed that signal_catch_counts is a dynamically-allocated array of
constant size, allocated at startup an never freed.  This might as well
be a statically-allocated array.

gdb/ChangeLog:

* break-catch-sig.c (signal_catch_counts): Make a static arrray.
(_initialize_break_catch_sig): Don't allocate array.

Change-Id: I220321df5ad6c1d2664ec9d483eea2dc1c979afe

4 years agogdb: Fix installation of gcore.1 on some platforms
Michael Forney [Tue, 6 Oct 2020 21:12:57 +0000 (17:12 -0400)]
gdb: Fix installation of gcore.1 on some platforms

gcore is installed on NetBSD, FreeBSD, Solaris (HAVE_NATIVE_GCORE_HOST=1)
and Linux (HAVE_NATIVE_GCORE_TARGET=1). However, even though gcore.1
is installed conditional on those variables, HAVE_NATIVE_GCORE_HOST
was missing from gdb/doc/Makefile.in, so manual installation was
skipped on NetBSD, FreeBSD, and Solaris.

gdb/doc/ChangeLog:
2020-10-06  Michael Forney  <mforney@mforney.org>

        * Makefile.in (HAVE_NATIVE_GCORE_HOST): Add for gcore.1
        install condition.

Change-Id: I17c3ce2ecdfb806ece17f05ba78356b25ffa865e

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 7 Oct 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agox86: Properly merge -z ibt and -z shstk
H.J. Lu [Tue, 6 Oct 2020 22:38:23 +0000 (15:38 -0700)]
x86: Properly merge -z ibt and -z shstk

Merge -z ibt and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND, not
any GNU_PROPERTY_X86_UINT32_AND_XXX properties.

bfd/

PR ld/26711
* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Merge -z ibt
and -z shstk only with GNU_PROPERTY_X86_FEATURE_1_AND.

ld/

PR ld/26711
* testsuite/ld-i386/i386.exp: Run ld/26711 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr26711-1.d: Likewise.
* testsuite/ld-i386/pr26711-2.d: Likewise.
* testsuite/ld-i386/pr26711-3.d: Likewise.
* testsuite/ld-x86-64/pr26711-1-x32.d: Likewise.
* testsuite/ld-x86-64/pr26711-1.d: Likewise.
* testsuite/ld-x86-64/pr26711-2-x32.d: Likewise.
* testsuite/ld-x86-64/pr26711-2.d: Likewise.
* testsuite/ld-x86-64/pr26711-3-x32.d: Likewise.
* testsuite/ld-x86-64/pr26711-3.d: Likewise.
* testsuite/ld-x86-64/pr26711.s: Likewise.

4 years agogdbserver: Remove unused argument in register_data()
Shahab Vahedi [Tue, 6 Oct 2020 11:15:32 +0000 (13:15 +0200)]
gdbserver: Remove unused argument in register_data()

The register_data() function in gdbserver/regcache.cc has an
input argument called "fetch".  This argument is not used by this
static function at all.  Therefore, it is time to get rid of it.

gdbserver/ChangeLog:

* regcache.cc (register_data): Remove unused "fetch" argument.

4 years agoaarch64: Fix bogus type punning in parse_barrier() [PR26699]
Alex Coplan [Tue, 6 Oct 2020 14:56:44 +0000 (15:56 +0100)]
aarch64: Fix bogus type punning in parse_barrier() [PR26699]

This patch fixes a bogus use of type punning in parse_barrier() which
was causing an assembly failure on big endian LP64 hosts when attempting
to assemble "isb sy" for AArch64.

The type of the entries in aarch64_barrier_opt_hsh is
aarch64_name_value_pair. We were incorrectly casting this to the
locally-defined asm_barrier_opt which has a wider type (on LP64) for the
second member. This happened to work on little-endian hosts but fails on
LP64 big endian.

The fix is to use the correct type in parse_barrier(). This makes the
locally-defined asm_barrier_opt redundant, so remove it.

gas/ChangeLog:

* config/tc-aarch64.c (asm_barrier_opt): Delete.
(parse_barrier): Fix bogus type punning.
* testsuite/gas/aarch64/system.d: Update disassembly.
* testsuite/gas/aarch64/system.s: Add isb sy test.

4 years agoFix a bug in objcopy/strip's ability to merge notes in multiple same-named sections.
Nick Clifton [Tue, 6 Oct 2020 14:49:40 +0000 (15:49 +0100)]
Fix a bug in objcopy/strip's ability to merge notes in multiple same-named sections.

* objcopy.c (copy_object): Compare input and output sections by
pointer rather than name.

4 years agoFix gdb.base/list.exp with Clang
Gary Benson [Tue, 6 Oct 2020 14:08:37 +0000 (15:08 +0100)]
Fix gdb.base/list.exp with Clang

Two subtests of gdb.base/list.exp failed when built with Clang
because the unused function "unused" was optimized out.  This
commit adds __attribute__ ((used)) to both definitions.

gdb/testsuite/ChangeLog:

* gdb.base/list0.c (unused): Add __attribute__ ((used)).
* gdb.base/list1.c (unused): Likewise.

4 years agoFix gdb.base/list-ambiguous.exp with Clang
Gary Benson [Tue, 6 Oct 2020 14:08:37 +0000 (15:08 +0100)]
Fix gdb.base/list-ambiguous.exp with Clang

The ambiguous variable parts of gdb.base/list-ambiguous.exp failed
when built with Clang because the variable in question was unused
and was optimized out.  This commit adds __attribute__ ((used)) to
both definitions.

gdb/testsuite/ChangeLog:

* gdb.base/list-ambiguous0.c (ambiguous_var): Add
__attribute__ ((used)).
* gdb.base/list-ambiguous1.c (ambiguous_var): Likewise.

4 years agoA small set of code improvements for the Z80 assembler.
Sergey Belyashav [Tue, 6 Oct 2020 10:58:57 +0000 (11:58 +0100)]
A small set of code improvements for the Z80 assembler.

PR 26692
* config/tc-z80.c (md_begin): Ensure that xpressions are empty
before using them.
(unify_indexed): Likewise.
(z80_start_line_hook): Improve hash sign handling when SDCC
compatibility mode enabled.
(md_parse_exp_not_indexed): Improve indirect addressing
detection.
(md_pseudo_table): Accept hd64 as an alias of z810.

4 years agosim: Fix autoreconf errors in sim/ directory
Andrew Burgess [Mon, 5 Oct 2020 08:53:50 +0000 (09:53 +0100)]
sim: Fix autoreconf errors in sim/ directory

Run autoreconf in sim/ directory and you'll see some errors.  The
problem is that autoreconf (a perl script) does not evaluate the value
passed as an argument to AC_CONFIG_AUX_DIR, so something like:

  AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..)

does not do the right thing inside autoreconf, my understanding is
that changing to something like this is fine:

  AC_CONFIG_AUX_DIR(../..)

the generated configure seems to check the value passed, and the value
passed relative to the source directory, so I think we get basically
the same behaviour as before.

sim/testsuite/ChangeLog:

* configure: Regnerate.
* configure.ac (AC_CONFIG_AUX_DIR): Update.

sim/testsuite/d10v-elf/ChangeLog:

* configure: Regnerate.
* configure.ac (AC_CONFIG_AUX_DIR): Update.

sim/testsuite/frv-elf/ChangeLog:

* configure: Regnerate.
* configure.ac (AC_CONFIG_AUX_DIR): Update.

sim/testsuite/m32r-elf/ChangeLog:

* configure: Regnerate.
* configure.ac (AC_CONFIG_AUX_DIR): Update.

sim/testsuite/mips64el-elf/ChangeLog:

* configure: Regnerate.
* configure.ac (AC_CONFIG_AUX_DIR): Update.

4 years agogdb: handle unmapped overlays in find_pc_line
Andrew Burgess [Sun, 13 Sep 2020 20:53:26 +0000 (21:53 +0100)]
gdb: handle unmapped overlays in find_pc_line

I configured and built an m32r-elf toolchain, and ran the
gdb.base/overlays.exp test.  I saw a couple of errors where GDB would
place a breakpoint in the wrong place when placing a breakpoint using
a function name, for example in this function:

/* 1 */  int foo (int x)
/* 2 */  {
/* 3 */    if (x)
/* 4 */      return some_global_variable;
/* 5 */    else
/* 6 */      return 0;
/* 7 */  }

GDB would place the breakpoint on line 2 instead of line 3.  The issue
is that GDB was failing to skip the prologue correctly.

The reason for this is that in m32r-tdep.c:m32r_skip_prologue, we
first use find_pc_partial_function to find the functions start and end
addresses, then we use find_pc_line to find the start and end of the
first line of the function.

Currently, if the pc value passed to find_pc_partial_function is in an
unmapped overlay then the function start and end addresses that are
returned are also the unmapped addresses.

However, this is not the case for find_pc_line, here, if the address
passed in is in an unmapped overlay then we still get back a
symtab_and_line describing the mapped location.

What this means is that if a function's mapped location is 0x100 ->
0x120, and its unmapped locations is 0x400 -> 0x420 then we think that
the start/end is 0x400 and 0x420 respectively, but the first line
might run from 0x100 to 0x108.

GDB will then try to scan the prologue starting from 0x400 and ending
at 0x108, this immediately gives up as it thinks we have gone past the
end of the prologue and the breakpoint is placed at 0x400.

In this commit I propose that we change find_pc_line to return
addresses in the unmapped range if the address passed in is already in
the unmapped range.  Now the first line will appear to run from 0x400
to 0x408 and the prologue scanner will correctly find the end of the
prologue.

With this commit gdb.base/overlays.exp now completely passes with an
m32r-elf toolchain.

gdb/ChangeLog:

* symtab.c (find_pc_line): Return unmapped addresses when the
requested address is also unmapped.

4 years agogdb/testsuite: allow gdb.base/overlays.exp to compile for m32r
Andrew Burgess [Sun, 13 Sep 2020 20:53:08 +0000 (21:53 +0100)]
gdb/testsuite: allow gdb.base/overlays.exp to compile for m32r

The gdb.base/overlays.exp test is only currently supported on m32r
baremetal targets, however, when I configure a toolchain for m32r-elf
the test does not compile.

This commit updates the linker script, fixes some TCL errors in the
exp file, and adds some missing includes to the source file so that
the test does compile.

With this test, when run against an m32r-elf toolchain the test mostly
passes, but there are a couple of failures, these are GDB issues and
will be addressed in a later commit.

gdb/testsuite/ChangeLog:

* gdb.base/m32r.ld: Remove SEARCH_DIR line.  Add MEMORY regions,
make use of regions throughout.
* gdb.base/overlays.exp: Enclose string with variableds in "..",
not {...}.
* gdb.base/ovlymgr.c: Add 'string.h' and 'stdlib.h' includes.

4 years agoFix gas sh-link-zero test for hppa64-hpux
Alan Modra [Tue, 6 Oct 2020 09:52:43 +0000 (20:22 +1030)]
Fix gas sh-link-zero test for hppa64-hpux

* testsuite/gas/elf/sh-link-zero.s: Don't start directives in
first column.  Don't use numeric labels.

4 years agoPR26667, Add powerpc64le-*-freebsd* support
Brandon Bergren [Mon, 5 Oct 2020 22:49:23 +0000 (09:19 +1030)]
PR26667, Add powerpc64le-*-freebsd* support

PR 26667
bfd/
* config.bfd: Add powerpc64le-*-freebsd*.
* configure.ac: Add powerpc_elf64_fbsd_le_vec.
* elf64-ppc.c (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME): Define for
freebsd.
* targets.c (powerpc_elf64_fbsd_le_vec): Declare.
(_bfd_target_vector): Add it.
* configure: Regenerate.
ld/
* Makefile.am (ALL_64_EMULATION_SOURCES): Add eelf64lppc_fbsd.c.
Include $(DEPDIR)/eelf64lppc_fbsd.Pc.
* configure.tgt: Add powerpc64le-*-freebsd*.
* emulparams/elf64lppc_fbsd.sh: New file.
* Makefile.in: Regenerate.
* po/BLD-POTFILES.in: Regenerate.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 6 Oct 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

4 years agogdb: sync tui header files in HFILES_NO_SRCDIR
Simon Marchi [Mon, 5 Oct 2020 16:37:23 +0000 (12:37 -0400)]
gdb: sync tui header files in HFILES_NO_SRCDIR

I noticed that tui/tui-windata.h didn't exist anymore, and that
tui/tui-out.h wasn't listed.  Fix that.

gdb/ChangeLog:

* Makefile.in (HFILES_NO_SRCDIR): Remove tui/tui-windata.h, add
tui/tui-out.h.

Change-Id: Ic75cc68432b90ba5be857a2852ad52dea326fe36

4 years agogdb: TYPE_VECTOR -> type::is_vector in amd64-windows-tdep.c
Simon Marchi [Mon, 5 Oct 2020 16:21:14 +0000 (12:21 -0400)]
gdb: TYPE_VECTOR -> type::is_vector in amd64-windows-tdep.c

I get this build failure:

      CXX    amd64-windows-tdep.o
    cc1plus: warning: command-line option '-Wmissing-prototypes' is valid for C/ObjC but not for C++
    /home/smarchi/src/binutils-gdb/gdb/amd64-windows-tdep.c: In function 'return_value_convention amd64_windows_return_value(gdbarch*, value*, type*, regcache*, gdb_byte*, const gdb_byte*)':
    /home/smarchi/src/binutils-gdb/gdb/amd64-windows-tdep.c:374:6: error: 'TYPE_VECTOR' was not declared in this scope
      374 |  if (TYPE_VECTOR (type) && len == 16)
          |      ^~~~~~~~~~~

TYPE_VECTOR was removed in favor of the type::is_vector method.

gdb/ChangeLog:

* amd64-windows-tdep.c (amd64_windows_return_value): Use
type::is_vector instead of TYPE_VECTOR.

Change-Id: I0ce26c3f7a33625761a8dba351c3158464f21b01

4 years agoFix compile time error building windmc, detected by gcc 11.
Nick Clifton [Mon, 5 Oct 2020 15:09:00 +0000 (16:09 +0100)]
Fix compile time error building windmc, detected by gcc 11.

PR 26698
* windmc.c (mc_unify_path): Fix typo checking character at end of
pathname.

4 years ago[PATCH][GAS][AArch64] Update Cortex-X1 feature flags
Przemyslaw Wirkus [Mon, 5 Oct 2020 14:43:41 +0000 (15:43 +0100)]
[PATCH][GAS][AArch64] Update Cortex-X1 feature flags

This is feature flags update for Cortex-X1 CPU.
For more information about this processor, see [0].

[0] : https://www.arm.com/products/cortex-x

gas/ChangeLog:

2020-10-05  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* config/tc-aarch64.c: Update Cortex-X1 feature flags.

4 years ago[PATCH][GAS][arm] Update Cortex-X1 feature flags
Przemyslaw Wirkus [Mon, 5 Oct 2020 14:43:32 +0000 (15:43 +0100)]
[PATCH][GAS][arm] Update Cortex-X1 feature flags

This is feature flags update for Cortex-X1 CPU.
For more information about this processor, see [0].

[0] : https://www.arm.com/products/cortex-x

gas/ChangeLog:

2020-10-05  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* config/tc-arm.c: Update Cortex-X1 feature flags.

4 years agoAdd NetBSD AArch64 Little Endian and Big Endian BFD support.
Nick Clifton [Mon, 5 Oct 2020 13:56:42 +0000 (14:56 +0100)]
Add NetBSD AArch64 Little Endian and Big Endian BFD support.

bfd      * config.bfd (aarch64-*-netbsd*, aarch64_be-*-netbsd*): Add target.

4 years agoAdd NetBSD AArch64 GAS support.
Kamil Rytarowski [Mon, 5 Oct 2020 13:54:00 +0000 (14:54 +0100)]
Add NetBSD AArch64 GAS support.

gas * configure.tgt (aarch64*-*-netbsd*): Add target.

4 years agoFix spelling mistakes
Samanta Navarro [Mon, 5 Oct 2020 13:20:15 +0000 (14:20 +0100)]
Fix spelling mistakes

4 years agogdb: avoid unnecessary string copy in auto_load_objfile_script_1
Simon Marchi [Mon, 5 Oct 2020 13:02:42 +0000 (09:02 -0400)]
gdb: avoid unnecessary string copy in auto_load_objfile_script_1

Assigning the result of STRIP_DRIVE_SPEC to an std::string creates an
unnecessary copy of the string.  STRIP_DRIVE_SPEC is defined as:

  #define STRIP_DRIVE_SPEC(f) ((f) + 2)

So if it is passed a "const char *", it returns a "const char *".  We
could use a "const char *" intermediary variable instead of an
std::string, or (as implemented in this patch) just use it directly in
the concatenation right after.

gdb/ChangeLog:

* auto-load.c (auto_load_objfile_script_1): Don't use
debugfile_holder as temporary variable when stripping drive
letter.

Change-Id: If2ccc7a156b22100754d9cdf6778ac7eeb93da4c

4 years agoi386: Allow non-absolute segment values for lcall/ljmp
T.K. Chia [Mon, 5 Oct 2020 12:46:23 +0000 (05:46 -0700)]
i386: Allow non-absolute segment values for lcall/ljmp

Allow an unresolved or non-absolute symbol as the segment operand of an
immediate far jump (`ljmp SEG, OFF') or far call (`lcall SEG, OFF').

gas/

2020-10-05  T.K. Chia  <u1049321969@caramail.com>

PR gas/26694
* NEWS: Updated for i386 lcall and ljmp change.
* config/tc-i386.c (output_interseg_jump): Allow non-absolute
segment operand for immediate lcall and ljmp.
* testsuite/gas/i386/jump.d,
* testsuite/gas/i386/jump.s,
* testsuite/gas/i386/jump16.d,
* testsuite/gas/i386/jump16.e,
* testsuite/gas/i386/jump16.s: Add tests for non-absolute
segment operand for immediate ljmp.

ld/

2020-10-05  T.K. Chia  <u1049321969@caramail.com>

PR gas/26694
* testsuite/ld-i386/ljmp.s,
* testsuite/ld-i386/ljmp1.d,
* testsuite/ld-i386/ljmp1.s,
* testsuite/ld-i386/ljmp2.d,
* testsuite/ld-i386/ljmp2.s,
* testsuite/ld-x86-64/ljmp1.d,
* testsuite/ld-x86-64/ljmp2.d: New testcases.
* testsuite/ld-i386/i386.exp,
* testsuite/ld-x86-64/x86-64.exp: Run them.

4 years agoUpdate the BFD linker so that it deprecates grouped short options.
Nick Clifton [Mon, 5 Oct 2020 12:53:59 +0000 (13:53 +0100)]
Update the BFD linker so that it deprecates grouped short options.

* lexsup.c (parse_args): Generate an error or warning message when
multiple short options are used together.

4 years agoFix function argument and return value locations
Hannes Domani [Tue, 5 May 2020 12:31:26 +0000 (14:31 +0200)]
Fix function argument and return value locations

Fixes these testsuite fails on Windows:
FAIL: gdb.base/callfuncs.exp: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_values(fc1, fc2)
FAIL: gdb.base/callfuncs.exp: noproto: p t_float_complex_many_args(fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4, fc1, fc2, fc3, fc4)
FAIL: gdb.base/call-sc.exp: p/c fun(); call call-sc-tld
FAIL: gdb.base/call-sc.exp: advance to fun for return; return call-sc-tld
FAIL: gdb.base/call-sc.exp: zed L for return; return call-sc-tld
FAIL: gdb.base/call-sc.exp: return foo; return call-sc-tld
FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld'
FAIL: gdb.base/call-sc.exp: return foo; synchronize pc to main() for 'call-sc-tld'
FAIL: gdb.base/call-sc.exp: advance to fun for finish; return call-sc-tld
FAIL: gdb.base/call-sc.exp: zed L for finish; return call-sc-tld
FAIL: gdb.base/call-sc.exp: finish foo; return call-sc-tld (the program is no longer running)
FAIL: gdb.base/call-sc.exp: value foo finished; return call-sc-tld

For function arguments (callfuncs.exp), only TYPE_CODE_COMPLEX was
missing in the types passed via integer registers.

For return values, there were a lot more issues:
- TYPE_CODE_DECFLOAT is NOT returned via XMM0.
- long double is NOT returned via XMM0.
- but __int128 IS returned via XMM0.
- the comments for TYPE_CODE_FLT state that __m128, __m128i and __m128d are
  returned by XMM0, and this is correct, but it doesn't actually check for
  them, because they are TYPE_CODE_ARRAY with TYPE_VECTOR

So I had to add TYPE_CODE_DECFLOAT to the arguments passed via XMM register,
but I had to remove it from the values returned via XMM0 register.

gdb/ChangeLog:

2020-10-05  Hannes Domani  <ssbssa@yahoo.de>

* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Add TYPE_CODE_COMPLEX.
(amd64_windows_return_value): Fix types returned via XMM0.

gdb/testsuite/ChangeLog:

2020-10-05  Hannes Domani  <ssbssa@yahoo.de>

* gdb.base/call-sc.c: Fix return struct on stack test case.
* gdb.base/call-sc.exp: Likewise.

4 years agox86-64: Always display suffix for %LQ in 64bit
H.J. Lu [Mon, 5 Oct 2020 12:27:58 +0000 (05:27 -0700)]
x86-64: Always display suffix for %LQ in 64bit

In 64bit, assembler generates a warning for "sysret":

$ echo sysret | as --64 -o x.o -
{standard input}: Assembler messages:
{standard input}:1: Warning: no instruction mnemonic suffix given and no register operands; using default for `sysret'

Always display suffix for %LQ in 64bit to display "sysretl".

gas/

PR binutils/26704
* testsuite/gas/i386/noreg64-data16.d: Expect sysretl instead of
sysret.
* testsuite/gas/i386/noreg64.d: Likewise.
* testsuite/gas/i386/x86-64-intel64.d: Likewise.
* testsuite/gas/i386/x86-64-opcode.d: Likewise.

opcodes/

PR binutils/26704
* i386-dis.c (putop): Always display suffix for %LQ in 64bit.

4 years agox86: Clear modrm if not needed
H.J. Lu [Mon, 5 Oct 2020 12:23:29 +0000 (05:23 -0700)]
x86: Clear modrm if not needed

The MODRM byte can be checked to display the instruction name only if the
MODRM byte needed.  Clear modrm if the MODRM byte isn't needed so that
modrm field checks in putop like, modrm.mod == N with N != 0, can be done
without checking need_modrm.

gas/

PR binutils/26705
* testsuite/gas/i386/x86-64-suffix.s: Add "mov %rsp,%rbp" before
sysretq.
* testsuite/gas/i386/x86-64-suffix-intel.d: Updated.
* testsuite/gas/i386/x86-64-suffix.d: Likewise.

opcodes/

PR binutils/26705
* i386-dis.c (print_insn): Clear modrm if not needed.
(putop): Check need_modrm for modrm.mod != 3.  Don't check
need_modrm for modrm.mod == 3.

4 years agoAdd Luis Machado to AArch64/ARM GDB maintainers
Alan Hayward [Fri, 25 Sep 2020 11:13:25 +0000 (12:13 +0100)]
Add Luis Machado to AArch64/ARM GDB maintainers

gdb/ChangeLog:

* MAINTAINERS (Responsible Maintainers): Add Luis Machado to
  AArch64/ARM maintainers.

4 years agoGAS: Update the .section directive so that a numeric section index can be provided...
Nick Clifton [Mon, 5 Oct 2020 09:40:07 +0000 (10:40 +0100)]
GAS: Update the .section directive so that a numeric section index can be provided when the "o" flag is used.

PR 26253
gas * config/obj-elf.c (obj_elf_section): Accept a numeric value for
the "o" section flag.  Interpret it as a section index.  Allow an
index of zero.
* doc/as.texi: Document the new behaviour.
* NEWS: Mention the new feature.  Tidy entries.
* testsuite/gas/elf/sh-link-zero.s: New test.
* testsuite/gas/elf/sh-link-zero.d: New test driver.
* testsuite/gas/elf/elf.exp: Run the new test.
* testsuite/gas/elf/section21.l: Updated expected assembler
output.

bfd * elf.c (_bfd_elf_setup_sections): Do not complain about an
sh_link value of zero when the SLF_LINK_ORDER flag is set.
(assign_section_numbers): Likewise.

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

4 years agogdb: add doc for "set/show debug event-loop"
Simon Marchi [Sun, 4 Oct 2020 16:41:56 +0000 (12:41 -0400)]
gdb: add doc for "set/show debug event-loop"

I forgot that "set/show debug" commands are listed in the doc and in
NEWS, so here they are.

gdb/doc/ChangeLog:

* gdb.texinfo (Debugging Output): Add set/show debug event-loop.

gdb/ChangeLog:

* NEWS: Mention set/show debug event-loop.

Change-Id: If30b80177049006578280a06912ee2b97bd03a75

4 years agogdb/doc: space out list entries, fix one type
Simon Marchi [Sun, 4 Oct 2020 16:36:02 +0000 (12:36 -0400)]
gdb/doc: space out list entries, fix one type

I want to add an item to this list, but it's so packed I have trouble
finding where one item ends and the next starts.  Add a few empty lines
to make it a bit more readable.

Doing this, I also noticed that an "aix-thread" should in fact be
"aix-solib".

gdb/doc/ChangeLog:

* gdb.texinfo (Debugging Output): Add empty lines, fix typo.

Change-Id: I7ef211f9e3988cfbc6ec94124d23a5f2412f3c82

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

4 years agox86: Update register operand check for AddrPrefixOpReg
H.J. Lu [Sat, 3 Oct 2020 11:23:55 +0000 (04:23 -0700)]
x86: Update register operand check for AddrPrefixOpReg

When the address size prefix applies to both the memory and the register
operand, we need to extract the address size prefix from the register
operand if the memory operand has no real registers, like symbol, DISP
or symbol(%rip).

NB: GCC always generates symbol(%rip) for RIP-relative addressing for
both x32 and x86-64.

Move the .code16 tests in movdir.s to movdir-16bit to show the correct
output from objdump.

PR gas/26685
* config/tc-i386.c (process_suffix): Also check the register
operand for the address size prefix if the memory operand has
no real registers.
* testsuite/gas/i386/enqcmd-16bit.d: New file.
* testsuite/gas/i386/enqcmd-16bit.s: Likewise.
* testsuite/gas/i386/movdir-16bit.d: Likewise.
* testsuite/gas/i386/movdir-16bit.s: Likewise.
* testsuite/gas/i386/enqcmd.s: Add tests with symbol and DISP.
* testsuite/gas/i386/x86-64-enqcmd.s: Likewise.
* testsuite/gas/i386/x86-64-movdir.s: Likewise.
* testsuite/gas/i386/movdir.s: Add tests with symbol and DISP.
Remove the .code16 test.
* testsuite/gas/i386/i386.exp: Run movdir-16bit and enqcmd-16bit.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Updated.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.
* testsuite/gas/i386/enqcmd-intel.d: Likewise.
* testsuite/gas/i386/enqcmd.d: Likewise.
* testsuite/gas/i386/movdir-intel.d: Likewise.
* testsuite/gas/i386/movdir.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-movdir-intel.d: Likewise.
* testsuite/gas/i386/x86-64-movdir.d: Likewise.

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

4 years agoUnconditionally use REG_EXTENDED
Tom Tromey [Fri, 2 Oct 2020 16:23:25 +0000 (10:23 -0600)]
Unconditionally use REG_EXTENDED

skip.c checks whether REG_EXTENDED is defined -- but this should
always be available, and is used unconditionally in other parts of
gdb.  This patch removes this check, then further simplifies this
code, removing a declaration and a repeated assertion.

2020-10-02  Tom Tromey  <tromey@adacore.com>

* skip.c (skiplist_entry::skiplist_entry): Unconditionally use
REG_EXTENDED.

4 years agoarm: add support for Cortex-A78 and Cortex-A78AE
Przemyslaw Wirkus [Fri, 2 Oct 2020 19:44:13 +0000 (20:44 +0100)]
arm: add support for Cortex-A78 and Cortex-A78AE

bfd/ChangeLog:

2020-09-30  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* cpu-arm.c: Add cortex-a78 and cortex-a78ae.

gas/ChangeLog:

2020-09-30  Przemyslaw Wirkus  <przemyslaw.wirkus@arm.com>

* config/tc-arm.c: Add cortex-a78 and cortex-a78ae cores.
* doc/c-arm.texi: Update docs.
* NEWS: Update news.
* testsuite/gas/arm/cpu-cortex-a78.d: New test.
* testsuite/gas/arm/cpu-cortex-a78ae.d: New test.

4 years agogdb: fix some inferior_created observer signatures
Simon Marchi [Fri, 2 Oct 2020 19:22:21 +0000 (15:22 -0400)]
gdb: fix some inferior_created observer signatures

I just noticed that in a7aba2668a7b ("gdb: remove arguments from
inferior_created observable"), I forgot to update
aix_thread_inferior_created and procfs_inferior_created, which are in
files I can't compile.

Remove the parameters from aix_thread_inferior_created.  And simply
remove procfs_inferior_created, since it's empty anyway.

gdb/ChangeLog:

* aix-thread.c (aix_thread_inferior_created): Remove parameters.
* procfs.c (procfs_inferior_created): Remove.
(_initialize_procfs): Don't register procfs_inferior_created.

Change-Id: Ifc7def7c096332033b5d466d32cb873d1df18c2c

4 years agogdb: add debug prints in event loop
Simon Marchi [Fri, 2 Oct 2020 18:44:40 +0000 (14:44 -0400)]
gdb: add debug prints in event loop

Add debug printouts about event loop-related events:

 - When a file descriptor handler gets invoked
 - When an async event/signal handler gets invoked

gdb/ChangeLog:

* async-event.c (invoke_async_signal_handlers): Add debug
print.
(check_async_event_handlers): Likewise.
* event-top.c (show_debug_event_loop): New function.
(_initialize_event_top): Register "set debug event-loop"
setting.

gdbserver/ChangeLog:

* server.cc (handle_monitor_command): Handle "set
debug-event-loop".
(captured_main): Handle "--debug-event-loop".
(monitor_show_help): Mention new setting.
(gdbserver_usage): Mention new flag.

gdbsupport/ChangeLog:

* event-loop.h (debug_event_loop): New variable declaration.
(event_loop_debug_printf_1): New function declaration.
(event_loop_debug_printf): New macro.
* event-loop.cc (debug_event_loop): New variable.
(handle_file_event): Add debug print.
(event_loop_debug_printf_1): New function.

Change-Id: If78ed3a69179881368e7895b42940ce13b6a1a05

4 years agogdb: move debug_prefixed_vprintf here
Simon Marchi [Fri, 2 Oct 2020 18:44:39 +0000 (14:44 -0400)]
gdb: move debug_prefixed_vprintf here

The following patch needs to output debug prints from gdbsupport code.
Move debug_prefixed_vprintf so that it is possible to use it from
gdbsupport.

gdb/ChangeLog:

* debug.c (debug_prefixed_vprintf): Move to gdbsupport.
* debug.h: Remove.
* infrun.c: Include gdbsupport/common-debug.h.
* linux-nat.c: Likewise.

gdbsupport/ChangeLog:

* common-debug.cc (debug_prefixed_vprintf): Move here.
* common-debug.h (debug_prefixed_vprintf): Move here.

Change-Id: I5170065fc10a7a49c0f1bba67c691decb2cf3bcb