deliverable/binutils-gdb.git
3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 26 Jun 2020 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogdb: use make_unique_xstrdup in set_inferior_io_terminal
Simon Marchi [Thu, 25 Jun 2020 21:06:18 +0000 (17:06 -0400)] 
gdb: use make_unique_xstrdup in set_inferior_io_terminal

gdb/ChangeLog:

* infcmd.c (set_inferior_io_terminal): Use make_unique_xstrdup.

Change-Id: I38b6e753f58947531fe4a293d574bc27ec128f47

3 years agogdb: make inferior::terminal a unique ptr
Simon Marchi [Thu, 25 Jun 2020 18:44:13 +0000 (14:44 -0400)] 
gdb: make inferior::terminal a unique ptr

This changes the inferior::terminal field to be a unique pointer, so its
deallocation is automatically managed.

gdb/ChangeLog:

* inferior.h (struct inferior) <terminal>: Change type to
gdb::unique_xmalloc_ptr<char>.
* inferior.c (inferior::~inferior): Don't free inf->terminal.
* infcmd.c (set_inferior_io_terminal): Don't free terminal
field, adjust to unique pointer.
(get_inferior_io_terminal): Adjust to unique pointer.

Change-Id: Iedb6459b4f9eeae812b0cb9d514b5707d5107cdb

3 years agocpu: fix offset16 type, update c-calls in bpf.cpu
David Faust [Thu, 25 Jun 2020 18:34:29 +0000 (20:34 +0200)] 
cpu: fix offset16 type, update c-calls in bpf.cpu

Correct the type of the offset16 field to HI, and simplify memory
accesses which use it. Also update c-calls in semantics for a
few instructions.

cpu/ChangeLog:

2020-06-25 David Faust  <david.faust@oracle.com>

* bpf.cpu (f-offset16): Change type from INT to HI.
(dxli): Simplify memory access.
(dxsi): Likewise.
(define-endian-insn): Update c-call in semantics.
(dlabs) Likewise.
(dlind) Likewise.

3 years agogdb/riscv: Loop over all registers for 'info all-registers'
Andrew Burgess [Tue, 16 Jun 2020 16:00:33 +0000 (17:00 +0100)] 
gdb/riscv: Loop over all registers for 'info all-registers'

Currently the 'info all-registers' command only loops over those
registers that are known to GDB.  Any registers that are unknown, that
is, are mentioned in the target description, but are not something GDB
otherwise knows, will not be displayed.

This feels wrong, so this commit fixes this mistake.  The output of
'info all-registers' now matches 'info registers all'.

gdb/ChangeLog:

* riscv-tdep.c (riscv_print_registers_info): Loop over all
registers, not just the known core set of registers.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-tdesc-regs.exp: New test cases.

3 years agogdb/riscv: Record information about unknown tdesc registers
Andrew Burgess [Tue, 16 Jun 2020 13:53:12 +0000 (14:53 +0100)] 
gdb/riscv: Record information about unknown tdesc registers

Making use of the previous commit, record information about unknown
registers in the target description, and use this to resolve two
issues.

1. Some targets (QEMU) are reporting three register fflags, frm, and
   fcsr, twice, once in the FPU feature, and once in the CSR feature.
   GDB does create two registers with identical names, but this
   is (sort of) fine, we only ever use the first one, and as both
   registers access the same target state things basically work OK.
   The only real problem is that the register names show up twice in
   'info registers all' output.

   In this commit we spot the duplicates of these registers and then
   return NULL when asked for the name of these registers.  This
   causes GDB to hide these registers from the user, fixing this
   problem.

2. Some targets (QEMU) advertise CSRs that GDB then can't read.  The
   problem is these targets also say these CSRs are part of the
   save/restore register groups.

   This means that before an inferior call GDB tries to save all of
   these CSRs, and a failure to read one causes the inferior call to
   be abandoned.

   We already work around this issue to some degree, known CSRs are
   removed from the save/restore groups, despite what the target might
   say.  However, any unknown CSRs are (currently) not removed in this
   way.

   After this commit we keep a log of the register numbers for all
   unknown CSRs, then when asked about the register groups, we
   override the group information for unknown CSRs, removing them from
   the save and restore groups.

gdb/ChangeLog:

* riscv-tdep.c (riscv_register_name): Return NULL for duplicate
fflags, frm, and fcsr registers.
(riscv_register_reggroup_p): Remove unknown CSRs from save and
restore groups.
(riscv_tdesc_unknown_reg): New function.
(riscv_gdbarch_init): Pass riscv_tdesc_unknown_reg to
tdesc_use_registers.
* riscv-tdep.h (struct gdbarch_tdep): Add
unknown_csrs_first_regnum, unknown_csrs_count,
duplicate_fflags_regnum, duplicate_frm_regnum, and
duplicate_fcsr_regnum fields.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-tdesc-regs.exp: Extend test case.

3 years agogdb: Extend target description processing of unknown registers
Andrew Burgess [Tue, 16 Jun 2020 12:14:04 +0000 (13:14 +0100)] 
gdb: Extend target description processing of unknown registers

This commit adds a new step to the processing of a target description
done in tdesc_use_registers, this new step is about how unknown
registers are processed.

Currently an architecture looks through the target description and
calls tdesc_numbered_register for each register is was expecting (or
hoping) to find.  This builds up a map from GDB's register numbers to
the tdesc_reg object.  Later the architecture calls
tdesc_use_registers.

In tdesc_use_registers we build a hash with keys being all the
tdesc_reg object pointers, from this hash we remove all of the
tdesc_reg objects that were assigned register numbers using
tdesc_numbered_register.

Finally we walk through all of the tdesc_reg objects, and if it was
not already assigned a number we assign that register the next
available number.

The problem with this is that the architecture has no visibility of
which unknown registers exist, and which tdesc_feature the register
came from, in some cases this might be important.

For example, on RISC-V GDB overrides the use of
tdesc_register_reggroup_p, with riscv_register_reggroup_p to modify
some of the register group choices.  In this function GDB wants to
treat all registers from a particular feature in a certain way.  This
is fine for registers that GDB knows might be in that feature, but for
unknown registers the RISC-V parts of GDB have no easy way to figure
out which unknown registers exist, and what numbers they were
assigned.

We could figure this information out by probing the register
structures after calling tdesc_use_registers, but this would be
horrible, much better to have tdesc_use_registers tell the
architecture about unknown registers.

This is what this commit does.  A new phase of tdesc_use_registers,
just before the unknown registers are assigned a number, we loop over
each tdesc_reg object, if it has not been assigned a number then we
figure out what number would be assigned and then call back into the
architecture passing the tdesc_feature, register name, and the
proposed register number.

The architecture is free to return the proposed register number, or it
can return a different number (which has a result identical to having
called tdesc_numbered_register).  Alternatively the architecture can
return -1 to indicate the register should be numbered later.

After calling the callback for every tdesc_reg object any registers
still don't have a number assigned (because the architecture returned
-1), then a new register number is assigned, which might be different
from the proposed number that was suggested earlier.

This commit adds the general target-description parts of this
mechanism.  No targets are currently using this code.  The RISC-V
target will make use of this in the next commit.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* target-descriptions.c (tdesc_use_registers): Add new parameter a
callback, use the callback (when not null) to help number unknown
registers.
* target-descriptions.h (tdesc_unknown_register_ftype): New typedef.
(tdesc_use_registers): Add extra parameter to declaration.

3 years agogdb/riscv: Improve support for matching against target descriptions
Andrew Burgess [Tue, 16 Jun 2020 09:02:09 +0000 (10:02 +0100)] 
gdb/riscv: Improve support for matching against target descriptions

For the RISC-V target it is desirable if the three floating pointer
status CSRs fflags, frm, and fcsr can be placed into either the FPU
feature or the CSR feature.  This allows different targets to build
the features in a way that better reflects their target.

The change to support this within GDB is fairly simple, so this is
done in this commit, and some tests added to check this new
functionality.

gdb/ChangeLog:

* riscv-tdep.c (value_of_riscv_user_reg): Moved to here from later
in the file.
(class riscv_pending_register_alias): Likewise.
(riscv_register_feature::register_info): Change 'required_p' field
to 'required', and change its type.  Add 'check' member function.
(riscv_register_feature::register_info::check): Define new member
function.
(riscv_xreg_feature): Change initialisation of 'required' field.
(riscv_freg_feature): Likewise.
(riscv_virtual_feature): Likewise.
(riscv_csr_feature): Likewise.
(riscv_check_tdesc_feature): Take extra parameter, the csr
tdesc_feature, rewrite the function to use the new
riscv_register_feature::register_info::check function.
(riscv_gdbarch_init): Pass the csr tdesc_feature where needed.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-tdesc-loading-01.xml: New file.
* gdb.arch/riscv-tdesc-loading-02.xml: New file.
* gdb.arch/riscv-tdesc-loading-03.xml: New file.
* gdb.arch/riscv-tdesc-loading-04.xml: New file.
* gdb.arch/riscv-tdesc-loading.exp: New file.

3 years agogdb/riscv: Remove CSR feature file
Andrew Burgess [Mon, 15 Jun 2020 18:22:22 +0000 (19:22 +0100)] 
gdb/riscv: Remove CSR feature file

There is currently a bug in the RISC-V CSR/FPU feature files.  The
CSRs containing the FPU status registers are mentioned in both the FPU
feature file and the CSR feature file.

My original thinking when adding the FPU feature file was that it made
more sense to group the FPU status registers with the other FPU
state.  This opened up the possibility of debugging very
simple (possibly simulator only) targets that had little more than CPU
and FPU available for GDB to access.

When I then added code to automatically generate the CSR XML file I
forgot to filter out the FPU status CSRs, so these registers were
mentioned twice.

Now for GDB's default RISC-V target descriptions this doesn't actually
matter.  I did consider adding the CSRs to the default target
description, but in the end I didn't bother.  The reasoning again was
simplicity; the default target description is only to be used when the
target doesn't supply its own description, and NOT supplying the CSRs
actually serves to encourage targets to supply an accurate
description.  Combine this with the fact that the CSRs change from
revision to revision, sometimes in non-backward compatible ways, then
having a "default" set of CSRs just feels like a path to confusion and
complaints.

However, having a broken CSR XML file in the GDB source tree has had
one negative effect, QEMU has copied this file into its source tree,
and is using this as its description that it passes to GDB.  That is
QEMU announces the FPU status registers twice, once in the FPU
feature, and once in the CSR feature.

This commit starts along the path back to sanity by deleting the
default CSR XML files from within GDB.  These files were not used in
any way by current GDB, so there is absolutely no loss of
functionality with this change.

gdb/ChangeLog:

* features/Makefile: Remove all references to the deleted files
below.
* features/riscv/32bit-csr.c: Deleted.
* features/riscv/32bit-csr.xml: Deleted.
* features/riscv/64bit-csr.c: Deleted.
* features/riscv/64bit-csr.xml: Deleted.
* features/riscv/rebuild-csr-xml.sh: Deleted.

3 years agogdb/riscv: Take CSR names from target description
Andrew Burgess [Thu, 11 Jun 2020 10:49:05 +0000 (11:49 +0100)] 
gdb/riscv: Take CSR names from target description

First, consider the RISC-V register $x1.  This register has an alias
$ra.  When GDB processes an incoming target description we allow the
target to use either register name to describe the target.

However, within GDB's UI we want to use the $ra alias in preference to
the $x1 architecture name.

To achieve this GDB overrides the tdesc_register_name callback with
riscv_register_name.  In riscv_register_name we ensure that we always
return the preferred name, so in this case "ra".

To ensure the user can still access the register as $x1 if they want
to, when in riscv_check_tdesc_feature we spot that the target has
supplied the register, we add aliases for every name except the
preferred one, so in this case we add the alias "x1".

This scheme seems to work quite well, the targets have the flexibility
to be architecture focused if they wish (using x0 - x31) while GDB is
still using the ABI names ra, sp, gp, etc.

When this code was originally added there was an attempt made to
include the CSRs in the same scheme.  At the time the CSRs only had
two names, one pulled from riscv-opc.h, and one generated in GDB that
had the pattern csr%d.

The idea was that if the remote targets description described the CSRs
as csr%d then GDB would rename these back to the real CSR name.  This
code was only included because if followed the same pattern as the
x-regs and f-regs, not because I was actually aware of any target that
did this.

However, recent changes to add additional CSR aliases has made me
rethink the position here.

Lets consider the CSR $dscratch0.  This register has an alias
'csr1970' (1970 is 0x7b2, which is the offset of the CSR register into
the CSR address space).  However, this register was originally called
just 'dscratch', and so, after recent commits, this register also has
the alias 'dscratch'.

As the riscv-opc.h file calls this register 'dscratch0' GDB's
preferred name for this register is 'dscratch0'.

So, if the remote target description includes the register
'dscratch0', then GDB will add the aliases 'dscratch', and 'csr1970'.
In the UI GDB will describe the register as 'dscratch0', and all it
good.

The problem I see in this case is where the target describes the
register as 'dscratch'.  In this case GDB will still spot the register
and add the aliases 'dscratch', and 'csr1970', GDB will then give the
register the preferred name 'dscratch0'.

I don't like this.  For the CSRs I think that we should stick with the
naming scheme offered by the remote target description.  As the RISC-V
specification evolves and CSR register names evolve, insisting on
referring to registers by the most up to date name makes it harder for
a target to provide a consistent target description for an older
version of the RISC-V architecture spec.

In this precise case the target offers 'dscratch', which is from an
older version of the RISC-V specification, the newer version of the
spec has two registers 'dscratch0' and 'dscratch1'.  If we insist on
using 'dscratch0' it is then a little "weird" (or seems so to me) when
'dscratch1' is missing.

This patch makes a distinction between the x and f registers and the
other register sets.  For x and f we still make use of the renaming
scheme, forcing GDB to prefer the ABI name.  But after this patch the
CSR register group, and also the virtual register group, will always
prefer to use the name given in the target description, adding other
names as aliases, but not making any other name the preferred name.

gdb/ChangeLog:

* riscv-tdep.c (struct riscv_register_feature::register_info): Fix
whitespace error for declaration of names member variable.
(struct riscv_register_feature): Add new prefer_first_name member
variable, and fix whitespace error in declaration of registers.
(riscv_xreg_feature): Initialize prefer_first_name field.
(riscv_freg_feature): Likewise.
(riscv_virtual_feature): Likewise.
(riscv_csr_feature): Likewise.
(riscv_register_name): Expand on comments.  Remove register name
modifications for CSR and virtual registers.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-tdesc-regs.exp: Extend test case.

3 years agogdb/riscv: Fix whitespace error
Andrew Burgess [Tue, 16 Jun 2020 09:06:35 +0000 (10:06 +0100)] 
gdb/riscv: Fix whitespace error

Should be 'std::vector<type>' not 'std::vector <type>'.

gdb/ChangeLog:

* riscv-tdep.c (struct riscv_register_feature): Fix whitespace
errors.

3 years agogdb/riscv: Improved register alias name creation
Andrew Burgess [Tue, 9 Jun 2020 16:38:30 +0000 (17:38 +0100)] 
gdb/riscv: Improved register alias name creation

