binutils-gdb.git
17 months agox86: re-work build_modrm_byte()'s register assignment
Jan Beulich [Mon, 20 Mar 2023 15:56:24 +0000 (16:56 +0100)]
x86: re-work build_modrm_byte()'s register assignment

The function has accumulated a number of special cases for no real
reason. Some were necessary because insn attributes (SwapSources in
particular) weren't suitably utilized instead. Note that the addition of
SwapSources actually increases consistency among the templates: Like
others which already have the attribute, these are all insns where the
VEX.VVVV-encoded register comes first (or last when looking at the SDM).

Note that the vexvvvv attribute now has merely boolean meaning anymore,
in line with the SDM long having dropped the NDS/NDD/DDS concept of
identifying encoding variants. The fallout will be taken care of
subsequently, though, to not further clutter the change here.

As to the TILEZERO special case: If more instructions like this
appeared, a new attribute would likely be the way to go. But as long as
it's only a single insn, going from the mnemonic is cheaper.

17 months agoChanged ld and gas BPF tests
Cupertino Miranda [Fri, 17 Mar 2023 15:29:36 +0000 (15:29 +0000)]
Changed ld and gas BPF tests

Recent BPF patch removed and renamed the list of relocations based on
the limitations of BPF instruction set.
This patch is a correction to the tests.

17 months agoReloc howto access broken for BPF
Cupertino Miranda [Fri, 17 Mar 2023 15:27:02 +0000 (15:27 +0000)]
Reloc howto access broken for BPF

Forgot to change the logic to access the reloc howto from
bpf_elf_relocate_section.
Problem was introduced in previous BPF commit.

17 months agoUse rust_demangle to fix a crash
Tom Tromey [Sun, 19 Mar 2023 15:13:10 +0000 (09:13 -0600)]
Use rust_demangle to fix a crash

PR rust/30211 points out a crash caused by a particular completion.
This turns out to happen because a Rust minsym winds up in a
C++-specific path in strncmp_iw_with_mode, which ultimately causes the
completer to pass invalid arguments to string::append.

This patch fixes the bug by reordering the language constants so that
Rust comes before C++, and then using rust_demangle.  This ensures
that minsyms are correctly marked as "Rust", avoiding this code and
thus the crash.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20367
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30211
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
17 months agoMake ui_out::do_progress_end 'private'
Tom Tromey [Thu, 16 Mar 2023 16:12:17 +0000 (10:12 -0600)]
Make ui_out::do_progress_end 'private'

I noticed that ui_out::do_progress_end is public, just to support one
use in debuginfod-support.c.  This patch makes it private, updates
progress_info to call it from its destructor, and finally changes
debuginfod-support.c to follow.

17 months agogdb: don't use the global thread-id in the saved breakpoints file
Andrew Burgess [Wed, 8 Feb 2023 13:56:22 +0000 (13:56 +0000)]
gdb: don't use the global thread-id in the saved breakpoints file

I noticed that breakpoint::print_recreate_thread was printing the
global thread-id.  This function is used to implement the 'save
breakpoints' command, and should be writing out suitable CLI commands
for recreating the current breakpoints.  The CLI does not use global
thread-ids, but instead uses the inferior specific thread-ids,
e.g. "2.1".

After some discussion on the mailing list it was suggested that the
most consistent solution would be for the saved breakpoints file to
always contain the inferior-qualified thread-id, so the file would
include "thread 1.1" instead of just "thread 1", even when there is
only a single inferior.

So, this commit adds print_full_thread_id, which is just like the
existing print_thread_id, only it always prints the inferior-qualified
thread-id.

I then update the existing print_thread_id to make use of this new
function, and finally, I update  breakpoint::print_recreate_thread to
also use this new function.

There's a multi-inferior test that confirms the saved breakpoints file
correctly includes the fully-qualified thread-id, and I've also
updated the single inferior test gdb.base/save-bp.exp to have it
validate that the saved breakpoints file includes the
inferior-qualified thread-id, even for this single inferior case.

17 months agoRevert "segfault at i386-dis.c:9815"
Alan Modra [Mon, 20 Mar 2023 10:26:57 +0000 (20:56 +1030)]
Revert "segfault at i386-dis.c:9815"

This reverts commit 92d450c79ad321e42f9a77692b5db10d0f7b9344.

Accessing these local var structs using a volatile qualified pointer
may indeed read the object, but I don't think changed values are
guaranteed to be written back to the object unless the actual object
is declared volatile.  That would probably slow down i386 disassembly
unacceptably.

17 months agolibctf: unused variable
Alan Modra [Mon, 20 Mar 2023 05:35:27 +0000 (16:05 +1030)]
libctf: unused variable

* ctf-archive.c (arc_mmap_writeout): Delete unused variable.

17 months agogprofng: Use prototype to call libc functions
Vladimir Mezentsev [Fri, 17 Mar 2023 00:19:23 +0000 (17:19 -0700)]
gprofng: Use prototype to call libc functions

libcollector may not link against libC.
We use dlsym() to get a function from libc.
In some files, pointers to these functions do not have prototypes.
I also moved the shared definitions to libcollector/collect.h.

gprofng/ChangeLog
2023-03-15  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

libcollector/collector.c: Add prototypes.
libcollector/dispatcher.c: Likewise.
libcollector/heaptrace.c: Likewise.
libcollector/iotrace.c: Likewise.
libcollector/linetrace.c: Likewise.
libcollector/mmaptrace.c: Likewise.
libcollector/synctrace.c: Likewise.
libcollector/collector.h: Add CALL_REAL(), NULL_PTR(), and DBG_LT.

17 months agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Mar 2023 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in

17 months agoDon't declare psymbol_functions::fill_psymbol_map
Tom Tromey [Sun, 19 Mar 2023 15:51:41 +0000 (09:51 -0600)]
Don't declare psymbol_functions::fill_psymbol_map

psymbol_functions::fill_psymbol_map was removed, but I forgot to
remove the declaration.  This patch removes it.  Tested by rebuilding.

17 months agosegfault at i386-dis.c:9815
Alan Modra [Fri, 17 Mar 2023 10:34:52 +0000 (21:04 +1030)]
segfault at i386-dis.c:9815

* i386-dis.c (print_insn): Access "ins" and "priv" via volatile
pointers after second sigsetjmp return.

17 months agoEnable vector register visibility in core file for AIX binutils
Aditya Vidyadhar Kamath [Mon, 13 Mar 2023 12:32:57 +0000 (07:32 -0500)]
Enable vector register visibility in core file for AIX binutils

This patch will enable vector register visibility when AIX FOLKS do
core file analysis.

17 months agoRegen ld/po/BLD-POTFILES.in
Alan Modra [Sat, 18 Mar 2023 07:11:05 +0000 (17:41 +1030)]
Regen ld/po/BLD-POTFILES.in

17 months agoXCOFF archive sanity check
Alan Modra [Sat, 18 Mar 2023 06:04:08 +0000 (16:34 +1030)]
XCOFF archive sanity check

