]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
8 months agoIntroduce and use gnat_version_compare
Tom Tromey [Thu, 26 Sep 2024 14:48:03 +0000 (08:48 -0600)] 
Introduce and use gnat_version_compare

While testing a modified GNAT, I found that this test in
fun_renaming.exp was returning 0 for GCC 13:

    if {[test_compiler_info {gcc-6*}]}

This patch introduces a new, more robust way to check the GNAT
compiler version, and changes the gda.ada tests to use it.  A small
update to version_compare was also needed.

Note that, in its current form, this new code won't really interact
well with non-GCC compilers (specifically gnat-llvm).  This doesn't
seem like a major issue at this point, though, because gnat-llvm
doesn't properly emit debuginfo yet, and when it does, more changes
will be needed in these tests anyway.

Reviewed-by: Keith Seitz <keiths@redhat.com>
8 months agoLoongArch: Add more relaxation support for call36
mengqinggang [Thu, 10 Oct 2024 08:23:30 +0000 (16:23 +0800)] 
LoongArch: Add more relaxation support for call36

Add relaxation support for call36 that jump to PLT entry.

Add relaxation support for call36 with IFUNC symbol.

Add relaxation support for call36 that jump to undefweak symbol.
For undefweak symbol, it can always be relaxed if it have no PLT entry.
Because we set the address of undefweak symbol without PLT entry to PC
like relocate_section.

8 months agoLoongArch: Optimize the relaxation process
mengqinggang [Thu, 10 Oct 2024 08:20:52 +0000 (16:20 +0800)] 
LoongArch: Optimize the relaxation process

The symbol value is only calculated when the relocation can be relaxed.

8 months agox86: Refine instruction check in x86_check_tls_relocation
Cui, Lili [Tue, 15 Oct 2024 06:13:33 +0000 (14:13 +0800)] 
x86: Refine instruction check in x86_check_tls_relocation

gas/ChangeLog:

        * config/tc-i386.c
(x86_check_tls_relocation): Refine instruction check.

8 months agox86/testsuite: Rename AVX10.2 media testcases
Haochen Jiang [Sat, 12 Oct 2024 08:45:58 +0000 (16:45 +0800)] 
x86/testsuite: Rename AVX10.2 media testcases

Change these testcase name to make them clearer.

gas/ChangeLog:

* testsuite/gas/i386/avx10_2-256-1-intel.d: Renamed to...
* testsuite/gas/i386/avx10_2-256-media-intel.d: ...this.
* testsuite/gas/i386/avx10_2-256-1.d: Renamed to...
* testsuite/gas/i386/avx10_2-256-media.d: ...this.
* testsuite/gas/i386/avx10_2-256-1.s: Renamed to...
* testsuite/gas/i386/avx10_2-256-media.s: ...this.
* testsuite/gas/i386/avx10_2-512-1-intel.d: Renamed to...
* testsuite/gas/i386/avx10_2-512-media-intel.d: ...this.
* testsuite/gas/i386/avx10_2-512-1.d: Renamed to...
* testsuite/gas/i386/avx10_2-512-media.d: ...this.
* testsuite/gas/i386/avx10_2-512-1.s: Renamed to...
* testsuite/gas/i386/avx10_2-512-media.s: ...this.
* testsuite/gas/i386/x86-64-avx10_2-256-1-intel.d: Renamed to...
* testsuite/gas/i386/x86-64-avx10_2-256-media-intel.d: ...this.
* testsuite/gas/i386/x86-64-avx10_2-256-1.d: Renamed to...
* testsuite/gas/i386/x86-64-avx10_2-256-media.d: ...this.
* testsuite/gas/i386/x86-64-avx10_2-256-1.s: Renamed to...
* testsuite/gas/i386/x86-64-avx10_2-256-media.s: ...this.
* testsuite/gas/i386/x86-64-avx10_2-512-1-intel.d: Renamed to...
* testsuite/gas/i386/x86-64-avx10_2-512-media-intel.d: ...this.
* testsuite/gas/i386/x86-64-avx10_2-512-1.d: Renamed to...
* testsuite/gas/i386/x86-64-avx10_2-512-media.d: ...this.
* testsuite/gas/i386/x86-64-avx10_2-512-1.s: Renamed to...
* testsuite/gas/i386/x86-64-avx10_2-512-media.s: ...this.
* testsuite/gas/i386/i386.exp: Change testcase name.
* testsuite/gas/i386/x86-64.exp: Ditto.