This commit does two things:

 1. Makes use of the DECLARE_CSR_ALIAS definitions in riscv-opc.h to
 add additional aliases for CSRs.

 2. Only creates aliases for registers that are actually present on
 the target (as announced in the target XML description).

This means that the 'csr%d' aliases that exist will only be created
for those CSRs the target actually has, which is a nice improvement,
as accessing one of the CSRs that didn't exist would cause GDB to
crash with this error:

  valprint.c:1560: internal-error: bool maybe_negate_by_bytes(const gdb_byte*, unsigned int, bfd_endian, gdb::byte_vector*): Assertion `len > 0' failed.

When we look at the DECLARE_CSR_ALIAS lines in riscv-opc.h, these can
be split into three groups:

 DECLARE_CSR_ALIAS(misa, 0xf10, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P9P1)

The 'misa' register used to exist of offset 0xf10, but was moved to
its current offset (0x301) in with privilege spec 1.9.1.  We don't
want GDB to create an alias called 'misa' as we will already have a
'misa' register created by the DECLARE_CSR(misa ....) call earlier in
riscv-opc.h

 DECLARE_CSR_ALIAS(ubadaddr, CSR_UTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR_ALIAS(sbadaddr, CSR_STVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR_ALIAS(sptbr, CSR_SATP, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR_ALIAS(mbadaddr, CSR_MTVAL, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)
 DECLARE_CSR_ALIAS(mucounteren, CSR_MCOUNTINHIBIT, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P10)

These aliases are all CSRs that were removed in privilege spec 1.10,
and whose addresses were reused by new CSRs.  The names meaning of the
old names is totally different to the new CSRs that have taken their
place.  I don't believe we should add these as aliases into GDB.  If
the new CSR exists in the target then that should be enough.

 DECLARE_CSR_ALIAS(dscratch, CSR_DSCRATCH0, CSR_CLASS_I, PRIV_SPEC_CLASS_1P9, PRIV_SPEC_CLASS_1P11)

In privilege spec 1.11 the 'dscratch' register was renamed to
'dscratch0', however the meaning of the register didn't change.
Adding the 'dscratch' alias makes sense I think.

Looking then at the final PRIV_SPEC_CLASS_* field for each alias then
we can see that currently we only want to take the alias from
PRIV_SPEC_CLASS_1P11.  For now then this is what I'm using to filter
the aliases within GDB.

In the future there's no telling how DECLARE_CSR_ALIAS will be used.
I've heard it said that future RISC-V privilege specs will not reuse
CSR offsets again.  But it could happen.  We just don't know.

If / when it does we may need to revisit how aliases are created for
GDB, but for now this seems to be OK.

gdb/ChangeLog:

* riscv-tdep.c (riscv_create_csr_aliases): Handle csr aliases from
riscv-opc.h.
(class riscv_pending_register_alias): New class.
(riscv_check_tdesc_feature): Take vector of pending aliases and
populate it as appropriate.
(riscv_setup_register_aliases): Delete.
(riscv_gdbarch_init): Create vector of pending aliases and pass it
to riscv_check_tdesc_feature in all cases.  Use the vector to
create the register aliases.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-tdesc-regs-32.xml: New file.
* gdb.arch/riscv-tdesc-regs-64.xml: New file.
* gdb.arch/riscv-tdesc-regs.c: New file.
* gdb.arch/riscv-tdesc-regs.exp: New file.

3 years agoRemove obsolete gdbarch_static_transform_name
Rainer Orth [Thu, 25 Jun 2020 15:56:12 +0000 (17:56 +0200)] 
Remove obsolete gdbarch_static_transform_name

gdbarch_static_transform_name is completely Solaris-specific or rather
specific to the Studio compilers.  Studio cc has deprecated Stabs support
in the 12.4 release back in 2015, GCC has defaulted to DWARF-2 on Solaris
7+ since 2004 and Stabs themselves are pretty much obsolete, so the whole
code can go.

Tested on sparcv9-sun-solaris2.11 and x86_64-pc-linux-gnu with
--enable-targets=all.

* sol2-tdep.c (sol2_static_transform_name): Remove.
(sol2_init_abi): Don't register it.
* gdbarch.sh (static_transform_name): Remove.
* gdbarch.c, gdbarch.h: Regenerate.

* dbxread.c (read_dbx_symtab) <'S'>: Remove call to
gdbarch_static_transform_name.
* mdebugread.c (parse_partial_symbols) <'S'>: Likewise.
* stabsread.c (define_symbol) <'X'>: Remove.
(define_symbol) <'S'>: Remove gdbarch_static_transform_name
handling.
<'V'>: Likewise.
* xcoffread.c (scan_xcoff_symtab): Remove gdbarch.
<'S'>: Remove call to gdbarch_static_transform_name.

3 years agoUse fork instead of vfork on Solaris
Rainer Orth [Thu, 25 Jun 2020 15:48:14 +0000 (17:48 +0200)] 
Use fork instead of vfork on Solaris

The gdb.mi/mi-exec-run.exp test never completed/timed out on Solaris for
quite some time:

FAIL: gdb.mi/mi-exec-run.exp: inferior-tty=main: mi=main: force-fail=1: run failure detected (timeout)

This is for gdb trying to exec mi-exec-run.nox, a copy of mi-exec-run
with execute permissions removed.

The process tree at this point looks like this:

          21254 /vol/gcc/bin/expect -- /vol/gcc/share/dejagnu/runtest.exp GDB_PARALLEL=yes --outdir=outputs/gdb.mi/mi-exec-run-vfork gdb.mi/mi-exec-run.exp
            21300 <defunct>
            21281 <defunct>
            21294 $obj/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory $obj/gdb/testsuite/../data-directory -i=mi
              21297 $obj/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory $obj/gdb/testsuite/../data-directory -i=mi

The parent gdb hangs here:

21294:  $obj/gdb/testsuite/../../gdb/gdb -nw
------------  lwp# 1 / thread# 1  ---------------
 0000000000000000 SYS#0    ()
 0000000000daeccd procfs_target::create_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, int) () + 97 (procfs.c:2853)
 0000000000ca63a7 run_command_1(char const*, int, run_how) () + 349 (basic_string.h:187)
 0000000000ca6516 start_command(char const*, int) () + 26 (infcmd.c:584)
 0000000000b3ca8e do_const_cfunc(cmd_list_element*, char const*, int) () + f (cli-decode.c:96)
 0000000000b3ed77 cmd_func(cmd_list_element*, char const*, int) () + 32 (cli-decode.c:2113)
 0000000000f2d219 execute_command(char const*, int) () + 455 (top.c:657)
 0000000000d4ad77 mi_execute_cli_command(char const*, int, char const*) () + 242 (basic_string.h:187)
 0000000000d4ae80 mi_cmd_exec_run(char const*, char**, int) () + ba (mi-main.c:473)

with these process flags

21294: $obj/gdb/testsuite/../../gdb/gdb -nw
data model = _LP64  flags = VFORKP|ORPHAN|MSACCT|MSFORK
sigpend = 0x00004103,0x00000000,0x00000000
 /1: flags = 0
sigmask = 0xffbffeff,0xffffffff,0x000000ff
cursig = SIGKILL
 /2: flags = DETACH|STOPPED|ASLEEP  lwp_park(0x0,0x0,0x0)
why = PR_SUSPENDED
sigmask = 0x000a2002,0x00000000,0x00000000
[...]

while the child sits at

21297:  $obj/gdb/testsuite/../../gdb/gdb -nw
 00007fffbf078a0b execve   (7fffbffff7567fffbfffec587fffbfffec90, 0)
 00007fffbef84cf6 execvpex () + f6
 00007fffbef84f45 execvp () + 15
 0000000000d60a44 fork_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), gdb::function_view<void (int)>, void (*)(), char const*, void (*)(char const*, char* const*, char* const*)) () + 47f (fork-inferior.c:423)
 0000000000daeccd procfs_target::create_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, int) () + 97 (procfs.c:2853)
 0000000000ca63a7 run_command_1(char const*, int, run_how) () + 349 (basic_string.h:187)
 0000000000ca6516 start_command(char const*, int) () + 26 (infcmd.c:584)
 0000000000b3ca8e do_const_cfunc(cmd_list_element*, char const*, int) () + f (cli-decode.c:96)
 0000000000b3ed77 cmd_func(cmd_list_element*, char const*, int) () + 32 (cli-decode.c:2113)
 0000000000f2d219 execute_command(char const*, int) () + 455 (top.c:657)
 0000000000d4ad77 mi_execute_cli_command(char const*, int, char const*) () + 242 (basic_string.h:187)
 0000000000d4ae80 mi_cmd_exec_run(char const*, char**, int) () + ba (mi-main.c:473)

with

21297: $obj/gdb/testsuite/../../gdb/gdb -nw
data model = _LP64  flags = MSACCT|MSFORK
exitset  = 0x00000000 0x04000000 0x00000000 0x00000000
           0x00000000 0x00000000 0x00000000 0x00000000
 /1: flags = STOPPED|ISTOP  execve(0x7fffbffff756,0x7fffbfffec58,0x7fffbfffec90,0x0)
why = PR_SYSEXIT  what = execve

We have a deadlock here: the execve in the child cannot return until the
parent has handled the PR_SYSEXIT while the parent cannot run with a
vfork'ed child as documented in proc(4):

       The child of a vfork(2) borrows the  parent's  address  space.  When  a
       vfork(2) is executed by a traced process, all watched areas established
       for the parent are suspended until the child terminates or performs  an
       exec(2).  Any  watched areas established independently in the child are
       cancelled when the parent resumes  after  the  child's  termination  or
       exec(2).  PCWATCH  fails  with  EBUSY  if  applied  to  the parent of a
       vfork(2) before the child has terminated or performed an  exec(2).  The
       PR_VFORKP  flag  is  set  in  the  pstatus  structure for such a parent
       process.

In that situation, the parent cannot be killed even with SIGKILL (as
runtest will attempt once the timeout occurs; the pending signal can be
seen in the pflags output above), so the whole test hangs until one
manually kills the child process.

Fortunately, there's an easy way out: when using fork instead of vfork,
the problem doesn't occur, and this is what the current patch does: it
calls fork_inferior with a dummy pre_trace_fun arg.

Tested on amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11.

* procfs.c (procfs_pre_trace): New function.
(procfs_target::create_inferior): Pass it to fork_inferior.

3 years agoDon't include *sol2-tdep.o on Linux/sparc*
Rainer Orth [Thu, 25 Jun 2020 11:54:42 +0000 (13:54 +0200)] 
Don't include *sol2-tdep.o on Linux/sparc*

Linux/sparc* currently links Solaris-specific files (sparc-sol2-tdep.o,
sparc64-sol2-tdep.o, sol2-tdep.o) for no apparent reason.  It has no
business doing so, and none of the functions/variables defined there are
used explicitly.  If support for the Solaris OSABI were desired, this
should be done using --enable-targets instead.

Since neither sparc{32,64}_sol2_init_abi currently declared in common
headers (sparc*-tdep.h) are used outside their source files, they are made
static and the declarations removed.

Tested on sparcv9-sun-solaris2.11 and sparc64-unknown-linux-gnu.

* configure.tgt <sparc-*-linux*> (gdb_target_obs): Remove
sparc-sol2-tdep.o, sol2-tdep.o, sparc64-sol2-tdep.o.
<sparc64-*-linux*> (gdb_target_obs): Remove sparc64-sol2-tdep.o,
sol2-tdep.o, sparc-sol2-tdep.o.
* sparc-sol2-tdep.c (sparc32_sol2_init_abi): Make static.
* sparc-tdep.h (sparc32_sol2_init_abi): Remove.
* sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Make static.
* sparc64-tdep.h (sparc64_sol2_init_abi): Remove.

3 years agoMove common handlers to sol2_init_abi
Rainer Orth [Thu, 25 Jun 2020 11:43:46 +0000 (13:43 +0200)] 
Move common handlers to sol2_init_abi

There's some overlap and duplication between 32 and 64-bit Solaris/SPARC
and x86 tdep files, in particular

        sol2_core_pid_to_str
*_sol2_sigtramp_p
        sol2_skip_solib_resolver
        *_sol2_static_transform_name (forgotten on amd64)
        set_gdbarch_sofun_address_maybe_missing (likewise)

This patch avoids this by centralizing common code in sol2-tdep.c.
While sparc_sol2_pc_in_sigtramp and sparc_sol2_static_transform_name
were declared in the shared sparc-tdep.h, they were only used in Solaris
files.

Tested on amd64-pc-solaris2.11, i386-pc-solaris2.11,
sparcv9-sun-solaris2.11, and sparc-sun-solaris2.11, and
sparc64-unknown-linux-gnu.

* amd64-sol2-tdep.c (amd64_sol2_sigtramp_p): Remove.
(amd64_sol2_init_abi): Use sol2_sigtramp_p.
Call sol2_init_abi.
  Remove calls to set_gdbarch_skip_solib_resolver,
set_gdbarch_core_pid_to_str.
* i386-sol2-tdep.c (i386_sol2_sigtramp_p): Remove.
(i386_sol2_static_transform_name): Remove.
(i386_sol2_init_abi): Call sol2_init_abi.
Remove calls to set_gdbarch_sofun_address_maybe_missing,
set_gdbarch_static_transform_name,
set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str.
Use sol2_sigtramp_p.
* sol2-tdep.c (sol2_pc_in_sigtramp): New function.
(sol2_sigtramp_p): New function.
(sol2_static_transform_name): New function.
(sol2_skip_solib_resolver, sol2_core_pid_to_str): Make static.
(sol2_init_abi): New function.
* sol2-tdep.h (sol2_sigtramp_p, sol2_init_abi): Declare.
(sol2_skip_solib_resolver, sol2_core_pid_to_str): Remove.
* sparc-sol2-tdep.c (sparc_sol2_pc_in_sigtramp): Remove.
(sparc32_sol2_sigtramp_frame_sniffer): Just call sol2_sigtramp_p.
(sparc_sol2_static_transform_name): Remove.
(sparc32_sol2_init_abi): Call sol2_init_abi.
Remove calls to set_gdbarch_sofun_address_maybe_missing,
set_gdbarch_static_transform_name,
set_gdbarch_skip_solib_resolver,
set_gdbarch_core_pid_to_str.
* sparc-tdep.h (sparc_sol2_pc_in_sigtramp)
(sparc_sol2_static_transform_name): Remove
* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_sniffer): Just
call sol2_sigtramp_p.
(sparc64_sol2_init_abi): Call sol2_init_abi.
Remove calls to set_gdbarch_sofun_address_maybe_missing,
set_gdbarch_static_transform_name,
set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str.

3 years agoUpdate the Swedish translation in the gprof/ subdirectory.
Nick Clifton [Thu, 25 Jun 2020 10:29:24 +0000 (11:29 +0100)] 
Update the Swedish translation in the gprof/ subdirectory.

* po/sv.po: Updated Swedish translation.

3 years agoRemove the use of the register keyword in the libiberty.h header file - it is depreca...
Nick Clifton [Thu, 25 Jun 2020 10:16:42 +0000 (11:16 +0100)] 
Remove the use of the register keyword in the libiberty.h header file - it is deprecated and incompatible with C++17.

* libiberty.h (bsearch_r): Remove use of the register keyword from
the prototype.

3 years agoStop the assembler from generating R_ARM_THM_JMP11 relocations as these are not suppo...
Nick Clifton [Thu, 25 Jun 2020 10:11:51 +0000 (11:11 +0100)] 
Stop the assembler from generating R_ARM_THM_JMP11 relocations as these are not supported by the kernel.

PR 26141
* config/tc-arm.c (arm_force_relocation): Force resolution of
BFD_RELOC_THUMB_PCREL_BRANCH12 relocations.
* testsuite/gas/arm/plt-1.d: Adjust expected disassembly.

3 years agox86: make J disassembler macro available for new use
Jan Beulich [Thu, 25 Jun 2020 07:31:50 +0000 (09:31 +0200)] 
x86: make J disassembler macro available for new use

There's clearly a shortage of available macro characters, as can be seen
from the various two-character macros that had to be introduced. Don't
waste characters for things that can be expressed differently. In the
case of J this alternative is {l|}.

3 years agox86: drop left-over 4-way alternative disassembler templates
Jan Beulich [Thu, 25 Jun 2020 07:30:39 +0000 (09:30 +0200)] 
x86: drop left-over 4-way alternative disassembler templates

Commit 7c52e0e8658a, dropping the general concept of 4-way alternatives,
for whatever reason, omitted cleaning up these two instances.

3 years agox86: move ImmExt processing
Jan Beulich [Thu, 25 Jun 2020 07:30:09 +0000 (09:30 +0200)] 
x86: move ImmExt processing

With abuses of ImmExt gone, all templates using it have operands. Move
its main invocation into process_operands(), matching its secondary one
for the SSE2AVX case.

3 years agox86: operand sizing prefixes can disambiguate insns
Jan Beulich [Thu, 25 Jun 2020 07:29:29 +0000 (09:29 +0200)] 
x86: operand sizing prefixes can disambiguate insns

Use of an explicit data size or REX.W prefix is sufficient indication of
the intended operation when operand size can't be derived from suffix or
register operands. Avoid the ambiguity warning and make in particular
immediate handling (sizing) cope with explicitly specified prefixes.

Extending/reusing the noreg16 test made me notice a few cases of
unintentional 32-bit addressing, which gets corrected at the same time.

3 years agox86: fix SYSRET disassembly, improve {,V}CVTSI2S{S,D} and PTWRITE
Jan Beulich [Thu, 25 Jun 2020 07:27:21 +0000 (09:27 +0200)] 
x86: fix SYSRET disassembly, improve {,V}CVTSI2S{S,D} and PTWRITE

SYSRET can't use the same macro as IRET, since there's no 16-bit operand
size form of it. Re-use LQ for it instead.

Doing so made obvious that outside of 64-bit mode {,V}CVTSI2S{S,D} and
PTWRITE should have an 'l' suffix printed only in suffix-always mode.

3 years agox86-64: REX prefix is invalid with VEX etc
Jan Beulich [Thu, 25 Jun 2020 07:26:28 +0000 (09:26 +0200)] 
x86-64: REX prefix is invalid with VEX etc

Just like for the data size prefix (see commit 7a8655d2bbdc ["x86: don't
abort() upon DATA16 prefix on (E)VEX encoded insn"]), any form of REX
prefix is invalid with VEX/XOP/EVEX.

3 years agox86-64: honor REX prefixes for SSE2AVX
Jan Beulich [Thu, 25 Jun 2020 07:25:52 +0000 (09:25 +0200)] 
x86-64: honor REX prefixes for SSE2AVX

Legacy encoded insns do so, and their automatic conversion to AVX ones
ought to produce functionally identical code. Therefore explicit REX
prefixes cannot simply be ignored. This is in particular relevant
because at least PCMPESTR{I,M}'s 64-bit forms couldn't be expressed in
older gas by other than using a REX64 prefix.

3 years agox86: also refuse data size prefix on SIMD insns
Jan Beulich [Thu, 25 Jun 2020 07:25:12 +0000 (09:25 +0200)] 
x86: also refuse data size prefix on SIMD insns

The data size prefix alters the meaning of legacy encoded SIMD insns,
and hence shouldn't be accepted there. Use of it also leads to
inconsistencies in SSE2AVX mode. Don't match insns with data size prefix
against SSE2AVX templates.

3 years agox86: drop stray assignment from build_evex_prefix()
Jan Beulich [Thu, 25 Jun 2020 07:24:23 +0000 (09:24 +0200)] 
x86: drop stray assignment from build_evex_prefix()

Unlike in build_vex_prefix() this is not needed here.

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 25 Jun 2020 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoSync config, include and libiberty with GCC
H.J. Lu [Wed, 24 Jun 2020 19:27:57 +0000 (12:27 -0700)] 
Sync config, include and libiberty with GCC

config/

2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>

Sync with GCC
2020-05-29  H.J. Lu  <hjl.tools@gmail.com>

PR bootstrap/95413
* cet.m4: Replace save_CFLAGS and save_LDFLAGS with
cet_save_CFLAGS and cet_save_LDFLAGS.

include/

2020-06-24  H.J. Lu  <hongjiu.lu@intel.com>

Sync with GCC
2020-06-23  Nick Alcock  <nick.alcock@oracle.com>

* libiberty.h (bsearch_r): New.

2020-04-17  Martin Liska  <mliska@suse.cz>
    Jonathan Yong <10walls@gmail.com>

PR gcov-profile/94570
* filenames.h (defined): Do not define HAVE_DOS_BASED_FILE_SYSTEM
for CYGWIN.

libiberty/

2020-06-23  Nick Alcock  <nick.alcock@oracle.com>

* bsearch_r.c: New file.
* Makefile.in (CFILES): Add bsearch_r.c.
(REQUIRED_OFILES): Add bsearch_r.o.
* functions.texi: Regenerate.

2020-05-29  H.J. Lu  <hjl.tools@gmail.com>

PR bootstrap/95413
* configure: Regenerated.

2020-05-15  Iain Buclaw  <ibuclaw@gdcproject.org>

* d-demangle.c (dlang_attributes): Add @live attribute.
* testsuite/d-demangle-expected: Add new tests.

2020-05-14  Rainer Schuetze  <r.sagitario@gmx.de>
    Iain Buclaw  <ibuclaw@gdcproject.org>

* d-demangle.c (enum dlang_symbol_kinds): Remove enum.
(struct dlang_info): New struct
(dlang_decode_backref): New function.
(dlang_backref): New function.
(dlang_symbol_backref): New function.
(dlang_type_backref): New function.
(dlang_symbol_name_p): New function.
(dlang_function_type_noreturn): New function.
(dlang_function_type): Add 'info' parameter.  Decode function type
with dlang_function_type_noreturn.
(dlang_function_args): Add 'info' parameter.
(dlang_type): Add 'info' parameter.  Handle back referenced types.
(dlang_identifier): Replace 'kind' parameter with 'info'.  Handle back
referenced symbols.  Split off decoding of plain identifiers to...
(dlang_lname): ...here.
(dlang_parse_mangle): Replace 'kind' parameter with 'info'.  Decode
function type and return with dlang_type.
(dlang_parse_qualified): Replace 'kind' parameter with 'info', add
'suffix_modifier' parameter.  Decode function type with
dlang_function_type_noreturn.
(dlang_parse_tuple): Add 'info' parameter.
(dlang_template_symbol_param): New function.
(dlang_template_args): Add 'info' parameter.  Decode symbol parameter
with dlang_template_symbol_param.  Handle back referenced values, and
externally mangled parameters.
(dlang_parse_template): Add 'info' parameter.
(dlang_demangle_init_info): New function.
(dlang_demangle): Initialize and pass 'info' parameter.
* testsuite/d-demangle-expected: Add new tests.

3 years agoW/ Clang, compile/link C++ test programs with "-x c++"
Pedro Alves [Wed, 24 Jun 2020 22:18:19 +0000 (23:18 +0100)] 
W/ Clang, compile/link C++ test programs with "-x c++"

Some testcases want to compile .c files with a C++ compiler.  So they
pass the "c++" option to gdb_compile.  That works fine with GCC, but
with Clang, it results in:

  gdb compile failed, clang-5.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]

and the testcase is skipped with UNTESTED.

A previous patch fixed a case like that in
gdb.compile/compile-cplus.exp, by adding -Wno-deprecated to the build
options.  However, there are other testcases that use the same
pattern, and all fail for the same reason.  For example:

 gdb.base/info-types-c++.exp
 gdb.base/max-depth-c++.exp
 gdb.base/msym-lang.exp
 gdb.base/whatis-ptype-typedefs.exp
 gdb.btrace/rn-dl-bind.exp

Fix this in a central place, within gdb_compile, by passing "-x c++"
to the compiler driver when we're compiling/linking C++.

This revealed that gdb.compile/compile-cplus.exp and
gdb.arch/amd64-entry-value-paramref.exp tests are compiling an
assembly file with the "c++" option, which would now fail to compile,
with the C++ compiler not grokking the assembly, of course.  We just
need to not pass "c++" and all the other related C++ options when
compiling an assembly file.

gdb/testsuite/ChangeLog:
2020-06-24  Pedro Alves  <palves@redhat.com>

* gdb.arch/amd64-entry-value-paramref.exp: Use
prepare_for_testing_full and don't pass "c++" for the .S file
build spec.
* gdb.compile/compile-cplus.exp: Don't compile $srcfile3 with
$options, since it's an assembly file.  Remove -Wno-deprecated.
* lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
compiling C++ programs.

3 years agoW/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option
Pedro Alves [Wed, 24 Jun 2020 22:18:19 +0000 (23:18 +0100)] 
W/ Clang, compile C/C++ testcases with -Wno-unknown-warning-option

Some C/C++ testcases unconditionally pass -Wno-foo as additional
options to disable some warning.  That is OK with GCC, because GCC
accepts -Wno-foo silently even if it doesn't support -Wfoo.  This is a
feature which allows disabling warnings with newer compilers without
breaking builds with older compilers.  Clang however warns about
unknown -Wno-foo by default, unless you pass
-Wno-unknown-warning-option as well:

 $ gcc -Wno-foo test.c
 * nothing, compiles successfuly *

 $ clang -Wno-foo test.c
 warning: unknown warning option '-Wno-foo [-Wunknown-warning-option]

This commit adds -Wunknown-warning-option centrally in gdb_compile, so
that individual testcases don't have to worry about breaking older
Clangs.

IOW, this avoids this problematic scenario:

#1 - A testcase compiles successfully with Clang version X.
#2 - Clang version "X + 1" adds a new warning, enabled by default,
     which breaks the test.
#3 - We add -Wno-newwarning to the testcase, fixing the testcase with
     clang "X + 1".
#4 - Now building the test with Clang version X no longer works, due
     to "unknown warning option".

gdb/testsuite/ChangeLog:
2020-06-24  Pedro Alves  <palves@redhat.com>

* lib/gdb.exp (gdb_compile): Update intro comment.  If C/C++ with
Clang, add "-Wno-unknown-warning-option" to the options.

3 years agoFixes PR 25475: ensure exec-file-mismatch "ask" always asks in case of mismatch.
Philippe Waroquiers [Sun, 21 Jun 2020 19:26:25 +0000 (21:26 +0200)] 
Fixes PR 25475: ensure exec-file-mismatch "ask" always asks in case of mismatch.

As explained in https://sourceware.org/bugzilla/show_bug.cgi?id=25475,
when the currently loaded file has no debug symbol,
symbol_file_add_with_addrs does not ask a confirmation to the user
before loading the new symbol file.  The behaviour is not consistent
when symbol_file_add_with_addrs is called due to exec-file-mismatch "ask"
setting.

The PR discusses several solutions/approaches.
The preferred approach (suggested by Joel) is to ensure that GDB always asks
a confirmation when it loads a new symbol file due to exec-file-mismatch,
using a new SYMFILE add-flag.

I tested this manually.  If OK, we can remove the bypass introduced by Tom
in 6b9374f1, in order to always answer to the 'load' question.

gdb/ChangeLog
2020-06-24  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* symfile-add-flags.h: New flag SYMFILE_ALWAYS_CONFIRM.
* exec.c (validate_exec_file): If from_tty, set both
SYMFILE_VERBOSE (== from_tty) and SYMFILE_ALWAYS_CONFIRM.
* symfile.c (symbol_file_add_with_addrs): if always_confirm
and from_tty, unconditionally ask a confirmation.

3 years agobfd/riscv: tighten matching rules in riscv_scan
Andrew Burgess [Tue, 23 Jun 2020 22:22:43 +0000 (23:22 +0100)] 
bfd/riscv: tighten matching rules in riscv_scan

The following GDB behaviour was observed:

  (gdb) x/1i 0x0001014a
     0x1014a <main+8>: jal 0x10132 <foo>
  (gdb) show architecture
  The target architecture is set automatically (currently riscv:rv32)
  (gdb) set architecture riscv:rv32
  The target architecture is assumed to be riscv:rv32
  (gdb) x/1i 0x0001014a
     0x1014a <main+8>: 0x37e5
  (gdb)

Notice that initially we can disassemble the instruction (it's a
compressed jal instruction), but after setting the architecture we can
no longer disassemble the instruction.

This is particularly puzzling as GDB initially thought the
architecture was 'riscv:rv32', but when we force the architecture to
be that, the disassembly stops working.

This issue was introduced with this commit:

  commit c35d018b1a5ec604e49a807402c4205530b25ca8
  Date:   Mon Jan 27 15:19:30 2020 -0800

      RISC-V: Fix gdbserver problem with handling arch strings.

In this commit we try to make riscv_scan handle cases where we see
architecture strings like 'riscv:rv32imc' (for example).  Normally
this wouldn't match as bfd_default_scan requires an exact match, so we
extended riscv_scan to ignore trailing characters.

Unfortunately the default riscv arch is called 'riscv', is 64-bit,
and has its mach type set to 0, which I think is intended to pair with
code is riscv-dis.c:riscv_disassemble_insn that tries to guess if we
are 32 or 64 bit.

What happens then is that 'riscv:rv32' is first tested against 'riscv'
using bfd_default_scan, this doesn't match, we then compare this to
'riscv', but allowing trailing characters to be ignored, this matches,
and our 'riscv:rv32' matches against the default (64-bit)
architecture.

The solution I propose is to prevent the default architecture from
taking part in this "ignore trailing characters" extra match case,
only the more specific 'riscv:rv32' and 'riscv:rv64' get this extra
matching.

bfd/ChangeLog:

* cpu-riscv.c (riscv_scan): Don't allow shorter matches using the
default architecture.

3 years agoFix a potential use of an uninitialised variable error in gold.
Nick Clifton [Wed, 24 Jun 2020 16:38:16 +0000 (17:38 +0100)] 
Fix a potential use of an uninitialised variable error in gold.

* target-reloc.h (issue_discarded_error): Initialise the
key_symndx variable.

3 years agold: Correct --dependency-file order
H.J. Lu [Wed, 24 Jun 2020 13:39:03 +0000 (06:39 -0700)] 
ld: Correct --dependency-file order

Change ld --help output to

  -d, -dc, -dp                Force common symbols to be defined
  --dependency-file FILE      Write dependency file

instead of

  -d, -dc                     Force common symbols to be defined
  --dependency-file FILE, -dp Write dependency file

PR ld/26165
* lexsup.c (ld_options): Correct --dependency-file order.

3 years agocsky: Don't generate unnecessary dynamic tags
H.J. Lu [Wed, 24 Jun 2020 13:14:18 +0000 (06:14 -0700)] 
csky: Don't generate unnecessary dynamic tags

Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

PR ld/26083
* elf32-csky.c (csky_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.

ld/

PR ld/26083
* testsuite/ld-csky/tls-ie-v1.d: Updated.
* testsuite/ld-csky/tls-ie.d: Likewise.

3 years agocris: Don't generate unnecessary dynamic tags
H.J. Lu [Wed, 24 Jun 2020 11:00:19 +0000 (04:00 -0700)] 
cris: Don't generate unnecessary dynamic tags

Dynamic tags, DT_JMPREL, PLTREL and PLTRELSZ, are needed only if there
are relocation entries for PLT.  Don't generate them if there are no
relocation entries for PLT.

bfd/

PR ld/26083
* elf32-cris.c (elf_cris_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.

ld/

PR ld/26083
* testsuite/ld-cris/libdso-15b.d: Updated.
* testsuite/ld-cris/libdso-1c.d: Likewise.
* testsuite/ld-cris/libdso-1d.d: Likewise.
* testsuite/ld-cris/libdso-15c.d: New file.

3 years agold: Set non_ir_ref_regular on source for assignment
H.J. Lu [Wed, 24 Jun 2020 10:56:05 +0000 (03:56 -0700)] 
ld: Set non_ir_ref_regular on source for assignment

We need to set non_ir_ref_regular on the source for assignment to get
the correct LTO resolution:

190 a27be7f4ad90c5ce PREVAILING_DEF real_g

instead of

190 30c3b2d8f967f5ea PREVAILING_DEF_IRONLY real_g

PR ld/26163
* ldexp.c (exp_fold_tree_1): Set non_ir_ref_regular on the source
for assignment.
* testsuite/ld-plugin/lto.exp: Run ld/26163 test.
* testsuite/ld-plugin/pr26163a.c: New file.
* testsuite/ld-plugin/pr26163b.c: Likewise.

3 years agold --help output
Alan Modra [Wed, 24 Jun 2020 04:47:38 +0000 (14:17 +0930)] 
ld --help output

It's best if help message output does not contain tabs, since we don't
know tab stop settings or even if tabs are handled by the output
device.  This reverts some 2020-06-23 changes and fixes the csky help
message.

* lexsup.c (elf_shlib_list_options): Properly format help message.
(elf_plt_unwind_list_options): Likewise.
* emultempl/cskyelf.em (PARSE_AND_LIST_OPTIONS): Likewise.

3 years agoubsan: alpha-vms: shift exponent 536874240 is too large
Alan Modra [Wed, 24 Jun 2020 00:54:32 +0000 (10:24 +0930)] 
ubsan: alpha-vms: shift exponent 536874240 is too large

C_OPR_ASH is supposed to be an arithmetic shift.  By the look of it,
this operator implemented logical shifts since the original binutils
support was added.  This patch corrects that and avoids some nonsense
ubsan complaints.  I chose to implement infinite precision shifts
rather than masking shift counts to the word size as the spec I had is
silent on what is supposed to happen with overlarge shift counts.

* vms-alpha.c (_bfd_vms_slurp_etir <ETIR__C_OPR_ASH>): Implement
shifts without undefined behaviour.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 24 Jun 2020 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agogdb: New maintenance command to print XML target description
Andrew Burgess [Tue, 9 Jun 2020 22:08:54 +0000 (23:08 +0100)] 
gdb: New maintenance command to print XML target description

This commit adds a new maintenance command that dumps the current
target description as an XML document.  This is a maintenance command
as I currently only see this being useful for GDB developers, or for
people debugging a new remote target.

By default the command will print whatever the current target
description is, whether this was delivered by the remote, loaded by
the user from a file, or if it is a built in target within GDB.

The command can also take an optional filename argument.  In this case
GDB loads a target description from the file, and then reprints it.
This could be useful for testing GDB's parsing of target descriptions,
or to check that GDB can successfully parse a particular XML
description.

It is worth noting that the XML description printed will not be an
exact copy of the document fed into GDB.  For example this minimal
input file:

  <target>
    <feature name="abc">
      <reg name="r1" bitsize="32"/>
    </feature>
  </target>

Will produce this output:

  (gdb) maint print xml-tdesc path/to/file.xml
  <?xml version="1.0"?>
  <!DOCTYPE target SYSTEM "gdb-target.dtd">
  <target>
    <feature name="abc">
      <reg name="r1" bitsize="32" type="int" regnum="0"/>
    </feature>
  </target>

Notice that GDB filled in both the 'type' and 'regnum' fields of the
<reg>.  I think this is actually a positive as it means we get to
really understand how GDB processed the document, if GDB made some
assumptions that differ to those the user expected then hopefully this
will bring those issues to the users attention.

To implement this I have tweaked the output produced by the
print_xml_feature which is defined within the gdbsupport/ directory.
The changes I have made to this class are:

  1. The <architecture>...</architecture> tags are now not produced if
  the architecture name is NULL.

  2. The <osabi>...</osabi> tags get a newline at the end.

  3. And, the whole XML document is indented using white space in a
  nested fashion (as in the example output above).

I think that these changes should be fine, the print_xml_feature class
is used:

  1. In gdbserver to generate an XML document to send as the target
  description to GDB.

  2. In GDB as part of a self-check function, a target_desc is
  converted to XML then parsed back into a target_desc.  We then check
  the before and after target_desc objects are the same.

  3. In the new 'maint print xml-tdesc' command.

In all of these use cases adding the extra white space should be fine.

gdbsupport/ChangeLog:

* tdesc.cc (print_xml_feature::visit_pre): Use add_line to add
output content, and call indent as needed in all overloaded
variants.
(print_xml_feature::visit_post): Likewise.
(print_xml_feature::visit): Likewise.
(print_xml_feature::add_line): Two new overloaded functions.
* tdesc.h (print_xml_feature::indent): New member function.
(print_xml_feature::add_line): Two new overloaded member
functions.
(print_xml_feature::m_depth): New member variable.

gdb/ChangeLog:

* target-descriptions.c (tdesc_architecture_name): Protect against
NULL pointer dereference.
(maint_print_xml_tdesc_cmd): New function.
(_initialize_target_descriptions): Register new 'maint print
xml-tdesc' command and give it the filename completer.
* NEWS: Mention new 'maint print xml-tdesc' command.

gdb/testsuite/ChangeLog:

* gdb.xml/tdesc-reload.c: New file.
* gdb.xml/tdesc-reload.exp: New file.
* gdb.xml/maint-xml-dump-01.xml: New file.
* gdb.xml/maint-xml-dump-02.xml: New file.
* gdb.xml/maint-xml-dump.exp: New file.

gdb/doc/ChangeLog:

* gdb.texinfo (Maintenance Commands): Document new 'maint print
xml-desc' command.

3 years agogdb: Print compatible information within print_xml_feature
Andrew Burgess [Thu, 11 Jun 2020 21:36:29 +0000 (22:36 +0100)] 
gdb: Print compatible information within print_xml_feature

The gdbsupport directory contains a helper class print_xml_feature
that is shared between gdb and gdbserver.  This class is used for
printing an XML representation of a target_desc object.

Currently this class doesn't have the ability to print the
<compatible> entities that can appear within a target description, I
guess no targets have needed that functionality yet.

The print_xml_feature classes API is based around operating on the
target_desc class, however, the sharing between gdb and gdbserver is
purely textural, we rely on their being a class called target_desc in
both gdb and gdbserver, but there is no shared implementation.  We
then have a set of functions declared that operate on an object of
type target_desc, and again these functions have completely separate
implementations.

Currently then the gdb version of target_desc contains a vector of
bfd_arch_info pointers which represents the compatible entries from a
target description.  The gdbserver version of target_desc has no such
information.  Further, the gdbserver code doesn't seem to include the
bfd headers, and so doesn't know about the bfd types.

I was reluctant to include the bfd headers into gdbserver just so I
can reference the compatible information, which isn't (currently) even
needed in gdbserver.

So, the approach I take in this patch is to wrap the compatible
information into a new helper class.  This class is declared in the
gdbsupport library, but implemented separately in both gdb and
gdbserver.

In gdbserver the class is empty.  The compatible information within
the gdbserver is an empty list, of empty classes.

In gdb the class contains a pointer to the bfd_arch_info object.

With this in place we can now add support to print_xml_feature for
printing the compatible information if it is present.  In the
gdbserver code this will never happen, as the gdbserver never has any
compatible information.  But in gdb, this code will trigger when
appropriate.

gdb/ChangeLog:

* target-descriptions.c (class tdesc_compatible_info): New class.
(struct target_desc): Change type of compatible vector.
(tdesc_compatible_p): Update for change in type of
target_desc::compatible.
(tdesc_compatible_info_list): New function.
(tdesc_compatible_info_arch_name): New function.
(tdesc_add_compatible): Update for change in type of
target_desc::compatible.
(print_c_tdesc::visit_pre): Likewise.

gdbserver/ChangeLog:

* tdesc.cc (struct tdesc_compatible_info): New struct.
(tdesc_compatible_info_list): New function.
(tdesc_compatible_info_arch_name): New function.

gdbsupport/ChangeLog:

* tdesc.cc (print_xml_feature::visit_pre): Print compatible
information.
* tdesc.h (struct tdesc_compatible_info): Declare new struct.
(tdesc_compatible_info_up): New typedef.
(tdesc_compatible_info_list): Declare new function.
(tdesc_compatible_info_arch_name): Declare new function.

3 years agogdb: Allow target description to be dumped even when it is remote
Andrew Burgess [Tue, 9 Jun 2020 18:00:55 +0000 (19:00 +0100)] 
gdb: Allow target description to be dumped even when it is remote

The maintenance command 'maintenance print c-tdesc' can only print the
target description if it was loaded from a local file, or if the local
filename is passed to the maintenance command as an argument.

Sometimes it would be nice to know what target description GDB was
given by the remote, however, if I connect to a remote target and try
this command I see this:

  (gdb) maintenance print c-tdesc
  The current target description did not come from an XML file.
  (gdb)

Which is not very helpful.

This commit changes things so that if the description came from the
remote end then GDB will use a fake filename 'fetched from target' as
the filename for the description, GDB will then create the C
description of the target as though it came from this file.  Example
output would look like this (I snipped the feature creation from the
middle as that hasn't changed):

  (gdb) maintenance print c-tdesc
  /* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
    Original: fetched from target */

  #include "defs.h"
  #include "osabi.h"
  #include "target-descriptions.h"

  struct target_desc *tdesc_fetched_from_target;
  static void
  initialize_tdesc_fetched_from_target (void)
  {
    struct target_desc *result = allocate_target_description ();
    struct tdesc_feature *feature;

    /* ... features created here ... */

    tdesc_fetched_from_target = result;
  }
  (gdb)

In order to support using 'fetched from target' I had to update the
print_c_tdesc code to handle filenames that include a space.  This has
the benefit that we can now print out real files with spaces in the
name, for example the file 'with space.xml':

  (gdb) maint print c-tdesc with space.xml

I originally added this functionality so I could inspect the
description passed to GDB by the remote target.  After using this for
a while I realised that actually having GDB recreate the XML would be
even better, so a later commit will add that functionality too.

Still, given how small this patch is I thought it might be nice to
include this in GDB anyway.

While I was working on this anyway I've added filename command
completion to this command.

gdb/ChangeLog:

* target-descriptions.c (print_c_tdesc::print_c_tdesc): Change
whitespace to underscore.
(maint_print_c_tdesc_cmd): Use fake filename for target
descriptions that came from the target.
(_initialize_target_descriptions): Add filename command completion
for 'maint print c-tdesc'.

3 years agogdb: add some more empty lines in loc.c
Simon Marchi [Tue, 23 Jun 2020 19:40:23 +0000 (15:40 -0400)] 
gdb: add some more empty lines in loc.c

Add some empty lines at places I forgot in the previous patch.

gdb/ChangeLog:

* dwarf2/loc.c (decode_debug_loclists_addresses): Add empty
lines.

Change-Id: I8a9f3766ede1ce750e0703023285dca873bce0da

3 years agogdb: add empty lines in loc.c
Simon Marchi [Tue, 23 Jun 2020 19:26:36 +0000 (15:26 -0400)] 
gdb: add empty lines in loc.c

I always found that some switch statements in this file were a bit too
packed.  I think having empty lines between each case helps with
reading.  I'm pushing this as obvious, I hope it won't be too
controversial.

gdb/ChangeLog:

* dwarf2/loc.c (decode_debug_loc_dwo_addresses): Add empty
lines.
(dwarf2_find_location_expression): Likewise.
(call_site_parameter_matches): Likewise.
(dwarf2_compile_expr_to_ax): Likewise.
(disassemble_dwarf_expression): Likewise.
(loclist_describe_location): Likewise.

Change-Id: I381366a0468ff1793faa612c46ef48a9d4773192

3 years agoPR 22843: ld, gold: Add --dependency-file option.
Roland McGrath [Tue, 23 Jun 2020 19:01:24 +0000 (12:01 -0700)] 
PR 22843: ld, gold: Add --dependency-file option.

gold/
* options.h (class General_options): Add --dependency-file option.
* fileread.cc (File_read::files_read): New static variable.
(File_read::open): Add the file to the files_read list.
(File_read::record_file_read): New static member function.
(File_read::write_dependency_file): New static member function.
* fileread.h (class File_read): Declare them.
* layout.cc (Layout::read_layout_from_file): Call record_file_read.
(Close_task_runner::run): Call write_dependency_file if
--dependency-file was passed.

ld/
* NEWS: Note --dependency-file.
* ld.texi (Options): Document --dependency-file.
* ldlex.h (enum option_values): Add OPTION_DEPENDENCY_FILE.
* ld.h (ld_config_type): New member dependency_file.
* lexsup.c (ld_options, parse_args): Parse --dependency-file.
* ldmain.c (struct dependency_file): New type.
(dependency_files, dependency_files_tail): New static variables.
(track_dependency_files): New function.
(write_dependency_file): New function.
(main): Call it when --dependency-file was passed.
* ldfile.c (ldfile_try_open_bfd): Call track_dependency_files.
(ldfile_open_command_file_1): Likewise.
* ldelf.c (ldelf_try_needed): Likewise.
* pe-dll.c (pe_implied_import_dll): Likewise.

3 years agoFix "maint selftest" regression, add struct scoped_mock_context
Pedro Alves [Tue, 23 Jun 2020 14:18:41 +0000 (15:18 +0100)] 
Fix "maint selftest" regression, add struct scoped_mock_context

This commit:

 commit 3922b302645fda04da42a5279399578ae2f6206c
 Author:     Pedro Alves <palves@redhat.com>
 AuthorDate: Thu Jun 18 21:28:37 2020 +0100

    Decouple inferior_ptid/inferior_thread(); dup ptids in thread list (PR 25412)

caused a regression for gdb.gdb/unittest.exp when GDB is configured
with --enable-targets=all.  The failure is:

  gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `current_thread_ != nullptr' failed.