XCOFF archive elements are in a linked list.  Add a little more sanity
checking.  This of course doesn't stop the fuzzers finding a way to
make a loop, but this check is cheap.

* coff-rs6000.c (_bfd_xcoff_openr_next_archived_file): Sanity
check that next element isn't pointing back to the header.

17 months agorewrite_elf_program_header and want_p_paddr_set_to_zero
Alan Modra [Sat, 18 Mar 2023 04:58:19 +0000 (15:28 +1030)]
rewrite_elf_program_header and want_p_paddr_set_to_zero

Layout in rewrite_elf_program_header is really done by lma, even if
program headers are going to have their p_paddr forced to zero.  Thus
when not matching against an existing segment, don't try to use a
"vma" from elf_segment_map.

* elf.c (is_contained_by): Replace "bed" param with "use_vaddr".
(IS_SECTION_IN_INPUT_SEGMENT): Adjust is_contained_by call.
(rewrite_elf_program_header): Always match against lma in
calls to is_contained_by using new maps.

17 months agoAnother sanity check for read_section_stabs_debugging_info
Alan Modra [Sat, 18 Mar 2023 02:05:15 +0000 (12:35 +1030)]
Another sanity check for read_section_stabs_debugging_info

* rddbg.c (read_section_stabs_debugging_info): Ignore invalid
stab sections with size less than 12 bytes.

17 months agoctf segfaults
Alan Modra [Fri, 17 Mar 2023 10:39:31 +0000 (21:09 +1030)]
ctf segfaults

PR 30228
PR 30229
* ctf-open.c (ctf_bufopen_internal): Check for NULL cts_data.
* ctf-archive.c (ctf_arc_bufpreamble, ctf_arc_bufopen): Likewise.

17 months agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Mar 2023 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

17 months agoRemove objfile_type
Tom Tromey [Sat, 11 Mar 2023 16:58:15 +0000 (09:58 -0700)]
Remove objfile_type

This removes objfile_type, in favor of always using the per-arch
builtins.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoAdd some types to struct builtin_type
Tom Tromey [Sat, 11 Mar 2023 16:51:23 +0000 (09:51 -0700)]
Add some types to struct builtin_type

This adds some types to struct builtin_type, ensuring it contains all
the types currently used by objfile_type.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoRename objfile_type to builtin_type
Tom Tromey [Sat, 11 Mar 2023 16:39:58 +0000 (09:39 -0700)]
Rename objfile_type to builtin_type

This renames objfile_type to be an overload of builtin_type, in
preparation for their unification.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUse builtin type when appropriate
Tom Tromey [Sat, 11 Mar 2023 16:37:15 +0000 (09:37 -0700)]
Use builtin type when appropriate

There are a few spots that check whether a type is objfile-owned, and
then choose either the objfile- or arch-specific builtin type.  I
don't think there is a need to do this any more (if there ever was),
because it is ok for an objfile-allocated type to refer to an
arch-allocated type.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUse type allocator for set types
Tom Tromey [Mon, 13 Mar 2023 19:25:41 +0000 (13:25 -0600)]
Use type allocator for set types

This changes the set type creation function to accept a type
allocator, and updates all the callers.  Note that symbol readers
should generally allocate on the relevant objfile, regardless of the
underlying type of the set, which is what this patch implements.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUse type allocator for array types
Tom Tromey [Mon, 13 Mar 2023 19:20:22 +0000 (13:20 -0600)]
Use type allocator for array types

This changes the array type creation functions to accept a type
allocator, and updates all the callers.  Note that symbol readers
should generally allocate on the relevant objfile, regardless of the
placement of the index type of the array, which is what this patch
implements.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUse type allocator for range types
Tom Tromey [Mon, 13 Mar 2023 18:53:48 +0000 (12:53 -0600)]
Use type allocator for range types

This changes the range type creation functions to accept a type
allocator, and updates all the callers.  Note that symbol readers
should generally allocate on the relevant objfile, regardless of the
underlying type of the range, which is what this patch implements.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUnify arch_pointer_type and init_pointer_type
Tom Tromey [Mon, 13 Mar 2023 18:25:27 +0000 (12:25 -0600)]
Unify arch_pointer_type and init_pointer_type

This unifies arch_pointer_type and init_pointer_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUnify arch_decfloat_type and init_decfloat_type
Tom Tromey [Mon, 13 Mar 2023 17:58:31 +0000 (11:58 -0600)]
Unify arch_decfloat_type and init_decfloat_type

This unifies arch_decfloat_type and init_decfloat_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUnify arch_float_type and init_float_type
Tom Tromey [Mon, 13 Mar 2023 17:30:08 +0000 (11:30 -0600)]
Unify arch_float_type and init_float_type

This unifies arch_float_type and init_float_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUnify arch_boolean_type and init_boolean_type
Tom Tromey [Mon, 13 Mar 2023 17:09:08 +0000 (11:09 -0600)]
Unify arch_boolean_type and init_boolean_type

This unifies arch_boolean_type and init_boolean_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUnify arch_character_type and init_character_type
Tom Tromey [Mon, 13 Mar 2023 16:57:56 +0000 (10:57 -0600)]
Unify arch_character_type and init_character_type

This unifies arch_character_type and init_character_type by using a
type allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoUnify arch_integer_type and init_integer_type
Tom Tromey [Mon, 13 Mar 2023 16:31:06 +0000 (10:31 -0600)]
Unify arch_integer_type and init_integer_type

This unifies arch_integer_type and init_integer_type by using a type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoRemove init_type
Tom Tromey [Mon, 13 Mar 2023 16:17:09 +0000 (10:17 -0600)]
Remove init_type

This removes init_type, replacing all uses with the new type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoRemove arch_type
Tom Tromey [Mon, 13 Mar 2023 15:53:35 +0000 (09:53 -0600)]
Remove arch_type

This removes arch_type, replacing all uses with the new type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoReuse existing builtin types
Tom Tromey [Mon, 13 Mar 2023 15:31:13 +0000 (09:31 -0600)]
Reuse existing builtin types

This changes a few spots to reuse the existing builting "void" type,
rather than construct a new one.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoRemove alloc_type
Tom Tromey [Mon, 13 Mar 2023 15:01:08 +0000 (09:01 -0600)]
Remove alloc_type

This removes alloc_type, replacing all uses with the new type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoRemove alloc_type_copy
Tom Tromey [Mon, 13 Mar 2023 14:59:34 +0000 (08:59 -0600)]
Remove alloc_type_copy

This removes alloc_type_copy, replacing all uses with the new type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoRemove alloc_type_arch
Tom Tromey [Mon, 13 Mar 2023 14:56:13 +0000 (08:56 -0600)]
Remove alloc_type_arch

This removes alloc_type_arch, replacing all uses with the new type
allocator.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months agoIntroduce type_allocator
Tom Tromey [Mon, 13 Mar 2023 14:51:34 +0000 (08:51 -0600)]
Introduce type_allocator

