]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
12 months agogold: Properly remove the versioned symbol
H.J. Lu [Sat, 1 Jun 2024 04:30:34 +0000 (21:30 -0700)] 
gold: Properly remove the versioned symbol

When the versioned symbol foo is removed from the shared library,  the
".symver foo,foo@VER" directive provides binary compatibility for foo@VER.
In this case, the unversioned symbol foo should be hidden and shouldn't
generate a multiple definition error.

PR gold/31830
* resolve.cc (Symbol_table::resolve): Move symbol version handling
to ...
* symtab.cc (Symbol_table::add_from_object): Here. If the hidden
version from .symver is the same as the default version from the
unversioned symbol, don't make the unversioned symbol the default
versioned
symbol.
* testsuite/Makefile.am (check_SCRIPTS): Add ver_test_pr31830.sh.
(check_DATA): ver_test_pr31830_a.syms and ver_test_pr31830_b.syms.
(ver_test_pr31830_a.syms): New.
(ver_test_pr31830_b.syms): Likewise.
(ver_test_pr31830_a.so): Likewise.
(ver_test_pr31830_b.so): Likewise.
* testsuite/Makefile.in: Regenerated.
* testsuite/ver_test_pr31830.script: New file.
* testsuite/ver_test_pr31830.sh: Likewise.
* testsuite/ver_test_pr31830_a.c: Likewise.
* testsuite/ver_test_pr31830_b.c: Likewise.
* testsuite/ver_test_pr31830_lto.c: Likewise.
* testsuite/ver_test_pr31830_lto.sh: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Sun, 9 Jun 2024 00:00:35 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoFix typo in warning in gdb/configure
Tom Tromey [Sat, 8 Jun 2024 14:30:03 +0000 (08:30 -0600)] 
Fix typo in warning in gdb/configure

Eli pointed out that "babeltrace" is misspelled in a warning in
gdb/configure.  This patch fixes the typo.

12 months agogdb: Avoid compilation warning in gcore.c.
Eli Zaretskii [Sat, 8 Jun 2024 07:22:03 +0000 (10:22 +0300)] 
gdb: Avoid compilation warning in gcore.c.

See https://sourceware.org/pipermail/gdb-patches/2024-June/209726.html
for the details.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb: remove get_exec_file
Simon Marchi [Thu, 30 May 2024 18:53:56 +0000 (14:53 -0400)] 
gdb: remove get_exec_file

I believe that the get_exec_file function is unnecessary, and the code
can be simplified if we remove it.

Consider for instance when you "run" a program on Linux with native
debugging.

 1. run_command_1 obtains the executable file from
    `current_program_space->exec_filename ()`
 2. it passes it to `run_target->create_inferior()`, which is
    `inf_ptrace_target::create_inferior()` in this case, which then
    passes it to `fork_inferior()`
 3. `fork_inferior()` then has a fallback, where if the passed exec file
    is nullptr, it gets its from `get_exec_file()`.
 4. `get_exec_file()` returns `current_program_space->exec_filename ()`
    - just like the things we started with - or errors out if the
    current program space doesn't have a specified executable.

If there's no exec filename passed in step 1, there's not going to be
any in step 4, so it seems pointless to call `get_exec_file()`, we could
just error out when `exec_file` is nullptr.  But we can't error out
directly in `fork_inferior()`, since the error is GDB-specific, and that
function is shared with GDBserver.

Speaking of GDBserver, all code paths that lead to `fork_inferior()`
provide a non-nullptr exec file.

Therefore, to simplify things:

 - Make `fork_inferior()` assume that the passed exec file is not
   nullptr, don't call `get_exec_file()`
 - Change some targets (darwin-nat, go32-nat, gnu-nat, inf-ptrace,
   nto-procfs, procfs) to error out when the exec file passed to their
   create_inferior method is nullptr.  Some targets are fine with a
   nullptr exec file, so we can't check that in `run_command_1()`.
 - Add the `no_executable_specified_error()` function, which re-uses the
   error message that `get_exec_file()` had.
 - Change some targets (go32-nat, nto-procfs) to not call
   `get_exec_file()`, since it's pointless for the same reason as in the
   example above, if it returns, it's going the be the same value as the
   `exec_file` parameter.  Just rely on `exec_file`.
 - Remove the final use of `get_exec_file()`, in `load_command()`.
 - Remove the `get_exec_file()` implementations in GDB and GDBserver and
   remove the shared declaration.

Change-Id: I601c16498e455f7baa1f111a179da2f6c913baa3
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb: remove dead code in nto-procfs.c
Simon Marchi [Thu, 30 May 2024 18:53:55 +0000 (14:53 -0400)] 
gdb: remove dead code in nto-procfs.c

`get_exec_file()` never returns nullptr, so remove some dead code that
check for a nullptr return.

Change-Id: I9eff2a013d602588aaf4477a22cf45f2bc417c6a
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb: replace `get_exec_file (0)` calls with `current_program_space->exec_filename ()`
Simon Marchi [Thu, 30 May 2024 18:53:54 +0000 (14:53 -0400)] 
gdb: replace `get_exec_file (0)` calls with `current_program_space->exec_filename ()`

Calls of `get_exec_file (0)` are equivalent to just getting the exec
filename from the current program space.  I'm looking to remove
`get_exec_file`, so replace these uses with
`current_program_space->exec_filename ()`.

Remove the `err` parameter of `get_exec_wrapper` since all the calls
that remain pass 1, meaning to error out if no executable is specified.

Change-Id: I7729ea4c7f03dbb046211cc5aa3858ab3a551965
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb: make progspace::exec_filename private, add getter / setter
Simon Marchi [Thu, 30 May 2024 18:53:53 +0000 (14:53 -0400)] 
gdb: make progspace::exec_filename private, add getter / setter

Just like the title says... I think this makes things a bit clearer, for
instance where the exec filename is set.  It also makes the read call
sites a bit nicer, avoiding the `.get ()`.

Change-Id: If8b58ae8f6270c8a34b868f6ca06128c6671ea3c
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/tui: cleanup includes
Simon Marchi [Fri, 31 May 2024 02:54:07 +0000 (22:54 -0400)] 
gdb/tui: cleanup includes

Remove includes reported as unused by clangd.  Then, add any includes
necessary to get rid of errors (includes possibly relying on previous
includes)..

I didn't remove the includes of gdb-safe-ctypes.h, because it appears to
do some some preprocessor magic, redefining standard macros.  I'm afraid
that removing these includes could change the behavior unintentionally.

Change-Id: I4c5b652355c3bbce022fe0d447a72dc4e1d17d34
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb: add IWYU export pragams to gdb_curses.h
Simon Marchi [Fri, 31 May 2024 02:54:06 +0000 (22:54 -0400)] 
gdb: add IWYU export pragams to gdb_curses.h

It seems like gdb_curses.h is included whenever we want to access
ncurses functionality, instead of including directly ncurses.h.  As a
result, clangd often erroneously shows that gdb_curses.h inclusions are
unused.

By adding those pragmas, clangd (and the include-what-you-use tool)
understands that gdb_curses.h is a valid provider for whatever these
ncurses.h files provide.

Change-Id: Ia8acd761dae1577f7151d5fb558f35514b4e4ea2
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb/tui: change some macros to functions
Simon Marchi [Fri, 31 May 2024 02:54:05 +0000 (22:54 -0400)] 
gdb/tui: change some macros to functions

Change the `TUI_*` macros to access known windows to functions.  Define
them in their respective files, because trying to define them in
tui-data.h would end up causing include cycles.

This makes static analysis (detection of unused include files in this
case) more accurate, and I think in general we should avoid hiding
code behind macros if not necessary.

Change-Id: I1e38cee843984c48ab34030b19dac0d726f851af
Approved-By: Tom Tromey <tom@tromey.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Jun 2024 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp
Thiago Jung Bauermann [Thu, 4 Apr 2024 17:05:47 +0000 (14:05 -0300)] 
gdb/testsuite: Add gdb.arch/aarch64-mops-watchpoint.exp

Test behaviour of watchpoints triggered by MOPS instructions.  This test
is similar to gdb.base/memops-watchpoint.exp, but specifically for MOPS
instructions rather than whatever instructions are used in the libc's
implementation of memset/memcpy/memmove.

There's a separate watched variable for each set of instructions so that
the testcase can test whether GDB correctly identified the watchpoint
that triggered in each case.

Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>
12 months agogdb/aarch64: Add record support for MOPS instructions.
Thiago Jung Bauermann [Sun, 21 Apr 2024 02:18:26 +0000 (23:18 -0300)] 
gdb/aarch64: Add record support for MOPS instructions.

There are two kinds of MOPS instructions: set instructions and copy
instructions.  Within each group there are variants with minor
differences in how they read or write to memory — e.g., non-temporal
read and/or write, unprivileged read and/or write and permutations of
those — but they work in the same way in terms of the registers and
regions of memory that they modify.

The new gdb.reverse/aarch64-mops.exp testcase verifies that MOPS
instructions are recorded and correctly reversed.  Not all variants of the
copy and set instructions are tested, since there are many and the record
and replay target processes them in the same way.

PR tdep/31666
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666
Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>
12 months agogdb/aarch64: Disable displaced single-step for MOPS instructions
Thiago Jung Bauermann [Sat, 27 Apr 2024 21:38:22 +0000 (18:38 -0300)] 
gdb/aarch64: Disable displaced single-step for MOPS instructions