The problem is in this line in regcache.c:cooked_read_test:

  /* Switch to the mock thread.  */
  scoped_restore restore_inferior_ptid
    = make_scoped_restore (&inferior_ptid, mock_ptid);

Both gdbarch-selftest.c and regcache.c set up a similar mock context,
but the series the patch above belongs to only updated the
gdbarch-selftest.c context to not write to inferior_ptid directly, and
missed updating regcache.c's.

Instead of copying the fix over to regcache.c, share the mock context
setup code in a new RAII class, based on gdbarch-selftest.c's version.

Also remove the "target already pushed" error from regcache.c, like it
had been removed from gdbarch-selftest.c in the multi-target series.
That check is unnecessary because each inferior now has its own target
stack, and the unit test pushes a target on a separate (mock)
inferior, not the current inferior on entry.

gdb/ChangeLog:
2020-06-23  Pedro Alves  <palves@redhat.com>

* gdbarch-selftests.c: Don't include inferior.h, gdbthread.h or
progspace-and-thread.h.  Include scoped-mock-context.h instead.
(register_to_value_test): Use scoped_mock_context.
* regcache.c: Include "scoped-mock-context.h".
(cooked_read_test): Don't error out if a target is already pushed.
Use scoped_mock_context.  Adjust.
* scoped-mock-context.h: New file.