This introduces a new type_allocator class.  This class will be used
to abstract out the placement of new types, so that type-creation code
can be simplified and shared.

Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
17 months ago[gdb/testsuite] Handle unbuffer_output.c for remote host
Tom de Vries [Sat, 18 Mar 2023 16:50:56 +0000 (17:50 +0100)]
[gdb/testsuite] Handle unbuffer_output.c for remote host

Handle $srcdir/lib/unbuffer_output.c using lappend_include_file.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Handle my-syscalls.h for remote host
Tom de Vries [Sat, 18 Mar 2023 09:30:16 +0000 (10:30 +0100)]
[gdb/testsuite] Handle my-syscalls.h for remote host

Handle $srcdir/lib/my-syscalls.h using lappend_include_dir.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Handle attributes.h for remote host
Tom de Vries [Sat, 18 Mar 2023 09:16:30 +0000 (10:16 +0100)]
[gdb/testsuite] Handle attributes.h for remote host

Handle $srcdir/lib/attributes.h using lappend_include_dir.

Tested on x86_64-linux.

17 months agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Mar 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

17 months agoFix line table regression
Tom Tromey [Thu, 16 Mar 2023 20:41:31 +0000 (14:41 -0600)]
Fix line table regression

Simon pointed out a line table regression, and after a couple of false
starts, I was able to reproduce it by hand using his instructions.

The bug is that most of the code in do_mixed_source_and_assembly uses
unrelocated addresses, but one spot does:

  pc = low;

... after the text offset has been removed.

This patch fixes the problem by introducing a new type to represent
unrelocated addresses in the line table.  This prevents this sort of
bug to some degree (it's still possible to manipulate a CORE_ADDR in a
bad way, this is unavoidable).

However, this did let the compiler flag a few spots in that function,
and now it's not possible to compare an unrelocated address from a
line table with an ordinary CORE_ADDR.

Regression tested on x86-64 Fedora 36, though note this setup never
reproduced the bug in the first place.  I also tested it by hand on
the disasm-optim test program.

17 months agoUpdate the NetBSD system call table to add eventfd(2) and timerfd(2).
Frederic Cambus [Fri, 17 Mar 2023 09:29:06 +0000 (10:29 +0100)]
Update the NetBSD system call table to add eventfd(2) and timerfd(2).

Generated from sys/sys/syscall.h revision 1.321.

17 months agogdb: introduce bp_loc_tracepoint
Simon Marchi [Fri, 25 Nov 2022 18:56:14 +0000 (13:56 -0500)]
gdb: introduce bp_loc_tracepoint

Since commit cb1e4e32c2d9 ("catch catch/throw/rethrow", breakpoint ->
catchpoint), this simple tracing scenario does not work:

    $ gdb/gdb -nx -q --data-directory=gdb/data-directory ./test
    Reading symbols from ./test...
    (gdb) tar rem :1234
    Remote debugging using :1234
    Reading symbols from /lib64/ld-linux-x86-64.so.2...
    (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
    0x00007ffff7fe5730 in ?? () from /lib64/ld-linux-x86-64.so.2
    (gdb) trace do_something
    Tracepoint 1 at 0x555555555144: file test.c, line 5.
    (gdb) tstart
    (gdb) continue
    Continuing.
    Target returns error code '01'.

The root cause is that the bp_location::nserted flag does not transfer
anymore from an old bp_location to the new matching one.  When a shared
library gets loaded, GDB computes new breakpoint locations for each
breakpoint in update_breakpoint_locations.  The new locations are in the
breakpoint::loc chain, while the old locations are still in the
bp_locations global vector.  Later, update_global_location_list is
called.  It tries to map old locations to new locations, and if
necessary transfer some properties, like the inserted flag.

Since commit cb1e4e32c2d9, the inserted flag isn't transferred for
locations of tracepoints.  This is because bl_address_is_meaningful used
to be implemented like this:

    static int
    breakpoint_address_is_meaningful (struct breakpoint *bpt)
    {
      enum bptype type = bpt->type;

      return (type != bp_watchpoint && type != bp_catchpoint);
    }

and was changed to this:

    static bool
    bl_address_is_meaningful (bp_location *loc)
    {
      return loc->loc_type != bp_loc_other;
    }

Because locations for tracepoints have the bp_loc_other type,
bl_address_is_meaningful started to return false for them, where it
returned true before.  This made update_global_location_list skip the
part where it calls swap_insertion.

I think this can be solved by introduced a new bp_loc_tracepoint
bp_loc_type.

I don't know if it's accurate, but my understanding is that bp_loc_type
describes roughly "how do we ask the target to insert that location".
bp_loc_software_breakpoint are inserted using
target_ops::insert_breakpoint_location.  bp_loc_hardware_breakpoint are
inserted using target_ops::insert_hw_breakpoint.
bp_loc_software_watchpoint and bp_loc_hardware_watchpoint are inserted
using target_ops::insert_watchpoint.  For all these, the address is
meaningful, as we ask the target to insert the point at a specific
address.  bp_loc_other is a catch-all for "the rest", in practice for
catchpoints that don't have a specific address (hence why
bl_address_is_meaningful returns false for them).  For instance,
inserting a signal catchpoint is done by asking the target to report
that specific signal.  GDB doesn't associate an address to that.

But tracepoints do have a meaningful address to thems, so they can't be
bp_loc_other, with that logic.  They also can't be
bp_loc_software_breakpoint, because we don't want GDB to insert
breakpoints for them (even though they might be implemented using
software breakpoints by the remote side).  So, the new bp_loc_tracepoint
type describes that the way to insert these locations is with
target_ops::download_tracepoint.  It makes bl_address_is_meaningful
return true for them.  And they'll be ignored by insert_bp_location and
GDB won't try to insert a memory breakpoint for them.