The AArch64 MOPS (Memory Operation) instructions provide a standardised
instruction sequence to perform a memset, memcpy or memmove.  A sequence is
always composed of three instructions: a prologue instruction, a main
instruction and an epilogue instruction.  As an illustration, here are the
implementations of these memory operations in glibc 2.39:

  (gdb) disassemble/r
  Dump of assembler code for function __memset_mops:
  => 0x0000fffff7e8d780 <+0>:     d503201f        nop
     0x0000fffff7e8d784 <+4>:     aa0003e3        mov     x3, x0
     0x0000fffff7e8d788 <+8>:     19c10443        setp    [x3]!, x2!, x1
     0x0000fffff7e8d78c <+12>:    19c14443        setm    [x3]!, x2!, x1
     0x0000fffff7e8d790 <+16>:    19c18443        sete    [x3]!, x2!, x1
     0x0000fffff7e8d794 <+20>:    d65f03c0        ret
  End of assembler dump.

  (gdb) disassemble/r
  Dump of assembler code for function __memcpy_mops:
  => 0x0000fffff7e8c580 <+0>:     d503201f        nop
     0x0000fffff7e8c584 <+4>:     aa0003e3        mov     x3, x0
     0x0000fffff7e8c588 <+8>:     19010443        cpyfp   [x3]!, [x1]!, x2!
     0x0000fffff7e8c58c <+12>:    19410443        cpyfm   [x3]!, [x1]!, x2!
     0x0000fffff7e8c590 <+16>:    19810443        cpyfe   [x3]!, [x1]!, x2!
     0x0000fffff7e8c594 <+20>:    d65f03c0        ret
  End of assembler dump.

  (gdb) disassemble/r
  Dump of assembler code for function __memmove_mops:
  => 0x0000fffff7e8d180 <+0>:     d503201f        nop
     0x0000fffff7e8d184 <+4>:     aa0003e3        mov     x3, x0
     0x0000fffff7e8d188 <+8>:     1d010443        cpyp    [x3]!, [x1]!, x2!
     0x0000fffff7e8d18c <+12>:    1d410443        cpym    [x3]!, [x1]!, x2!
     0x0000fffff7e8d190 <+16>:    1d810443        cpye    [x3]!, [x1]!, x2!
     0x0000fffff7e8d194 <+20>:    d65f03c0        ret
  End of assembler dump.

The Arm Architecture Reference Manual says that "the prologue, main, and
epilogue instructions are expected to be run in succession and to appear
consecutively in memory".  Therefore this patch disables displaced stepping
on them.

The testcase verifies that MOPS sequences are correctly single-stepped.

PR tdep/31666
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31666
Approved-By: Luis Machado <luis.machado@arm.com>
Tested-By: Luis Machado <luis.machado@arm.com>
12 months ago[gdb/tdep] Fix ARM_LINUX_JB_PC_EABI
Tom de Vries [Fri, 7 Jun 2024 11:59:46 +0000 (13:59 +0200)] 
[gdb/tdep] Fix ARM_LINUX_JB_PC_EABI

In arm-linux-tdep.c, ARM_LINUX_JB_PC_EABI is defined as 9, but it's been 1
since glibc 2.20.

See glibc commit 80a56cc3ee ("ARM: Add SystemTap probes to longjmp and
setjmp.").

Update it, allowing us to run into the gdb/26967 kfail.

Tested on arm-linux.

Approved-By: Luis Machado <luis.machado@arm.com>
PR arm/tdep
Bug: https://www.sourceware.org/bugzilla/show_bug.cgi?id=31089

12 months agoRe: Yet another ecoff fuzzed object fix
Alan Modra [Thu, 6 Jun 2024 22:57:31 +0000 (08:27 +0930)] 
Re: Yet another ecoff fuzzed object fix

In commit 6fc018e9e593 I replaced the fdr_ptr csym check against the
header isymMax count with a check against bfd symcount.  In fact, both
checks are needed.  The isymMax check sanity checks accesses against
the external sym array, the symcount one against the internal array.

* ecoff.c (_bfd_ecoff_slurp_symbol_table): Reinstate fdr_ptr
csym check against isymMax.

12 months agoaarch64: Test DT_RELR with discarded sections
Szabolcs Nagy [Tue, 4 Jun 2024 08:23:41 +0000 (09:23 +0100)] 
aarch64: Test DT_RELR with discarded sections

12 months agoaarch64: Fix DT_RELR support with discarded sections
Szabolcs Nagy [Mon, 3 Jun 2024 16:20:32 +0000 (17:20 +0100)] 
aarch64: Fix DT_RELR support with discarded sections

In case of discarded sections, via /DISCARD/ or .gnu.linkonce,
relr relocation accounting was wrong.  This broke building linux.

The issue was that the *_relocate_section logic was copied to
record_relr_non_got_relocs to find the relative relocs that can
be packed, however *_relocate_section is not called on sections
that are discarded, while record_relr_non_got_relocs is called
for all input sections. The fix is to filter out the discarded
sections with the same logic that is used to count non-GOT
relocs in *_late_size_sections for local symbols earlier.
Use the discarded_section helper in both cases to clarify the
intent and handle all corner-cases consistently.

GOT relocations are affected too if all sections are discarded
that reference the GOT entry of a particular symbol, however
this can cause unused GOT entries independently of DT_RELR, and
the only difference with DT_RELR is that a relative reloc may be
emitted instead of a R_AARCH64_NONE for the unused GOT entry
which is acceptable. A proper fix would require redoing the GOT
refcounting after we know the discarded sections, see bug 31850.

12 months ago[gdb/testsuite] Fix gdb.fortran/array-bounds.exp on arm
Tom de Vries [Fri, 7 Jun 2024 06:12:34 +0000 (08:12 +0200)] 
[gdb/testsuite] Fix gdb.fortran/array-bounds.exp on arm

When running test-case gdb.fortran/array-bounds.exp on arm-linux, we run into:
...
(gdb) print &foo^M
$1 = (PTR TO -> ( real(kind=4) (0:1) )) 0xfffef008^M
(gdb) FAIL: gdb.fortran/array-bounds.exp: print &foo
print &bar^M
$2 = (PTR TO -> ( real(kind=4) (-1:0) )) 0xfffef010^M
(gdb) FAIL: gdb.fortran/array-bounds.exp: print &bar
...

This is due to gcc PR debug/54934.

The test-case contains a kfail for this, which is only activated for
x86_64/i386.

Fix this by enabling the kfail for all ilp32 targets.

Also:
- change the kfail into an xfail, because gdb is not at fault here, and
- limit the xfail to the gfortran compiler.

Tested on arm-linux.

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Jun 2024 00:00:43 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb/doc: use POD2MAN5 when appropriate
Andrew Burgess [Thu, 6 Jun 2024 16:55:54 +0000 (17:55 +0100)] 
gdb/doc: use POD2MAN5 when appropriate

In commit:

  commit 824083f34c222aa7419e2ea58e82d6f230d5f531
  Date:   Fri Apr 12 17:47:20 2024 +0100

      gdb/doc: use silent-rules.mk in the Makefile

I rewrote the rules for building the man pages.  While doing this I
accidentally switched from using MAN2POD5 to MAN2POD1 for generating
the file gdbinit.5.

Restore use of MAN2POD5 where appropriate.

12 months agoDAP: Handle "stepOut" request in outermost frame
Johan Sternerup [Sat, 1 Jun 2024 16:16:32 +0000 (18:16 +0200)] 
DAP: Handle "stepOut" request in outermost frame

Previously a "stepOut" request when in the outermost frame would result
in a sucessful response even though gdb internally would reject the
associated "finish" request, which means no stoppedEvent would ever be
sent back to the client. Thus the client would believe the inferior was
still running and as a consequence reject subsequent "next" and "stepIn"
requests from the user.

The solution is to execute the underlying finish command as a background
command, i.e. `finish &`. If we're in the outermost frame an exception
will be raised immediately, which we can now capture and report back to
the client as success=False so then the absence of a `stopped` event is
no longer a problem.

We also make use of the `defer_stop_event` option to prevent a stop
event from reaching the client until the response has been sent.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoDAP: Allow gdb exception in exec_and_log to propagate
Johan Sternerup [Sat, 1 Jun 2024 16:16:31 +0000 (18:16 +0200)] 
DAP: Allow gdb exception in exec_and_log to propagate

This allows a request to specify that any gdb exception raised in
exec_and_log within the gdb thread to be propagated back to the DAP
thread (using the Canceller object as the orchestrator).

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoDAP: Allow for deferring stop events from gdb thread
Johan Sternerup [Sat, 1 Jun 2024 16:16:30 +0000 (18:16 +0200)] 
DAP: Allow for deferring stop events from gdb thread

The existing `send_event_later()` method allows commands processed on
the DAP thread to queue an event for execution until after the response
has been sent to the client.

We now introduce a corresponding method for use by the gdb thread. This
method `send_event_maybe_later()` will queue the event just like
`send_event_later()`, but only if it has been configured to do so by a
new @request option `defer_stop_events`. As the name implies the
functionality is currently only used for handling stop events.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoarm: fix testsuite fallout on arm-elf and arm-nto from FPA removal
Richard Earnshaw [Thu, 6 Jun 2024 14:55:16 +0000 (15:55 +0100)] 
arm: fix testsuite fallout on arm-elf and arm-nto from FPA removal

Removing FPA means that in some cases we default to 'no-fpu' in the
assembler when previously we would have picked FPA-format floating
numbers.  This patch fixes the testsuite fallout on a couple of
targets that are affected by this change.  Where possible we do this
by adding an option to set the floating-point format, but for bad-bss
we just skip the test.

12 months agoUpdated Spanish translation for the bfd/ directory
Nick Clifton [Thu, 6 Jun 2024 11:10:29 +0000 (12:10 +0100)] 
Updated Spanish translation for the bfd/ directory

12 months agoopcodes/riscv: prevent future use of disassemble_info::fprintf_func
Andrew Burgess [Wed, 5 Jun 2024 12:12:42 +0000 (13:12 +0100)] 
opcodes/riscv: prevent future use of disassemble_info::fprintf_func

The previous commit removed a use of disassemble_info::fprintf_func
which had been added to the RISC-V disassembler after the disassembler
had been switched to use ::fprintf_styled_func, for styled output.

To prevent future mistakes, I propose adding a #define to rename
fprintf_func to something which does not exist.  If this had been in
place then the before the previous commit libopcodes would have failed
to compile, like this:

  ../../src/opcodes/riscv-dis.c: In function ‘print_reg_list’:
  ../../src/opcodes/riscv-dis.c:229:7: error: ‘disassemble_info’ {aka ‘struct disassemble_info’} has no member named ‘please_use_fprintf_styled_func_instead’
    229 |   info->fprintf_func (info->stream, "%s", riscv_gpr_names[X_RA]);
        |       ^~

If this commit is accepted then I'll follow up with another commit
that adds the same #define to every disassembler that has been
converted to use styled output.

As the RISC-V disassembler is now fully styled, this commit should
make no difference at all.

12 months agoopcodes/riscv: add styling support to print_reg_list
Andrew Burgess [Wed, 5 Jun 2024 11:57:55 +0000 (12:57 +0100)] 
opcodes/riscv: add styling support to print_reg_list

I noticed that some unstyled output had crept into the risc-v
disassembler in this commit:

  commit 9132c8152b899a1683bc886f8ba76bedadb48aa1
  Date:   Tue Feb 27 11:48:11 2024 +0800

      RISC-V: Support Zcmp push/pop instructions.

this commit adds styling support.  The risc-v disassembler is now once
again, fully styled.

12 months agoRISC-V: Add support for Zvfbfwma extension
Xiao Zeng [Thu, 6 Jun 2024 07:59:53 +0000 (15:59 +0800)] 
RISC-V: Add support for Zvfbfwma extension

This implements the Zvfbfwma extension, as of version 1.0.
View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/bfloat16.adoc#zvfbfwma---vector-bf16-widening-mul-add>

1 In spec: "Zvfbfwma requires the Zvfbfmin extension and the Zfbfmin extension."
  1.1 In Embedded    Processor: Zvfbfwma -> Zvfbfmin -> Zve32f
  1.2 In Application Processor: Zvfbfwma -> Zvfbfmin -> V
  1.3 In both scenarios, there are: Zvfbfwma -> Zfbfmin

2 Depending on different usage scenarios, the Zvfbfwma extension may
depend on 'V' or 'Zve32f'. This patch only implements dependencies in
scenario of Embedded Processor. This is consistent with the processing
strategy in Zvfbfmin. In scenario of Application Processor, it is
necessary to explicitly indicate the dependent 'V' extension.

For relevant information in gcc, please refer to:
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=38dd4e26e07c6be7cf4d169141ee4f3a03f3a09d>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zvfbfwma.
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Updated.
* testsuite/gas/riscv/march-help.l: Ditto.
* testsuite/gas/riscv/zvfbfwma.d: New test.
* testsuite/gas/riscv/zvfbfwma.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_VFWMACCBF16_VF): Define.
(MASK_VFWMACCBF16_VF): Ditto.
(MATCH_VFWMACCBF16_VV): Ditto.
(MASK_VFWMACCBF16_VV): Ditto.
(DECLARE_INSN): New declarations for Zvfbfwma.
* opcode/riscv.h (enum riscv_insn_class): Add
INSN_CLASS_ZVFBFWMA

