Commit Graph

102179 Commits

Author SHA1 Message Date
Nick Clifton e4b7104b1e 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.
2020-06-22 17:44:56 +01:00
Alex Coplan 359157df20 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.
2020-06-22 14:51:04 +01:00
Saagar Jha d768f160a9 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.
2020-06-22 14:29:20 +01:00
Tankut Baris Aktemur 013e3554b2 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.
2020-06-22 14:13:48 +02:00
Tankut Baris Aktemur bd920864f3 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.
2020-06-22 14:03:33 +02:00
Pedro Alves f809832224 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.
2020-06-22 11:10:49 +01:00
Nelson Chu 39ff0b8123 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.
2020-06-22 10:01:14 +08:00
Nelson Chu cbd7581f34 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.
2020-06-22 09:54:02 +08:00
GDB Administrator 41ab2f9b7b Automatic date update in version.in 2020-06-22 00:00:06 +00:00
Rainer Orth 196535a69c 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.
2020-06-21 18:51:58 +02:00
Rainer Orth cf6f3e86de [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.
2020-06-21 18:32:27 +02:00
Alan Modra 1e92785005 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.
2020-06-21 22:16:59 +09:30
Alan Modra 0381901e62 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.
2020-06-21 22:16:10 +09:30
Philippe Waroquiers 48e9cc8405 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.
2020-06-21 12:48:18 +02:00
Sandra Loosemore 160f8a8f32 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.
2020-06-20 19:37:49 -07:00
Sandra Loosemore 4d91c2a467 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.
2020-06-20 17:23:53 -07:00
GDB Administrator bfbf16ce8b Automatic date update in version.in 2020-06-21 00:00:06 +00:00
Alan Modra 348fe36b1d 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.
2020-06-20 15:53:37 +09:30
Alan Modra b0ee49d21b 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.
2020-06-20 10:59:11 +09:30
Alan Modra e2201c2a57 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.
2020-06-20 10:56:39 +09:30
GDB Administrator 17fc27167f Automatic date update in version.in 2020-06-20 00:00:20 +00:00
Sandra Loosemore 87f83f2002 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.
2020-06-19 09:15:38 -07:00
Tom de Vries 37ab86550b [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.
2020-06-19 17:55:52 +02:00
Nick Clifton 13aa5ceb01 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.
2020-06-19 10:25:43 +01:00
Alan Modra e443398846 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.
2020-06-19 12:59:30 +09:30
Alan Modra 2d0a923cc6 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.
2020-06-19 10:01:09 +09:30
Alan Modra 5fd104addf 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".
2020-06-19 09:50:20 +09:30
GDB Administrator 753d1583f7 Automatic date update in version.in 2020-06-19 00:00:18 +00:00
Pedro Alves 3922b30264 Decouple inferior_ptid/inferior_thread(); dup ptids in thread list (PR 25412)
In PR 25412, Simon noticed that after the multi-target series, the
tid-reuse.exp testcase manages to create a duplicate thread in the
thread list.  Or rather, two threads with the same PTID.

add_thread_silent has code in place to detect the case of a new thread
reusing some older thread's ptid, but it doesn't work correctly
anymore when the old thread is NOT the current thread and it has a
refcount higher than 0.  Either condition prevents a thread from being
deleted, but the refcount case wasn't being considered.  I think the
reason that case wasn't considered is that that code predates
thread_info refcounting.  Back when it was originally written,
delete_thread always deleted the thread.

That add_thread_silent code in question has some now-unnecessary
warts, BTW.  For instance, this:

  /* Make switch_to_thread not read from the thread.  */
  new_thr->state = THREAD_EXITED;

... used to be required because switch_to_thread would update
'stop_pc' otherwise.  I.e., it would read registers from an exited
thread otherwise.  switch_to_thread no longer reads the stop_pc, since:

  commit f2ffa92bbc
  Author:     Pedro Alves <palves@redhat.com>
  AuthorDate: Thu Jun 28 20:18:24 2018 +0100

      gdb: Eliminate the 'stop_pc' global

Also, if the ptid of the now-gone current thread is reused, we
currently return from add_thread_silent with the current thread
pointing at the _new_ thread.  Either pointing at the old thread, or
at no thread selected would be reasonable.  But pointing at an
unrelated thread (the new thread that happens to reuse the ptid) is
just broken.  Seems like I was the one who wrote it like that but I
have no clue why, FWIW.

Currently, an exited thread kept in the thread list still holds its
original ptid.  The idea was that we need the ptid to be able to
temporarily switch to another thread and then switch back to the
original thread, because thread switching is really inferior_ptid
switching.  Switching back to the original thread requires a ptid
lookup.

Now, in order to avoid exited threads with the same ptid as a live
thread in the same thread list, one thing I considered (and tried) was
to change an exited thread's ptid to minus_one_ptid.  However, with
that, there's a case that we won't handle well, which is if we end up
with more than one exited thread in the list, since then all exited
threads will all have the same ptid.  Since inferior_thread() relies
on inferior_ptid, may well return the wrong thread.

My next attempt to address this, was to switch an exited thread's ptid
to a globally unique "exited" ptid, which is a ptid with pid == -1 and
tid == 'the thread's global GDB thread number'.  Note that GDB assumes
that the GDB global thread number is monotonically increasing and
doesn't wrap around.  (We should probably make GDB thread numbers
64-bit to prevent that happening in practice; they're currently signed
32-bit.)  This attempt went a long way, but still ran into a number of
issues.  It was a major hack too, obviously.

My next attempt is the one that I'm proposing, which is to bite the
bullet and break the connection between inferior_ptid and
inferior_thread(), aka the current thread.  I.e., make the current
thread be a global thread_info pointer that is written to directly by
switch_to_thread, etc., and making inferior_thread() return that
pointer, instead of having inferior_thread() lookup up the
inferior_ptid thread, by ptid_t.  You can look at this as a
continuation of the effort of using more thread_info pointers instead
of ptids when possible.

By making the current thread a global thread_info pointer, we can make
switch_to_thread simply write to the global thread pointer, which
makes scoped_restore_current_thread able to restore back to an exited
thread without relying on unrelyable ptid look ups.  I.e., this makes
it not a real problem to have more than one thread with the same ptid
in the thread list.  There will always be only one live thread with a
given ptid, so code that looks up a live thread by ptid will always be
able to find the right one.

This change required auditing the whole codebase for places where we
were writing to inferior_ptid directly to change the current thread,
and change them to use switch_to_thread instead or one of its
siblings, because otherwise inferior_thread() would return a thread
unrelated to the changed-to inferior_ptid.  That was all (hopefully)
done in previous patches.

After this, inferior_ptid is mainly used by target backend code.  It
is also relied on by a number of target methods.  E.g., the
target_resume interface and the memory reading routines -- we still
need it there because we need to be able to access memory off of
processes for which we don't have a corresponding inferior/thread
object, like when handling forks.  Maybe we could pass down a context
explicitly to target_read_memory, etc.

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

	PR gdb/25412
	* gdbthread.h (delete_thread, delete_thread_silent)
	(find_thread_ptid): Update comments.
	* thread.c (current_thread_): New global.
	(is_current_thread): Move higher, and reimplement.
	(inferior_thread): Reimplement.
	(set_thread_exited): Use bool.  Add assertions.
	(add_thread_silent): Simplify thread-reuse handling by always
	calling delete_thread.
	(delete_thread): Remove intro comment.
	(find_thread_ptid): Skip exited threads.
	(switch_to_thread_no_regs): Write to current_thread_.
	(switch_to_no_thread): Check CURRENT_THREAD_ instead of
	INFERIOR_PTID.  Clear current_thread_.
2020-06-18 23:18:36 +01:00
Pedro Alves 6dbdab44e5 Don't write to inferior_ptid in aix-thread.c
There are other writes in the file, but they seem more harmless.  This
one is changing the current thread permanently.

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

	* aix-thread.c (pd_update): Use switch_to_thread.
2020-06-18 23:18:08 +01:00
Pedro Alves 2da4b788f7 Don't write to inferior_ptid in ravenscar-thread.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* ravenscar-thread.c (ravenscar_thread_target): Update.
	(ravenscar_thread_target::update_inferior_ptid): Rename to ...
	(ravenscar_thread_target::add_active_thread): ... this.  Don't
	set m_base_ptid here.  Update to avoid referencing inferior_ptid.
	(ravenscar_thread_target::wait): Don't write to inferior_ptid.
2020-06-18 23:17:31 +01:00
Pedro Alves 50838d1be7 Don't write to inferior_ptid in windows-nat.c, part II
Writing to inferior_ptid in
windows_nat_target::get_windows_debug_event is just incorrect and not
necessary.  We'll report the event to GDB's core, which then takes
care of switching inferior_ptid / current thread.

Related (see windows_nat_target::get_windows_debug_event), there's
also a "current_windows_thread" global that is just begging to get out
of sync with core GDB's current thread.  This patch removes it.
gdbserver already does not have an equivalent global in win32-low.cc.

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

	* nat/windows-nat.c (current_windows_thread): Remove.
	* nat/windows-nat.h (current_windows_thread): Remove.
	* windows-nat.c (windows_nat_target::stopped_by_sw_breakpoint):
	Adjust.
	(display_selectors): Adjust to fetch the current
	windows_thread_info based on inferior_ptid.
	(fake_create_process): No longer write to current_windows_thread.
	(windows_nat_target::get_windows_debug_event):
	Don't set inferior_ptid or current_windows_thread.
	(windows_nat_target::wait): Adjust to not rely on
	current_windows_thread.
	(do_initial_windows_stuff): Now a method of windows_nat_target.
	Switch to the last_ptid thread.
	(windows_nat_target::attach): Adjust.
	(windows_nat_target::detach): Use switch_to_no_thread instead of
	writing to inferior_ptid directly.
	(windows_nat_target::create_inferior): Adjust.
2020-06-18 23:17:01 +01:00
Pedro Alves 31ce04e9e0 Don't write to inferior_ptid in windows-nat.c, part I
The inferior_ptid hack in do_initial_win32_stuff, added back in 2008:

  https://sourceware.org/ml/gdb-patches/2008-10/msg00012.html

with:

  commit 9f9d052e60
  Author:     Pierre Muller <muller@sourceware.org>
  AuthorDate: Thu Oct 2 14:20:07 2008 +0000

	      * win32-nat.c (do_initial_win32_stuff): Set inferior_ptid.

is no longer needed.  Back then, current_inferior looked like this:

  struct inferior*
  current_inferior (void)
  {
    struct inferior *inf = find_inferior_pid (ptid_get_pid (inferior_ptid));
    gdb_assert (inf);
    return inf;
  }

Nowadays, current_inferior() just returns the global current_inferior_
pointer, which didn't exist back then.

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

	* windows-nat.c (do_initial_windows_stuff): No longer set inferior_ptid.
2020-06-18 23:16:25 +01:00
Pedro Alves 1ee1a36345 Don't write to inferior_ptid in go32-nat.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* go32-nat.c (go32_nat_target::create_inferior): Switch to thread
	after creating it, instead of writing to inferior_ptid.  Don't
	write to inferior_ptid.
2020-06-18 23:15:48 +01:00
Pedro Alves 6d350754a3 Don't write to inferior_ptid in fork-child.c
This is no longer necessary.  All targets that call fork_inferior now
also call switch_to_thread as soon as they add the main thread.

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

	* fork-child.c (postfork_hook): Don't write to inferior_ptid.
2020-06-18 23:15:16 +01:00
Pedro Alves 5d971d48b9 Don't write to inferior_ptid in bsd-kvm.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* bsd-kvm.c (bsd_kvm_target_open): Switch to thread after adding
	it, instead of writing to inferior_ptid.
2020-06-18 23:14:40 +01:00
Pedro Alves 86e57d1b23 Don't write to inferior_ptid in btrace_fetch
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* btrace.c (btrace_fetch): Use switch_to_thread instead of writing
	to inferior_ptid.
2020-06-18 23:14:15 +01:00
Pedro Alves f2e1c129f8 Don't write to inferior_ptid in bsd-kvm.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* bsd-kvm.c (bsd_kvm_target::close): Use switch_to_no_thread
	instead of writing to inferior_ptid directly.
2020-06-18 23:13:47 +01:00
Pedro Alves 60db1b8565 Don't write to inferior_ptid in corelow.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* corelow.c (core_target::close): Use switch_to_no_thread instead
	of writing to inferior_ptid directly.
	(add_to_thread_list, core_target_open): Use switch_to_thread
	instead of writing to inferior_ptid directly.
2020-06-18 23:12:43 +01:00
Pedro Alves fe7d6a8db0 Don't write to inferior_ptid in darwin-nat.c
Untested.

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

	* darwin-nat.c (darwin_nat_target::decode_message): Don't write to
	inferior_ptid.
	(darwin_nat_target::stop_inferior, darwin_nat_target::kill): Avoid
	inferior_ptid.
	(darwin_attach_pid): Use switch_to_no_thread instead of writing to
	inferior_ptid directly.
	(darwin_nat_target::init_thread_list): Switch to thread, instead
	of writing to inferior_ptid.
	(darwin_nat_target::attach): Don't write to inferior_ptid.
	(darwin_nat_target::get_ada_task_ptid): Avoid inferior_ptid.
2020-06-18 23:11:57 +01:00
Pedro Alves 975f8708de Don't write to inferior_ptid in gnu-nat.c
Untested.

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

	* gnu-nat.c (gnu_nat_target::create_inferior): Switch to the added
	thread.
	(gnu_nat_target::attach): Don't write to inferior_ptid directly.
	Instead use switch_to_thread.
	(gnu_nat_target::detach): Use switch_to_no_thread
	instead of writing to inferior_ptid directly.  Used passed-in
	inferior instead of looking up the inferior by pid.
2020-06-18 23:11:23 +01:00
Pedro Alves 1a20473059 Don't write to inferior_ptid in go32-nat.c
generic_mourn_inferior already takes care of switching to no thread.

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

	* go32-nat.c (go32_nat_target::create_inferior): Don't write to
	inferior_ptid.
2020-06-18 23:10:53 +01:00
Pedro Alves ebe84f23d2 Don't write to inferior_ptid in nto-procfs.c
A best effort patch, which fixes some bit rot and removes some
inferior_ptid references -- this port clearly hasn't been built in a
long while.

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

	* nto-procfs.c (nto_procfs_target::update_thread_list): Avoid
	inferior_ptid.
	(nto_procfs_target::attach): Avoid inferior_ptid.  Switch to
	thread.
	(nto_procfs_target::detach): Avoid referencing
	inferior_ptid.  Use switch_to_no_thread instead of writing to
	inferior_ptid directly.
	(nto_procfs_target::mourn_inferior): Use switch_to_no_thread
	instead of writing to inferior_ptid directly.
	(nto_procfs_target::create_inferior): Avoid inferior_ptid.  Switch
	to thread.
2020-06-18 23:10:09 +01:00
Pedro Alves 191f02e593 Don't write to inferior_ptid in remote-sim.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* remote-sim.c (gdbsim_target::create_inferior): Switch to thread
	after creating it, instead of writing to inferior_ptid.
	(gdbsim_target_open): Use switch_to_no_thread instead of writing
	to inferior_ptid directly.
	(gdbsim_target::wait): Don't write to inferior_ptid.
2020-06-18 23:09:05 +01:00
Pedro Alves 0ac553107c Don't write to inferior_ptid in remote.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* remote.c (remote_target::remote_notice_new_inferior): Use
	switch_to_thread instead of writing to inferior_ptid directly.
	(remote_target::add_current_inferior_and_thread): Use
	switch_to_no_thread instead of writing to inferior_ptid directly.
	(extended_remote_target::attach): Use switch_to_inferior_no_thread
	and switch_to_thread instead of using set_current_inferior or
	writing to inferior_ptid directly.
2020-06-18 23:08:14 +01:00
Pedro Alves 5233f39b8b Don't write to inferior_ptid in tracectf.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* tracectf.c (ctf_target_open): Switch to added thread instead of
	writing to inferior_ptid directly.
	(ctf_target::close): Use switch_to_no_thread instead of writing to
	inferior_ptid directly.
2020-06-18 23:07:35 +01:00
Pedro Alves 087e161b3c Don't write to inferior_ptid in tracefile-tfile.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* tracefile-tfile.c (tfile_target_open): Don't write to
	inferior_ptid directly, instead switch to added thread.
	(tfile_target::close): Use switch_to_no_thread instead of writing
	to inferior_ptid directly.
2020-06-18 23:06:57 +01:00
Pedro Alves 7fb43e53d5 Don't write to inferior_ptid in procfs.c
The inferior_ptid write in procfs_do_thread_registers should be
unnecessary because the target_fetch_registers method should (and
does) extract the ptid from the regcache.

Not tested.

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

	* procfs.c (procfs_target::attach): Don't write to inferior_ptid.
	(procfs_target::detach): Use switch_to_no_thread
	instead of writing to inferior_ptid directly.
	(do_attach): Change return type to void.  Switch to the added
	thread.
	(procfs_target::create_inferior): Switch to the added thread.
	(procfs_do_thread_registers): Don't write to inferior_ptid.
2020-06-18 23:06:03 +01:00
Pedro Alves 18493a005a Don't write to inferior_ptid in infrun.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* infrun.c (generic_mourn_inferior): Use switch_to_thread instead
	of writing to inferior_ptid.
	(scoped_restore_exited_inferior): Delete.
	(handle_vfork_child_exec_or_exit): Simplify using
	scoped_restore_current_pspace_and_thread.  Use switch_to_thread
	instead of writing to inferior_ptid.
	(THREAD_STOPPED_BY): Delete.
	(thread_stopped_by_watchpoint, thread_stopped_by_sw_breakpoint)
	(thread_stopped_by_hw_breakpoint): Delete.
	(save_waitstatus): Use
	scoped_restore_current_thread+switch_to_thread, and call
	target_stopped_by_watchpoint instead of
	thread_stopped_by_watchpoint, target_stopped_by_sw_breakpoint
	instead of thread_stopped_by_sw_breakpoint, and
	target_stopped_by_hw_breakpoint instead of
	thread_stopped_by_hw_breakpoint.
	(handle_inferior_event)
	<TARGET_WAITKIND_EXITED/TARGET_WAITKIND_SIGNALLED>: Don't write to
	inferior_ptid directly, nor
	set_current_inferior/set_current_program_space.  Use
	switch_to_thread / switch_to_inferior_no_thread instead.
2020-06-18 23:05:18 +01:00
Pedro Alves a0776b131d Don't write to inferior_ptid in target.c
gdb/ChangeLog:
2020-06-18  Pedro Alves  <palves@redhat.com>

	* target.c (generic_mourn_inferior): Use switch_to_no_thread
	instead of writing to inferior_ptid.
2020-06-18 23:04:50 +01:00