3 years agoAdjust command completion output when TUI is disabled
Sandra Loosemore [Tue, 23 Jun 2020 16:33:31 +0000 (09:33 -0700)] 
Adjust command completion output when TUI is disabled

The history-scrolling commands "+", "-", "<" and ">" are only known to
GDB when TUI is enabled.  This means the "complete pipe " command
produces different output depending on whether TUI is present, which
in turn caused

FAIL: gdb.base/shell.exp: cmd complete "pipe "

This patch provides different patterns for that test depending on
whether or not TUI is available.

2020-06-23  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* lib/completion-support.exp (test_gdb_completion_offers_commands):
Adjust for omitted commands when TUI is disabled.

3 years agoAdd a testcase for PR binutils/26160
H.J. Lu [Tue, 23 Jun 2020 16:19:05 +0000 (09:19 -0700)] 
Add a testcase for PR binutils/26160

PR binutils/26160
* testsuite/binutils-all/pr26160.dwp.bz2: New file.
* testsuite/binutils-all/pr26160.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run PR binutils/26160 test.

3 years agoPR26150, Assertion when asm() defines global symbols, -flto and --start-group
Alan Modra [Tue, 23 Jun 2020 14:20:56 +0000 (23:50 +0930)] 
PR26150, Assertion when asm() defines global symbols, -flto and --start-group