opcodes/ChangeLog:

* riscv-opc.c: Add Zvfbfwma instructions.

12 months agoRISC-V: Add support for Zvfbfmin extension
Xiao Zeng [Thu, 6 Jun 2024 07:59:52 +0000 (15:59 +0800)] 
RISC-V: Add support for Zvfbfmin extension

This implements the Zvfbfmin extension, as of version 1.0.
View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/bfloat16.adoc#zvfbfmin---vector-bf16-converts>

Depending on different usage scenarios, the Zvfbfmin extension may
depend on 'V' or 'Zve32f'. This patch only implements dependencies
in scenario of Embedded Processor. In scenario of Application
Processor, it is necessary to explicitly indicate the dependent
'V' extension.

For relevant information in gcc, please refer to:
<https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=1ddf65c5fc6ba7cf5826e1c02c569c923a541c09>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zvfbfmin.
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Updated.
* testsuite/gas/riscv/march-help.l: Ditto.
* testsuite/gas/riscv/zvfbfmin.d: New test.
* testsuite/gas/riscv/zvfbfmin.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_VFNCVTBF16_F_F_W): Define.
(MASK_VFNCVTBF16_F_F_W): Ditto.
(MATCH_VFWCVTBF16_F_F_V): Ditto.
(MASK_VFWCVTBF16_F_F_V): Ditto.
(DECLARE_INSN): New declarations for Zvfbfmin.
* opcode/riscv.h (enum riscv_insn_class): Add
INSN_CLASS_ZVFBFMIN

opcodes/ChangeLog:

* riscv-opc.c: Add Zvfbfmin instructions.

12 months agoRISC-V: Add support for Zfbfmin extension
Xiao Zeng [Thu, 6 Jun 2024 07:59:51 +0000 (15:59 +0800)] 
RISC-V: Add support for Zfbfmin extension

This implements the Zfbfmin extension, as of version 1.0.

View detailed information in:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/bfloat16.adoc#zfbfmin---scalar-bf16-converts>

1 The Zfbfmin extension depend on 'F', and the FLH, FSH, FMV.X.H, and
  FMV.H.X instructions as defined in the Zfh extension.

2 The Zfhmin extension includes the following instructions from the Zfh
  extension: FLH, FSH, FMV.X.H, FMV.H.X... View detailed information in:
  <https://github.com/riscv/riscv-isa-manual/blob/main/src/zfh.adoc>

3 Zfhmin extension depend on 'F'.

4 Simply put, just make Zfbfmin dependent on Zfhmin.

Perhaps in the future, we could propose making the FLH, FSH, FMV.X.H, and
FMV.H.X instructions an independent extension to achieve precise dependency
relationships for the Zfbfmin.

5 For relevant information in gcc, please refer to:
  <https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=35224ead63732a3550ba4b1332c06e9dc7999c31>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Handle Zfbfmin.
(riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

* NEWS: Updated.
* testsuite/gas/riscv/march-help.l: Ditto.
* testsuite/gas/riscv/zfbfmin.d: New test.
* testsuite/gas/riscv/zfbfmin.s: New test.

include/ChangeLog:

* opcode/riscv-opc.h (MATCH_FCVT_BF16_S): Define.
(MASK_FCVT_BF16_S): Ditto.
(MATCH_FCVT_S_BF16): Ditto.
(MASK_FCVT_S_BF16): Ditto.
(DECLARE_INSN): New declarations for Zfbfmin.
* opcode/riscv.h (enum riscv_insn_class): Add INSN_CLASS_ZFBFMIN.

opcodes/ChangeLog:

* riscv-opc.c: Add Zfbfmin instructions.

12 months agoRe: aarch64: Add some DT_RELR ld tests
Alan Modra [Mon, 3 Jun 2024 23:30:57 +0000 (09:00 +0930)] 
Re: aarch64: Add some DT_RELR ld tests

aarch64-elf fails these tests due to .rela.dyn being at a different
address to that expected, and due to the symbol table being different.
Unexpected symbol numbering results in a mismatch of reloc r_info
field, but these are shown decoded so the raw field doesn't really add
anything to the test.

* testsuite/ld-aarch64/relr-align.d: Accept any address for
.relr.dyn section.  Don't match raw r_info field.
* testsuite/ld-aarch64/relr-data-shared.d: Likewise.
* testsuite/ld-aarch64/relr-got-shared.d: Likewise.
* testsuite/ld-aarch64/relr-text-shared.d: Likewise.

12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Jun 2024 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoNEWS: arm: note that FPA support has been removed
Richard Earnshaw [Tue, 4 Jun 2024 11:56:28 +0000 (12:56 +0100)] 
NEWS: arm: note that FPA support has been removed

12 months agoarm: minor documentation cleanup given removal of FPA
Richard Earnshaw [Tue, 4 Jun 2024 11:56:27 +0000 (12:56 +0100)] 
arm: minor documentation cleanup given removal of FPA

The use in the documentation of .save for an FPA instruction is no-longer
relevant, so remove it.

12 months agoarm: remove disassembly support for the FPA co-processor
Richard Earnshaw [Tue, 4 Jun 2024 11:56:26 +0000 (12:56 +0100)] 
arm: remove disassembly support for the FPA co-processor

Remove the FPA support from the disassembler.  This entails a couple
of testsuite fixes where we were (probably incorrectly) disassembling
a generic co-processor instruction using the legacy FPA opcodes.

12 months agoarm: remove FPA instructions from assembler
Richard Earnshaw [Tue, 4 Jun 2024 11:56:25 +0000 (12:56 +0100)] 
arm: remove FPA instructions from assembler

These can no-longer be generated as the options to reach them have now
gone.  So remove the parsing support for FPA instructions.

12 months agoarm: remove options to select the FPA
Richard Earnshaw [Tue, 4 Jun 2024 11:56:24 +0000 (12:56 +0100)] 
arm: remove options to select the FPA

Remove the command-line options to choose the FPA (or FPE - an
emulated FPA).  From this point on it should be impossible to assemble
the old FPA instructions.

12 months agoarm: change default FPUs from FPA to none
Richard Earnshaw [Tue, 4 Jun 2024 11:56:23 +0000 (12:56 +0100)] 
arm: change default FPUs from FPA to none

Change the cases where the default FPU was FPA to none.  This should
ensure that any code that used settings to pick the floating-point
order will not silently produce a different output.  The options that
explicitly set the FPA remain for the moment.

12 months agoarm: redirect fp constant data directives through a wrapper
Richard Earnshaw [Tue, 4 Jun 2024 11:56:22 +0000 (12:56 +0100)] 
arm: redirect fp constant data directives through a wrapper

Assembler directives such as .float, or .double are handled by generic
code, but on Arm, their output can vary depeding on the type of FPU
begin targetted.  When we remove FPA support we don't want to silently
generate different code for processors that previously defaulted to
the FPA, so redirect these directives through a wrapper function that
checks the FPU is enabled; we use the legacy -mno-fpu in the test to
catch this.

Also fix a few tests so that they won't start to fail on targets (eg
arm-wince-pe) where there is no default format for the FPU and we pick
this from the default processor type.