With this, I see a few instances of 'Target returns error code: 01'
disappearing from gdb.log, and the results of gdb.trace/*.exp improve a
little bit:

    -# of expected passes       3765
    +# of expected passes       3781
    -# of unexpected failures   518
    +# of unexpected failures   498

Things remain quite broken in that area though.

Change-Id: Ic40935c450410f4bfaba397c9ebc7faf97320dd3

17 months agoPowerPC: fix for gdb.reverse/finish-precsave.exp and gdb.reverse/finish-reverse.exp
Carl Love [Thu, 9 Mar 2023 21:10:18 +0000 (16:10 -0500)]
PowerPC: fix for gdb.reverse/finish-precsave.exp and gdb.reverse/finish-reverse.exp

PPC64 multiple entry points, a normal entry point and an alternate entry
point.  The alternate entry point is to setup the Table of Contents (TOC)
register before continuing at the normal entry point.  When the TOC is
already valid, the normal entry point is used, this is typically the case.
The alternate entry point is typically referred to as the global entry
point (GEP) in IBM.  The normal entry point is typically referred to as
the local entry point (LEP).

When GDB is executing the finish command in reverse, the function
finish_backward currently sets the break point at the alternate entry point.
This issue is if the function, when executing in the forward direction,
entered the function via the normal entry point, execution in the reverse
direction will never sees the break point at the alternate entry point.  In
this case, the reverse execution continues until the next break point is
encountered thus stopping at the wrong place.

This patch adds a new address to struct execution_control_state to hold the
address of the alternate entry point (GEP).  The finish_backwards function
is updated, if the stopping point is between the normal entry point (LEP)
and the end of the function, a breakpoint is set at the normal entry point.
If the stopping point is between the entry points, a breakpoint is set at
the alternate entry point.  This ensures that GDB will always stop at the
normal entry point.  If the function did enter via the alternate entry
point, GDB will detect that and continue to execute backwards in the
function until the alternate entry point is reached.

The patch fixes the behavior of the reverse-finish command on PowerPC to
match the behavior of the command on other platforms, specifically X86.
The patch does not change the behavior of the command on X86.

A new test is added to verify the reverse-finish command on PowerPC
correctly stops at the instruction where the function call is made.

The patch fixes 11 regression errors in test gdb.reverse/finish-precsave.exp
and 11 regression errors in test gdb.reverse/finish-reverse.exp.

The patch has been tested on Power 10 and X86 processor with no new
regression failures.

17 months agoMove step_until procedure
Carl Love [Wed, 1 Mar 2023 16:45:43 +0000 (11:45 -0500)]
Move step_until procedure

Procedure step_until from test gdb.reverse/step-indirect-call-thunk.exp
is moved to lib/gdb.exp and renamed repeat_cmd_until.  The existing procedure
gdb_step_until in lib/gdb.exp is simpler variant of the new repeat_cmd_until
procedure.  The existing procedure gdb_step_until is changed to just call
the new repeat_cmd_until procedure with the command set to "step" and an
optional CURRENT string.  The default CURRENT string is set to "\}" to work
with the existing uses of procedure gdb_step_until.

17 months ago[gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp
Tom de Vries [Fri, 17 Mar 2023 18:25:18 +0000 (19:25 +0100)]
[gdb/testsuite] Fix regexp in gdb.arch/ftrace-insn-reloc.exp

With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver I run into:
...
(gdb) info sharedlibrary^M
From To    Syms Read   Shared Object Library^M
$hex $hex  Yes         /lib64/ld-linux-x86-64.so.2^M
$hex $hex  Yes         /home/remote-host/libinproctrace.so^M
$hex $hex  Yes         /lib64/libm.so.6^M
$hex $hex  Yes         /lib64/libc.so.6^M
$hex $hex  Yes         /lib64/libdl.so.2^M
$hex $hex  Yes (*)     /usr/lib64/libstdc++.so.6^M
$hex $hex  Yes (*)     /lib64/libgcc_s.so.1^M
$hex $hex  Yes         /lib64/libpthread.so.0^M
(*): Shared library is missing debugging information.^M
(gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded
...
due to trying to match libinproctrace.so using the target path, while the
command lists it using the host path.

Fix this by making the regexp less strict.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Handle remote host in gdb_load_shlib
Tom de Vries [Fri, 17 Mar 2023 18:25:18 +0000 (19:25 +0100)]
[gdb/testsuite] Handle remote host in gdb_load_shlib

With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver I run into:
...
(gdb) tstart^M
Target returns error code '.In-process agent library not loaded in process.  \
  Fast and static trace points unavailable.'.^M
(gdb) FAIL: gdb.arch/ftrace-insn-reloc.exp: start trace experiment
...

Fix this by:
- handling remote host in gdb_load_shlib, and
- moving the gdb_load_shlib to after the clean_restart, such that the
  set solib-search-path can take effect.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host
Tom de Vries [Fri, 17 Mar 2023 18:25:18 +0000 (19:25 +0100)]
[gdb/testsuite] Fix gdb.arch/i386-biarch-core.exp for remote host

Fix test-case gdb.arch/i386-biarch-core.exp using gdb_download_remote host.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host
Tom de Vries [Fri, 17 Mar 2023 18:25:18 +0000 (19:25 +0100)]
[gdb/testsuite] Handle REMOTE_HOST_USERNAME in local-remote-host

Handle REMOTE_HOST_USERNAME in local-remote-host, similar to how that's done for
REMOTE_TARGET_USERNAME in remote-gdbserver-on-localhost.

This helps to keep the home dir clean.

Since the setup makes $build/gdb/testsuite on build unreadable for the remote
host, we run into permission problems for GDB and the data-directory, so fix
this (as was done for gdbserver in gdbserver-base.exp) using file normalize.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Set remotedir by default in some boards
Tom de Vries [Fri, 17 Mar 2023 15:06:39 +0000 (16:06 +0100)]
[gdb/testsuite] Set remotedir by default in some boards

When doing a gdb_simple_compile, and downloading the resulting exec $obj
to target the result $target_obj may be a relative file path, which may give
problems when trying to do:
...
remote_exec target $target_obj
...

Fix/workaround this on some target boards by setting remotedir by default, and
add a corresponding test in gdb.testsuite/board-sanity.exp.

This doesn't work for host/target board local-remote-host-native, so xfail this.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Fix have_avx for remote target
Tom de Vries [Fri, 17 Mar 2023 15:06:39 +0000 (16:06 +0100)]
[gdb/testsuite] Fix have_avx for remote target

In proc have_avx we compile some source into an exec, resulting in a file $obj
on build, and then attempt to execute it on target:
...
    set result [remote_exec target $obj]
...

Fix this by using gdb_remote_download target.

Likewise in a few other procs that use "remote_exec target".

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Handle precise-aligned-alloc.c for remote host
Tom de Vries [Fri, 17 Mar 2023 15:06:39 +0000 (16:06 +0100)]
[gdb/testsuite] Handle precise-aligned-alloc.c for remote host

With test-case gdb.arch/i386-sse.exp (and likewise gdb.arch/i386-avx.exp) and
host board local-remote-host-notty and target board native-gdbserver I run
into:
...
gdb compile failed, i386-sse.c:68:10: fatal error: \
  ../lib/precise-aligned-alloc.c: No such file or directory
 #include "../lib/precise-aligned-alloc.c"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

Fix this using '#include "precise-aligned-alloc.c"' and making that work with
non-remote and remote host.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Handle remote host in escape_for_host
Tom de Vries [Fri, 17 Mar 2023 12:29:13 +0000 (13:29 +0100)]
[gdb/testsuite] Handle remote host in escape_for_host

With test-case gdb.arch/ftrace-insn-reloc.exp and host board
local-remote-host-notty and target board native-gdbserver, I run into:
...
FAIL: gdb.arch/ftrace-insn-reloc.exp: IPA loaded
...
due to having:
...
$ readelf -d ftrace-insn-reloc | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: []
...
instead of:
...
$ readelf -d ftrace-insn-reloc | grep RUNPATH
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN]
...

Handle this in escape_for_host.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Add escape_for_host
Tom de Vries [Fri, 17 Mar 2023 12:29:13 +0000 (13:29 +0100)]
[gdb/testsuite] Add escape_for_host

In gdb_compile we have:
...
           lappend new_options "ldflags=-Wl,-rpath,\\\$ORIGIN"
...
and we could improve readability by using {} rather than "":
...
           lappend new_options {ldflags=-Wl,-rpath,\$ORIGIN}
...

But rather than manually adding escapes in a string, add a new proc
escape_for_host that care of this for us, allowing us to write:
...
           lappend new_options [escape_for_host {ldflags=-Wl,-rpath,$ORIGIN}]
...

Tested on x86_64-linux.

17 months agomach-o: out of memory in get_dynamic_reloc_upper_bound
Alan Modra [Fri, 17 Mar 2023 10:37:17 +0000 (21:07 +1030)]
mach-o: out of memory in get_dynamic_reloc_upper_bound

* mach-o.c (bfd_mach_o_canonicalize_dynamic_reloc): Move sanity
checks..
(bfd_mach_o_get_dynamic_reloc_upper_bound): ..to here.

17 months agoAnother source_sh
Alan Modra [Thu, 16 Mar 2023 07:05:05 +0000 (17:35 +1030)]
Another source_sh

* scripttempl/z80.sc: Use source_sh to source elf.sc.

17 months ago[gdb/testsuite] Declare ada unsupported for remote host
Tom de Vries [Fri, 17 Mar 2023 09:34:18 +0000 (10:34 +0100)]
[gdb/testsuite] Declare ada unsupported for remote host

Currently gdb_ada_compile doesn't support remote host.

Make this explicit in allow_ada_tests.

Tested on x86_64-linux.

17 months agogas: apply md_register_arithmetic also to unary '+'
Jan Beulich [Fri, 17 Mar 2023 09:07:05 +0000 (10:07 +0100)]
gas: apply md_register_arithmetic also to unary '+'

Even a unary '+' has to be considered arithmetic; at least on x86 in
Intel Syntax mode otherwise bogus insn operands may be accepted.
Convert this specific case to binary + (i.e. 0 + <register>). (An
implication is that md_operator(,1,) would need to deal with arch-
specific equivalents of unary '+' is a similar way, if such an arch-
specific variant would be specified in the first place.)

To avoid duplicating what make_expr_symbol() does to construct a
constant-zero expression, simply make its previously local variable a
file-scope static one. This way there's also no need to invoke
clean_up_expression().

17 months agogas: expose flag_macro_alternate globally
Jan Beulich [Fri, 17 Mar 2023 09:06:18 +0000 (10:06 +0100)]
gas: expose flag_macro_alternate globally

Yet again with the removal of gasp about 20 years ago this extra level
of indirection isn't necessary anymore either. Drop macro.c's local
variable and make as.c's global.

While doing the conversion, switch the variable to "bool".

17 months agogas: use flag_mri directly in macro processing
Jan Beulich [Fri, 17 Mar 2023 09:05:57 +0000 (10:05 +0100)]
gas: use flag_mri directly in macro processing

Again with the removal of gasp about 20 years ago the extra level of
indirection isn't necessary anymore. Drop macro.c's local variable and
use the global flag directly.

17 months agogas: isolate macro_strip_at to macro.c
Jan Beulich [Fri, 17 Mar 2023 09:05:32 +0000 (10:05 +0100)]
gas: isolate macro_strip_at to macro.c

This removes a leftover from i960 support; with that nothing is left
which would set macro_strip_at to non-zero, so the variable is converted
to a #define (retaining the logic in case a new user would appear) and
macro_init()'s respective parameter is dropped.

17 months agogas: drop function pointer parameter from macro_init()
Jan Beulich [Fri, 17 Mar 2023 09:05:05 +0000 (10:05 +0100)]
gas: drop function pointer parameter from macro_init()

With the removal of gasp (about 20 years ago) the need for this kind-
of-hook has disappeared. Go a step beyond merely moving the to be called
function: Inline its contents right at the sole call site.

17 months ago[gdb/testsuite] Fix filename in gdb.debuginfod/crc_mismatch.exp
Tom de Vries [Fri, 17 Mar 2023 09:01:07 +0000 (10:01 +0100)]
[gdb/testsuite] Fix filename in gdb.debuginfod/crc_mismatch.exp

After running test-case gdb.debuginfod/crc_mismatch.exp, I find a dir called '$':
...
$ ls $build/gdb/testsuite/
$      config.log     gdb.log  lib       outputs   site.exp
cache  config.status  gdb.sum  Makefile  site.bak  temp
...

Fix this by removing the stray '$' here:
...
set debugfile "$[standard_output_file ${testfile}.debug]"
...

Tested on x86_64-linux.

17 months agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Mar 2023 00:00:31 +0000 (00:00 +0000)]
Automatic date update in version.in

17 months agogdb/doc: extended documentation for inferior function calls
Andrew Burgess [Mon, 16 Jan 2023 17:38:10 +0000 (17:38 +0000)]
gdb/doc: extended documentation for inferior function calls

I noticed that the documentation for inferior function calls doesn't
say much about what happens if/when an inferior function call is
interrupted, i.e. it doesn't describe what the dummy frame looks like
on the stack, or how GDB behaves when the inferior is continued and
reaches the dummy frame.

This commit aims to add some of this missing information.

17 months agoFix build breakage in rs6000-aix-tdep.c
Tom Tromey [Thu, 16 Mar 2023 13:48:22 +0000 (07:48 -0600)]
Fix build breakage in rs6000-aix-tdep.c

A recent change to rs6000-aix-tdep.c broke the build.  This patch
fixes it by declaring a few target descriptions in ppc-tdep.h and then
not including the various features .c files in rs6000-aix-tdep.c.

17 months agogdb/testsuite: Add support for LoongArch in gdb.base/float.exp
Hui Li [Sat, 4 Mar 2023 00:45:28 +0000 (08:45 +0800)]
gdb/testsuite: Add support for LoongArch in gdb.base/float.exp

The test results on LoongArch as follows:

Without this patch:

```
$ make check-gdb TESTS="gdb.base/float.exp"
=== gdb Summary ===

 # of expected passes 2
 # of unexpected failures 1

```
With this patch:

```
$ make check-gdb TESTS="gdb.base/float.exp"
=== gdb Summary ===

 # of expected passes 3

```

Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Tom Tromey <tom@tromey.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
17 months agoRe: Add --enable-linker-version option
Christophe Lyon [Thu, 16 Mar 2023 13:03:40 +0000 (13:03 +0000)]
Re: Add --enable-linker-version option

The recently-added ld-version*.d tests expect
.*GNU ld \(GNU Binutils\) 2.*
in the .comment section.

However, when buidling --with-pkgversion=XXX, we get
GNU ld (XXX) 2.[...]
instead, leading to a spurious FAIL.

This small patch replaces "GNU Binutils" with ".*" instead.

I inspected other testcases to see if we already had similar
occurrences but I couldn't see any, so I hope this fix is OK for the
purpose?

Thanks,

Christophe

17 months agogdb/doc: spring clean the Python unwinders documentation
Andrew Burgess [Wed, 8 Mar 2023 15:26:32 +0000 (15:26 +0000)]
gdb/doc: spring clean the Python unwinders documentation

The documentation for the Python Unwinders API could do with some
improvement.  The 'Unwinder Skeleton Code' has an error: it says
'unwinders' when it should say 'unwinder' in one case.

Additionally, by placing the 'Unwinder Skeleton Code' before the
section 'Registering an Unwinder' we have skipping including the
registration line in the skeleton code.  But this is confusion for
users (I think) as the skeleton code is almost complete, except for
one missing line which the user has to figure out for themselves.  By
reordering the sections, it is now obvious that the registration
should be included in the skeleton code, and the example is therefore
almost complete.

Additionally, in the example skeleton code the way in which the
frame-id was being built (using the current stack point and program
counter is (a) not correct, and (b) counter to what is laid out in the
'Unwinder Input' section when describing building a frame-id.

I've removed the incorrect code and replaced it with more generic
comments indicating what needs to be done.  As the actual actions that
need to be performed are both architecture specific, and dependent on
the function being unwound, it's almost impossible to include more
exact code here, but I think what I'm proposing is less misleading
than what we had before.

I've also added more cross references.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
17 months agold/testsuite: disable ilp32 tests for aarch64-qnx
Clément Chigot [Thu, 27 Oct 2022 08:45:00 +0000 (10:45 +0200)]
ld/testsuite: disable ilp32 tests for aarch64-qnx

aarch64nto32 emulation isn't supported. The tests will then fall back
on aarch64elf32. It does work but some extra warnings are being
generated because the "-z relro" being added aarch64nto but ignored by
aarch64elf32 emulation.
Skip the tests to avoid any problems.

ld/ChangeLog:

        * testsuite/ld-aarch64/emit-relocs-112-overflow.d: Skip for
        aarch64nto.
        * testsuite/ld-aarch64/emit-relocs-112.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-113.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-114-overflow.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-114.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-115.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-116-overflow.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-116.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-117.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-118-overflow.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-118.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-119.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-22.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-23.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-28.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-86-overflow.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-86.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-87.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-88-overflow.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-88.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-89.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-90-overflow.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-90.d: Likewise.
        * testsuite/ld-aarch64/emit-relocs-92.d: Likewise.
        * testsuite/ld-aarch64/tls-desc-ie-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-all-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-gd-ie-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-gd-le-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-gdesc-le-2-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-gdesc-le-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-ie-le-2-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-ie-le-3-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-ie-le-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-ld-le-small-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-relax-ld-le-tiny-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-tiny-desc-ie-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-tiny-desc-le-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-tiny-gd-ie-ilp32.d: Likewise.
        * testsuite/ld-aarch64/tls-tiny-gd-le-ilp32.d: Likewise.

17 months agold/testsuite: add aarch64nto to ld-aarch64
Clément Chigot [Wed, 26 Oct 2022 15:03:40 +0000 (17:03 +0200)]
ld/testsuite: add aarch64nto to ld-aarch64

ld/ChangeLog:

        * testsuite/ld-aarch64/aarch64-elf.exp: Add support for
        aarch64nto.

17 months agold: add support of QNX stack arguments for aarch64nto
Clément Chigot [Mon, 28 Nov 2022 08:29:37 +0000 (09:29 +0100)]
ld: add support of QNX stack arguments for aarch64nto

QNX is handling the stack argument using a .note section. Generate it
according to ELF argument -zexecstack, -zstack-size and a new NTO
argument --lazy-stack. Another NTO argument --stack mimicking
-zstack-size is added in order to ensure compatibility with previously
made NTO linkers.
This requires a new emultempl nto.em which is applied above the default
${ARCH}elf.em.

ld/ChangeLog:

* emulparams/aarch64nto.sh: Move to nto.em.
* emultempl/nto.em: New file.
* testsuite/ld-aarch64/aarch64-nto.exp: New test.
* testsuite/ld-aarch64/nto-stack-note-1.d: New test.
* testsuite/ld-aarch64/nto-stack-note-2.d: New test.
* testsuite/ld-aarch64/start.s: New test.

17 months agoreadelf: add support for QNT_STACK note subsections
Clément Chigot [Fri, 18 Nov 2022 14:45:55 +0000 (15:45 +0100)]
readelf: add support for QNT_STACK note subsections

QNX provides some .note subsections. QNT_STACK is the one controling
the stack allocation.

bfd/ChangeLog:

* elf.c (BFD_QNT_CORE_INFO): Delete.
(BFD_QNT_CORE_STATUS): Likewise.
(BFD_QNT_CORE_GREG): Likewise.
(BFD_QNT_CORE_FPREG): Likewise.
(elfcore_grok_nto_note): Replace BFD_QNT_* by QNT_*.

binutils/ChangeLog:

* readelf.c (get_qnx_elfcore_note_type): New function.
(print_qnx_note): New function.
(process_note): Add support for QNX support.

include/ChangeLog:

* elf/common.h (QNT_DEBUG_FULLPATH): New define.
(QNT_DEBUG_RELOC): New define.
(QNT_STACK): New define.
(QNT_GENERATOR): New define.
(QNT_DEFAULT_LIB): New define.
(QNT_CORE_SYSINFO): New define.
(QNT_CORE_INFO): New define.
(QNT_CORE_STATUS): New define.
(QNT_CORE_GREG): New define.
(QNT_CORE_FPREG): New define.
(QNT_LINK_MAP): New define.

17 months agoconfigure: add new target aarch64-*-nto*
Clément Chigot [Fri, 18 Nov 2022 10:06:50 +0000 (11:06 +0100)]
configure: add new target aarch64-*-nto*

This target has its own ld emulation based on aarch64elf.em.

17 months agoBPF relocations review / refactoring
Cupertino Miranda [Thu, 16 Mar 2023 08:39:52 +0000 (08:39 +0000)]
BPF relocations review / refactoring

- Removed not needed relocations.
- Renamed relocations to match llvm and linux kernel.

Relocation changes:
  R_BPF_INSN_64  => R_BPF_64_64
  R_BPF_INSN_DISP32  => R_BPF_64_32
  R_BPF_DATA_32  => R_BPF_64_ABS32
  R_BPF_DATA_64  => R_BPF_64_ABS64

ChangeLog:

  * bfd/bpf-reloc.def: Created file with BPF_HOWTO macro entries.
  * bfd/reloc.c: Removed non needed relocations.
  * bfd/bfd-in2.h: regenerated.
  * bfd/libbfd.h: regenerated.
  * bfd/elf64-bpf.c: Changed relocations.
  * include/elf/bpf.h: Adapted relocation values/names.
  * gas/config/tc-bpf.c: Changed relocation mapping.

17 months agoRe: Add --enable-linker-verssion
Alan Modra [Thu, 16 Mar 2023 06:40:07 +0000 (17:10 +1030)]
Re: Add --enable-linker-verssion

Output sections without any input sections to initialise their flags
have their flags initialised by data statements to LOAD, ALLOC,
HAS_CONTENTS by default.  This is wrong for .comment.  Fix that by
making the script initialise the section type to INFO, one of the
noalloc section types.  That also allows the address of .comment to be
set to zero, as is usual for non-alloc sections.

Also, use source_sh for all of the sourced scripts to set up make
dependencies.

PR 30187
* scripttempl/misc-sections.sc: Set .comment address to zero
and type to INFO.
* scripttempl/ft32.sc: Fix breakages from last edit.
* scripttempl/arclinux.sc: Use source_sh to source DWARF.sc
and misc-sections.sc.
* scripttempl/avr.sc: Likewise.
* scripttempl/dlx.sc: Likewise.
* scripttempl/elf.sc: Likewise.
* scripttempl/elf32cr16.sc: Likewise.
* scripttempl/elf32crx.sc: Likewise.
* scripttempl/elf32msp430.sc: Likewise.
* scripttempl/elf64bpf.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Likewise.
* scripttempl/elfarcv2.sc: Likewise.
* scripttempl/elfd10v.sc: Likewise.
* scripttempl/elfd30v.sc: Likewise.
* scripttempl/elfm68hc11.sc: Likewise.
* scripttempl/elfm68hc12.sc: Likewise.
* scripttempl/elfm9s12z.sc: Likewise.
* scripttempl/elfmicroblaze.sc: Likewise.
* scripttempl/elfxgate.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/epiphany_4x4.sc: Likewise.
* scripttempl/i386beos.sc: Likewise.
* scripttempl/i386go32.sc: Likewise.
* scripttempl/ia64vms.sc: Likewise.
* scripttempl/ip2k.sc: Likewise.
* scripttempl/iq2000.sc: Likewise.
* scripttempl/mep.sc: Likewise.
* scripttempl/mmo.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/pru.sc: Likewise.
* scripttempl/v850.sc: Likewise.
* scripttempl/v850_rh850.sc: Likewise.
* scripttempl/visium.sc: Likewise.
* scripttempl/xstormy16.sc: Likewise.
* scripttempl/z80.sc: Likewise.
* testsuite/ld-scripts/ld-version-2.d: Don't skip ft32 or pru.

17 months agocpu/mem.opc whitespace tidy
Alan Modra [Thu, 16 Mar 2023 01:22:09 +0000 (11:52 +1030)]
cpu/mem.opc whitespace tidy

cpu/
* mep.opc: Whitespace and formatting.
opcodes/
* mep-asm.c: Regenerate.
* mep-dis.c: Regenerate.

17 months agoPR30217, dynamic relocations using local dynamic symbols
Alan Modra [Wed, 15 Mar 2023 07:37:44 +0000 (18:07 +1030)]
PR30217, dynamic relocations using local dynamic symbols

glibc's ld.so ignores local dynamic symbols.  It's been that way
forever.  We therefore can't use them on dynamic relocations.  Fixing
that problem uncovered another problem in sorting of dynamic relocs,
caused no doubt by copying make_iplt_section (where we don't want
reloc sorting by the generic gold function, we want iplt relocs last)
to make_lplt_section (where we do want sorting).

PR 30217
* powerpc.cc (branch_needs_plt_entry): New function.
(Target_powerpc::plt_off): Use it here..
(Target_powerpc::Scan::global): ..and here to correct PLT16 reloc
handling for forced-local global symbols.
(Output_data_plt_powerpc::add_entry): Rename "stash"
parameter "is_local".  Emit relative relocs for globals that
are forced local, and don't set_needs_dynsym_entry.
(Target_powerpc::make_lplt_section): Don't create a separate
reloc section, use rela_dyn.
(Target_powerpc::make_brlt_section): Likewise.

17 months agoRe: Sanity check read_section_stabs_debugging_info
Alan Modra [Tue, 14 Mar 2023 23:56:24 +0000 (10:26 +1030)]
Re: Sanity check read_section_stabs_debugging_info

* rddbg.c (read_section_stabs_debugging_info): Don't segfault on
zero size string section.

17 months agoAutomatic date update in version.in
GDB Administrator [Thu, 16 Mar 2023 00:00:51 +0000 (00:00 +0000)]
Automatic date update in version.in

17 months agoFix formatting in gdb/printing.py
Tom Tromey [Wed, 15 Mar 2023 19:14:14 +0000 (13:14 -0600)]
Fix formatting in gdb/printing.py

According to black 23, gdb/printing.py was mis-formatted.  This patch
fixes it.

17 months agoEnable vector register visibility in core for AIX.
Aditya Vidyadhar Kamath [Wed, 15 Mar 2023 03:48:40 +0000 (22:48 -0500)]
Enable vector register visibility in core for AIX.

This patch enables AIX folks to see vector register contents while they
analyse the core file.

17 months ago[gdb/testsuite] Fix re-used exec in gdb.arch/ftrace-insn-reloc.exp
Tom de Vries [Wed, 15 Mar 2023 15:38:03 +0000 (16:38 +0100)]
[gdb/testsuite] Fix re-used exec in gdb.arch/ftrace-insn-reloc.exp

In test-case gdb.arch/ftrace-insn-reloc.exp we generate two executables with
the same name, which is confusing and known to cause trouble.

Fix this by making the executable names unique.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Fix gdb.arch/amd64-stap-special-operands.exp for remote host
Tom de Vries [Wed, 15 Mar 2023 15:38:03 +0000 (16:38 +0100)]
[gdb/testsuite] Fix gdb.arch/amd64-stap-special-operands.exp for remote host

With test-case gdb.arch/amd64-stap-special-operands.exp and host board
local-remote-host-notty and target board native-gdbserver I run into:
...
(gdb) break -pstap three_arg^M
No probe matching objfile=`<any>', provider=`<any>', name=`three_arg'^M
Make breakpoint pending on future shared library load? (y or [n]) n^M
(gdb) FAIL: gdb.arch/amd64-stap-special-operands.exp: probe: three_arg: \
  gdb_breakpoint: set breakpoint at -pstap three_arg
...
due to compiling two executables with the same name, and when uploading the
second one from host to build, we run into:
...
Upload from 127.0.0.1 failed, \
  $outputs/gdb.arch/amd64-stap-special-operands/amd64-stap-special-operands: \
  Text file busy.
...

Fix this by making the executable names unique.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Fix gdb.arch/i386-pkru.exp for native-gdbserver
Tom de Vries [Wed, 15 Mar 2023 15:38:03 +0000 (16:38 +0100)]
[gdb/testsuite] Fix gdb.arch/i386-pkru.exp for native-gdbserver

With test-case gdb.arch/i386-pkru.exp and target board native-gdbserver we run
into:
...
FAIL: gdb.arch/i386-pkru.exp: variable after reading pkru
...

This looks similar to the the problem for which there's already an xfail, so
fix this by extending the xfail matching.

Tested on x86_64-linux.

Also tested on openSUSE Tumbleweed, where all tests in the test-case pass.

17 months ago[gdb/testsuite] Unset DEBUGINFOD_URLS on remote host
Tom de Vries [Wed, 15 Mar 2023 15:38:03 +0000 (16:38 +0100)]
[gdb/testsuite] Unset DEBUGINFOD_URLS on remote host

When running test-case gdb.arch/i386-pkru.exp with host board
local-remote-host-notty and target board native-gdbserver on openSUSE
Tumbleweed (with DEBUGINFOD_URLS set), I run into:
...
This GDB supports auto-downloading debuginfo from the following URLs:^M
  <https://debuginfod.opensuse.org/>^M
Enable debuginfod for this session? (y or [n]) ^CQuit^M
(gdb) FAIL: gdb.arch/i386-pkru.exp: runto: run to main
...

The problem is that the unsetenv for DEBUGINFOD_URLS in default_gdb_init:
...
    # If DEBUGINFOD_URLS is set, gdb will try to download sources and
    # debug info for f.i. system libraries.  Prevent this.
    unset -nocomplain ::env(DEBUGINFOD_URLS)
...
doesn't work on remote host.

Fix this by using "set debuginfod enabled off" for remote host.

Tested on x86_64-linux.

17 months ago[gdb/testsuite] Fix gdb.arch/amd64*.exp with local-remote-host-native.exp
Tom de Vries [Wed, 15 Mar 2023 15:38:03 +0000 (16:38 +0100)]
[gdb/testsuite] Fix gdb.arch/amd64*.exp with local-remote-host-native.exp

There's a number of gdb.arch/amd64*.exp test-cases that fail with host+target
board local-remote-host-native.exp because of using a .S file, generated from
a .c file.

If a test-case compiles the .S file when executing on remote host,
the .S file is already copied from build to host, such that it's available for
the compiler.

But that's not the case for the .c file, which is needed by gdb to show a
source line:
...
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, fn2 (y=y@entry=25, x=x@entry=6) at amd64-entry-value-inline.c:32^M
32      in gdb.arch/amd64-entry-value-inline.c^M
(gdb) FAIL: gdb.arch/amd64-entry-value-inline.exp: continue to breakpoint: \
  break-here
...

Fix this by using "gdb_remote_download host <.c file>".

Tested on x86_64-linux, with host+target board local-remote-host-native.

17 months agoAdd --enable-linker-version option to bfd linker to add an entry in the .comment...
Nick Clifton [Wed, 15 Mar 2023 14:27:21 +0000 (14:27 +0000)]
Add --enable-linker-version option to bfd linker to add an entry in the .comment section.

   PR 30187
  * NEWS: Mention the new feature. * ld.texi: Document the new feature. * ldgram.y: Handle LINKER_VERSION token. * ldlang.c (lang_add_version): New function. (enable_linker_version): New global variable. * ldlang.h (land_add_version): Prototype. (enable_linker_version): Export. * ldlex.h (OPTION_ENABLE_LINKER_VERSION): Define. (OPTION_DISABLE_LINKER_VERSION): Define. * ldlex.l (LINKER_VERSION): Add token. * lexsup.c (ld_options): Add --enable-linker-version and --disable-linker-version. (parse_args): Handle the new options. * scripttempl/arclinux.sc: Remove stabs and comment sections and replace with inclusion of misc-sections.sc * scripttempl/avr.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/ft32.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * testsuite/ld-scripts/script.exp: Run new tests. * scripttempl/misc-sections.sc: New file. * testsuite/ld-scripts/ld-version-2.d: New file. * testsuite/ld-scripts/ld-version.d: New file. * testsuite/ld-scripts/ld-version.t: New file.

17 months agoFix an illegal memory access when disassembling a corrupt MeP file.
Nick Clifton [Wed, 15 Mar 2023 13:06:23 +0000 (13:06 +0000)]
Fix an illegal memory access when disassembling a corrupt MeP file.

  PR 30231
  * mep.opc (mep_print_insn): Check for an out of range index.

17 months agoFix an illegal memory access when disassebling a corrupt ARM file.
Nick Clifton [Wed, 15 Mar 2023 11:44:56 +0000 (11:44 +0000)]
Fix an illegal memory access when disassebling a corrupt ARM file.

  PR 30230
  * arm-dis.c (get_sym_code_type): Check for non-ELF symbols.

17 months agoAutomatic date update in version.in
GDB Administrator [Wed, 15 Mar 2023 00:00:51 +0000 (00:00 +0000)]
Automatic date update in version.in

17 months agoImplement DAP variables, scopes, and evaluate requests
Tom Tromey [Mon, 13 Feb 2023 16:56:58 +0000 (09:56 -0700)]
Implement DAP variables, scopes, and evaluate requests

The DAP code already claimed to implement "scopes" and "evaluate", but
this wasn't done completely correctly.  This patch implements these
and also implements the "variables" request.

After this patch, variables and scopes correctly report their
sub-structure.  This also interfaces with the gdb pretty-printer API,
so the output of pretty-printers is available.

17 months agoHide the implementation of gdb_mpf
Tom Tromey [Thu, 23 Feb 2023 17:45:47 +0000 (10:45 -0700)]
Hide the implementation of gdb_mpf

This renames the data member of gdb_mpf and makes it private.  It also
adds a single new method to aid in this change.  Unlike the earlier
changes here, I did this one all together because gdb_mpf has very few
uses.

17 months agoRename gdb_mpq::val and make contents private
Tom Tromey [Thu, 23 Feb 2023 17:37:31 +0000 (10:37 -0700)]
Rename gdb_mpq::val and make contents private

This changes gdb_mpq to hide its data, and renames the data member
from 'val' to 'm_val', following gdb convention.

17 months agoAdd operators and methods to gdb_mpq
Tom Tromey [Thu, 23 Feb 2023 17:34:22 +0000 (10:34 -0700)]
Add operators and methods to gdb_mpq

This adds some operators and methods to gdb_mpq, in preparation for
making its implementation private.

This only adds the operators currently needed by gdb.  More could be
added as necessary.

17 months agoRename gdb_mpz::val and make contents private
Tom Tromey [Thu, 23 Feb 2023 17:05:58 +0000 (10:05 -0700)]
Rename gdb_mpz::val and make contents private

This changes gdb_mpz to hide its data, and renames the data member
from 'val' to 'm_val', following gdb convention.

17 months agoAdd methods and operators to gdb_mpz
Tom Tromey [Thu, 23 Feb 2023 14:30:26 +0000 (07:30 -0700)]
Add methods and operators to gdb_mpz

This adds various methods and operators to gdb_mpz, as a step toward
hiding the implementation.

This only adds the operators that were needed.  Many more could be
added as required.