If an archive map contains symbols that aren't actually defined by the
indexed element for any reason, then loading that element will leave
the symbol undefined (or common).  This leads to the possibility of
the element being loaded again should the archive be searched again
due to the action of --start-group/--end-group.  The testcase
triggering this problem was an archive containing fat lto objects,
with the archive map incorrectly created by ar rather than gcc-ar.

PR 26150
* ldlang.c (ldlang_add_file): Assert that we aren't adding the
current end of link.next list again too.
* ldmain.c (add_archive_element): Don't load archive elements
again that have already been loaded.

3 years agoFix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections. ...
Nick Clifton [Tue, 23 Jun 2020 15:06:38 +0000 (16:06 +0100)] 
Fix decoding of indexed DWARF strings using pre-DWARF-5 string offset sections.  Fix display of .debug_str_offsets.dwo sections.

PR 26160
* dwarf.c (fetch_indexed_string): Detect and handle old style
.debug_str_offset tables.
(display_debug_str_offsets): Likewise.  Also add support for
.debug_str_offsets.dwo sections.

3 years agoImprove -Wunused-value testcase build failures fix
Gary Benson [Tue, 23 Jun 2020 14:11:27 +0000 (15:11 +0100)] 
Improve -Wunused-value testcase build failures fix

This commit improves upon my previous -Wunused-value fix by
replacing the various dummy variables with casts to void, as
suggested by Pedro.

gdb/testsuite/ChangeLog:

* gdb.cp/namespace.cc: Improve -Wunused-value fix.
* gdb.cp/nsimport.cc: Likewise.
* gdb.cp/nsnested.cc: Likewise.
* gdb.cp/nsnoimports.cc: Likewise.
* gdb.cp/nsusing.cc: Likewise.
* gdb.cp/smartp.cc: Likewise.
* gdb.python/py-pp-integral.c: Likewise.
* gdb.python/py-pp-re-notag.c: Likewise.

3 years agoAdd a testcase for PR binutils/26112
H.J. Lu [Tue, 23 Jun 2020 13:50:23 +0000 (06:50 -0700)] 
Add a testcase for PR binutils/26112

PR binutils/26112
* testsuite/binutils-all/pr26112.o.bz2: New file.
* testsuite/binutils-all/pr26112.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run PR binutils/26112 test.

3 years agogdb: Convert language la_is_string_type_p field to a method
Andrew Burgess [Thu, 18 Jun 2020 21:01:33 +0000 (22:01 +0100)] 
gdb: Convert language la_is_string_type_p field to a method

This commit changes the language_data::la_is_string_type_p function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete la_is_string_type_p
initializer.
(ada_language::is_string_type_p): New member function.
* c-lang.c (c_language_data): Delete la_is_string_type_p
initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_is_string_type_p): Delete function, implementation
moved to f_language::is_string_type_p.
(f_language_data): Delete la_is_string_type_p initializer.
(f_language::is_string_type_p): New member function,
implementation from f_is_string_type_p.
* go-lang.c (go_is_string_type_p): Delete function, implementation
moved to go_language::is_string_type_p.
(go_language_data): Delete la_is_string_type_p initializer.
(go_language::is_string_type_p): New member function,
implementation from go_is_string_type_p.
* language.c (language_defn::is_string_type_p): Define new member
function.
(default_is_string_type_p): Make static, add comment copied from
header file.
(unknown_language_data): Delete la_is_string_type_p initializer.
(unknown_language::is_string_type_p): New member function.
(auto_language_data): Delete la_is_string_type_p initializer.
(auto_language::is_string_type_p): New member function.
* language.h (language_data): Delete la_is_string_type_p field.
(language_defn::is_string_type_p): Declare new function.
(default_is_string_type_p): Delete desclaration, move comment to
definition.
* m2-lang.c (m2_is_string_type_p): Delete function, implementation
moved to m2_language::is_string_type_p.
(m2_language_data): Delete la_is_string_type_p initializer.
(m2_language::is_string_type_p): New member function,
implementation from m2_is_string_type_p.
* objc-lang.c (objc_language_data): Delete la_is_string_type_p
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_is_string_type_p): Delete function,
implementation moved to pascal_language::is_string_type_p.
(pascal_language_data): Delete la_is_string_type_p initializer.
(pascal_language::is_string_type_p): New member function,
implementation from pascal_is_string_type_p.
* rust-lang.c (rust_is_string_type_p): Delete function,
implementation moved to rust_language::is_string_type_p.
(rust_language_data): Delete la_is_string_type_p initializer.
(rust_language::is_string_type_p): New member function,
implementation from rust_is_string_type_p.
* valprint.c (val_print_scalar_or_string_type_p): Update call to
is_string_type_p.

3 years agogdb: Convert language la_print_typedef field to a method
Andrew Burgess [Thu, 18 Jun 2020 20:38:50 +0000 (21:38 +0100)] 
gdb: Convert language la_print_typedef field to a method

This commit changes the language_data::la_print_typedef function
pointer member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete la_print_typedef
initializer.
(ada_language::print_typedef): New member function.
* c-lang.c (c_language_data): Delete la_print_typedef initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::print_typedef): New member function.
* go-lang.c (go_language_data): Delete la_print_typedef
initializer.
* language.c (language_defn::print_typedef): Define member
function.
(unknown_language_data): Delete la_print_typedef initializer.
(unknown_language::print_typedef): New member function.
(auto_language_data): Delete la_print_typedef initializer.
(auto_language::print_typedef): New member function.
* language.h (language_data): Delete la_print_typedef field.
(language_defn::print_typedef): Declare new member function.
(LA_PRINT_TYPEDEF): Update call to print_typedef.
(default_print_typedef): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_typedef
initializer.
(m2_language::print_typedef): New member function.
* objc-lang.c (objc_language_data): Delete la_print_typedef
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::print_typedef): New member function.
* rust-lang.c (rust_print_typedef): Delete function,
implementation moved to rust_language::print_typedef.
(rust_language): Delete la_print_typedef initializer.
(rust_language::print_typedef): New member function,
implementation from rust_print_typedef.
* typeprint.c (default_print_typedef): Delete.

3 years agogdb: Convert language la_printstr field to a method
Andrew Burgess [Wed, 3 Jun 2020 15:44:05 +0000 (16:44 +0100)] 
gdb: Convert language la_printstr field to a method

This commit changes the language_data::la_printstr function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete la_printstr initializer.
(ada_language::printstr): New member function.
* c-lang.c (c_language_data): Delete la_printstr initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_printstr): Rename to f_language::printstr.
(f_language_data): Delete la_printstr initializer.
(f_language::printstr): New member function, implementation from
f_printstr.
* go-lang.c (go_language_data): Delete la_printstr initializer.
* language.c (language_defn::printstr): Define new member
function.
(unk_lang_printstr): Delete.
(unknown_language_data): Delete la_printstr initializer.
(unknown_language::printstr): New member function.
(auto_language_data): Delete la_printstr initializer.
(auto_language::printstr): New member function.
* language.h (language_data): Delete la_printstr field.
(language_defn::printstr): Declare new member function.
(LA_PRINT_STRING): Update call to printstr.
* m2-lang.c (m2_printstr): Rename to m2_language::printstr.
(m2_language_data): Delete la_printstr initializer.
(m2_language::printstr): New member function, implementation from
m2_printstr.
* objc-lang.c (objc_language_data): Delete la_printstr
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_printstr): Rename to pascal_language::printstr.
(pascal_language_data): Delete la_printstr initializer.
(pascal_language::printstr): New member function, implementation
from pascal_printstr.
* p-lang.h (pascal_printstr): Delete declaration.
* rust-lang.c (rust_printstr): Update header comment.
(rust_language_data): Delete la_printstr initializer.
(rust_language::printstr): New member function.

3 years agogdb: Convert language la_printchar field to a method
Andrew Burgess [Wed, 3 Jun 2020 14:54:19 +0000 (15:54 +0100)] 
gdb: Convert language la_printchar field to a method

This commit changes the language_data::la_printchar function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete la_printchar initializer.
(ada_language::printchar): New member function.
* c-lang.c (c_language_data): Delete la_printchar initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_printchar): Rename to f_language::printchar.
(f_language_data): Delete la_printchar initializer.
(f_language::printchar): New member function, implementation from
f_printchar.
* go-lang.c (go_language_data): Delete la_printchar initializer.
* language.c (unk_lang_printchar): Delete.
(language_defn::printchar): Define new member function.
(unknown_language_data): Delete la_printchar initializer.
(unknown_language::printchar): New member function.
(auto_language_data): Delete la_printchar initializer.
(auto_language::printchar): New member function.
* language.h (language_data): Delete la_printchar field.
(language_defn::printchar): Declare new member function.
(LA_PRINT_CHAR): Update call to printchar.
* m2-lang.c (m2_language_data): Delete la_printchar initializer.
(m2_language::printchar): New member function.
* objc-lang.c (objc_language_data): Delete la_printchar
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Delete la_printchar
initializer.
(pascal_language::printchar): New member function.
* rust-lang.c (rust_printchar): Rename to
rust_language::printchar.
(rust_language_data): Delete la_printchar initializer.
(rust_language::printchar): New member function, implementation
from rust_printchar.

3 years agogdb: Convert language la_emitchar field to a method
Andrew Burgess [Tue, 2 Jun 2020 20:54:49 +0000 (21:54 +0100)] 
gdb: Convert language la_emitchar field to a method

This commit changes the language_data::la_emitchar function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (emit_char): Renamed to ada_language::emitchar.
(ada_language_data): Delete la_emitchar initializer.
(ada_language::emitchar): New member function, implementation from
emit_char.
* c-lang.c (c_language_data): Delete la_emitchar initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_emit_char): Rename to f_language::emitchar.
(f_language_data): Delete la_emitchar initializer.
(f_language::emitchar): New member function, implementation from
f_emit_char.
* go-lang.c (go_language_data): Delete la_emitchar initializer.
* language.c (unk_lang_emit_char): Delete.
(language_defn::emitchar): New member function definition.
(unknown_language_data): Delete la_emitchar initializer.
(unknown_language::emitchar): New member function.
(auto_language_data): Delete la_emitchar initializer.
(auto_language::emitchar): New member function.
* language.h (language_data): Delete la_emitchar field.
(language_defn::emitchar): New member field declaration.
(LA_EMIT_CHAR): Update call to emitchar.
* m2-lang.c (m2_emit_char): Rename to m2_language::emitchar.
(m2_language_data): Delete la_emitchar initializer.
(m2_language::emitchar): New member function, implementation from
m2_emit_char.
* objc-lang.c (objc_language_data): Delete la_emitchar
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_emit_char): Rename to pascal_language::emitchar.
(pascal_language_data): Delete la_emitchar initializer.
(pascal_language::emitchar): New member function, implementation
from pascal_emit_char.
* rust-lang.c (rust_emitchar): Rename to rust_language::emitchar.
(rust_language_data): Delete la_emitchar initializer.
(rust_language::emitchar): New member function, implementation
from rust_emitchar.

3 years agogdb: Convert language la_post_parser field to a method
Andrew Burgess [Tue, 2 Jun 2020 13:57:40 +0000 (14:57 +0100)] 
gdb: Convert language la_post_parser field to a method

This commit changes the language_data::la_post_parser function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (resolve): Rename to ada_language::post_parser.
(ada_language_data): Delete la_post_parser initializer.
(ada_language::post_parser): New member function.
* c-lang.c (c_language_data): Delete la_post_parser initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_post_parser field.
(language_defn::post_parser): New member function.
* m2-lang.c (m2_language_data): Delete la_post_parser initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* parse.c (parse_exp_in_context): Update call to post_parser.
(null_post_parser): Delete definition.
* parser-defs.h (null_post_parser): Delete declaration.
* rust-lang.c (rust_language_data): Delete la_post_parser
initializer.

3 years agogdb: Convert language la_parser field to a method
Andrew Burgess [Tue, 2 Jun 2020 13:48:04 +0000 (14:48 +0100)] 
gdb: Convert language la_parser field to a method