12 months agoarm: adjust FPU selection logic
Richard Earnshaw [Tue, 4 Jun 2024 11:56:21 +0000 (12:56 +0100)] 
arm: adjust FPU selection logic

The logic here seems to be overly complex, so simplify it a bit.  One
particular problem was that using the legacy -mno-fpu option was not
working properly, as this has all the feature bits set to zero causing
the code to then pick a different FPU as the default.  Fix this by
only selecting an FPU as a fallback if the code has not otherwise
selected one: there was only one route by which this could happen.

This patch is really a pre-cursor to the following one where we want
to make no-fpu internally a fall-back position for some legacy
processors where previously we would have dropped back to the FPA.

12 months agoarm: default to softvfp on armv6 or later cores
Richard Earnshaw [Tue, 4 Jun 2024 11:56:20 +0000 (12:56 +0100)] 
arm: default to softvfp on armv6 or later cores

From armv6 onwards a lot of cores started to come with a physical VFP
implementation; but many still did not and in some cases there are
both variants.  For the cores that lacked a physical VFP we would fall
back to FPU_NONE if the platform/ABI did not mandate something else.
To make matters worse, FPU_NONE is internal state used to imply
soft-fpa (ie a mixed-endian double format), so any use of .double in
hand-written assembly is almost certainly generating incorrect output.

That's undesirable, all these cores should really default to a softvfp
model.

12 months agoarm: rename FPU_ARCH_VFP to FPU_ARCH_SOFTVFP
Richard Earnshaw [Tue, 4 Jun 2024 11:56:19 +0000 (12:56 +0100)] 
arm: rename FPU_ARCH_VFP to FPU_ARCH_SOFTVFP

FPU_ARCH_VFP has always meant VFP floating-point format (natural FP
word order) but without any VFP instructions.  But the name
FPU_ARCH_VFP is potentially confusing.  This patch just changes the
name to make the meaning clearer.

12 months agoarm: remove FPA related tests
Richard Earnshaw [Tue, 4 Jun 2024 11:56:18 +0000 (12:56 +0100)] 
arm: remove FPA related tests

Remove various tests of the FPA instruction set and relocation support.

12 months agoFix illegal memory access when bfd_get_section_contents is called with a NULL section...
Nick Clifton [Wed, 5 Jun 2024 12:30:27 +0000 (13:30 +0100)] 
Fix illegal memory access when bfd_get_section_contents is called with a NULL section pointer.

  PR 31843

12 months agoRISC-V: Tidy vendor core-v extension gas testcases
Nelson Chu [Wed, 5 Jun 2024 09:55:33 +0000 (17:55 +0800)] 
RISC-V: Tidy vendor core-v extension gas testcases

1. Combined testcases into one if they use same extention name.
2. Likewise for the fail testcases.
3. Renamed with x-cv prefix, just like what other vendors did.

gas/
* testsuite/gas/riscv/cv-alu-*: Combined and renamed to
x-cv-alu.  Likewise for fail testcases, to x-cv-alu-fail*.
* testsuite/gas/riscv/cv-bi-*: Likewise, but renamed to
x-cv-bi and x-cv-bi-fail.
* testsuite/gas/riscv/cv-elw-*: Likewise, but renamed to
x-cv-elw and x-cv-elw-fail.
* testsuite/gas/riscv/cv-mac-*: Likewise, but renamed to
x-cv-mac and x-cv-mac-fail.
* testsuite/gas/riscv/cv-mem-*: Likewise, but renamed to
x-cv-mem and x-cv-mem-fail.

12 months agoRISC-V: Add support for XCVmem extension in CV32E40P
Mary Bennett [Thu, 30 May 2024 15:06:59 +0000 (16:06 +0100)] 
RISC-V: Add support for XCVmem extension in CV32E40P

Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html

Contributors:
  Mary Bennett <mary.bennett682@gmail.com>
  Nandni Jamnadas <nandni.jamnadas@embecosm.com>
  Pietra Ferreira <pietra.ferreira@embecosm.com>
  Charlie Keaney
  Jessica Mills
  Craig Blackmore <craig.blackmore@embecosm.com>
  Simon Cook <simon.cook@embecosm.com>
  Jeremy Bennett <jeremy.bennett@embecosm.com>
  Helene Chelin <helene.chelin@embecosm.com>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Add `xcvmem`