8 months agoAutomatic date update in version.in
GDB Administrator [Tue, 15 Oct 2024 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb/testsuite: fix gdb.multi/inferior-specific-bp.exp
Guinevere Larsen [Mon, 14 Oct 2024 13:13:13 +0000 (10:13 -0300)] 
gdb/testsuite: fix gdb.multi/inferior-specific-bp.exp

A recent commit, "16a6f7d2ee3 gdb: avoid breakpoint::clear_locations
calls in update_breakpoint_locations", started checking if GDB correctly
relocates a breakpoint from inferior 1's declaration of the function
"bar" to inferior 2's declaration.

Unfortunately, inferior 2 never calls bar in its regular execution, and
because of that, clang would optimize that whole function away, making
it so there is no location for the breakpoint to be relocated to.

This commit changes the .c file so that the function is not optimized
away and the test fully passes with clang. It is important to actually
call bar instead of using __attribute__((used)) because the latter
causes the breakpoint locations to be inverted, 3.1 belongs to inferior
2 and 3.2 belongs to inferior 1, which will cause an unrelated failure.

Approved-By: Andrew Burgess <aburgess@redhat.com>
8 months agoia64/ELF: fix HPUX testsuite fallout
Jan Beulich [Mon, 14 Oct 2024 12:38:23 +0000 (14:38 +0200)] 
ia64/ELF: fix HPUX testsuite fallout

... from 1f1b5e506bf0 ("bfd/ELF: restrict file alignment for object
files"), as noticed / reported by Alan.

8 months agox86: also template-expand trailing mnemonic part
Jan Beulich [Mon, 14 Oct 2024 12:38:02 +0000 (14:38 +0200)] 
x86: also template-expand trailing mnemonic part

So far template expansion was limited to fields other than the insn
mnemonic. In order to be able to use <fop> also for AVX10.2 we want the
trailing mnemonic part to also be expanded. Split out the respective
piece of code into a helper function, which is then invoked twice.

8 months agogas: drop SKIP_WHITESPACE_AFTER_NAME()
Jan Beulich [Mon, 14 Oct 2024 12:37:29 +0000 (14:37 +0200)] 
gas: drop SKIP_WHITESPACE_AFTER_NAME()

Exclusively all users should use restore_line_pointer() instead, at
which point SKIP_WHITESPACE() suffices as a check afterwards.

8 months agogdb: make frame_unwind_try_unwinder return bool
Guinevere Larsen [Mon, 14 Oct 2024 11:58:29 +0000 (08:58 -0300)] 
gdb: make frame_unwind_try_unwinder return bool

Before this commit, the function frame_unwind_try_unwinder would return
an int, where 1 meant the unwinder works, and 0 it doesn't. This is just
a boolean with extra steps, so this commit updates the function to
return bool instead.

8 months agoLoongArch: Fixed R_LARCH_[32/64]_PCREL generation bug
Lulu Cai [Sat, 21 Sep 2024 03:29:39 +0000 (11:29 +0800)] 
LoongArch: Fixed R_LARCH_[32/64]_PCREL generation bug

The enum BFD_RELOC_[32/64] was mistakenly used in the macro instead
of the relocation in fixp. This can cause the second relocation
of a pair to be deleted when -mthin-add-sub is enabled. Apply the
correct macro to fix this.

Also sets the initial value of -mthin-add-sub.

8 months agoAutomatic date update in version.in
GDB Administrator [Mon, 14 Oct 2024 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoFix 32110 gprofng segfaults on parsing DWARF of clang++ 18.1.3 produced binary
Vladimir Mezentsev [Thu, 10 Oct 2024 21:15:51 +0000 (14:15 -0700)] 
Fix 32110 gprofng segfaults on parsing DWARF of clang++ 18.1.3 produced binary

gprofng does not handle DW_FORM_strx1* forms correctly.

gprofng/ChangeLog
2024-10-10  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR 32110
* src/DwarfLib.cc: Handle DW_FORM_strx* forms.

8 months agoAutomatic date update in version.in
GDB Administrator [Sun, 13 Oct 2024 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoAdd to GDB manual information about building index with 'gold'
Robert Guthrie [Sat, 5 Oct 2024 04:50:52 +0000 (23:50 -0500)] 
Add to GDB manual information about building index with 'gold'

* gdb/doc/gdb.texinfo (Index Files): New subsection about building
the index using 'gold'.

Copyright-paperwork-exempt: yes

8 months agoAutomatic date update in version.in
GDB Administrator [Sat, 12 Oct 2024 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdbserver: remove declaration of init_registers_arm_with_neon
Andrew Burgess [Fri, 11 Oct 2024 12:07:18 +0000 (13:07 +0100)] 
gdbserver: remove declaration of init_registers_arm_with_neon

The last use of init_registers_arm_with_neon was removed in this
commit:

  commit 7cc17433020a62935e4d91053251fe900d83c7f0
  Date:   Fri Jul 19 15:04:48 2019 +0100

      Arm: Use read_description funcs in gdbserver

But the declaration was left around.  Remove the declaration now.

8 months agoRevert "gdbserver: pass osabi to GDB in target description"
Andrew Burgess [Fri, 11 Oct 2024 08:31:51 +0000 (09:31 +0100)] 
Revert "gdbserver: pass osabi to GDB in target description"

This reverts commit 98bcde5e268ea7cd54186c5f2c27c65103218fc3.  This
commit was causing build problems on at least sparc, ppc, and s390,
though I suspect some other targets might be impacted too.

8 months agox86: bring 64-bit-only cmdline option handling in sync
Jan Beulich [Fri, 11 Oct 2024 06:20:33 +0000 (08:20 +0200)] 
x86: bring 64-bit-only cmdline option handling in sync

--64 and --x32 are already suppressed in --help output when BFD64 is not
defined. Also avoid recognizing these options in such configurations.

8 months agobfd/ELF: drop align_file_position()
Jan Beulich [Fri, 11 Oct 2024 06:20:06 +0000 (08:20 +0200)] 
bfd/ELF: drop align_file_position()

Switch the sole user to BFD_ALIGN() instead. (It's comment was partly
wrong [stale?] anyway, talking of some maximum that was nowhere in
sight.)

8 months agobfd/ELF: restrict file alignment for object files
Jan Beulich [Fri, 11 Oct 2024 06:19:34 +0000 (08:19 +0200)] 
bfd/ELF: restrict file alignment for object files

While for executables properly aligning sections within the file can be
quite relevant, the same is of pretty little importance for relocatable
object files. Avoid passing "true" into
_bfd_elf_assign_file_position_for_section() when dealing with object
files, but compensate minimally by applying log_file_align in such
cases as a cap to the alignment put in place.

8 months agoSupport Intel AVX10.2 media instructions
Haochen Jiang [Thu, 30 Jul 2020 03:01:01 +0000 (11:01 +0800)] 
Support Intel AVX10.2 media instructions

In disassembler part, for vnni instructions, we extended previous
VEX part using %XE in disassembler to promote them to EVEX by reusing
the original VEX table. For vmpsadbw, we will also use %XE. However,
it is hard to reuse the VEX table, so we are using new ones.

In assmbler part, we put the vnni table entries with previous vnni
instructions since they are just promotion from AVX-VNNI-INT{8,16}.
Since we will prefer VEX encoding, we need to use the different table
order in template <vnni>, which prefers EVEX due to earlier introduction
for AVX512_VNNI than AVX_VNNI. This means a new <vnni>. For vdpphps
and vmpsadbw, we put them at the end of the table, with future AVX10.2
instructions.

Nit: I will remove the arch requirement for avx_vnni_int{8,16} in
evex-promote testcases after AVX10.2 implies AVX-VNNI-INT{8,16}.

gas/Changelog:

* testsuite/gas/i386/i386.exp: Add AVX10.2 tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/avx10_2-256-1-intel.d: New.
* testsuite/gas/i386/avx10_2-256-1.d: Ditto.
* testsuite/gas/i386/avx10_2-256-1.s: Ditto.
* testsuite/gas/i386/avx10_2-512-1-intel.d: Ditto.
* testsuite/gas/i386/avx10_2-512-1.d: Ditto.
* testsuite/gas/i386/avx10_2-512-1.s: Ditto.
* testsuite/gas/i386/avx10_2-promote.d: Ditto.
* testsuite/gas/i386/avx10_2-promote.s: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-256-1-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-256-1.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-256-1.s: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-512-1-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-512-1.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-512-1.s: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-promote.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-promote.s: Ditto.

opcodes/Changelog:

* i386-dis-evex-prefix.h: Adjust PREFIX_EVEX_0F3852.
Add PREFIX_EVEX_0F3A42_W_0.
* i386-dis-evex-w.h: Adjust EVEX_W_0F3A42.
* i386-dis-evex.h: Add table pass for AVX10.2
instructions.
* i386-dis.c: Adjust PREFIX_VEX_0F3850_W_0, PREFIX_VEX_0F3851_W_0,
PREFIX_VEX_0F38D2_W_0 and PREFIX_VEX_0F38D3_W_0.
* i386-opc.tbl: Add AVX10.2 instructions.
* i386-mnem.h: Regenerated.
* i386-tbl.h: Ditto.

Co-authored-by: Lili Cui <lili.cui@intel.com>
8 months agoAutomatic date update in version.in
GDB Administrator [Fri, 11 Oct 2024 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogprofng: Use $(DESTDIR) in install-examples
H.J. Lu [Thu, 10 Oct 2024 22:03:38 +0000 (06:03 +0800)] 
gprofng: Use $(DESTDIR) in install-examples

Use $(DESTDIR) in install-examples to fix

mkdir -p -- /usr/share/doc//gprofng
mkdir: cannot create directory ‘/usr/share/doc//gprofng’: Permission denied

for "make install DESTDIR=...".

* doc/Makefile.am (install-examples): Use $(DESTDIR).
* doc/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 months agogprofng: install examples to $(docdir)/gprofng
Vladimir Mezentsev [Wed, 9 Oct 2024 19:26:54 +0000 (12:26 -0700)] 
gprofng: install examples to $(docdir)/gprofng

gprofng/ChangeLog
2024-10-09  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

* doc/Makefile.am: Install gprofng examples.
* doc/Makefile.in: Rebuild.

8 months agogdbserver: pass osabi to GDB in target description
Andrew Burgess [Fri, 4 Oct 2024 18:30:04 +0000 (19:30 +0100)] 
gdbserver: pass osabi to GDB in target description

On a Windows machine I built gdbserver, configured for the target
'x86_64-w64-mingw32', then on a GNU/Linux machine I built GDB with
support for all target (--enable-targets=all).

On the Windows machine I start gdbserver with a small test binary:

  $ gdbserver 192.168.129.25:54321 C:\some\directory\executable.exe

On the GNU/Linux machine I start GDB without the test binary, and
connect to gdbserver.

As I have not given GDB the test binary, my expectation is that GDB
would connect to gdbserver and then download the file over the remote
protocol, but instead I was presented with this message:

  (gdb) target remote 192.168.129.25:54321
  Remote debugging using 192.168.129.25:54321
  warning: C:\some\directory\executable.exe: No such file or directory.
  0x00007ffa3e1e1741 in ?? ()
  (gdb)

What I found is that if I told GDB where to find the binary, like
this:

  (gdb) file target:C:/some/directory/executable.exe
  A program is being debugged already.
  Are you sure you want to change the file? (y or n) y
  Reading C:/some/directory/executable.exe from remote target...
  warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
  Reading C:/some/directory/executable.exe from remote target...
  Reading symbols from target:C:/some/directory/executable.exe...
  (gdb)

then GDB would download the executable.

I eventually tracked the problem down to exec_file_find (solib.c).
The remote target was passing an absolute Windows filename (beginning
with "C:/" in this case), but in exec_file_find GDB was failing the
IS_TARGET_ABSOLUTE_PATH call, and so was treating the filename as
relative.

The IS_TARGET_ABSOLUTE_PATH call was failing because GDB thought that
the file system kind was "unix", and as the filename didn't start with
a "/" it assumed the filename was not absolute.

But I'm connecting to a Windows target, my 'target-file-system-kind'
was set to "auto", so should be figuring out that my file-system is
"dos-based".

Looking in effective_target_file_system_kind (filesystem.c), we find
that the logic of "auto" is delegated to the current gdbarch.  However
in windows-tdep.c we see:

  set_gdbarch_has_dos_based_file_system (gdbarch, 1);

So if we are using a Windows gdbarch we should have "dos-based"
filesystems.  What this means is that after connecting to the remote
target GDB has selected the wrong gdbarch.

What's happening is that the target description sent back by the
remote target only includes the x86-64 registers.  There's no
information about which OS we're on.  As a consequence, GDB picks the
first x86-64 gdbarch which can handle the provided register set, which
happens to be a GNU/Linux gdbarch.

And indeed, there doesn't appear to be anywhere in gdbserver that sets
the osabi on the target descriptions, though some target descriptions
do have their osabi set when the description is created, e.g. in:

  gdb/arch/amd64.c - Sets GNU/Linux osabi when appropriate.
  gdb/arch/i386.c - Likewise.
  gdb/arch/tic6x.c - Always set GNU/Linux osabi.

Most target descriptions are created without an osabi, gdbserver does
nothing to fix this, and the description is returned to GDB without an
osabi included.

I propose that we always set the osabi name on the target descriptions
returned from gdbserver.  We could try to do this when the description
is first created, but that would mean passing extra flags into the
tdesc creation code (or just passing the osabi string in), and I don't
think that's really necessary.  If we consider the tdesc creation as
being about figuring out which registers are on the target, then it
makes sense that the osabi information is injected later.

So what I've done is require the osabi name to be passed to the
init_target_desc function.  This is called, I believe, for all
targets, in the gdbserver code.

Now when I connect to the Windows remote the target description
returned includes the osabi name.  With this extra information GDB
selects the correct gdbarch object, which means that GDB understands
the target has a "dos-based" file-system.  With that correct GDB
understands that the filename it was given is absolute, and so fetches
the file from the remote as we'd like.

Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
8 months agogdb/gdbserver: change shared set_tdesc_osabi to take gdb_osabi
Andrew Burgess [Tue, 8 Oct 2024 09:34:02 +0000 (10:34 +0100)] 
gdb/gdbserver: change shared set_tdesc_osabi to take gdb_osabi

There is a single declaration of set_tdesc_osabi that is shared
between gdbserver/ and gdb/, this declaration takes a 'const char *'
argument which is the string representing an osabi.

Then in gdb/ we have an overload of set_tdesc_osabi which takes an
'enum gdb_osabi'.

In this commit I change the shared set_tdesc_osabi to be the version
which takes an 'enum gdb_osabi', and I remove the version which takes
a 'const char *'.  All users of set_tdesc_osabi are updated to pass an
'enum gdb_osabi'.

The features/ code, which is generated from the xml files, requires a
new function to be added to osabi.{c,h} which can return a string
representation of an 'enum gdb_osabi'.  With that new function in
place the features/ code is regenerated.

This change is being made to support the next commit.  In the next
commit gdbserver will be updated to call set_tdesc_osabi in more
cases.  The problem is that gdbserver stores the osabi as a string.
The issue here is that a typo in the gdbserver/ code might go
unnoticed and result in gdbserver sending back an invalid osabi
string.

To fix this we want gdbserver to pass an 'enum gdb_osabi' to the
set_tdesc_osabi function.  With that requirement in place it seems to
make sense if all calls to set_tdesc_osabi pass an 'enum gdb_osabi'.

There should be no user visible changes after this commit.

Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
8 months agogdb: split osabi support between gdb/ and gdbsupport/ directories
Andrew Burgess [Tue, 8 Oct 2024 09:21:59 +0000 (10:21 +0100)] 
gdb: split osabi support between gdb/ and gdbsupport/ directories

In future commits I want to call set_tdesc_osabi from gdbserver/
code.  Currently the only version of set_tdesc_osabi available to
gdbserver takes a string representing the osabi.

The problem with this is that, having lots of calls to set_tdesc_osabi
which all take a string is an invite for a typo to slip in.  This typo
could potentially go unnoticed until someone tries to debug the wrong
combination of GDB and gdbserver, at which point GDB will fail to find
the correct gdbarch because it doesn't understand the osabi string.

It would be better if the set_tdesc_osabi calls in gdbserver could
take an 'enum gdb_osabi' value and then convert this to the "correct"
string internally.  In this way we are guaranteed to always have a
valid, known, osabi string.

This commit splits the osabi related code, which currently lives
entirely on the GDB side, between gdb/ and gdbsupport/.  I've moved
the enum definition along with the array of osabi names into
gdbsupport/.  Then all the functions that access the names list, and
which convert between names and enum values are also moved.

I've taken the opportunity of this move to add a '.def' file which
contains all the enum names along with the name strings.  This '.def'
file is then used to create 'enum gdb_osabi' as well as the array of
osabi name strings.  By using a '.def' file we know that the enum
order will always match the name string array.

This commit is just a refactor, there are no user visible changes
after this commit.  This commit doesn't change how gdbserver sets the
target description osabi string, that will come in the next commit.

Approved-By: Luis Machado <luis.machado@arm.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
8 months agogdb: make use of set_tdesc_osabi overload in features/ files
Andrew Burgess [Fri, 4 Oct 2024 18:24:32 +0000 (19:24 +0100)] 
gdb: make use of set_tdesc_osabi overload in features/ files

There are two versions of the set_tdesc_osabi function in GDB:

  void
  set_tdesc_osabi (struct target_desc *target_desc, const char *name)
  {
    set_tdesc_osabi (target_desc, osabi_from_tdesc_string (name));
  }

  void
  set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
  {
    target_desc->osabi = osabi;
  }

In the gdb/features/ files we call the second of these functions, like
this:

  set_tdesc_osabi (result.get (), osabi_from_tdesc_string ("GNU/Linux"));

This can be replaced with a call to the first set_tdesc_osabi
function, so lets do that.  I think that this makes the features/ code
slightly simpler and easier to understand.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
8 months agogdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char>
Andrew Burgess [Fri, 4 Oct 2024 17:45:04 +0000 (18:45 +0100)] 
gdbserver: make arch and osabi names gdb::unique_xmalloc_ptr<char>

Convert target_desc::arch and target_desc::osabi from 'const char*' to
gdb::unique_xmalloc_ptr<char>.  This also allows us to remove the user
defined ~target_desc destructor.

I doubt it ever actually occurred, but in theory at least, there was a
memory leak in set_tdesc_architecture and set_tdesc_osabi where the
member variables were assigned without freeing any previous
value... but I suspect that usually these fields are only set once.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
8 months ago[gdb/breakpoints] Fix gdb.base/scope-hw-watch-disable.exp on arm-linux
Tom de Vries [Thu, 10 Oct 2024 10:41:40 +0000 (12:41 +0200)] 
[gdb/breakpoints] Fix gdb.base/scope-hw-watch-disable.exp on arm-linux

On arm-linux, with test-case gdb.base/scope-hw-watch-disable.exp I run into:
...
(gdb) awatch a^M
Can't set read/access watchpoint when hardware watchpoints are disabled.^M
(gdb) PASS: $exp: unsuccessful attempt to create an access watchpoint
rwatch b^M
Can't set read/access watchpoint when hardware watchpoints are disabled.^M
(gdb) PASS: $exp: unsuccessful attempt to create a read watchpoint
continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0xf7ec82c8 in ?? () from /lib/arm-linux-gnueabihf/libc.so.6^M
(gdb) FAIL: $exp: continue until exit
...

Using "maint info break", we can see that the two failed attempts to set a
watchpoint each left behind a stale "watchpoint scope" breakpoint:
...
-5      watchpoint scope del  y   0xf7ec569a  inf 1
-5.1                          y   0xf7ec569a  inf 1
stop only in stack frame at 0xfffef4f8
-6      watchpoint scope del  y   0xf7ec569a  inf 1
-6.1                          y   0xf7ec569a  inf 1
stop only in stack frame at 0xfffef4f8
...

The SIGSEGV is a consequence of the stale "watchpoint scope" breakpoint: the
same happens if we:
- have can-use-hw-watchpoints == 1,
- set one of the watchpoints, and
- continue to exit.
The problem is missing symbol info on libc which is supposed to tell which
code is thumb.  After doing "set arm fallback-mode thumb" the SIGSEGV
disappears.

Extend the test-case to check the "maint info break" command before and after
the two failed attempts, to make sure that we catch the stale
"watchpoint scope" breakpoints also on x86_64-linux.

Fix this in watch_command_1 by moving creation of the "watchpoint scope"
breakpoint after the call to update_watchpoint.

Tested on x86_64-linux.

PR breakpoints/31860
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31860

8 months agos390: Add arch15 instructions
Andreas Krebbel [Tue, 8 Oct 2024 10:04:31 +0000 (12:04 +0200)] 
s390: Add arch15 instructions

opcodes/
* s390-mkopc.c (main) Accept arch15 as CPU string.
* s390-opc.txt: Add arch15 instructions.

include/
* opcode/s390.h (enum s390_opcode_cpu_val): Add
S390_OPCODE_ARCH15.

gas/
* config/tc-s390.c (s390_parse_cpu): New entry for arch15.
* doc/c-s390.texi: Document arch15 march option.
* doc/as.texi: Likewise.
* testsuite/gas/s390/s390.exp: Run the arch15 related tests.
* testsuite/gas/s390/zarch-arch15.d: Tests for arch15
instructions.
* testsuite/gas/s390/zarch-arch15.s: Likewise.

Signed-off-by: Andreas Krebbel <krebbel@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
8 months ago[gdb/testsuite] Fix gdb.dwarf2/enum-type-c++.exp with clang
Tom de Vries [Thu, 10 Oct 2024 06:19:26 +0000 (08:19 +0200)] 
[gdb/testsuite] Fix gdb.dwarf2/enum-type-c++.exp with clang

When running test-case gdb.dwarf2/enum-type-c++.exp with clang, we get:
...
FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent
FAIL: gdb.dwarf2/enum-type-c++.exp: print ns::A::val1
FAIL: gdb.dwarf2/enum-type-c++.exp: val2 has correct parent
FAIL: gdb.dwarf2/enum-type-c++.exp: print ns::ec::val2
...

The problem is that the debug info produced by clang does not contain any
references to enumerators val1 and val2, or the corresponding enumeration
types.

Instead, the variables u1 and u2 are considered to be simply of type int:
...
 <1><fb>: Abbrev Number: 2 (DW_TAG_variable)
    <fc>   DW_AT_name        : u1
    <fd>   DW_AT_type        : <0x106>
    <101>   DW_AT_external    : 1
    <103>   DW_AT_location    : (DW_OP_addrx <0>)
 <1><106>: Abbrev Number: 3 (DW_TAG_base_type)
    <107>   DW_AT_name        : int
    <108>   DW_AT_encoding    : 5       (signed)
    <109>   DW_AT_byte_size   : 4
 <1><10a>: Abbrev Number: 2 (DW_TAG_variable)
    <10b>   DW_AT_name        : u2
    <10c>   DW_AT_type        : <0x106>
    <110>   DW_AT_external    : 1
    <112>   DW_AT_location    : (DW_OP_addrx <0x1>)
...

Fix this by checking whether val1 and val2 are present in the cooked index
before checking whether they have the correct parent.

This cannot be expressed efficiently with gdb_test_lines, so factor out
gdb_get_lines and use that instead.

The test-case still calls "maint print objfiles" twice, but the first time is
for have_index.  We should probably use a gdb_caching_proc for this.

Tested on aarch64-linux.

Reported-By: Guinevere Larsen <guinevere@redhat.com>
Reviewed-By: Keith Seitz <keiths@redhat.com>
Tested-By: Guinevere Larsen <guinevere@redhat.com>
8 months ago[gdb/testsuite] Fix some gdb.dwarf2 test-cases for check-read1
Tom de Vries [Thu, 10 Oct 2024 05:46:06 +0000 (07:46 +0200)] 
[gdb/testsuite] Fix some gdb.dwarf2 test-cases for check-read1

I ran the testsuite in an environment simulating a stressed system in
combination with check-read1.  This exposes a few more FAILs.

Fix the gdb.dwarf2 ones by using pipe / grep to filter out unnecessary output.

Tested on x86_64-linux.

8 months agoAutomatic date update in version.in
GDB Administrator [Thu, 10 Oct 2024 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months ago[gdb/testsuite] Fix gdb.base/reggroups.exp with check-read1
Tom de Vries [Wed, 9 Oct 2024 09:17:41 +0000 (11:17 +0200)] 
[gdb/testsuite] Fix gdb.base/reggroups.exp with check-read1

On aarch64-linux, with make target check-read1, I run into:
...
(gdb) info reg vector^M
  ...
d19            {f = 0x0, u = 0x0, s = 0x0} {f =FAIL: gdb.base/reggroups.exp: fetch reggroup regs vector (timeout)
 0, u = 0, s = 0}^M
...

The problem is that while (as documented) the corresponding gdb_test_multiple
doesn't work for vector registers, it doesn't skip them either.  This causes
the timeout, and it also causes the registers after a vector register not to
be found.

Fix this by using -lbl style matching.

Make which reggroups and registers are found more explicit using verbose -log,
which makes us notice that regnames with underscores are skipped, so fix that
as well.

While we're at it, this:
...
set invalid_register_re "Invalid register .*"
...
and this:
...
       -re $invalid_register_re {
           fail "$test (unexpected invalid register response)"
       }
...
means that the prompt may or may not be consumed.  Fix this by limiting the
regexp to one line, and using exp_continue.

While we're at it, improve readability of the complex regexp matching a single
register by factoring out regexps.

Tested on aarch64-linux and x86_64-linux.

8 months agoPR32243, NAME_MAX does not exist on mingw-w64 without _POSIX_
Alan Modra [Wed, 9 Oct 2024 01:11:08 +0000 (11:41 +1030)] 
PR32243, NAME_MAX does not exist on mingw-w64 without _POSIX_

PR 32243
* dlltool.c: Move forward decls.  Delete unnecessary ones.
(bfd_errmsg): Delete macro, define as inline function.
(PATHMAX): Delete.
(NAME_MAX): Define.

8 months agoAutomatic date update in version.in
GDB Administrator [Wed, 9 Oct 2024 00:00:41 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agoUse ui-out tables in "maint print user-regs"
Tom Tromey [Thu, 3 Oct 2024 22:51:38 +0000 (16:51 -0600)] 
Use ui-out tables in "maint print user-regs"

This changes "maint print user-regs" to use ui-out tables rather than
printfs.

Approved-By: Andrew Burgess <aburgess@redhat.com>
8 months agoUse ui-out tables for info proc mappings
Tom Tromey [Thu, 3 Oct 2024 22:48:25 +0000 (16:48 -0600)] 
Use ui-out tables for info proc mappings

This changes a few implementations of "info proc mappings" to use
ui-out tables rather than printf.

Note that NetBSD and FreeBSD also use printfs here, but since I can't
test these, I didn't update them.

Approved-By: Andrew Burgess <aburgess@redhat.com>
8 months ago[gdb/testsuite] Fix gdb.base/break-interp.exp with check-read1
Tom de Vries [Tue, 8 Oct 2024 20:31:12 +0000 (22:31 +0200)] 
[gdb/testsuite] Fix gdb.base/break-interp.exp with check-read1

When running test-case gdb.base/break-interp.exp with check-read1, I run into:
...
(gdb) info files^M
  ...
0x00007ffff7e75980 - 0x00007ffff7e796a0 @ 0x001f1970 is .bss in /data/vries/gdb/leap-15-5/build/gdb/testsuite/outputs/gdb.base/break-interp/break-interp-BINprelinkNOdebugNOFAIL: gdb.base/break-interp.exp: ldprelink=NO: ldsepdebug=NO: binprelink=NO: binsepdebug=NO: binpie=NO: INNER: symbol-less: info files (timeout)
pieNO.d/libc.so.6^M
...

The code has two adaptations to deal with the large output:
- nested gdb_test_multiple, and
- an exp_continue in the inner gdb_test_multiple.

The former seems unnecessary, and the latter doesn't trigger often enough
because of an incomplete hex number regexp, causing the timeout.

Get rid of both of these, and use -lbl instead.

Tested on x86_64-linux.

8 months agogdb: include --enable-targets in 'show configuration' output
Andrew Burgess [Sat, 5 Oct 2024 11:34:14 +0000 (12:34 +0100)] 
gdb: include --enable-targets in 'show configuration' output

Include the value of configuration flag --enable-targets in the output
of GDB command 'show configuration' and also in the output printed for
'gdb --configuration'.  This will make it easier to see how GDB was
built.

No tests added or updated as we can't really check for a specific flag
appearing or not appearing on the configuration output.  But we do
print the configuration within lib/gdb.exp to check which features are
built into GDB, so if this change broke configuration printing then
plenty of tests should stop working (they don't).

Approved-By: Tom Tromey <tom@tromey.com>
8 months agogdb: avoid breakpoint::clear_locations calls in update_breakpoint_locations
Andrew Burgess [Mon, 23 Sep 2024 14:22:58 +0000 (15:22 +0100)] 
gdb: avoid breakpoint::clear_locations calls in update_breakpoint_locations

The commit:

  commit 6cce025114ccd0f53cc552fde12b6329596c6c65
  Date:   Fri Mar 3 19:03:15 2023 +0000

      gdb: only insert thread-specific breakpoints in the relevant inferior

added a couple of calls to breakpoint::clear_locations() inside
update_breakpoint_locations().

The intention of these calls was to avoid leaving redundant locations
around when a thread- or inferior-specific breakpoint was switched
from one thread or inferior to another.

Without the clear_locations() calls the tests gdb.multi/tids.exp and
gdb.multi/pending-bp.exp have some failures.  A b/p is changed such
that the program space it is associated with changes.  This triggers a
call to breakpoint_re_set_one() but the FILTER_PSPACE argument will be
the new program space.  As a result GDB correctly calculates the new
locations and adds these to the breakpoint, but the old locations, in
the old program space, are incorrectly retained.  The call to
clear_locations() solves this by deleting the old locations.

However, while working on another patch I realised that the approach
taken here is not correct.  The FILTER_PSPACE argument passed to
breakpoint_re_set_one() and then on to update_breakpoint_locations()
might not be the program space to which the breakpoint is associated.
Consider this example:

  (gdb) file /tmp/hello.x
  Reading symbols from /tmp/hello.x...
  (gdb) start
  Temporary breakpoint 1 at 0x401198: file hello.c, line 18.
  Starting program: /tmp/hello.x

  Temporary breakpoint 1, main () at hello.c:18
  18   printf ("Hello World\n");
  (gdb) break main thread 1
  Breakpoint 2 at 0x401198: file hello.c, line 18.
  (gdb) info breakpoints
  Num     Type           Disp Enb Address            What
  2       breakpoint     keep y   0x0000000000401198 in main at hello.c:18
   stop only in thread 1
  (gdb) add-inferior -exec /tmp/hello.x
  [New inferior 2]
  Added inferior 2 on connection 1 (native)
  Reading symbols from /tmp/hello.x...
  (gdb) info breakpoints
  Num     Type           Disp Enb Address    What
  2       breakpoint     keep y   <PENDING>  main
   stop only in thread 1.1

Notice that after creating the second inferior and loading a file the
thread-specific breakpoint was incorrectly made pending.  Loading the
exec file in the second inferior triggered a call to
breakpoint_re_set() with the new, second, program space as the
current_program_space.

This program space ends up being passed to
update_breakpoint_locations().

In update_breakpoint_locations this condition is true:

  if (all_locations_are_pending (b, filter_pspace) && sals.empty ())

and so we end up discarding all of the locations for this breakpoint,
making the breakpoint pending.

What we really want to do in update_breakpoint_locations() is, for
thread- or inferior- specific breakpoints, delete any locations which
are associated with a program space that this breakpoint is NOT
associated with.

But then I realised the answer was easier than that.

The ONLY time that a b/p can have locations associated with the
"wrong" program space like this is at the moment we change the thread
or inferior the b/p is associated with by calling
breakpoint_set_thread() or breakpoint_set_inferior().

And so, I think the correct solution is to hoist the call to
clear_locations() out of update_breakpoint_locations() and place a
call in each of the breakpoint_set_{thread,inferior} functions.

I've done this, and added a couple of new tests.  All of which are
now passing.

Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with read1+readnow
Tom de Vries [Tue, 8 Oct 2024 11:45:21 +0000 (13:45 +0200)] 
[gdb/testsuite] Fix gdb.ada/tagged-lookup.exp with read1+readnow

When running test-case gdb.ada/tagged-lookup.exp with target board readnow and
make target check-read1:
...
$ ( cd build/gdb; \
    make check-read1 \
      RUNTESTFLAGS="--target_board=readnow gdb.ada/tagged-lookup.exp" )
...
I run into:
...
(gdb) PASS: gdb.ada/tagged-lookup.exp: set debug symtab-create 1
print *the_local_var^M
$1 = (n => 2)^M
(gdb) FAIL: gdb.ada/tagged-lookup.exp: only one CU expanded
...

The problem is that the corresponding gdb_test_multiple uses line-by-line
matching (using -lbl) which doesn't work well with the multiline pattern
matching both the prompt and the line before it:
...
    -re -wrap ".* = \\\(n => $decimal\\\)" {
...

Fix this by making it a one-line pattern:
...
    -re -wrap "" {
...

While we're at it, replace an if-then-pass-else-fail with a gdb_assert.

Tested on aarch64-linux.

8 months ago[gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types
Tom de Vries [Tue, 8 Oct 2024 10:27:20 +0000 (12:27 +0200)] 
[gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types

When running test-case gdb.dwarf2/enum-type-c++.exp with target board
cc-with-debug-types, we run into:
...
(gdb) FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent
...
because val1 has no parent:
...
    [31] ((cooked_index_entry *) 0x7efedc002e90)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xef
    parent:     ((cooked_index_entry *) 0)

  ...

    [37] ((cooked_index_entry *) 0x38ffd280)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0xef
    parent:     ((cooked_index_entry *) 0)
...

There are two entries, which seems to be an inefficiency, but for now let's
focus on the correctness issue.

The debug info for val1 looks like this:
...
 <1><cb>: Abbrev Number: 2 (DW_TAG_namespace)
    <cc>   DW_AT_name        : ns
    <cf>   DW_AT_declaration : 1
 <2><d3>: Abbrev Number: 12 (DW_TAG_class_type)
    <d4>   DW_AT_name        : A
    <d6>   DW_AT_declaration : 1
 <3><d6>: Abbrev Number: 13 (DW_TAG_enumeration_type)
    <db>   DW_AT_declaration : 1
 <1><dd>: Abbrev Number: 14 (DW_TAG_enumeration_type)
    <e7>   DW_AT_specification: <0xd6>
 <2><ef>: Abbrev Number: 5 (DW_TAG_enumerator)
    <f0>   DW_AT_name        : val1
    <f4>   DW_AT_const_value : 1
...

Fix this by:
- adding a cooked index entry for DIE 0xcb (and consequently for child DIE
  0xd3), by marking it interesting,
- making sure that the entry for DIE 0xcb has a name, and
- using the entry for DIE 0xd3 as parent entry for DIE 0xdd.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/symtab] Fix parent of enumerator
Tom de Vries [Tue, 8 Oct 2024 10:27:20 +0000 (12:27 +0200)] 
[gdb/symtab] Fix parent of enumerator

As mentioned in commit 489b82720f5 ('[gdb/symtab] Revert "Change handling of
DW_TAG_enumeration_type in DWARF scanner"'), when doing "maint print objfiles" in
test-case gdb.dwarf2/enum-type.exp, for val1 we get an entry without parent:
...
    [27] ((cooked_index_entry *) 0x7fbbb4002ef0)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0x124
    parent:     ((cooked_index_entry *) 0)
...

This happens here in cooked_indexer::index_dies:
...
      info_ptr = recurse (reader, info_ptr,
  is_enum_class ? this_entry : parent_entry,
  fully);
...
when we're passing down a nullptr parent_entry, while the parent of this_entry
is deferred.

Fix this in cooked_indexer::index_dies by passing down a deffered parent
instead, such that we get:
...
    [27] ((cooked_index_entry *) 0x7ff0e4002ef0)^M
    name:       val1^M
    canonical:  val1^M
    qualified:  ns::val1^M
    DWARF tag:  DW_TAG_enumerator^M
    flags:      0x0 []^M
    DIE offset: 0x124^M
    parent:     ((cooked_index_entry *) 0x7ff0e4002f20) [ns]^M
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
8 months ago[gdb/contrib] Fix "sofar->so far" misspelling
Tom de Vries [Tue, 8 Oct 2024 06:24:13 +0000 (08:24 +0200)] 
[gdb/contrib] Fix "sofar->so far" misspelling

I forgot to follow up on a review comment and fix the "sofar->so far"
misspelling [1].

Fix this by adding it to gdb/contrib/common-misspellings.txt.

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2024-September/211894.html

8 months ago[gdb/contrib] Add more separators in spellcheck.sh
Tom de Vries [Tue, 8 Oct 2024 06:24:13 +0000 (08:24 +0200)] 
[gdb/contrib] Add more separators in spellcheck.sh

Add two more separators in spellcheck.sh: colon and comma.

Doing so triggers the "inbetween->between" rule, which gives an incorrect
result.  Override this with "inbetween->between, in between, in-between" [1],
in a new file gdb/contrib/common-misspellings.txt.

Fix the following common misspellings:
...
everytime -> every time
sucess -> success
thru -> through
transfered -> transferred
inbetween -> between, in between, in-between
...

Verified with spellcheck.sh.  Tested on x86_64-linux.

[1] https://www.grammarly.com/blog/commonly-confused-words/in-between-or-inbetween/

8 months ago[gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh
Tom de Vries [Tue, 8 Oct 2024 06:24:13 +0000 (08:24 +0200)] 
[gdb/contrib] Factor out grep_or and sed_or in spellcheck.sh

While trying to add more separators here:
...
 # Separators: space, slash, tab.
 grep_separator=" |/| "
 sed_separator=" \|/\|\t"
...
I mistakingly used "|" instead of "\|" in sed_separator.

Factor out new variables grep_or and sed_or, and construct the grep_separator
and sed_separator variables by joining the elements of a list using grep_or
and sed_or.

Verified with shellcheck, and tested by rerunning on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
8 months agoRevised "Don't return (null) from bfd_elf_sym_name"
Alan Modra [Mon, 7 Oct 2024 23:35:39 +0000 (10:05 +1030)] 
Revised "Don't return (null) from bfd_elf_sym_name"

Commit 68bbe1183379 results in a lot of follow up work, much of which
likely is still to be done. (And yes, since this is all for corrupted
or fuzzed object files, a whole lot of work doesn't much benefit
anyone.  It was a bad idea to put NULL in asymbol->name.)  So I'm
changing the approach to instead put a unique empty string for symbols
with a corrupted st_name.  An empty string won't require much work to
ensure nm, objcopy, objdump etc. won't crash, since these tools
already must work with unnamed local symbols.

The unique empty string is called bfd_symbol_error_name.  This patch
uses that name string for corrupted symbols in the ELF and COFF
backends.  Such symbols are displayed by nm and objdump as the
translated string "<corrupt>", which is what the COFF backend used to
put directly into corrupted symbols.

ie. it's the way I should have written the original patch, plus a few
tides and cleanups I retained from the reverted patches.

8 months agoRevert "Don't return "(null)" from bfd_elf_sym_name"
Alan Modra [Mon, 7 Oct 2024 23:21:37 +0000 (09:51 +1030)] 
Revert "Don't return "(null)" from bfd_elf_sym_name"

This reverts commit 68bbe118337939aa0b52e007a7415c8a157579a1.

8 months agoRevert "bfd_elf_sym_name_raw"
Alan Modra [Mon, 7 Oct 2024 23:21:01 +0000 (09:51 +1030)] 
Revert "bfd_elf_sym_name_raw"

This reverts commit 265757dc6e4d011a1b33ef1b3bfcd7f100f12f64.

8 months agoRevert "get_synthetic_symtab fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:19:26 +0000 (09:49 +1030)] 
Revert "get_synthetic_symtab fixes for commit 68bbe1183379"

This reverts commit 0c13ac533e59589793ee6c8045cff98663f3ea85.

8 months agoRevert "is_target_special_symbol fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:19:14 +0000 (09:49 +1030)] 
Revert "is_target_special_symbol fixes for commit 68bbe1183379"

This reverts commit 6e40f9bb31be2f3656df97a1fcba4d6a30081e24.

8 months agoRevert "dlltool fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:18:27 +0000 (09:48 +1030)] 
Revert "dlltool fixes for commit 68bbe1183379"

This reverts commit 06116013f80e474800cfb122924bc2a6f060606a.

8 months agoRevert "elf.c and elflink.c fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:18:08 +0000 (09:48 +1030)] 
Revert "elf.c and elflink.c fixes for commit 68bbe1183379"

This reverts commit 389fdfbe0d2aca0af1431ddf34704534dacc48c8.

8 months agoRevert "objcopy fixes for commit 68bbe1183379"
Alan Modra [Mon, 7 Oct 2024 23:17:47 +0000 (09:47 +1030)] 
Revert "objcopy fixes for commit 68bbe1183379"

This reverts commit ef166f451fbc2c7b251a251ab23cd35b36c5ee23.

8 months agoRISC-V: Fix implicit dependency of Zabha and Zacas
Xiao Zeng [Tue, 8 Oct 2024 01:10:35 +0000 (09:10 +0800)] 
RISC-V: Fix implicit dependency of Zabha and Zacas

1 Zabha depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zabha.adoc>

2 Zacas depends on Zaamo:
<https://github.com/riscv/riscv-isa-manual/blob/main/src/zacas.adoc>

bfd/ChangeLog:

* elfxx-riscv.c: Zabha and Zacas implicitly depend on Zaamo.

gas/ChangeLog:

* testsuite/gas/riscv/imply.d: Updated.

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
8 months agogprofng: add hardware counters for Neoverse-N1 and Ampere-1 processors
Vladimir Mezentsev [Fri, 4 Oct 2024 02:18:08 +0000 (19:18 -0700)] 
gprofng: add hardware counters for Neoverse-N1 and Ampere-1 processors

gprofng/ChangeLog
2024-10-03  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>.

* common/hwc_cpus.h: New constant for Neoverse-N1 and Ampere-1.
* common/hwctable.c: Add the hwc table for Neoverse-N1 and Ampere-1.
* src/hwc_arm_ampere_1.h: New file with hwc table for Ampere-1.
* src/hwc_arm_neoverse_n1.h: New file with hwc table for Neoverse-N1.

8 months agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Oct 2024 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agom68k: Support for jump visualization in disassembly
Andreas Schwab [Thu, 13 Jun 2024 17:41:13 +0000 (19:41 +0200)] 
m68k: Support for jump visualization in disassembly

opcodes/
* m68k-dis.c (m68k_opcode_to_insn_type): Define.
(match_insn_m68k): Call it to set insn_type.
(print_insn_arg) [case 'B']: Set branch target address.
(print_insn_m68k): Set insn_info_valid.

8 months ago[gdb/testsuite] Fix gdb.python/py-inferior.exp with -fsanitize=thread
Tom de Vries [Mon, 7 Oct 2024 08:44:45 +0000 (10:44 +0200)] 
[gdb/testsuite] Fix gdb.python/py-inferior.exp with -fsanitize=thread

With a gdb build with -fsanitize=thread, and test-case
gdb.python/py-inferior.exp I run into:
...
(gdb) python gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)^M
ERROR: ThreadSanitizer: requested allocation size 0xffffffffffffffff exceeds \
  maximum supported size of 0x10000000000^M
...

There's already a workaround for this using ASAN_OPTIONS, and apparently the
same is needed for TSAN_OPTIONS.

Add the allocator_may_return_null=1 workaround also in TSAN_OPTIONS.

Likewise in gdb.dap/memory.exp.

Tested on x86_64-linux.

8 months agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Oct 2024 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb/m2: add builtin procedure function ADR
Gaius Mulley [Sun, 6 Oct 2024 19:40:59 +0000 (20:40 +0100)] 
gdb/m2: add builtin procedure function ADR

This patch introduces ADR to the Modula-2 language interface.
It return the address of the parameter supplied.
The patch also contains a dejagnu test for ADR.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
8 months agogdb/MAINTAINERS: update my email address
Gaius Mulley [Sun, 6 Oct 2024 19:08:04 +0000 (20:08 +0100)] 
gdb/MAINTAINERS: update my email address

Sync the maintainers file with my new email address.

8 months ago[gdb] Rerun spellcheck.sh
Tom de Vries [Sun, 6 Oct 2024 06:07:31 +0000 (08:07 +0200)] 
[gdb] Rerun spellcheck.sh

Fix the following common misspellings:
...
completetion -> completion
inital -> initial
...

8 months ago[gdb] Fix more common misspellings
Tom de Vries [Sun, 6 Oct 2024 05:59:48 +0000 (07:59 +0200)] 
[gdb] Fix more common misspellings

Fix the following common misspellings:
...
addres -> address, adders
behavour -> behavior, behaviour
intented -> intended, indented
ther -> there, their, the
throught -> thought, through, throughout
...

Tested on x86_64-linux.

8 months ago[gdb] Fix common misspellings
Tom de Vries [Sun, 6 Oct 2024 05:59:48 +0000 (07:59 +0200)] 
[gdb] Fix common misspellings

Fix the following common misspellings:
...
accidently -> accidentally
additonal -> additional
addresing -> addressing
adress -> address
agaisnt -> against
albiet -> albeit
arbitary -> arbitrary
artifical -> artificial
auxillary -> auxiliary
auxilliary -> auxiliary
bcak -> back
begining -> beginning
cannonical -> canonical
compatiblity -> compatibility
completetion -> completion
diferent -> different
emited -> emitted
emiting -> emitting
emmitted -> emitted
everytime -> every time
excercise -> exercise
existance -> existence
fucntion -> function
funtion -> function
guarentee -> guarantee
htis -> this
immediatly -> immediately
layed -> laid
noone -> no one
occurances -> occurrences
occured -> occurred
originaly -> originally
preceeded -> preceded
preceeds -> precedes
propogate -> propagate
publically -> publicly
refering -> referring
substract -> subtract
substracting -> subtracting
substraction -> subtraction
taht -> that
targetting -> targeting
teh -> the
thier -> their
thru -> through
transfered -> transferred
transfering -> transferring
upto -> up to
vincinity -> vicinity
whcih -> which
whereever -> wherever
wierd -> weird
withing -> within
writen -> written
wtih -> with
doesnt -> doesn't
...

Tested on x86_64-linux.

8 months ago[gdb/contrib] Add spellcheck.sh
Tom de Vries [Sun, 6 Oct 2024 05:59:48 +0000 (07:59 +0200)] 
[gdb/contrib] Add spellcheck.sh

I came across a table containing common misspellings [1], and wrote a script to
detect and correct these misspellings.

The table also contains entries that have alternatives, like this:
...
addres->address, adders
...
and for those the script prints a TODO instead.

The script downloads the webpage containing the table, extracts the table and
caches it in .git/wikipedia-common-misspellings.txt to prevent downloading it
over and over again.

Example usage:
...
$ gdb/contrib/spellcheck.sh gdb*
...

ChangeLog files are silently skipped.

Checked with shellcheck.

Tested on x86_64-linux, by running it on the gdb* dirs on doing a build and
test run.

The results of running it are in the two following patches.

Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
[1] https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines

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

8 months agoobjcopy fixes for commit 68bbe1183379
Alan Modra [Sat, 5 Oct 2024 01:26:20 +0000 (10:56 +0930)] 
objcopy fixes for commit 68bbe1183379

* objcopy.c (is_specified_symbol): Handle NULL name.
(filter_symbols): Drop syms with a NULL name.

8 months agoelf.c and elflink.c fixes for commit 68bbe1183379
Alan Modra [Sat, 5 Oct 2024 01:09:17 +0000 (10:39 +0930)] 
elf.c and elflink.c fixes for commit 68bbe1183379

Plus some tidies to swap_out_syms.

* elf.c (swap_out_syms): Handle NULL sym name.  Use correct type
for return of _bfd_elf_strtab_add.  Simplify.
* elflink.c (bfd_elf_match_symbols_in_sections): Handle NULL
sym name.

8 months agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Oct 2024 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb segv in elfread.c:elf_rel_plt_read
Alan Modra [Thu, 3 Oct 2024 22:17:05 +0000 (07:47 +0930)] 
gdb segv in elfread.c:elf_rel_plt_read

After commit 68bbe1183379, ELF symbols read via bfd_canonicalize_symtab
and similar functions which have bad st_name fields will have NULL in
the name rather than "(null)".  gdb.base/bfd-errors.exp deliberately
creates a faulty shared library with st_name pointing outside of
.dynsym for some symbols, and thus now results in NULL symbol names.
This triggers a segv on string_buffer.assign(name).  Fix that.

8 months agodlltool fixes for commit 68bbe1183379
Alan Modra [Fri, 4 Oct 2024 12:22:53 +0000 (21:52 +0930)] 
dlltool fixes for commit 68bbe1183379

For some reason, dlltool supports mcore-elf input files.

* dlltool.c (filter_symbols): Drop symbols with NULL names.
(identify_member_contains_symname): Don't consider symbols
with NULL names.

8 months agois_target_special_symbol fixes for commit 68bbe1183379
Alan Modra [Fri, 4 Oct 2024 07:34:59 +0000 (17:04 +0930)] 
is_target_special_symbol fixes for commit 68bbe1183379

* elf.c (_bfd_elf_is_local_label_name): Don't segv on NULL name.
* elf32-v850.c (v850_elf_is_local_label_name): Likewise.
* elfnn-riscv.c (riscv_elf_is_target_special_symbol): Likewise.

8 months agoget_synthetic_symtab fixes for commit 68bbe1183379
Alan Modra [Fri, 4 Oct 2024 04:00:09 +0000 (13:30 +0930)] 
get_synthetic_symtab fixes for commit 68bbe1183379

Given that relocation symbol name can now be NULL for ELF, adjust
various get_synthetic_symtab routines so they don't segfault.

* elf.c (_bfd_elf_get_synthetic_symtab): Cope with sym->name
possibly being NULL.
* elf32-arm.c (elf32_arm_get_synthetic_symtab): Likewise.
* elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise.
* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise.
* elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise.
* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Likewise.

8 months agobfd_elf_sym_name_raw
Alan Modra [Fri, 4 Oct 2024 07:07:35 +0000 (16:37 +0930)] 
bfd_elf_sym_name_raw

Many uses of bfd_elf_sym_name report errors.  They ought to not return
a NULL, as was the case prior to commit 68bbe1183379.  Introduce a new
function for cases where we'd like to know there is a problem with a
symbol st_name.

* elf-bfd.h  (bfd_elf_sym_name_raw): Declare.
* elf.c (bfd_elf_sym_name_raw): New function.
(bfd_elf_sym_name): Revert to behaviour prior to 68bbe1183379,
but returning "<null>" rather than "(null)" for st_name errors.
(group_signature): Use bfd_elf_sym_name_raw.
* elfcode.h (elf_slurp_symbol_table): Likewise.
* elf32-i386.c (elf_i386_scan_relocs): Whitespace.

8 months agogas: hide emulation struct format_ops instances when not needed
Jan Beulich [Fri, 4 Oct 2024 07:42:45 +0000 (09:42 +0200)] 
gas: hide emulation struct format_ops instances when not needed

Most targets don't even support emulations, so this data (and certain
functions) are entirely dead code for them.

8 months agox86: prune OBJ_MAYBE_... uses
Jan Beulich [Fri, 4 Oct 2024 07:42:13 +0000 (09:42 +0200)] 
x86: prune OBJ_MAYBE_... uses

With the removal of emulations, OBJ_MAYBE_... can no longer be defined.
Tidy code wherever they're used, which also includes the dropping of
most IS_ELF and uses and checks of OUTPUT_FLAVOR.

Where touching such constructs anyway, also drop TE_PEP checks when used
together with TE_PE ones (the former implies the latter).

8 months agox86: drop largely defunct gas emulations
Jan Beulich [Fri, 4 Oct 2024 07:41:38 +0000 (09:41 +0200)] 
x86: drop largely defunct gas emulations

Both ELF and COFF have various sub-flavors, each of which would then
require its own emulation: Right now when configuring a COFF/PE
secondary target (with perhaps an ELF primary one), one gets plain COFF
emulation rather than COFF/PE one.

As such a multitude of emulations would be unwieldy (and likely fragile)
drop gas emulations altogether instead.

8 months agoinclude: de-duplicate i386.h and x86_64.h
Jan Beulich [Fri, 4 Oct 2024 07:39:36 +0000 (09:39 +0200)] 
include: de-duplicate i386.h and x86_64.h

Move common definitions to a new x86.h, thus allowing gas'es obj-coff.h
to include just that, getting rid of a TE_PEP compile-time dependency.

8 months agogas: drop generate_asm_lineno emulation hook
Jan Beulich [Fri, 4 Oct 2024 07:38:05 +0000 (09:38 +0200)] 
gas: drop generate_asm_lineno emulation hook

It's not wired up, so can't be used.

8 months agogas: don't use COFF-specific SF_SET_LOCAL() directly from read.c
Jan Beulich [Fri, 4 Oct 2024 07:37:37 +0000 (09:37 +0200)] 
gas: don't use COFF-specific SF_SET_LOCAL() directly from read.c

Make this a proper obj-format hook instead.

8 months agogas/dw2gencfi: correct .sframe section conditional
Jan Beulich [Fri, 4 Oct 2024 07:36:56 +0000 (09:36 +0200)] 
gas/dw2gencfi: correct .sframe section conditional

While originally this was in preparation of a subsequent change making
SUPPORT_FRAME_LINKONCE potentially dependent on a global variable, the
construct appears unlikely to have been correct in the first place: The
variable would have been passed reliably uninitialized when
SUPPORT_FRAME_LINKONCE is build-time true.

While there correct indentation of the parameters passed to
get_cfi_seg().

8 months agogas: put emul decls in emul.h
Jan Beulich [Fri, 4 Oct 2024 07:36:24 +0000 (09:36 +0200)] 
gas: put emul decls in emul.h

The individual struct emulation instances shouldn't be declared in a .c
file; it and the producers of the symbols want to both see the
declarations, so declarations and definitions don't go out of sync. Move
these declarations to emul.h.

While there also adjust the conditional around this_format: That symbol
is never #define-d anywhere, and it's needed only when USE_EMULATIONS is
defined. (Really, when obj-multi isn't in use, it also is effectively
only ever written to.)

8 months agogas: drop unused fields from struct emulation
Jan Beulich [Fri, 4 Oct 2024 07:35:56 +0000 (09:35 +0200)] 
gas: drop unused fields from struct emulation

Neither .match not .bfd_name appear to ever have been used in the last
about 25 years. Purge them.

8 months agoMAINTAINERS: move M R Swami Reddy to Past Maintainers
Jan Beulich [Fri, 4 Oct 2024 07:34:11 +0000 (09:34 +0200)] 
MAINTAINERS: move M R Swami Reddy to Past Maintainers

He/she cannot be reached at the given address anymore, and the name is
apparently too common to identify the person to attempt to establish
another contact. Sadly this orphans the CR16 and CRx ports.

8 months agoMAINTAINERS: move Matt Thomas to Past Maintainers
Jan Beulich [Fri, 4 Oct 2024 07:33:49 +0000 (09:33 +0200)] 
MAINTAINERS: move Matt Thomas to Past Maintainers

Matt cannot be reached at the @netbsd.org address anymore, and I was
unable to find another one, even with the help of the NetBSD community
(where his resigning was announced over 4 years ago [1]).

[1] http://mail-index.netbsd.org/netbsd-announce/2020/05/07/msg000314.html

8 months agoAutomatic date update in version.in
GDB Administrator [Fri, 4 Oct 2024 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogdb-dap: disable events when deleting breakpoints
oltolm [Sat, 28 Sep 2024 09:35:04 +0000 (11:35 +0200)] 
gdb-dap: disable events when deleting breakpoints

when I disable a breakpoint in VS Code the breakpoint is removed
instead. I compared the behavior to lldb-dap and disabled events when
removing a breakpoint. Now it is possible to disable and enable
breakpoints in VS Code.

8 months agobfd: fix unnecessary bfd.info regen
Alexey Izbyshev [Wed, 2 Oct 2024 19:58:08 +0000 (22:58 +0300)] 
bfd: fix unnecessary bfd.info regen

When building from an unmodified release tarball, a REGEN_TEXI
invocation is supposed to create a symlink to the .texi file
in the source directory and discard the newly generated .tmp file.
However, after commit bd32be01c997 ("bfd: merge doc subdir up a level")
it creates the symlink at the wrong level, and then a .texi with
a fresh timestamp, which in turn forces bfd.info regeneration.
This breaks builds in environments without makeinfo program.

Fix this by creating the symlink at the level of the target stamp.

Fixes: bd32be01c997 ("bfd: merge doc subdir up a level")
Signed-off-by: Alexey Izbyshev <izbyshev@ispras.ru>
8 months agopeicode.h formatting
Alan Modra [Wed, 2 Oct 2024 21:36:32 +0000 (07:06 +0930)] 
peicode.h formatting

Fix some overlong line, comment block style, whitespace issues.

8 months agoEnable dlltool --leading-underscore for targets other than x86
Alan Modra [Wed, 2 Oct 2024 05:09:02 +0000 (14:39 +0930)] 
Enable dlltool --leading-underscore for targets other than x86

This also makes the dlltool tests run more PE targets, finding that
sh-pe dlltool reports "Machine 'sh' not supported".  I guess no one
cares about that.

PR19459
* dlltool.c (asm_prefix): Remove "mach" parameter.  Return
leading_underscore independent of machine.
(ASM_PREFIX): Adjust.
* testsuite/binutils-all/dlltool.exp: Run on any target
satisfying is_pecoff_format for which dlltool is built.
Revert commit 0398b8d6c86a.  Remove target_xfail.

8 months agodlltool leading_underscore
Alan Modra [Wed, 2 Oct 2024 05:04:35 +0000 (14:34 +0930)] 
dlltool leading_underscore

This patch tidies dlltool code dealing with adding a leading
underscore to generated symbol names.  There should be no functional
change here, but there could be if we ever have a bfd target with
symbol_leading_char something other than '_' or 0.

* dlltool.c (leading_underscore): Change from an int to a
        char*.  Update all uses.  If neither --leading-underscore or
        --no=leading-underscore is given, set leading_underscore to a
        string with first char returned by bfd_get_target_info as the
        target's symbol underscoring.

8 months agonm: don't try to print line numbers for symbols without names
Alan Modra [Tue, 1 Oct 2024 23:32:16 +0000 (09:02 +0930)] 
nm: don't try to print line numbers for symbols without names

It doesn't make much sense trying to print line numbers for what are
usually broken symbols, and there is a possibility of a segfault if
we pass strcmp a NULL.

8 months agoDon't return "(null)" from bfd_elf_sym_name
Alan Modra [Tue, 1 Oct 2024 04:38:08 +0000 (14:08 +0930)] 
Don't return "(null)" from bfd_elf_sym_name

A NULL return from bfd_elf_string_from_elf_section indicates an error.
That shouldn't be masked by bfd_elf_sym_name but rather passed up to
callers such as group_signature.  If we want to print "(null)" then
that should be done at a higher level.  That's what this patch does,
except that I chose to print "<null>" instead, like readelf.  If we
see "(null)" we're probably passing a NULL to printf.  I haven't
changed aoutx.h or pdp11.c print_symbol functions because they already
handle NULL names by omitting the name.  I also haven't changed
mach-o.c, mmo.c, som.c, srec.c, tekhex.c, vms-alpha.c and
wasm-module.c print_symbol function because it looks like they will
never have NULL symbol names.

bfd/
* elf.c (bfd_elf_sym_name): Don't turn a NULL name into a
pointer to "(null)".
(bfd_elf_print_symbol): Print "<null>" for NULL symbol names.
* coffgen.c (coff_print_symbol): Likewise.
* ecoff.c (_bfd_ecoff_print_symbol): Likewise.
* pef.c (bfd_pef_print_symbol): Likewise.
* syms.c (bfd_symbol_info): Return "<null>" in symbol_info.name
if symbol name is NULL.
ld/
* ldlang.c (ld_is_local_symbol): Don't check for "(null)"
symbol name.

8 months agoAutomatic date update in version.in
GDB Administrator [Thu, 3 Oct 2024 00:00:21 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 months agogprofng: fix a problem with hardware event counters
Ruud van der Pas [Tue, 24 Sep 2024 19:54:54 +0000 (19:54 +0000)] 
gprofng: fix a problem with hardware event counters

Fix a bug where an experiment with hardware event counter data
causes the source and disassembly files not to be generated.
No longer suppress zero valued metrics and change the name
of the man page in a warning message. Adapt line lengths to
not exceed 79.

gprofng/ChangeLog
2024-09-24  Ruud van der Pas  <ruud.vanderpas@oracle.com>

PR 32193
PR 32199
PR 32201
* gp-display-html/gp-display-html.in: Implement all
the above changes.