This commit changes the language_data::la_parser function pointer
member variable into a member function of language_defn.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (parse): Rename to ada_language::parser.
(ada_language_data): Delete la_parser initializer.
(ada_language::parser): New member function, implementation from
parse.
* c-lang.c (c_language_data): Delete la_parser initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
(d_language::parser): New member function.
* f-lang.c (f_language_data): Delete la_parser initializer.
(f_language::parser): New member function.
* go-lang.c (go_language_data): Delete la_parser initializer.
(go_language::parser): New member function.
* language.c (unk_lang_parser): Delete.
(language_defn::parser): Define new member function.
(unknown_language_data): Delete la_parser initializer.
(unknown_language::parser): New member function.
(auto_language_data): Delete la_parser initializer.
(auto_language::parser): New member function.
* language.h (language_data): Delete la_parser field.
(language_defn::parser): Declare new member function.
* m2-lang.c (m2_language_data): Delete la_parser initializer.
(m2_language::parser): New member function.
* objc-lang.c (objc_language_data): Delete la_parser initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::parser): New member function.
* parse.c (parse_exp_in_context): Update call to parser.
* rust-lang.c (rust_language_data): Delete la_parser initializer.
(rust_language::parser): New member function.

3 years agoELF: Add _bfd_elf_add_dynamic_tags
H.J. Lu [Tue, 23 Jun 2020 12:07:31 +0000 (05:07 -0700)] 
ELF: Add _bfd_elf_add_dynamic_tags

All ELF backends with shared library support need to add dynamic tags.
Add dt_pltgot_required and dt_jmprel_required to elf_link_hash_table to
indicate that DT_PLTGOT and DT_JMPREL are required dynamic tags.

1. Add _bfd_elf_add_dynamic_tags to add common dynamic tags.
2. Add _bfd_elf_maybe_vxworks_add_dynamic_tags to add common VxWorks
dynamic tags.