instruction class.
(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:
* doc/c-riscv.texi: Note XCVmem as an additional ISA extension
for CORE-V.
* testsuite/gas/riscv/cv-mem-fail-march.d: New test.
* testsuite/gas/riscv/cv-mem-fail-march.l: New test.
* testsuite/gas/riscv/cv-mem-fail-march.s: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-01.d: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-01.l: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-01.s: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-02.d: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-02.l: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-02.s: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-03.d: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-03.l: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-03.s: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-04.d: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-04.l: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-04.s: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-05.d: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-05.l: New test.
* testsuite/gas/riscv/cv-mem-fail-operand-05.s: New test.
* testsuite/gas/riscv/cv-mem-lbpost.d: New test.
* testsuite/gas/riscv/cv-mem-lbpost.s: New test.
* testsuite/gas/riscv/cv-mem-lbrr.d: New test.
* testsuite/gas/riscv/cv-mem-lbrr.s: New test.
* testsuite/gas/riscv/cv-mem-lbrrpost.d: New test.
* testsuite/gas/riscv/cv-mem-lbrrpost.s: New test.
* testsuite/gas/riscv/cv-mem-lbupost.d: New test.
* testsuite/gas/riscv/cv-mem-lbupost.s: New test.
* testsuite/gas/riscv/cv-mem-lburr.d: New test.
* testsuite/gas/riscv/cv-mem-lburr.s: New test.
* testsuite/gas/riscv/cv-mem-lburrpost.d: New test.
* testsuite/gas/riscv/cv-mem-lburrpost.s: New test.
* testsuite/gas/riscv/cv-mem-lhpost.d: New test.
* testsuite/gas/riscv/cv-mem-lhpost.s: New test.
* testsuite/gas/riscv/cv-mem-lhrr.d: New test.
* testsuite/gas/riscv/cv-mem-lhrr.s: New test.
* testsuite/gas/riscv/cv-mem-lhrrpost.d: New test.
* testsuite/gas/riscv/cv-mem-lhrrpost.s: New test.
* testsuite/gas/riscv/cv-mem-lhupost.d: New test.
* testsuite/gas/riscv/cv-mem-lhupost.s: New test.
* testsuite/gas/riscv/cv-mem-lhurr.d: New test.
* testsuite/gas/riscv/cv-mem-lhurr.s: New test.
* testsuite/gas/riscv/cv-mem-lhurrpost.d: New test.
* testsuite/gas/riscv/cv-mem-lhurrpost.s: New test.
* testsuite/gas/riscv/cv-mem-lwpost.d: New test.
* testsuite/gas/riscv/cv-mem-lwpost.s: New test.
* testsuite/gas/riscv/cv-mem-lwrr.d: New test.
* testsuite/gas/riscv/cv-mem-lwrr.s: New test.
* testsuite/gas/riscv/cv-mem-lwrrpost.d: New test.
* testsuite/gas/riscv/cv-mem-lwrrpost.s: New test.
* testsuite/gas/riscv/cv-mem-sbpost.d: New test.
* testsuite/gas/riscv/cv-mem-sbpost.s: New test.
* testsuite/gas/riscv/cv-mem-sbrr.d: New test.
* testsuite/gas/riscv/cv-mem-sbrr.s: New test.
* testsuite/gas/riscv/cv-mem-sbrrpost.d: New test.
* testsuite/gas/riscv/cv-mem-sbrrpost.s: New test.
* testsuite/gas/riscv/cv-mem-shpost.d: New test.
* testsuite/gas/riscv/cv-mem-shpost.s: New test.
* testsuite/gas/riscv/cv-mem-shrr.d: New test.
* testsuite/gas/riscv/cv-mem-shrr.s: New test.
* testsuite/gas/riscv/cv-mem-shrrpost.d: New test.
* testsuite/gas/riscv/cv-mem-shrrpost.s: New test.
* testsuite/gas/riscv/cv-mem-swpost.d: New test.
* testsuite/gas/riscv/cv-mem-swpost.s: New test.
* testsuite/gas/riscv/cv-mem-swrr.d: New test.
* testsuite/gas/riscv/cv-mem-swrr.s: New test.
* testsuite/gas/riscv/cv-mem-swrrpost.d: New test.
* testsuite/gas/riscv/cv-mem-swrrpost.s: New test.
* testsuite/gas/riscv/march-help.l: Add xcvmem string.

include/ChangeLog:

* opcode/riscv-opc.h: Add corresponding MATCH and MASK macros
for XCVmem.
* opcode/riscv.h: Add corresponding EXTRACT and ENCODE macros
for XCVmem.
(enum riscv_insn_class): Add the XCVmem instruction class.

opcodes/ChangeLog:

* riscv-opc.c: Add XCVmem instructions.

12 months agoRISC-V: Add support for XCVbi extension in CV32E40P
Mary Bennett [Thu, 30 May 2024 15:06:58 +0000 (16:06 +0100)] 
RISC-V: Add support for XCVbi extension in CV32E40P

Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html

Contributors:
  Mary Bennett <mary.bennett682@gmail.com>
  Nandni Jamnadas <nandni.jamnadas@embecosm.com>
  Pietra Ferreira <pietra.ferreira@embecosm.com>
  Charlie Keaney
  Jessica Mills
  Craig Blackmore <craig.blackmore@embecosm.com>
  Simon Cook <simon.cook@embecosm.com>
  Jeremy Bennett <jeremy.bennett@embecosm.com>
  Helene Chelin <helene.chelin@embecosm.com>
  Nazareno Bruschi <nazareno.bruschi@embecosm.com>
  Lin Sinan

include/ChangeLog:

* opcode/riscv-opc.h: Add corresponding MATCH and MASK
macros for XCVbi.
* opcode/riscv.h: Add corresponding EXTRACT and ENCODE macros
for XCVbi.
(enum riscv_insn_class): Add the XCVbi instruction class.

gas/ChangeLog:

* config/tc-riscv.c (validate_riscv_insn): Add the necessary
operands for the extension.
(riscv_ip): Likewise.
* doc/c-riscv.texi: Note XCVbi as an additional ISA extension
for CORE-V.
* testsuite/gas/riscv/cv-bi-beqimm.d: New test.
* testsuite/gas/riscv/cv-bi-beqimm.s: New test.
* testsuite/gas/riscv/cv-bi-bneimm.d: New test.
* testsuite/gas/riscv/cv-bi-bneimm.s: New test.
* testsuite/gas/riscv/cv-bi-fail-march.d: New test.
* testsuite/gas/riscv/cv-bi-fail-march.l: New test.
* testsuite/gas/riscv/cv-bi-fail-march.s: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-01.d: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-01.l: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-01.s: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-02.d: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-02.l: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-02.s: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-03.d: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-03.l: New test.
* testsuite/gas/riscv/cv-bi-fail-operand-03.s: New test.
* testsuite/gas/riscv/march-help.l: Add xcvbi string.

include/ChangeLog:

* opcode/riscv-opc.h: Add corresponding MATCH and MASK
macros for XCVbi.
* opcode/riscv.h: Add corresponding EXTRACT and ENCODE macros
for XCVbi.
(enum riscv_insn_class): Add the XCVbi instruction class.

opcodes/ChangeLog:

* riscv-dis.c (print_insn_args): Add disassembly for new operand.
* riscv-opc.c: Add XCVbi instructions.

12 months agoRISC-V: Add support for XCVelw extension in CV32E40P
Mary Bennett [Thu, 30 May 2024 15:06:57 +0000 (16:06 +0100)] 
RISC-V: Add support for XCVelw extension in CV32E40P

Spec: https://docs.openhwgroup.org/projects/cv32e40p-user-manual/en/latest/instruction_set_extensions.html

Contributors:
  Mary Bennett <mary.bennett682@gmail.com>
  Nandni Jamnadas <nandni.jamnadas@embecosm.com>
  Pietra Ferreira <pietra.ferreira@embecosm.com>
  Charlie Keaney
  Jessica Mills
  Craig Blackmore <craig.blackmore@embecosm.com>
  Simon Cook <simon.cook@embecosm.com>
  Jeremy Bennett <jeremy.bennett@embecosm.com>
  Helene Chelin <helene.chelin@embecosm.com>

bfd/ChangeLog:

* elfxx-riscv.c (riscv_multi_subset_supports): Add `xcvelw` instruction
class.
(riscv_multi_subset_supports_ext): Likewise.

gas/ChangeLog:

* doc/c-riscv.texi: Note XCVelw as an additional ISA extension
for CORE-V.
* testsuite/gas/riscv/cv-elw-fail.d: New test.
* testsuite/gas/riscv/cv-elw-fail.l: New test.
* testsuite/gas/riscv/cv-elw-fail.s: New test.
* testsuite/gas/riscv/cv-elw-fail-march.d: New test.
* testsuite/gas/riscv/cv-elw-fail-march.l: New test.
* testsuite/gas/riscv/cv-elw-fail-march.s: New test.
* testsuite/gas/riscv/cv-elw-pass.d: New test.
* testsuite/gas/riscv/cv-elw-pass.s: New test.
* testsuite/gas/riscv/march-help.l: Add xcvelw string.

opcodes/ChangeLog:

* riscv-opc.c: (riscv_opcode) Add event load instructions.

include/ChangeLog:

* opcode/riscv-opc.h: Add corresponding MATCH and MASK
instruction opcode macros.
* opcode/riscv.h (riscv_insn_class): Add INSN_CLASS_XCVELW.

12 months agogdb/testsuite: remove trailing \r from rust_llvm_version result
Andrew Burgess [Fri, 31 May 2024 21:03:06 +0000 (22:03 +0100)] 
gdb/testsuite: remove trailing \r from rust_llvm_version result

I noticed that the value returned by rust_llvm_version had a trailing
carriage return.  I don't think this is causing any problems right
now, but looking at the code I don't think this was the desired
behaviour.

The current code runs 'rustc --version --verbose', splits the output
at each '\n' and then loops over every line looking for the line that
contains the LLVM version.

There are two problems here.  First, at the end of each captured line
we have '\r\n', so when we split the lines on '\n', each of the lines
will still end with a '\r' character.

Second, though we loop over the lines, when we try to compare the line
contents we actually compare the unsplit full output.  Luckily this
still finds the match, but this renders the loop over lines redundant.

This commit makes two fixes:

 1. I use regsub to convert all '\r\n' sequences to '\n'; now when we
    split on '\n' the lines will not end in '\r'.

 2. Within the loop over lines block I now check the line contents
    rather than the unsplit full output; now we capture a value
    without a trailing '\r'.

There's only one test (gdb.rust/simple.exp) that uses
rust_llvm_version, and it doesn't care if there's a trailing '\r' or
not, so this change should make no difference there.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb: more filename styling in remote.c and target.c
Andrew Burgess [Tue, 21 May 2024 15:20:43 +0000 (16:20 +0100)] 
gdb: more filename styling in remote.c and target.c

I spotted a few more places where we could apply filename styling in
remote.c and target.c.  Other than the styling, there should be no
user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Jun 2024 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoReturn global scope from DAP scopes request
Tom Tromey [Thu, 16 May 2024 13:58:07 +0000 (07:58 -0600)] 
Return global scope from DAP scopes request

A co-worker requested that the DAP code emit a scope for global
variables.  It's not really practical to do this for all globals, but
it seemed reasonable to do this for globals coming from the frame's
compilation unit.  For Ada in particular, this is convenient as it
exposes package-scoped variables.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
12 months agoConvert DAP disassemble code to use Block hashing
Tom Tromey [Thu, 16 May 2024 13:57:59 +0000 (07:57 -0600)] 
Convert DAP disassemble code to use Block hashing

This changes the DAP disassemble code to use the new Block hashing,
storing the already-visited blocks in a set rather than a list.

12 months agoMemoize gdb.Block and make them hashable
Tom Tromey [Wed, 15 May 2024 18:07:36 +0000 (12:07 -0600)] 
Memoize gdb.Block and make them hashable

In subsequent patches, it's handy if gdb.Block is hashable, so it can
be stored in a set or a dictionary.  However, doing this in a
straightforward way is not really possible, because a block isn't
truly immutable -- it can be invalidated.  And, while this isn't a
real problem for my use case (in DAP the maps are only used during a
single stop), it seemed error-prone.

This patch instead takes the approach of using the gdb.Block's own
object identity to allow hashing.  This seems fine because the
contents don't affect the hashing.  In order for this to work, though,
the blocks have to be memoized -- two requests for the same block must
return the same object.

This also allows (actually, requires) the simplification of the
rich-compare method for blocks.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
12 months agoPut "source" into DAP scope
Tom Tromey [Mon, 29 Apr 2024 18:57:11 +0000 (12:57 -0600)] 
Put "source" into DAP scope

I noticed a FIXME comment in the DAP code about adding a "source"
field to a scope.  This is easy to implement; I don't know why I
didn't do this originally.

12 months agoRemove a couple unnecessary casts
Tom Tromey [Wed, 20 Mar 2024 19:32:02 +0000 (13:32 -0600)] 
Remove a couple unnecessary casts

After the previous bcache change, a couple of casts in objfiles.h are
now redundant.

12 months agoMake bcache more type-safe
Tom Tromey [Wed, 20 Mar 2024 19:24:33 +0000 (13:24 -0600)] 
Make bcache more type-safe

The bcache uses memcpy to make copies of the data passed to it.  In
C++, this is only safe for trivially-copyable types.

This patch changes bcache to require this property, and slightly
changes the API to make it easier to use when copying a single object.
It also makes the new 'insert' template methods return the correct
type.

12 months agoSome constification in psymtab
Tom Tromey [Wed, 20 Mar 2024 19:42:36 +0000 (13:42 -0600)] 
Some constification in psymtab

This patch changes some spots in psymtab.[ch] to use 'const'.  This is
just preparation for a subsequent patch.  Note that psymbols are
conceptually const, and since they were changed to be
objfile-indepdendent, they are truly never modified -- which is what
makes this patch reasonably short.

12 months agoRely on std::uncaught_exceptions
Tom Tromey [Tue, 27 Feb 2024 17:24:30 +0000 (10:24 -0700)] 
Rely on std::uncaught_exceptions

std::uncaught_exceptions is a C++17 feature, so I think we can remove
this conditional code from inferior.h.

12 months agoAdd myself to gdb/MAINTAINERS
Dmitry Neverov [Tue, 4 Jun 2024 15:34:49 +0000 (17:34 +0200)] 
Add myself to gdb/MAINTAINERS

12 months agosrc-release.sh: fix adjusting files permissions and cleaning
Rostislav Krasny [Tue, 4 Jun 2024 13:58:49 +0000 (14:58 +0100)] 
src-release.sh: fix adjusting files permissions and cleaning

  PR 31800

12 months agogdb/testsuite: tests for debug lookup within the sysroot
Andrew Burgess [Sat, 18 May 2024 09:50:23 +0000 (10:50 +0100)] 
gdb/testsuite: tests for debug lookup within the sysroot

Add tests for looking up debug information within the sysroot via both
build-id and gnu_debuglink.

I wanted to ensure that the gnu_debuglink test couldn't make use of
build-ids, so I added the 'no-build-id' flag to gdb_compile.

As these tests rely on setting the sysroot, if I'm running a
dynamically linked executable, GDB will try to find all shared
libraries within the sysroot.  This would mean I'd have to figure out
and copy all shared libraries the executable uses, certainly possible,
but a bit of a pain.

So instead, I've just compiled the test executable as a static binary.
Now there are no shared library dependencies.

I can now split the debug information out from the test binary, and
place it within the sysroot.  When GDB is started and the executable
loaded, we can check that GDB is finding the debug information within
the sysroot.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804

Approved-By: Tom de Vries <tdevries@suse.de>
12 months agogdb/testsuite: make gdb_gnu_strip_debug consistent
Andrew Burgess [Sat, 18 May 2024 10:05:49 +0000 (11:05 +0100)] 
gdb/testsuite: make gdb_gnu_strip_debug consistent

While writing a test I realised that the default behaviour of
gdb_gnu_strip_debug doesn't match its comment.

The comment says that the function takes a FILENAME, and splits the
file into FILENAME.stripped and FILENAME.debug, leaving FILENAME
unchanged.  The comment says that a .gnu_debuglink will be added to
FILENAME.stripped.

However, this is not true, FILENAME.stripped is created, with no debug
information.  FILENAME.debug is created containing the debug
information.

But, when adding the .gnu_debuglink we take FILENAME.stripped as the
input, and then overwrite FILENAME with the output.  As a result,
FILENAME.stripped does not include a .gnu_debuglink, while FILENAME
contains the .gnu_debuglink and no debug information!

The users of gdb_gnu_strip_debug can be split into two groups, those
who are using the .gnu_debuglink, these tests are all written assuming
that FILENAME is updated.

Then there are some tests that only rely on gdb_gnu_strip_debug's
ability to split out the debug information, these tests are then going
to do a lookup based on the build-id, these tests don't require the
.gnu_debuglink.  These tests use the FILENAME.stripped output file.

This all seems too confused to me.

As most uses of gdb_gnu_strip_debug assume that FILENAME is updated, I
propose that we just make that the actual, advertised behaviour of
this proc.

So now, gdb_gnu_strip_debug will take FILENAME, and will split the
debug information out into FILENAME.debug.  The debug information will
then be stripped from FILENAME, and by default a .gnu_debuglink will
be added to FILENAME pointing to FILENAME.debug.

I've updated the two tests that actually relied on FILENAME.stripped
to instead just use FILENAME.

One of the tests was doing a build-id based lookup, but was still
allowing the .gnu_debuglink to be added to FILENAME, I've updated this
test to pass the no-debuglink flag to gdb_gnu_strip_debug, which stops
the .gnu_debuglink from being added.

All of the tests that call gdb_gnu_strip_debug still pass for me.

Acked-By: Tom de Vries <tdevries@suse.de>
12 months agogdb/Makefile.in: silence recipe for creating .deps/ directories
Andrew Burgess [Mon, 3 Jun 2024 18:51:40 +0000 (19:51 +0100)] 
gdb/Makefile.in: silence recipe for creating .deps/ directories

When building in a fresh directory we'll see some output like this:

  /bin/sh ../../src/gdb/../mkinstalldirs arch/.deps
  mkdir -p -- arch/.deps
  /bin/sh ../../src/gdb/../mkinstalldirs cli/.deps
  mkdir -p -- cli/.deps
  /bin/sh ../../src/gdb/../mkinstalldirs dwarf2/.deps
  mkdir -p -- dwarf2/.deps
  ... etc ...

this commit uses silent-rules.mk to silence this output, now we'll
see:

  GEN    arch/.deps
  GEN    cli/.deps
  GEN    dwarf2/.deps
  ... etc ...

The recipe that currently generates these directories uses
mkinstalldirs, as I mention in commit 032e5e0c0c08977, mkinstalldirs
is deprecated and 'install-sh -d' should be used instead.  This
silences the 'mkdir -p -- ...' part of the output.

There should be no change in what is actually built after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoLoongArch: Disable linker relaxation if set the address of section or segment
mengqinggang [Thu, 30 May 2024 11:52:34 +0000 (19:52 +0800)] 
LoongArch: Disable linker relaxation if set the address of section or segment

If set the address of section or segment, the offset from pc to symbol
may become bigger and cause overflow.

12 months agoLoongArch: Make align symbol be in same section with alignment directive
mengqinggang [Wed, 29 May 2024 06:50:39 +0000 (14:50 +0800)] 
LoongArch: Make align symbol be in same section with alignment directive

R_LARCH_ALIGN (psABI v2.30) requires a symbol index. The symbol is only
created at the first time to handle alignment directive. This means that
all other sections may use this symbol. If the section of this symbol is
discarded, there may be problems. Search it in its own section.

Remove elf_backend_data.is_rela_normal() function added at commit daeda14191c.

Co-authored-by: Jinyang He <hejinyang@loongson.cn>
Reported-by: WANG Xuerui <git@xen0n.name>
Link: https://lore.kernel.org/loongarch/2abbb633-a10e-71cc-a5e1-4d9e39074066@loongson.cn/T/#t
12 months agoarm: testsuite: fix msdos line endings in tests
Richard Earnshaw [Tue, 4 Jun 2024 10:31:50 +0000 (11:31 +0100)] 
arm: testsuite: fix msdos line endings in tests

A couple of the tests in the testsuite were at some point in the past
committed with DOS-style CRLF line endings.  This potentially causes
email problems if the tests are touched in the middle of a large patch
series so convert them to standard Un*x line endings.

12 months agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Jun 2024 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogprofng: add hardware counters for AMD Zen4
Vladimir Mezentsev [Sun, 2 Jun 2024 03:36:06 +0000 (20:36 -0700)] 
gprofng: add hardware counters for AMD Zen4

ChangeLog
2024-06-01  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* common/hwctable.c: Add the hwc table for AMD Zen4.
* src/hwc_amd_zen4.h: New file.
* src/hwc_amd_zen3.h: Define _HWC_AMD_ZEN3_H.

12 months agoRemove one call to can_box from TUI
Tom Tromey [Fri, 31 May 2024 20:02:54 +0000 (14:02 -0600)] 
Remove one call to can_box from TUI

This removes a call to can_box from
tui_source_window_base::show_source_content.  can_box will always
return true here.

Approved-By: Andrew Burgess <aburgess@redhat.com>
12 months agoFix deprecation text
Tom Tromey [Fri, 31 May 2024 15:44:14 +0000 (09:44 -0600)] 
Fix deprecation text

I noticed one spot where deprecate_cmd is called with a second
argument that is not a command name.  This patch fixes the problem.

Regression tested on x86-64 Fedora 38.

12 months agoEnable call of overloaded subscript operator from python
Hannes Domani [Mon, 3 Jun 2024 15:23:26 +0000 (17:23 +0200)] 
Enable call of overloaded subscript operator from python

If you try to use the overloaded subscript operator of a class
in python, it fails like this:

(gdb) py print(gdb.parse_and_eval('b')[5])
Traceback (most recent call last):
  File "<string>", line 1, in <module>
gdb.error: Cannot subscript requested type.
Error while executing Python code.

This simply checks if such an operator exists, and calls it
instead, making this possible:

(gdb) py print(gdb.parse_and_eval('b')[5])
102 'f'

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoAllow calling of convenience functions with python
Hannes Domani [Mon, 3 Jun 2024 15:18:30 +0000 (17:18 +0200)] 
Allow calling of convenience functions with python

As mentioned in PR13326, currently when you try to call a
convenience function with python, you get this error:

(gdb) py print(gdb.convenience_variable("_isvoid")(3))
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Value is not callable (not TYPE_CODE_FUNC or TYPE_CODE_METHOD).
Error while executing Python code.

So this extends valpy_call to handle TYPE_CODE_INTERNAL_FUNCTION as
well, making this possible:

(gdb) py print(gdb.convenience_variable("_isvoid")(3))
0

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Approved-By: Tom Tromey <tom@tromey.com>
12 months agosrc-release.sh: Use -T0 for xz compression
Mark Wielaard [Thu, 30 May 2024 21:06:41 +0000 (23:06 +0200)] 
src-release.sh: Use -T0 for xz compression

Use parallel compression to create the xz archive.

On my machine (using 4 cores) this reduces the time to create
binutils-2.42.50.tar.xz from 1 minute 40 seconds to 56 seconds.

xz has supported -T0 since version 5.2.0 (released 2014-12-21).

12 months ago[gdb/testsuite] Fix timeout in gdb.tui/resize-2.exp
Tom de Vries [Mon, 3 Jun 2024 05:49:24 +0000 (07:49 +0200)] 
[gdb/testsuite] Fix timeout in gdb.tui/resize-2.exp

When running test-case gdb.tui/resize-2.exp with taskset -c 0, I sometimes run
into:
...
tui disable^[[40;1H^M(gdb) PASS: $exp: tui disable
^M^[[K(gdb) FAIL: $exp: two prompt redisplays after resize (timeout)
...

The test-case does "Term::resize 24 80 0" while having the settings of an
earlier "Term::resize 40 90", so both dimensions change.

When TUI is enabled, we call Term::resize with wait_for_msg == 1, and the proc:
- calls stty to change one dimension,
- waits for the message (enabled by "maint set tui-resize-message on")
  confirming the resize has happened,
- calls stty to change the other dimension, and again
- waits for the message confirming the resize has happened.

Since TUI is disabled, we call Term::resize with wait_for_msg == 0 because the
message is not printed, so stty is called twice, and afterwards we check for
the results of the two resizes, which is the test that is failing.

The problem is that not waiting for a response after each stty call opens up
the possibility of the responses being merged.

Fix this by calling Term::resize twice, changing one dimension at a time, and
waiting for a single prompt redisplay after each one.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
PR testsuite/31822
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31822

12 months agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Jun 2024 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoFix typo in tui-data.h
Tom Tromey [Fri, 31 May 2024 21:11:12 +0000 (15:11 -0600)] 
Fix typo in tui-data.h

I noticed a typo in a comment in tui-data.h.

12 months agoAutomatic date update in version.in
GDB Administrator [Sun, 2 Jun 2024 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agoAutomatic date update in version.in
GDB Administrator [Sat, 1 Jun 2024 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months ago[gdb/testsuite] New test: gdb.base/errno.exp
Kevin Buettner [Thu, 2 May 2024 01:37:58 +0000 (18:37 -0700)] 
[gdb/testsuite] New test: gdb.base/errno.exp

Printing the value of 'errno' from GDB is sometimes problematic.  The
situation has improved in recent years, though there are still
scenarios for which "print errno" doesn't work.

The test, gdb.base/errno.exp, introduced by this commit, tests whether
or not GDB can print errno using a binary compiled in the following
different ways:

- default: no switches aside from -g (and whatever else is added by the
  testing framework)
- macros: macro info is included in the debuginfo; this is enabled by
  using -g3 when using gcc or clang
- static: statically linked binary
- static-macros: statically linked binary w/ macro definitions included
  in debuginfo
- pthreads: libpthread linked binary
- pthreads-macros: libpthread linked binary w/ macro definitions included
  in debuginfo
- pthreads-static: Statically linked against libpthread
- pthreads-static-macros: Statically linked against libpthread w/ macro
  definitions

For each of these, the test also creates a corefile, then loads the
corefile and attempts to print errno again.

Additionally, the test checks that a "masking" errno declared as a
local variable will print correctly.

On Linux, if the machine is missing glibc debuginfo (or you have
debuginfod disabled), it's likely you'll see:

    (gdb) print errno
    'errno' has unknown type; cast it to its declared type

But if you add a cast, the value of errno is often available:

    (gdb) print (int) errno
    $1 = 42

The test detects this situation along with several others and does
'setup_xfail' for tests that will almost certainly fail.  It could be
argued that some of these ought to be KFAILs due to deficiencies in
GDB, but I'm not entirely certain which, if any, are fixable yet.

On Fedora 39, without glibc debuginfo, there are no failures, but
I do see the following XFAILS:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

On Fedora 39, with glibc debug info, but without libc.a (for static
linking), there are 2 XFAILs, 2 UNSUPPORTED tests, and 4 UNTESTED
tests.

So, even when testing in less than ideal conditions, either due to lack
of glibc debuginfo or lack of a libc to link against to make a static
binary, there are no failures.

With glibc debuginfo installed, on Fedora 38, Fedora 39, Fedora 40,
Fedora rawhide (41), and Ubuntu 22.04.1 LTS, I see these XFAILs:

XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

On FreeBSD 13.1, the total number of XFAILs are fewer, and could be
even better still if it had debug info for glibc:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

Starting with glibc-2.34, most of the pthreads library has been
incorporated into libc, so finding thread-local variables using
libthread_db is possible for several scenarios in which it previously
wasn't.  But, prior to this, accessing errno for the default scenario
was a problem.  This is borne out by running this new test on Fedora
34, which uses glibc-2.33:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: print errno
XFAIL: gdb.base/errno.exp: static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

In the v3 version of this test, Tom de Vries tested on openSUSE Leap
15.5 and found a number of cases which showed a FAIL instead of an
XFAIL.  The v4 version of this test fixed those problems.  On Leap
15.5, which uses glibc-2.31, with glibc debug info, I now see:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

On Leap 15.5, with glibc debuginfo missing, the results are a little
worse:

XFAIL: gdb.base/errno.exp: default: print errno
XFAIL: gdb.base/errno.exp: default: print (int) errno
XFAIL: gdb.base/errno.exp: default: check errno value from corefile
XFAIL: gdb.base/errno.exp: macros: print errno
XFAIL: gdb.base/errno.exp: macros: print (int) errno
XFAIL: gdb.base/errno.exp: macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: static: print errno
XFAIL: gdb.base/errno.exp: static: print (int) errno
XFAIL: gdb.base/errno.exp: static: check errno value from corefile
XFAIL: gdb.base/errno.exp: static-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads: print errno
XFAIL: gdb.base/errno.exp: pthreads: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-macros: print errno
XFAIL: gdb.base/errno.exp: pthreads-macros: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-macros: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static: print errno
XFAIL: gdb.base/errno.exp: pthreads-static: print (int) errno
XFAIL: gdb.base/errno.exp: pthreads-static: check errno value from corefile
XFAIL: gdb.base/errno.exp: pthreads-static-macros: check errno value from corefile

The v5 version of this test fixed failures when testing with
check-read1.  (Thanks to Linaro CI for finding these.)  I revised the
regular expressions being used so that the failures were eliminated,
but the results mentioned above have not changed.

The v6 version of this test fixes some nits pointed out by both Tom
de Vries and Pedro Alves.  One of Pedro's suggestions was to rename the
test from check-errno.exp to errno.exp, so in v5, the name has
changed.  Tom also noticed that there were failures when using
--target_board=native-extended-gdbserver.  For v6, I've tested on 10
different Linux machines (F38, F39, F39 w/o glibc debuginfo, F39 w/o
static glibc, F40, rawhide, Ubuntu 22.04, Leap 15.5, Leap 15.5 w/o
glibc debuginfo, and Fedora 34) using "make check" and "make check-read1"
using target boards "unix", "native-extended-gdbserver", and
"native-gdbserver", with CC_FOR_TARGET set to both gcc and clang, for
a total of 12 distinct test runs on each machine.  I've also tested the
native-only cases on FreeBSD.  (Attempting to test against gdbserver
on FreeBSD resulted in hangs while running the test suite.)

The v7 version of this test simplifies the REs used in the uses of
gdb_test_multiple by adding -wrap and removing parts of the REs which
match the GDB prompt.  In cases where there was a leading '.*', those
were removed too.  Thanks to Pedro for explaining how to use -wrap.

So, bottom line, this test does not introduce any new failures on the
platforms on which I've tested, but the XFAILs are certainly unfortunate.
Some aren't fixable - e.g. when attempting to make a function call while
debugging a core file - but I think that some of them are.  I'm using
this new test case as a starting point for investigating problems with
printing errno.

Co-Authored-By: Jan Kratochvil
Approved-By: Tom de Vries <tdevries@suse.de>
12 months agoaarch64, testsuite: avoid regexes in opcode field
Claudio Bantaloukas [Thu, 30 May 2024 08:42:37 +0000 (08:42 +0000)] 
aarch64, testsuite: avoid regexes in opcode field

Some dejagnu files use regexes rather than specific encodings. This
change replaces them with the explicit encodings we expect.

Tested against aarch64-unknown-linux-gnu and aarch64-none-elf.

12 months agogas, aarch64: Fixes in texi and tests following faminmax and lut changes
saurabh.jha@arm.com [Thu, 30 May 2024 08:38:24 +0000 (09:38 +0100)] 
gas, aarch64: Fixes in texi and tests following faminmax and lut changes

Making two cleanups that came out of the comments from my previous
patches:
1. Fixing `c-aarch64.texi` file so that the AArch64 architecture
   extensions are ordered alphabetically.
2. Fixing faminmax test cases so that they follow the existing test
   conventions.

12 months agoMove dwarf2_per_bfd::index_addrmap to mapped_gdb_index
Tom Tromey [Thu, 30 May 2024 16:39:17 +0000 (10:39 -0600)] 
Move dwarf2_per_bfd::index_addrmap to mapped_gdb_index

dwarf2_per_bfd::index_addrmap is only used by the .gdb_index reader,
so this field can be moved to mapped_gdb_index instead.  Then,
cooked_index_functions::find_per_cu can be removed in favor of a
method on the index object.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31821
Approved-By: Simon Marchi <simon.marchi@efficios.com>
12 months agoaarch64: Add some DT_RELR ld tests
Szabolcs Nagy [Wed, 22 May 2024 15:52:11 +0000 (16:52 +0100)] 
aarch64: Add some DT_RELR ld tests

12 months agoaarch64: Add DT_RELR support
Szabolcs Nagy [Wed, 27 Mar 2024 15:38:06 +0000 (15:38 +0000)] 
aarch64: Add DT_RELR support

The logic to decide if an input relocation for a symbol becomes a
particular kind of output relocation is one of the hard to maintain
parts of the bfd ld backend, since it is partially repeated across

 elfNN_aarch64_check_relocs (where dynamic relocations are counted per
 symbol and input section),

 elfNN_aarch64_late_size_sections (where relocation sections are sized
 and GOT offsets assigned),

 elfNN_aarch64_relocate_section (where most relocations are applied and
 output to a relocation section),

 elfNN_aarch64_finish_dynamic_symbol (where some of the GOT
 relocations are applied and output).

The DT_RELR support adds another layer to this complexity: after the
output relocation sections are sized, so all dynamic relocations are
accounted (in elfNN_aarch64_late_size_sections), we scan the symbols
and input relocations again to decide which ones become relative
relocations that can be packed. The sizes of the relocation sections
are updated accordingly. This logic must be consistent with the code
that applies the relocs later so each relative relocation is emitted
exactly once: either in .rela.* or packed in .relr.dyn.

Sizing of .relr.dyn is done via elfNN_aarch64_size_relative_relocs that
may be called repeatedly whenever the layout changes since an address
change can affect the size of the packed format. Then the final content
is emitted in elfNN_aarch64_finish_relative_relocs, that is called
after the layout is final and before relocations are applied and
emitted. These hooks are only called if DT_RELR is enabled.

We only pack relative relocs that are known to be aligned in the output
during .relr.dyn sizing, the potentially unaligned relative relocs are
emitted normally (in .rela.*, not packed), because the format requires
aligned addresses.

12 months agox86: reduce check_{byte,word,long,qword}_reg() overhead
Jan Beulich [Fri, 31 May 2024 08:22:50 +0000 (10:22 +0200)] 
x86: reduce check_{byte,word,long,qword}_reg() overhead

These run after template matching. Therefore it is quite pointless for
them to check all operands, when operand sizes matching across operands
is already known. Exit the loops early in such cases.

In check_byte_reg() also drop a long-stale part of a comment.

12 months agogdb, amd64: remove unused forward declarations
Felix Willgerodt [Thu, 14 Jul 2022 14:46:37 +0000 (16:46 +0200)] 
gdb, amd64: remove unused forward declarations

These structs are not referenced anywhere anymore and seemed to have been
missed at some point when their usage was removed.

Co-authored-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Approved-By: Tom Tromey <tom@tromey.com>
12 months agogdb, doc: Fix AVX-512 documentation.
Felix Willgerodt [Tue, 21 May 2024 12:54:05 +0000 (14:54 +0200)] 
gdb, doc: Fix AVX-512 documentation.

org.gnu.gdb.i386.avx512 adds k registers, but these aren't mentioned in the
docs yet.  Fix that.

In addition the documentation describes xmm registers with an `h`
(e.g. xmm16h).  I am assuming that we follow the register xml files here,
which don't have the h suffix.  So this removes that as well.

Approved-By: Eli Zaretskii <eliz@gnu.org>
12 months agogdb: remove unused includes in utils.h
Simon Marchi [Mon, 29 Apr 2024 15:07:22 +0000 (11:07 -0400)] 
gdb: remove unused includes in utils.h

Remove some includes reported as unused by clangd.  Add some includes in
other files that were previously relying on the transitive include.

Change-Id: Ibdd0a998b04d21362a20d0ca8e5267e21e2e133e

12 months agoAutomatic date update in version.in
GDB Administrator [Fri, 31 May 2024 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb: remove unused includes in symfile.c
Simon Marchi [Tue, 23 Apr 2024 02:34:13 +0000 (22:34 -0400)] 
gdb: remove unused includes in symfile.c

Remove some includes reported as unused by clangd.

Change-Id: Iebd986eaf42409f1e526f09df0fcb0ce45c2fad6

12 months agogdb: remove unused includes in breakpoint.{c,h}
Simon Marchi [Tue, 23 Apr 2024 02:26:41 +0000 (22:26 -0400)] 
gdb: remove unused includes in breakpoint.{c,h}

Remove some includes reported as unused by clangd.

Change-Id: I36d388bcff166f6baafa212f0bcbe8af64b2946d

12 months agoUpdate binutils release documentation to include using the -z option when invoking...
Nick Clifton [Thu, 30 May 2024 11:52:37 +0000 (12:52 +0100)] 
Update binutils release documentation to include using the -z option when invoking src-release.sh

12 months agosrc-release.sh: Support zstd compression
Mark Wielaard [Thu, 30 May 2024 11:50:11 +0000 (12:50 +0100)] 
src-release.sh: Support zstd compression

12 months ago.gitignore: ignore .vscode
Simon Marchi [Thu, 30 May 2024 11:09:35 +0000 (12:09 +0100)] 
.gitignore: ignore .vscode

12 months agoAutomatic date update in version.in
GDB Administrator [Thu, 30 May 2024 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 months agogdb/doc: don't have .pod targets separate to man page targets
Andrew Burgess [Sun, 26 May 2024 22:30:37 +0000 (23:30 +0100)] 
gdb/doc: don't have .pod targets separate to man page targets

While preparing the new release it was discovered that commit:

  commit 824083f34c222aa7419e2ea58e82d6f230d5f531
  Date:   Fri Apr 12 17:47:20 2024 +0100

      gdb/doc: use silent-rules.mk in the Makefile

was causing problems.  Given a release tar file, an attempt to build
and install GDB would give an error like this:

  [...]
    TEXI2POD gdb.pod
  cannot find GDBvn.texi at ../../../gdb-15.0.50.20240508/gdb/doc/../../etc/texi2pod.pl line 251, <GEN0> line 16.
  make[5]: *** [Makefile:663: gdb.pod] Error 2

The problem here is how the man pages are built, and how they are
distributed within a release.

Within the development (git) tree, the man page files are not part of
the source tree, these files are built as needed.  Within a release
tar file though, the man pages are included.  The idea being that a
user can build and install GDB, including getting the man pages,
without having to install the tools needed to generate the man pages.

The man pages are generated in a two step process.  First the .texi
file is processed with texi2pod to create a .pod file, then this .pod
file is processed to create the .1 or .5 man file.

Prior to the above commit these two steps were combined into a single
recipe, this meant that when a user performed a build/install from a
release tree all of the dependencies, as well as the final result,
were all present in the source tree, and so nothing needed to be
rebuilt.

However, the above commit split the two steps apart.  Now we had a
separate rule for building the .pod files, and the .1/.5 man page
files depended on the relevant .pod file.

As the .pod files are not shipped in a GDB release, this meant that
one of the dependencies of the man page files was now missing.  As a
result if a user tried to install from a release tree a rebuild of the
.pod files would be attempted, and if that succeeded then building the
man pages would follow that.

Unfortunately, building the .pod files would fail as the GDBvn.texi
file, though present in the source tree, was not present in the build
tree, which is where it is needed for the .pod file generation to
work.

To fix this, I propose merging the .pod creation and the .1/.5 man
page creation back into a single recipe.  Having these two steps split
is probably the "cleaner" solution, but makes it harder for us to
achieve our goal of shipping the prebuilt man page files.  I've added
a comment explaining what's going on (such a comment would have
prevented this mistake having been made in the first place).

One possibly weird thing here is that I have left both an
ECHO_TEXI2POD and a ECHO_TEXI2MAN in the rule $(MAN1S) and $(MAN5S)
recipes.  This is 100% not going to break anything, these just print
two different progress messages while executing the recipes, but I'm
not sure if this is considered poor style or not.  Maybe we're only
supposed to have a single ECHO_* per recipe?

Anyway, even if this is poor style, I figure it really is just a style
thing.  We can tweak this later as needed.  Otherwise, this commit
should fix the current issue blocking the next GDB release.

Approved-By: Tom Tromey <tom@tromey.com>
12 months agoreadelf: Use section names for displaying RELR relocs
Szabolcs Nagy [Tue, 28 May 2024 16:23:41 +0000 (17:23 +0100)] 
readelf: Use section names for displaying RELR relocs

In some cases using section names instead of symbol names for
displaying an address is more useful.

If the symbol falls outside the section where the address is
then likely it is not useful to display the address relative to.

And if symbols are stripped from a binary then printing the
section that contains the address is more useful than printing
<no sym>.