* elf-bfd.h (elf_link_hash_table): Add dt_pltgot_required and
dt_jmprel_required.
(_bfd_elf_add_dynamic_tags): New.
* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
* elf32-bfin.c (elf32_bfinfdpic_size_dynamic_sections): Likewise.
* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
* elf32-frv.c (elf32_frvfdpic_size_dynamic_sections): Likewise.
* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-microblaze.c (microblaze_elf_size_dynamic_sections):
Likewise.
* elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise.
* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise.
* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections):
Likewise.
* elfnn-riscv.c (riscv_elf_size_dynamic_sections): Likewise.
* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise.
* elf32-arm.c (elf32_arm_size_dynamic_sections): Call
_bfd_elf_maybe_vxworks_add_dynamic_tags.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections):
Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Likewise.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
* elfxx-x86.h (elf_x86_link_hash_table): Remove dt_reloc,
dt_reloc_sz and dt_reloc_ent.
* elf-vxworks.c (_bfd_elf_maybe_vxworks_add_dynamic_tags): New.
* elf-vxworks.h (_bfd_elf_maybe_vxworks_add_dynamic_tags):
Likewise.
* elf32-hppa.c (elf32_hppa_link_hash_table_create): Set
etab.dt_pltgot_required.
(elf32_hppa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf32-metag.c (elf_metag_link_hash_table_create): Set
etab.dt_pltgot_required.
(elf_metag_size_dynamic_sections): Call _bfd_elf_add_dynamic_tags.
* elf32-sh.c (sh_elf_link_hash_table_create): Set
root.dt_pltgot_required for FDPIC output.
(sh_elf_size_dynamic_sections): Call
_bfd_elf_maybe_vxworks_add_dynamic_tags.
* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Set
elf.dt_pltgot_required.
(elf_xtensa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elf64-hppa.c (elf64_hppa_hash_table_create): Set
root.dt_pltgot_required.
(elf64_hppa_size_dynamic_sections): Call
_bfd_elf_add_dynamic_tags.
* elfnn-ia64.c (elfNN_ia64_hash_table_create): Set
root.dt_pltgot_required.
(elfNN_ia64_size_dynamic_sections): Set root.dt_jmprel_required
for rel_pltoff_sec.  Call _bfd_elf_add_dynamic_tags.
* elflink.c (_bfd_elf_add_dynamic_tags): New.

3 years agoAvoid testcase build failures with -Wunused-value
Gary Benson [Tue, 23 Jun 2020 11:25:34 +0000 (12:25 +0100)] 
Avoid testcase build failures with -Wunused-value

A number of testcases fail to build with -Wunused-value enabled.
This commit adds dummy values to avoid this.

gdb/testsuite/ChangeLog:

* gdb.cp/namespace.cc: Avoid build failure with -Wunused-value.
* gdb.cp/nsimport.cc: Likewise.
* gdb.cp/nsnested.cc: Likewise.
* gdb.cp/nsnoimports.cc: Likewise.
* gdb.cp/nsusing.cc: Likewise.
* gdb.cp/smartp.cc: Likewise.
* gdb.python/py-pp-integral.c: Likewise.
* gdb.python/py-pp-re-notag.c: Likewise.

3 years agogdb: Add --with-python-libdir to gdb's --configuration output
Andrew Burgess [Tue, 23 Jun 2020 09:02:47 +0000 (10:02 +0100)] 
gdb: Add --with-python-libdir to gdb's --configuration output

Commit:

  commit d13c7322fe1266984024644154003a19664610ea
  Date:   Fri Jan 17 00:10:22 2020 +0000

      gdb: Allow more control over where to find python libraries

Added a new configuration option --with-python-libdir, but failed to
add this option to the output of 'gdb --configuration'.  This commit
fixes this mistake.

gdb/ChangeLog:

* top.c (print_gdb_configuration): Print --with-python-libdir
configuration value.

3 years agoRISC-V: Generate ELF priv attributes if priv instruction are explicited used.
Nelson Chu [Mon, 22 Jun 2020 08:11:18 +0000 (16:11 +0800)] 
RISC-V: Generate ELF priv attributes if priv instruction are explicited used.

We should generate the ELF priv attributes only if,

1. The priv attributes are already set in the assembly file.
2. The CSR are explicited used.
3. The privileged instruction are explicited used.

* There are four privileged instruction defined in the v1.11 priv spec:
`mret`, `sret`, `wfi` and `sfence.vma`.

* `sfence.vm` is dropped in the v1.10 priv spec.

* `uret` is actually a N-ext instruction.  So it is better to regard it as
an user instruction rather than the priv instruction.

* `hret` is used to return from traps in H-mode.  H-mode is removed since
the v1.10 priv spec, but probably be added in the new hypervisor spec.
Therefore, `hret` should be controlled by the hypervisor spec rather than
priv spec in the future.

* `dret` is a debug instruction.  We should record the debug spec versions
once it is explicited used in the future.

gas/
* config/tc-riscv.c (explicit_priv_attr): Rename explicit_csr to
explicit_priv_attr.  It used to indicate CSR or priv instructions are
explictly used.
(riscv_is_priv_insn): Return True if it is a privileged instruction.
(riscv_ip): Call riscv_is_priv_insn to check whether the instruction
is privileged or not.  If it is, then set explicit_priv_attr to TRUE.
(riscv_write_out_attrs): Clarification of when to generate the elf
priv spec attributes.

* testsuite/gas/riscv/attribute-11.s: Add comments.
* testsuite/gas/riscv/attribute-14.s: New testcase.  Use symbol
`priv_insn_<n>` to decide which priv instruction is expected to used.
(<n> is a to g.)
* testsuite/gas/riscv/attribute-14a.d: Likewise.
* testsuite/gas/riscv/attribute-14b.d: Likewise.
* testsuite/gas/riscv/attribute-14c.d: Likewise.
* testsuite/gas/riscv/attribute-14d.d: Likewise.
* testsuite/gas/riscv/attribute-14e.d: Likewise.

3 years agoCorrect bfin XPASSes
Alan Modra [Mon, 22 Jun 2020 02:20:46 +0000 (11:50 +0930)] 
Correct bfin XPASSes

bfin-elf and bfin-linux differ.  This patch fixes these:
bfin-linux-uclibc  -XPASS: PR ld/14170
bfin-linux-uclibc  -XPASS: pr17068 link --as-needed lib in group
bfin-linux-uclibc  -XPASS: -Bsymbolic-functions
bfin-linux-uclibc  -XPASS: pr22374 function pointer initialization

* testsuite/ld-elf/shared.exp (pr14170): Clear xfail for
bfin-*-linux*.
(pr17068, symbolic-func.so, pr22374): Likewise.

3 years agobinutils objdump.exp remote_file typo
Alan Modra [Mon, 22 Jun 2020 02:13:30 +0000 (11:43 +0930)] 
binutils objdump.exp remote_file typo

* testsuite/binutils-all/objdump.exp (bintest.a): Correct
remote_file delete command.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 23 Jun 2020 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoNEWS and documentation for alias default-args related concept and commands.
Philippe Waroquiers [Mon, 24 Jun 2019 22:50:29 +0000 (00:50 +0200)] 
NEWS and documentation for alias default-args related concept and commands.

gdb/ChangeLog
2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* NEWS: Mention change to the alias command.

gdb/doc/ChangeLog
2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.texinfo (Command aliases default args): New node documenting
how to use default args for a command using aliases.
(Aliases): Document the new 'DEFAULT-ARGS...' option.
(Help): Update help aliases text and describe when full alias
definition is provided.

3 years agoAdd tests for new alias default-args related commands and arguments.
Philippe Waroquiers [Sun, 23 Jun 2019 21:13:57 +0000 (23:13 +0200)] 
Add tests for new alias default-args related commands and arguments.

Test the new default-args behaviour and completion for the alias command.
Note that gdb.base/default-args.exp is somewhat copied from
with.exp (the test of the with command), while default-exp.c
is a plain copy of with.c.

gdb/testsuite/ChangeLog
2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/default-args.exp: New test.
* gdb.base/default-args.c: New file.
* gdb.base/alias.exp: Update expected error msg for alias foo=bar.
* gdb.base/default.exp: Update to new help text.
* gdb.base/help.exp: Likewise.
* gdb.base/page.exp: Likewise.
* gdb.base/style.exp: Likewise.
* gdb.guile/guile.exp: Likewise.
* gdb.python/python.exp: Likewise.

3 years agodefault-args: allow to define default arguments for aliases
Philippe Waroquiers [Wed, 19 Jun 2019 10:49:55 +0000 (12:49 +0200)] 
default-args: allow to define default arguments for aliases

Currently, a user can define an alias, but cannot have default
arguments for this alias.

This patch modifies the 'alias' command so that default args can
be provided.
    (gdb) h alias
    Define a new command that is an alias of an existing command.
    Usage: alias [-a] [--] ALIAS = COMMAND [DEFAULT-ARGS...]
    ALIAS is the name of the alias command to create.
    COMMAND is the command being aliased to.

    Options:
      -a
        Specify that ALIAS is an abbreviation of COMMAND.
        Abbreviations are not used in command completion..

    GDB will automatically prepend the provided DEFAULT-ARGS to the list
    of arguments explicitly provided when using ALIAS.
    Use "help aliases" to list all user defined aliases and their default args.

    Examples:
    Make "spe" an alias of "set print elements":
      alias spe set print elements
    Make "elms" an alias of "elements" in the "set print" command:
      alias -a set print elms set print elements
    Make "btf" an alias of "backtrace -full -past-entry -past-main" :
      alias btf = backtrace -full -past-entry -past-main
    Make "wLapPeu" an alias of 2 nested "with":
      alias wLapPeu = with language pascal -- with print elements unlimited --
    (gdb)

The way 'default-args' is implemented makes it trivial to set default
args also for GDB commands (such as "backtrace") and for GDB pre-defined
aliases (such as "bt").  It was however deemed better to not allow to
define default arguments for pre-defined commands and aliases, to avoid
users believing that e.g. default args for "backtrace" would apply to "bt".

If needed, default-args could be allowed for GDB predefined commands
and aliases by adding a command
'set default-args GDB_COMMAND_OR_PREDEFINED_ALIAS [DEFAULT-ARGS...]'.

* 'alias' command now has a completer that helps to complete:
     - ALIAS (if the user defines an alias after a prefix),
     - the aliased COMMAND
     - the possible options for the aliased COMMAND.

* Help and apropos commands show the definitions of the aliases
  that have default arguments, e.g.
        (gdb) help backtrace
        backtrace, btf, where, bt
          alias btf = backtrace -full -past-entry -past-main
        Print backtrace of all stack frames, or innermost COUNT frames.
        Usage: backtrace [OPTION]... [QUALIFIER]... [COUNT | -COUNT]

        Options:
          -entry-values no|only|preferred|if-needed|both|compact|default
            Set printing of function arguments at function entry.
        ...

gdb/ChangeLog
2020-06-22  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* cli/cli-cmds.c (lookup_cmd_for_default_args)
(alias_command_completer)
(make_alias_options_def_group): New functions.
(alias_opts, alias_option_defs): New struct and array.
(alias_usage_error): Update usage.
(alias_command): Handles optional DEFAULT-ARGS... arguments.
Use option framework.
(_initialize_cli_cmds): Update alias command help.
Update aliases command help.
(show_user):
Add NULL for new default_args lookup_cmd argument.
(valid_command_p): Rename to validate_aliased_command.
Add NULL for new default_args lookup_cmd argument.  Verify that the
aliased_command has no default args.
* cli/cli-decode.c (help_cmd): Show aliases definitions.
(lookup_cmd_1, lookup_cmd): New argument default_args.
(add_alias_cmd):
Add NULL for new default_args lookup_cmd argument.
(print_help_for_command): Show default args under the layout
 alias some_alias = some_aliased_cmd some_alias_default_arg.
* cli/cli-decode.h (struct cmd_list_element): New member default_args.
xfree default_args in destructor.
* cli/cli-script.c (process_next_line, do_define_command):
Add NULL for new default_args lookup_cmd argument.
* command.h: Declare new default_args argument in lookup_cmd
and lookup_cmd_1.
* completer.c (complete_line_internal_1):
Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
* guile/scm-cmd.c (gdbscm_parse_command_name): Likewise.
* guile/scm-param.c (add_setshow_generic, pascm_parameter_defined_p):
Likewise.
* infcmd.c (_initialize_infcmd): Likewise.
* python/py-auto-load.c (gdbpy_initialize_auto_load): Likewise.
* python/py-cmd.c (gdbpy_parse_command_name): Likewise.
* python/py-param.c (add_setshow_generic): Likewise.
* remote.c (_initialize_remote): Likewise.
* top.c (execute_command): Prepend default_args if command has some.
(set_verbose):
Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.
* tracepoint.c (validate_actionline, encode_actions_1):
Add NULL for new default_args lookup_cmd or lookup_cmd_1 argument.

3 years agoDisable parts of gdb.base/source-dir.exp on remote host
Sandra Loosemore [Mon, 22 Jun 2020 17:10:02 +0000 (10:10 -0700)] 
Disable parts of gdb.base/source-dir.exp on remote host

One set of tests in this file does a lot of complicated directory
manipulations to force a specific DW_AT_comp_dir format and gdb
directory search path.  As it's written, everything assumes host ==
build, and it does not seem to me that there is any obvious way to
rewrite this so it will work in general on remote host.  For instance,
our harness for testing on remote Windows host normally does all
compilation and GDB execution in $cwd using relative pathnames and I'm
not sure all these directory tricks would set up the scenario it's
trying to test even if they were correctly performed on host rather
than build.  So I think it's reasonable just to disable this on remote
host instead.

I also noted that it's using the wrong search path syntax for Windows
host in the "set directories" command and conditionalized that while I
was looking at it.  That's a necessary fix to make this work in a
situation where host == build and it's Windows, but I'm not actually
set up to test that it's sufficient, too.

2020-06-22  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/source-dir.exp (test_truncated_comp_dir): Skip on
remote host.  Fix search path syntax on Windows host.

3 years agoAdd support for decoding the DW_MACRO_define_strx and DW_MACRO_undef_strx operands...
Nick Clifton [Mon, 22 Jun 2020 16:44:56 +0000 (17:44 +0100)] 
Add support for decoding the DW_MACRO_define_strx and DW_MACRO_undef_strx operands found in DWARF-5 .debug_macro sections.

PR 26112
* dwarf.c (display_debug_str_offsets): Add code to display the
contents of the .debug_str_offsets section.
(display_debug_macro): Add support for DW_MACRO_define_strx and
DW_MACRO_undef_strx.

3 years agoaarch64: Normalize and sort feature bit macros
Alex Coplan [Mon, 22 Jun 2020 13:51:04 +0000 (14:51 +0100)] 
aarch64: Normalize and sort feature bit macros

This patch normalizes and sorts the feature bit macros in
include/opcode/aarch64.h such that it's easy to tell which bits are
allocated and where it's safe to add new feature bits.

Testing:
 * Testsuite run on aarch64-none-elf.

include/ChangeLog:

2020-06-22  Alex Coplan  <alex.coplan@arm.com>

* opcode/aarch64.h (AARCH64_FEATURE_SHA2): Normalize.
(AARCH64_FEATURE_AES): Likewise.
(AARCH64_FEATURE_V8_4): Likewise.
(AARCH64_FEATURE_SM4): Likewise.
(AARCH64_FEATURE_SHA3): Likewise.
(AARCH64_FEATURE_V8): Likewise.
(AARCH64_FEATURE_V8_2): Likewise.
(AARCH64_FEATURE_V8_3): Likewise.
(AARCH64_FEATURE_FP): Likewise.
(AARCH64_FEATURE_SIMD): Likewise.
(AARCH64_FEATURE_CRC): Likewise.
(AARCH64_FEATURE_LSE): Likewise.
(AARCH64_FEATURE_PAN): Likewise.
(AARCH64_FEATURE_LOR): Likewise.
(AARCH64_FEATURE_RDMA): Likewise.
(AARCH64_FEATURE_V8_1): Likewise.
(AARCH64_FEATURE_F16): Likewise.
(AARCH64_FEATURE_RAS): Likewise.
(AARCH64_FEATURE_PROFILE): Likewise.
(AARCH64_FEATURE_SVE): Likewise.
(AARCH64_FEATURE_RCPC): Likewise.
(AARCH64_FEATURE_COMPNUM): Likewise.
(AARCH64_FEATURE_DOTPROD): Likewise.
(AARCH64_FEATURE_F16_FML): Likewise.
(AARCH64_FEATURE_V8_5): Likewise.
(AARCH64_FEATURE_V8_6): Likewise.
(AARCH64_FEATURE_BFLOAT16): Likewise.
(AARCH64_FEATURE_FLAGMANIP): Likewise.
(AARCH64_FEATURE_FRINTTS): Likewise.
(AARCH64_FEATURE_SB): Likewise.
(AARCH64_FEATURE_PREDRES): Likewise.
(AARCH64_FEATURE_CVADP): Likewise.
(AARCH64_FEATURE_RNG): Likewise.
(AARCH64_FEATURE_BTI): Likewise.
(AARCH64_FEATURE_SCXTNUM): Likewise.
(AARCH64_FEATURE_ID_PFR2): Likewise.
(AARCH64_FEATURE_SSBS): Likewise.
(AARCH64_FEATURE_MEMTAG): Likewise.
(AARCH64_FEATURE_TME): Likewise.
(AARCH64_FEATURE_I8MM): Likewise.
(AARCH64_FEATURE_F32MM): Likewise.
(AARCH64_FEATURE_F64MM): Likewise.
(AARCH64_FEATURE_SVE2): Likewise.
(AARCH64_FEATURE_SVE2_AES): Likewise.
(AARCH64_FEATURE_SVE2_BITPERM): Likewise.
(AARCH64_FEATURE_SVE2_SM4): Likewise.
(AARCH64_FEATURE_SVE2_SHA3): Likewise.

3 years agoRecognize some new Mach-O load commands
Saagar Jha [Mon, 22 Jun 2020 13:29:20 +0000 (14:29 +0100)] 
Recognize some new Mach-O load commands

bfd
* mach-o.c: Support the new load commands by reading a linkedit data
command for them.
binutils
* od-macho.c: Dump linkedit data for new load commands.
include
* mach-o/loader.h: Add declarations of two new Mach-O load
commands.

3 years agogdbserver/linux-low: use std::list to store pending signals
Tankut Baris Aktemur [Mon, 22 Jun 2020 12:13:48 +0000 (14:13 +0200)] 
gdbserver/linux-low: use std::list to store pending signals

Use std::list to store pending signals instead of a manually-managed
linked list.  This is a refactoring.

In the existing code, pending signals are kept in a manually-created
linked list with "prev" pointers.  A new pending signal is thus
inserted to the beginning of the list.  When consuming, GDB goes until
the end of the list, following the "prev" pointers, and processes the
final item.  With this patch, a new item is added to the end of the
list and the item at the front of the list is consumed.  In other
words, the list elements used to be stored in reverse order; with this
patch, they are stored in their order of arrival.  This causes a change
in the debug messages that print the pending signals.  Otherwise, no
behavioral change is expected.

gdbserver/ChangeLog:
2020-06-22  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

Use std::list to stop pending signal instead of manually-created
linked list.
* linux-low.h: Include <list>.
(struct pending_signal): Move here from linux-low.cc.
(struct lwp_info) <pending_signals>
<pending_signals_to_report>: Update the type.
* linux-low.cc (struct pending_signals): Remove.
(linux_process_target::delete_lwp)
(linux_process_target::add_lwp)
(enqueue_one_deferred_signal)
(dequeue_one_deferred_signal)
(enqueue_pending_signal)
(linux_process_target::resume_one_lwp_throw)
(linux_process_target::thread_needs_step_over)
(linux_process_target::resume_one_thread)
(linux_process_target::proceed_one_lwp): Update the use of pending
signal list.

3 years agogdb/jit: return bool in jit_breakpoint_re_set_internal and jit_read_descriptor
Tankut Baris Aktemur [Mon, 22 Jun 2020 12:03:33 +0000 (14:03 +0200)] 
gdb/jit: return bool in jit_breakpoint_re_set_internal and jit_read_descriptor

This is a minor refactoring that converts the return type of
jit_read_descriptor and jit_breakpoint_re_set_internal functions
from 'int' to 'bool'.

The return value logic of jit_breakpoint_re_set_internal has been
reversed.  With this patch it now returns true if the jit breakpoint
has been successfully initialized.

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

* jit.c (jit_read_descriptor): Use bool as the return type.
(jit_breakpoint_re_set_internal): Use bool as the return type.
Invert the return value logic; return true if the jit breakpoint
has been successfully initialized.
(jit_inferior_init): Update the call to
jit_breakpoint_re_set_internal.

3 years agoSolaris, target_wait(), don't rely on inferior_ptid
Pedro Alves [Mon, 22 Jun 2020 09:54:08 +0000 (10:54 +0100)] 
Solaris, target_wait(), don't rely on inferior_ptid

Debugging on Solaris is broken, with the procfs target backend failing
with:

 procfs: couldn't find pid 0 in procinfo list.

as soon as you start a program.

The problem is procfs_target::wait assuming that inferior_ptid is
meaningful on entry, but, since the multi-target series, inferior_ptid
is null_ptid before we call target_wait, in infrun.c:

  static ptid_t
  do_target_wait_1 (inferior *inf, ptid_t ptid,
    target_waitstatus *status, int options)
  {
...
    /* We know that we are looking for an event in the target of inferior
       INF, but we don't know which thread the event might come from.  As
       such we want to make sure that INFERIOR_PTID is reset so that none of
       the wait code relies on it - doing so is always a mistake.  */
    switch_to_inferior_no_thread (inf);

This patch tweaks the backend to remove the assumption that
inferior_ptid points at something.  sol-thread.c (the thread_stratum
that sits on top of procfs.c) also has the same issue.

Some spots in procfs_target::wait were returning
TARGET_WAITKIND_SPURIOUS+inferior_ptid.  This commit replaces those
with waiting again without returning to the core.  This fixes the
relying on inferior_ptid, and also should fix the issue discussed
here:
  https://sourceware.org/pipermail/gdb/2020-May/048616.html
  https://sourceware.org/pipermail/gdb/2020-June/048660.html

gdb/ChangeLog:
2020-06-22  Pedro Alves  <palves@redhat.com>

PR gdb/25939
* procfs.c (procfs_target::wait): Don't reference inferior_ptid.
Use the current inferior instead.  Don't return
TARGET_WAITKIND_SPURIOUS/inferior_ptid -- instead continue and
wait again.
* sol-thread.c (sol_thread_target::wait): Don't reference
inferior_ptid.
(ps_lgetregs, ps_lsetregs, ps_lgetfpregs, ps_lsetfpregs)
(sol_update_thread_list_callback): Use the current inferior's pid
instead of inferior_ptid.

3 years agoRISC-V: Report warning when linking the objects with different priv specs.
Nelson Chu [Fri, 12 Jun 2020 15:06:49 +0000 (23:06 +0800)] 
RISC-V: Report warning when linking the objects with different priv specs.

We do know some conflicts among different privileged specs.  For linker,
the safest approach is that don't allow the object linked with others which
may cause conflicts.  But this may cause inconvenience since not all objects
with conflicting priv specs are linked will cause problems.  But it is hard
to know the detailed conflict cases for linker, so we probably need a option
to tell linker that we do know there are no conflicts, or we are willing to
take risks to link the objects with conflicted priv specs.  But the option
is still under discussion.

Therefore, we can report warnings rather than errors when linking the objects
with conflicted priv specs.  This not only makes the linker more flexible,
but also warns people that the conflicts may happen.  We also need to update
the output priv spec version once the input priv spec is newer.

bfd/
* elfxx-riscv.c (struct priv_spec_t priv_specs[]): Move them from
opcodes/riscv-opc.c to bfd/elfxx-riscv.c, since we need it in linker.
(riscv_get_priv_spec_class): Likewise.
(riscv_get_priv_spec_name): Likewise.
(riscv_get_priv_spec_class_from_numbers): New function, convert
the version numbers into string, then call riscv_get_priv_spec_class
to get the priv spec class.
* elfxx-riscv.h (riscv_get_priv_spec_class): Move forward declaration
from include/opcode/riscv.h to bfd/elfxx-riscv.h.
(riscv_get_priv_spec_name): Likewise.
(riscv_get_priv_spec_class_from_numbers): New forward declaration.
(opcode/riscv.h): Include it in the header rather than elfxx-riscv.c.
* elfnn-riscv.c (riscv_merge_attributes):  Get the priv spec classes
of input and output objects form their priv spec attributes by
riscv_get_priv_spec_class_from_numbers.  Report warning rather than
errors when linking objects with differnet priv spec versions.  We do
know v1.9.1 may have conflicts to other versions, so report the
warning, too.  After that, update the output priv spec version to the
newest one so far.

gas/
* config/tc-riscv.c (buf_size, buf): Remove the unused variables.
(riscv_set_default_priv_spec): Get the priv spec version from the
priv spec attributes by riscv_get_priv_spec_class_from_numbers.

include/
* opcode/riscv.h (riscv_get_priv_spec_class): Move the function
forward declarations to bfd/elfxx-riscv.h.
(riscv_get_priv_spec_name): Likewise.

opcodes/
* riscv-opc.c: Move the structures and functions to bfd/elfxx-riscv.c.
* riscv-dis.c: Include elfxx-riscv.h.

ld/
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-01.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-02.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-03.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-04.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-05.d: Updated.
* testsuite/ld-riscv-elf/attr-merge-priv-spec-failed-06.d: Updated.

3 years agoRISC-V: Don't assume the priv attributes are in order when handling them.
Nelson Chu [Tue, 9 Jun 2020 07:33:08 +0000 (15:33 +0800)] 
RISC-V: Don't assume the priv attributes are in order when handling them.

There is no guarantee that the priv attributes should be defined in order.
Therefore, we shouldn't have the order assumption when handling them in the
riscv_merge_attributes.  Set priv_attrs_merged to TRUE if we have handled
all of the priv attributes.

bfd/
* elfnn-riscv.c (riscv_merge_attributes): Once we meet one of the
priv attributes, we will check the conflicts for all of them (major,
minor and revision), and then set the priv_attrs_merged to TRUE to
indicate that we have handled all of the priv attributes.  Remove
the unused boolean priv_may_conflict, in_priv_zero and out_priv_zero.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 22 Jun 2020 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoVarious procfs.c cleanups
Rainer Orth [Sun, 21 Jun 2020 16:51:58 +0000 (18:51 +0200)] 
Various procfs.c cleanups

While reading through procfs.c, I noticed a couple of cleanup
opportunities:

* Some comments and code allowed for portability across different
  targets.  Since procfs.c is Solaris-only for some time now, those can
  go.

* Likewise, there were some references to the old ioctl-based /proc left.

* The code still allowed for SYS_exec.  However, it is no longer present
  in either Solaris 11.3, 11.4, or Illumos.  Checking the OpenSolaris
  sources, I found that it had already been removed in 2010 well before
  the Solaris 11 release.

* Some blocks of #if 0 code can go:

** References to struct procinfo.{g,fp}regs_dirty which are no longer
   defined.

** Code handling the PR_ASLWP flag where <sys/procfs.h> has

#define PR_ASLWP   0x00000040 /* obsolete flag; never set */

Tested on amd64-pc-solaris2.11.

* procfs.c: Cleanup many comments.

(READ_WATCHFLAG, WRITE_WATCHFLAG, EXEC_WATCHFLAG)
(AFTER_WATCHFLAG): Replace by value.

(MAIN_PROC_NAME_FORMAT): Inline ...
(create_procinfo): ... here.

(procfs_debug_inferior): Remove SYS_exec handling.
(syscall_is_exec): Likewise.
(procfs_set_exec_trap): Likewise.

(syscall_is_lwp_exit): Inline in callers.
(syscall_is_exit): Likewise.
(syscall_is_exec): Likewise.
(syscall_is_lwp_create): Likewise.

(invalidate_cache): Remove #if 0 code.

(make_signal_thread_runnable):  Remove.
(procfs_target::resume): Remove #if 0 code.

3 years ago[PR gdb/25939] Move push_target call earlier in procfs.c
Rainer Orth [Sun, 21 Jun 2020 16:32:27 +0000 (18:32 +0200)] 
[PR gdb/25939] Move push_target call earlier in procfs.c

Since the multi-target patch, the run command fails on Solaris with an
assertion failure even for a trivial program:

$ ./gdb -D ./data-directory ./hello
GNU gdb (GDB) 10.0.50.20200106-git
[...]
Reading symbols from ./hello...
(gdb) run
Starting program: /vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello
/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:336: internal-error:
thread_info::thread_info(inferior*, ptid_t): Assertion `inf_ != NULL'
failed.

Here's the start of the corresponding stack trace:

#0  internal_error (
    file=file@entry=0x966150
"/vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c", line=line@entry=336,
fmt=0x9ddb94 "%s: Assertion `%s' failed.")
    at /vol/src/gnu/gdb/hg/master/reghunt/gdb/gdbsupport/errors.c:51
#1  0x0000000000ef81f4 in thread_info::thread_info (this=0x1212020,
    inf_=<optimized out>, ptid_=...)
    at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:344
#2  0x0000000000ef82cd in new_thread (inf=inf@entry=0x0, ptid=...)
    at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:239
#3  0x0000000000efac3c in add_thread_silent (
    targ=targ@entry=0x11b0940 <the_procfs_target>, ptid=...)
    at /vol/src/gnu/gdb/hg/master/reghunt/gdb/thread.c:304
#4  0x0000000000d90692 in procfs_target::create_inferior (
    this=0x11b0940 <the_procfs_target>,
    exec_file=0x13dbef0
"/vol/obj/gnu/gdb/gdb/reghunt/no-resync/122448/gdb/hello", allargs="",
env=0x13c48f0, from_tty=<optimized out>)
    at /vol/src/gnu/gdb/hg/master/reghunt/gdb/gdbsupport/ptid.h:47
#5  0x0000000000c84e64 in run_command_1 (args=<optimized out>, from_tty=1,
    run_how=run_how@entry=RUN_NORMAL)
    at /vol/gcc-9/include/c++/9.1.0/bits/basic_string.h:263
#6  0x0000000000c85007 in run_command (args=<optimized out>,
    from_tty=<optimized out>)
    at /vol/src/gnu/gdb/hg/master/reghunt/gdb/infcmd.c:687

Looking closer, I found that in add_thread_silent as called from
procfs.c (procfs_target::create_inferior) find_inferior_ptid returns
NULL.  The all_inferiors (targ) iterator comes up empty.

Going from there, I see that in add_thread_silent

m_target_stack = {m_top = file_stratum, m_stack = {0x20190e0
<the_dummy_target>, 0x200b8c0 <exec_ops>, 0x0, 0x0, 0x0, 0x0, 0x0}}}

i.e. the_procfs_target is missing compared to the_amd64_linux_nat_target
on Linux/x86_64.

Moving the push_target call earlier allows debugging to get over the
initial assertion failure.  I run instead into

procfs: couldn't find pid 0 in procinfo list.

which is fixed by

https://sourceware.org/pipermail/gdb-patches/2020-June/169674.html

Both patches tested together on amd64-pc-solaris2.11.

PR gdb/25939
* procfs.c (procfs_target::procfs_init_inferior): Move push_target
call ...
(procfs_target::create_inferior): ... here.

3 years agoPR26132, ar creates invalid libraries for some targets with plugins enabled
Alan Modra [Sun, 21 Jun 2020 11:24:24 +0000 (20:54 +0930)] 
PR26132, ar creates invalid libraries for some targets with plugins enabled

PR 26132
* configure.ac: Disable plugins by default for some targets.
* plugin.c: Comment typo fix.
* configure: Regenerate.

3 years agoDo without ld ENABLE_PLUGINS
Alan Modra [Sun, 21 Jun 2020 04:53:46 +0000 (14:23 +0930)] 
Do without ld ENABLE_PLUGINS

Instead, use BFD_SUPPORTS_PLUGINS.

* ldfile.c: Replace uses of ENABLE_PLUGINS with BFD_SUPPORTS_PLUGINS.
* ldlang.c: Likewise.
* ldlang.h: Likewise.
* ldlex.h: Likewise.
* ldmain.c: Likewise.
* lexsup.c: Likewise.
* plugin.c: Wrap body of file in #if BFD_SUPPORTS_PLUGINS.
* testplug.c: Likewise.
* testplug2.c: Likewise.
* testplug3.c: Likewise.
* testplug4.c: Likewise.
* configure.ac (ENABLE_PLUGINS): Don't define AM_CONTITIONAL.
* Makefile.am: Remove ENABLE_PLUGINS conditionals.
(PLUGIN_CFLAGS): Don't define.
(PLUGIN_C, PLUGIN_H, PLUGIN_OBJECT): Likewise.  Substitute all
uses with plugin file name.
* configure: Regenerate.
* Makefile.in: Regenerate.

3 years agoEnsure 'exec-file has changed' check has priority over 'exec-file-mismatch' check
Philippe Waroquiers [Sat, 23 May 2020 12:54:31 +0000 (14:54 +0200)] 
Ensure 'exec-file has changed' check has priority over 'exec-file-mismatch' check

Following the implementation of exec-file-mismatch based on build-id,
an attach to a process that runs a modified exec-file was triggering
the exec-file-mismatch handling, giving a warning such as:
  warning: Mismatch between current exec-file /bd/home/philippe/gdb/git/build_termours/gdb/testsuite/outputs/gdb.base/attach/attach
  and automatically determined exec-file /bd/home/philippe/gdb/git/build_termours/gdb/testsuite/outputs/gdb.base/attach/attach
  exec-file-mismatch handling is currently "ask"
as the build-ids differ when an exec-file is recompiled.

This patch ensures that the exec-file-mismatch check is done with an up to date
build-id.  With this, exec-file-mismatch check will only trigger when the
PID file really differs from the (build-id refreshed) current exec-file.
Note that the additional check does not (yet) reload the symbols if
the exec-file is changed: this reload will happen later if needed.

gdb/ChangeLog
2020-06-21  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* exec.c (validate_exec_file): Ensure the build-id is up to
date by calling reopen_exec_file (that checks file timestamp
to decide to re-read the file).

gdb/testsuite/ChangeLog

2020-06-21  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/attach.exp: Test priority of 'exec-file' changed
over 'exec-file-mismatch'.
* gdb.base/attach.c: Mark should_exit volatile.
* gdb.base/attach2.c: Likewise.  Add a comment explaining
why the sleep cannot be big.
* gdb.base/attach3.c: New file.

3 years agoAdjust gdb.mi/mi-sym-info.exp filename patterns.
Sandra Loosemore [Sun, 21 Jun 2020 02:37:49 +0000 (19:37 -0700)] 
Adjust gdb.mi/mi-sym-info.exp filename patterns.

2020-06-20  Sandra Loosemore  <sandra@codesourcery.com>

* gdb.mi/mi-sym-info.exp: Adjust filename patterns to make directory
prefix optional.

3 years agoFix gdb.base/list-missing-source.exp on remote host.
Sandra Loosemore [Sun, 21 Jun 2020 00:23:53 +0000 (17:23 -0700)] 
Fix gdb.base/list-missing-source.exp on remote host.

2020-06-20  Sandra Loosemore  <sandra@codesourcery.com>

gdb/testsuite/
* gdb.base/list-missing-source.exp: Correct $srcfile manipulation
for remote host.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 21 Jun 2020 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 years agoRemove perror from ld_assemble, ld_compile and ld_nm
Alan Modra [Sat, 20 Jun 2020 06:23:37 +0000 (15:53 +0930)] 
Remove perror from ld_assemble, ld_compile and ld_nm

ERROR should really be reserved for errors in the testsuite framework,
not just normal errors from the tools under test.  Removing use of
perror has been suggested before but without action, over concerns
that some test failures might be missed.  This patch removes uses of
perror in ld_assemble, ld_compile and ld_nm, and updates numerous
places that ignored the result of these functions by inappropriately
returning an "unresolved" test status.  Net result over my large set
of targets look good, in some cases improving the diagnostics, eg:

i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  -ERROR: tmpdir/script: nm failed
i386-msdos  +FAIL: script
i386-msdos  +FAIL: MRI script
i386-msdos  +FAIL: MEMORY
i386-msdos  +FAIL: MEMORY with symbols

* testsuite/lib/ld-lib.exp (default_ld_compile): Don't perror on
a compiler error.
(default_ld_assemble): Similarly for an assembler error.
(default_ld_nm): Similarly for an nm error.
(run_ld_link_tests): Report ld_assemble errors as a fail.
(check_as_cfi): Remove now unnecessary perror substitution.
* testsuite/ld-elf/exclude.exp: Report ld_nm error return as test
fails rather then unresolved.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-scripts/alignof.exp: Likewise.
* testsuite/ld-scripts/defined.exp: Likewise.
* testsuite/ld-scripts/script.exp: Likewise.
* testsuite/ld-scripts/sizeof.exp: Likewise.
* testsuite/ld-selective/selective.exp: Likewise.
* testsuite/ld-scripts/extern.exp: Likewise.  Return on ld_link
failure.
* testsuite/ld-elfweak/elfweak.exp: Report compiler errors as
test unresolved.
* testsuite/ld-fastcall/fastcall.exp: Report assember errors as
test fails.
* testsuite/ld-i386/i386.exp (iamcu_tests): Likewise.
* testsuite/ld-ia64/line.exp: Likewise.
* testsuite/ld-mep/mep.exp: Likewise.
* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
* testsuite/ld-nios2/nios2.exp: Likewise.
* testsuite/ld-scripts/alignof.exp: Likewise.
* testsuite/ld-x86-64/line.exp: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-scripts/log2.exp: Formatting.
* testsuite/ld-tic6x/tic6x.exp: Report ld_link errors as a test fail.

3 years agoecoff testsuite fixes
Alan Modra [Sat, 20 Jun 2020 01:17:32 +0000 (10:47 +0930)] 
ecoff testsuite fixes

The aim of this change is to remove a whole lot of "assembly failed"
errors for ecoff targets.

* testsuite/ld-alpha/alpha.exp: Exclude *ecoff targets.
* testsuite/ld-elf/binutils.exp: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-scripts/phdrs2.exp: Likewise.

3 years agoSH gas configure and ld tests
Alan Modra [Sat, 20 Jun 2020 01:11:40 +0000 (10:41 +0930)] 
SH gas configure and ld tests

All current SH gas targets use BFD.  sh-coff was incorrectly reported
as unsupported.

gas/
* configure.tgt: Set bfd_gas for all SH targets.
ld/
* testsuite/ld-sh/sh.exp: Don't run relax tests for non-ELF.
Fail when ld_assemble fails.  Use elseif to reduce indentation.

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

3 years agoFixes for gdb.xml/tdesc-regs.exp.
Sandra Loosemore [Fri, 19 Jun 2020 16:15:38 +0000 (09:15 -0700)] 
Fixes for gdb.xml/tdesc-regs.exp.

2020-06-19  Sandra Loosemore  <sandra@codesourcery.com>
    Hafiz Abid Qadeer  <abidh@codesourcery.com>

* gdb.xml/tdesc-regs.exp (load_description): Correct pathname of
file sent to remote host.
(top level): Allow int32_t as type of 32-bit register.

3 years ago[gdb/testsuite] Limit default_target_compile override
Tom de Vries [Fri, 19 Jun 2020 15:55:52 +0000 (17:55 +0200)] 
[gdb/testsuite] Limit default_target_compile override

The file lib/future.exp contains an override of dejagnu's
default_target_compile.

The override is activated if dejagnu's default_target_compile is missing
support for one or more languages.

However, if the override is activated, it's active for all languages.

This unnecessarily extends the scope of potential problems in the override to
languages that don't need the override.

Fix this by limiting the scope of the override.

Also add a note stating for which languages the override is active, as a
reminder that support for those languages needs to be ported to dejagnu.  With
my system dejagnu 1.6.1, as well as with current dejagnu trunk, that gives us:
...
NOTE: Dejagnu's default_target_compile is missing support for Go, using \
  local override
NOTE: Dejagnu's default_target_compile is missing support for Rust, using \
  local override
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-06-19  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_note): New proc.
* lib/future.exp (gdb_default_target_compile_1): Factor out of ...
(gdb_default_target_compile): ... here.  Only call
gdb_default_target_compile_1 if use_gdb_compile(<lang>) is set.
(use_gdb_compile): Change to array.
(toplevel): Update sets of use_gdb_compile to specify language.
Warn about default_target_compile override.  Store dejagnu's version
of default_target_compile in dejagnu_default_target_compile.

3 years agoSilence warnings about incompatible plugins.
Nick Clifton [Fri, 19 Jun 2020 09:25:43 +0000 (10:25 +0100)] 
Silence warnings about incompatible plugins.

I have been looking at a Fedora bug report[1] from a user who was
receiving warning messages from the BFD library about incompatible
plugins.  It turns out that they had both 32-bit and 64-bit versions
of the same plugin installed, and the BFD library was attempting to
load all of them.

After thinking about it for a while, it seemed to me that the simplest
solution was to not warn about incompatible plugins whilst attempting
to create a list of viable plugins.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1836618

* plugin.c (try_load_plugin): Suppress the error message about
being unable to open a plugin if creating a list of viable
plugins.

3 years agoRe: ld testsuite fixes for alpha
Alan Modra [Fri, 19 Jun 2020 03:26:12 +0000 (12:56 +0930)] 
Re: ld testsuite fixes for alpha

I missed some.

* testsuite/ld-plugin/pr22983.1.d: Accept st_other notations.
* testsuite/ld-plugin/pr22983.2.d: Likewise.
* testsuite/ld-plugin/pr22983.4.d: Likewise.

3 years agold testsuite fixes for alpha
Alan Modra [Fri, 19 Jun 2020 00:30:30 +0000 (10:00 +0930)] 
ld testsuite fixes for alpha

Some tests failed just due to st_other info, eg. [NOPV], being
emitted by readelf or objdump.  Fix that.  Also since alpha doesn't
support ifunc, don't run the ifunc tests for alpha.

* testsuite/ld-elf/dynamic-1.rd: Accept st_other notations.
* testsuite/ld-elf/rdynamic-1.rd: Likewise.
* testsuite/ld-elf/pr9676.rd: Likewise.
* testsuite/ld-elf/pr9679.rd: Likewise.
* testsuite/ld-elfvers/vers30.dsym: Likewise.
* testsuite/ld-elfvers/vers31.dsym: Likewise.
* testsuite/ld-plugin/pr22983.3.d: Likewise.
* testsuite/ld-ifunc/ifunc.exp: Exclude alpha.

3 years agoEmit a warning when -z relro is unsupported
Alan Modra [Thu, 18 Jun 2020 23:47:20 +0000 (09:17 +0930)] 
Emit a warning when -z relro is unsupported

ld silently accepts -z relro and -z norelro for targets that lack the
necessary GNU_RELRO support.  This patch makes those targets emit a
warning instead, and adds testsuite infrastructure to detect when
relro is unsupported.

binutils/
* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
* testsuite/lib/binutils-common.exp (check_relro_support): New proc.
(run_dump_test): Use check_relro_support to decide whether to pass
extra ld option "-z norelro".
ld/
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Omit
-z relro and -z norelro when target support for GNU_RELRO is lacking.
(gld${EMULATION_NAME}_before_parse): Ignore RELRO default too.
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Ignore
RELRO default when target support for GNU_RELRO is lacking.
* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Likewise.
* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
* testsuite/ld-elf/pr16322.d: xfail when no relro support.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/shared.exp (pr20995-2.so, pr20995-2): Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Use check_relro_support
to decide whether to pass extra ld option "-z norelro".

This page took 0.064128 seconds and 4 git commands to generate.