Commit Graph

122657 Commits

Author SHA1 Message Date
Pietro Monteiro
eec64e3f6d sim: ppc: use correct macros
AC_STRUCT_ST_* are the names of the autoconf macros, the C
preprocessor macros defined by autoconf/authoeader are
HAVE_STRUCT_STAT_ST_*.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-07-04 21:44:21 -04:00
Pietro Monteiro
3960e5b824 sim: configury: fix obsolete macros
Running `autoreconf -vf -Wall' in the sim directory shows errors about the use
of obsolete macros.  This patch fix the issues with macros used or defined in
the sim directory.  However, it doesn't fix all warnings.  There's 1 autoconf
warning  from `config/pkg.m4', and many automake warnings about target
shadowing.  It cuts a lot of the noise down and makes an upgrade to
autoconf 2.71+ easier.

- Replace AC_CANONICAL_SYSTEM by AC_CANONICAL_TARGET
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fCANONICAL_005fSYSTEM-1997

- Replace AC_TRY_COMPILE by AC_COMPILE_IFELSE
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fTRY_005fCOMPILE-2203

- Replace AC_ERROR by AC_MSG_ERROR
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fERROR-2034

- Remove AC_TYPE_SIGNAL and replace `RETSIGTYPE' by `void' in the source
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fTYPE_005fSIGNAL-2213

- Remove AC_STRUCT_ST_BLKSIZE, it's already covered by a AC_CHECK_MEMBERS call
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fSTRUCT_005fST_005fBLKSIZE-2176

- Remove AC_STRUCT_ST_RDEV, it's already covered by a AC_CHECK_MEMBERS call
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Obsolete-Macros.html#index-AC_005fSTRUCT_005fST_005fRDEV-2180

- Remove AC_STRUCT_ST_BLOCKS.  It is not obsolete, but it's already covered by a
AC_CHECK_MEMBERS call.

- Replace deprecated C macros HAVE_ST_${MEMBER} by HAVE_STRUCT_STAT_ST_${MEMBER}
  https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/
Particular-Structures.html#index-AC_005fSTRUCT_005fST_005fBLOCKS-693

Approved-By: Tom Tromey <tom@tromey.com>
2025-07-04 21:13:13 -04:00
Pietro Monteiro
f4dfd7625a gdb: add Pietro Monteiro to gdb/MAINTAINERS 2025-07-04 20:46:02 -04:00
GDB Administrator
bf3748a157 Automatic date update in version.in 2025-07-05 00:01:07 +00:00
Jan Beulich
42c97689a5 gas: introduce .errif and .warnif
Rather than having people resort to indirect means to issue a certain
kind of diagnostic conditionally upon an expression which can (or
should) only be evaluated when all sections were sized and all symbols
had their final values established, provide directives to directly
achieve this.
2025-07-04 10:42:18 +02:00
Jan Beulich
7b40f4c658 gas: add a means to programmatically determine the assembler version
It has been more than once that I would have wanted to have a way to
know the gas version in assembly sources, perhaps for use with .if. Add
such a pre-defined symbol, introducing the common pattern GAS(<symbol>)
for any such symbols. The use of parentheses is to keep the risk of
collisions with users' symbols as low as possible. (Possible future
arch-specific symbols may want to use GAS(<arch>:<symbol>).)

Similarly permit determining whether the assembler is a released
version. The exact value probably isn't of much use, it's more the
defined-ness that one might care about. Yet the symbol needs to have
some value anyway.

While by default pre-defined symbols won't be emitted to the symbol
table, introduce -emit-local-absolute to allow requesting this. Re-
purpose flag_strip_local_absolute to become tristate, with a negative
value indicating to also emit pre-defined symbols.
2025-07-04 10:41:34 +02:00
Jan Beulich
52be9c1ba3 cris/testsuite: don't use --em=
Using such abbreviations is fine when written on an interactive command
line by a human. In scripts and alike, doing so risks colliding with
later option additions, as is about to occur for gas: Shortly there'll
be --emit-local-absolute.
2025-07-04 10:40:31 +02:00
GDB Administrator
dfce0d9e38 Automatic date update in version.in 2025-07-04 00:01:17 +00:00
Simon Marchi
b7ff16c68a gdb/linux-nat: initialize lwp_info::syscall_state
When running gdb.base/foll-fork-syscall.exp with a GDB built with UBSan,
I get:

    /home/simark/src/binutils-gdb/gdb/linux-nat.c:1906:28: runtime error: load of value 3200171710, which is not a valid value for type 'target_waitkind'
    ERROR: GDB process no longer exists
    GDB process exited with wait status 3026417 exp9 0 1
    UNRESOLVED: gdb.base/foll-fork-syscall.exp: follow-fork-mode=child: detach-on-fork=on: test_catch_syscall: continue to breakpoint after fork

The error happens here:

    #0  __sanitizer::Die () at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_termination.cpp:50
    #1  0x00007ffff600d8dd in __ubsan::__ubsan_handle_load_invalid_value_abort (Data=<optimized out>, Val=<optimized out>) at /usr/src/debug/gcc/gcc/libsanitizer/ubsan/ubsan_handlers.cpp:551
    #2  0x00005555636d37b6 in linux_handle_syscall_trap (lp=0x7cdff1eb1b00, stopping=0) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:1906
    #3  0x00005555636e0991 in linux_nat_filter_event (lwpid=3030627, status=1407) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3044
    #4  0x00005555636e407f in linux_nat_wait_1 (ptid=..., ourstatus=0x7bfff0d6cf18, target_options=...) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3381
    #5  0x00005555636e7795 in linux_nat_target::wait (this=0x5555704d35e0 <the_amd64_linux_nat_target>, ptid=..., ourstatus=0x7bfff0d6cf18, target_options=...) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3607
    #6  0x000055556378fad2 in thread_db_target::wait (this=0x55556af42980 <the_thread_db_target>, ptid=..., ourstatus=0x7bfff0d6cf18, options=...) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1398
    #7  0x0000555564811327 in target_wait (ptid=..., status=0x7bfff0d6cf18, options=...) at /home/simark/src/binutils-gdb/gdb/target.c:2593

I believe the problem is that lwp_info::syscall_state is never
initialized.  Fix that by initializing it with TARGET_WAITKIND_IGNORE.
This is the value we use elsewhere when resetting this field to mean
"not stopped at a syscall".

Change-Id: I5b76c63d1466d6e63448fced03305fd5ca8294eb
Approved-By: Tom Tromey <tom@tromey.com>
2025-07-03 15:37:08 -04:00
Thiago Jung Bauermann
27e5f9c975 bfd/aarch64-linux: Support reading and writing the GCS core file note
Reviewed-By: Luis Machado <luis.machado@arm.com>
2025-07-03 13:26:40 -03:00
Simon Marchi
8b5072aef1 gdb/testsuite: remove spurious whitespace in gdb.python/py-symbol.exp
Change-Id: I15e307e6910ecbea5a5852e07757f892ea799536
2025-07-03 12:11:07 -04:00
Simon Marchi
01d8dc11f1 gdb/alpha-tdep: add empty line
This was suggested in review, to separate the comment from the following
code.

Change-Id: I077ad4545ee5ef1d362dcfacf585400e26dfdb29
2025-07-03 12:00:49 -04:00
GDB Administrator
239f72374a Automatic date update in version.in 2025-07-03 00:01:22 +00:00
Yodel Eldar
8ceec7b520 gdb/alpha: Redefine fpcr with fpcr_flags type
This commit adds fpcr_flags and dyn_rm_enum types to define the fpcr.

For details on the floating-point control register (fpcr), please see
the Alpha Architecture Reference Manual, 4th Ed. [1]; in brief, it
consists of a 64-bit bitfield with most bits reserved/unused. All but a
pair of the used bits are boolean flags; the exception, DYN_RM, is a
2-bit enum indicating the IEEE rounding mode and is defined as a
dyn_rm_enum type in the target description annex.

[1] https://archive.org/details/dec-alpha_arch_ref

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Iea54c9e201faae6147a03de124b0368752bce060
2025-07-02 13:10:17 -04:00
Yodel Eldar
fb2b625650 gdb/alpha: Add target description support
This commit adds target description support for Alpha.

The target description obviates the alpha_register_type and
alpha_register_name functions in alpha-tdep.c. Removal of
alpha_register_reggroup_p was considered but ultimately abandoned,
because the "info regs" command would no longer omit the zero, fpcr, and
unique registers from its output (they are neither vector nor float
types).

Register types in the target description annex match the types that the
alpha_register_type function returned.

The locally defined register_names array was moved out of
alpha_register_name and renamed to alpha_register_names as a static
global; calls to alpha_register_name have been replaced with direct
access of the array.

The patch follows the code pattern outlined in the following GDB
Internals Wiki entry:

https://sourceware.org/gdb/wiki/Internals%20Adding-Target-Described-Register-Support

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: If4b25a891228388519074a31a682e33358c71063
2025-07-02 13:08:55 -04:00
Tom de Vries
13d1429112 [gdb/testsuite] Use support_displaced_stepping in gdb.arch/amd64-disp-step-avx.exp
In commit 8e73fddeb0 ("[gdb/testsuite] Fix gdb.arch/amd64-disp-step-avx.exp
on x86_64-freebsd") I added a "require {istarget *-*-linux*}", but since then
I found support_displaced_stepping, which seems more appropriate and
descriptive.

Fix this by requiring support_displaced_stepping instead.

Tested on x86_64-freebsd.
2025-07-02 18:05:11 +02:00
Tom de Vries
8e73fddeb0 [gdb/testsuite] Fix gdb.arch/amd64-disp-step-avx.exp on x86_64-freebsd
With test-case gdb.arch/amd64-disp-step-avx.exp on x86_64-freebsd I run into:
...
(gdb) continue
Continuing.

Breakpoint 3, test_rip_vex2_end () at amd64-disp-step-avx.S:35
35		nop
(gdb) FAIL: $exp: vex2: continue to test_rip_vex2_end
...

This happens while executing this bit of the test-case:
...
    # Turn "debug displaced" on to make sure a displaced step is actually
    # executed, not an inline step.
    gdb_test_no_output "set debug displaced on"

    gdb_test "continue" \
	"Continuing.*prepared successfully .*Breakpoint.*, ${test_end_label} ().*" \
	"continue to ${test_end_label}"
...

The problem is that on x86_64, displaced stepping is only supported for linux.
Consequently, the "prepared successfully" message is missing.

Fix this by requiring linux.

Approved-by: Kevin Buettner <kevinb@redhat.com>

Tested on x86_64-freebsd.
2025-07-02 08:14:03 +02:00
GDB Administrator
aafbb9ac8e Automatic date update in version.in 2025-07-02 00:01:21 +00:00
Tom Tromey
7b18593a9e Fix handling of terminal escape sequences in TUI
A user noticed that if the remote sends terminal escape sequences from
the "monitor" command, then these will not be correctly displayed when
in TUI mode.

I tracked this down to remote.c emitting one character at a time --
something the TUI output functions did not handle correctly.

I decided in the end to fix in this in the ui-file layer, because the
same bug seems to affect logging and, as is evidenced by the test case
in this patch, Python output in TUI mode.

The idea is simple: buffer escape sequences until they are either
complete or cannot possibly be recognized by gdb.

Regression tested on x86-64 Fedora 40.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=14126
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-07-01 15:59:41 -06:00
Jens Remus
b054ff6042 x86: ld: sframe: Remove SFrame NULL FRE template
A SFrame NULL FRE template is used as NULL value in some but not all
instances to initialize unused elements of SFrame FRE pointer arrays of
fixed size.  Additionally it is erroneously used as SFrame FRE template
for PLT GOT entries.

Define a separate SFrame FRE template for PLT GOT entries with the same
properties as the SFrame NULL FRE and use that for all PLT GOT entries.
Remove the SFrame NULL FRE template, as initialization of unused array
elements is not required, as demonstrated by the instances where it was
not done.

bfd/
	* elf64-x86-64.c (elf_x86_64_sframe_null_fre): Remove.
	(elf_x86_64_sframe_pltgot_fre1): New SFrame FRE template for
	PLT GOT entries.
	(elf_x86_64_sframe_non_lazy_plt,
	elf_x86_64_sframe_non_lazy_ibt_plt): Do not initialize unused
	FRE array elements with elf_x86_64_sframe_null_fre.  Use
	elf_x86_64_sframe_pltgot_fre1 for PLT GOT.
	(elf_x86_64_sframe_plt, elf_x86_64_sframe_ibt_plt): Use
	elf_x86_64_sframe_pltgot_fre1 for PLT GOT.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
2025-07-01 17:56:10 +02:00
Bruce McCulloch
dac12bc242 libctf: doc: add __float128 and SIMD vector classification to spec.
This patch adds two additional distinct types (__float128 and the SIMD
vector type generated from the vector_size attribute) to the umbrella of
two existing types (long double and array, respectively). These types
were previously invalid, producing CTF_K_UNKNOWN in the case of
__float128 or a float in the case of the SIMD vector. This patch will
cleanly allow these types to be represented more accurately without
breaking back-compat.

Signed-off-by: Bruce McCulloch <bruce.mcculloch@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
2025-07-01 15:54:27 +01:00
Nick Alcock
feebe58d0f libctf: add root-visibility-addition test
libctf/
	* testsuite/libctf-writable/ctf-nonroot-addition.*: New test.
2025-07-01 15:54:27 +01:00
Nick Alcock
d54eea8750 libctf: create: check the right root-visible flag when adding enumerands
The root-visible flag we're dealing with here is directly out of the dict,
not a flag passed in to the API, so it does not have the values CTF_ADD_ROOT
or CTF_ADD_NONROOT: instead it's simply zero for non-root-visible, nonzero
otherwise.  Fix the test.

libctf/
	* ctf-create.c (ctf_add_enumerator): Fix root-visibility test.
2025-07-01 15:54:27 +01:00
Nick Alcock
84b2be94e5 libctf: create: addition of non-root types should not return root types
If you add a non-root type to a dict, you should always get a new, unique
type ID back, even if a root-visible type with the same name already exists.
Unfortunately, if the root-visible type is a forward, and you're adding a
non-root-visible struct, union, or enum, the machinery to detect forwards
and promote them to the concrete type fires in this case and returns the
root-visible type!  If this is an enum being inserted hidden because its
enumerands conflict with some other enum, this will lead to failure later
on: in any case, it's seriously counterintuitive to add a non-root- visible
type and get a root-visible one instead.

Fix this by checking the root-visible flag properly and only checking for
forwards if this type is root-visible.  (This may lead to a certain degree
of proliferation of non-root-visible forwards: we can add a cleanup pass for
those later if needed.)

libctf/
	* ctf-create.c (ctf_add_struct_sized): Check the root-visible flag when
	doing forward promotion.
	(ctf_add_union_sized): Likewise.
	(ctf_add_enum): Likewise.

Reviewed-by: Bruce McCulloch <bruce.mcculloch@oracle.com>
2025-07-01 15:54:26 +01:00
Alan Modra
a17dd69b33 MIPS: Fix addend handling with rela R_MIPS16_GOT16 and R_MICROMIPS_GOT16
In rela howtos these relocations should not be using
_bfd_mips_elf_got16_reloc.  That special function is for extracting
addends from section contents, and only for that (ie. it doesn't
subtract gp).  Make these rela howtos like the corresponding
R_MIPS_GOT16 rela howto.

	* elf64-mips.c (mips16_elf64_howto_table_rela <R_MIPS16_GOT16>):
	Use _bfd_mips_elf_generic_reloc.
	(micromips_elf64_howto_table_rela <R_MICROMIPS_GOT16>): Likewise.
	* elfn32-mips.c (elf_mips16_howto_table_rela <R_MIPS16_GOT16>):
	Likewise.
	(elf_micromips_howto_table_rela <R_MICROMIPS_GOT16>): Likewise.
2025-07-01 14:05:07 +01:00
GDB Administrator
e65d831ce1 Automatic date update in version.in 2025-07-01 00:01:40 +00:00
WANG Xuerui
304662234d RISC-V: [gprofng] Allow building gprofng without asm/hwprobe.h
The code is actually able to gracefully fallback if the syscall number
of riscv_hwprobe is not available at build time, but it still depended
on the <asm/hwprobe.h> header unconditionally. In certain environments
such as one of crosstool-NG's Canadian Cross build step (binutils for
host), or one with very outdated kernel headers, the header will not be
present, causing the build to fail.

While the relevant projects/environments should be fixed nevertheless,
a configure-time check for <asm/hwprobe.h> is helpful for fixing gprofng
builds with released versions of ct-ng etc.

Signed-off-by: WANG Xuerui <git@xen0n.name>
2025-06-30 09:32:05 -07:00
Vladimir Mezentsev
88c66eca24 Fix typos in binutils/dwarf.c
binutils/ChangeLog
2025-06-29  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	* dwarf.c: Change "/usrlib64/debug/usr" to "/usr/lib64/debug/usr/" and
	.gun_debugaltlink to .gnu_debugaltlink.
2025-06-30 00:25:34 -07:00
GDB Administrator
cf729dbef8 Automatic date update in version.in 2025-06-30 00:00:47 +00:00
Simon Marchi
ce7a53912a gdb/solib-target: move make_target_solib_ops out of HAVE_LIBEXPAT
When building without expat, we get a missing make_target_solib_ops
error:

    /usr/bin/ld: arch-utils.o: in function `gdbarch::gdbarch()':
    /home/simark/src/binutils-gdb/gdb/gdbarch-gen.c:30:(.text+0x15be): undefined reference to `make_target_solib_ops()'

Fix it by moving make_target_solib_ops out of HAVE_LIBEXPAT.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33118
Change-Id: I76fe4698c6b71bd76096e6cdcbacf8de42a3eb43
Tested-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
2025-06-28 22:44:28 -04:00
GDB Administrator
1d106f7e1c Automatic date update in version.in 2025-06-29 00:00:33 +00:00
H.J. Lu
803e6cfb43 x86-64.exp: Correct pr26808.dump to pr27708.dump
Change

verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr26808.dump" 1

to

verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump" 1

	* testsuite/binutils-all/x86-64/x86-64.exp: Correct pr26808.dump
	to pr27708.dump.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-06-29 06:41:05 +08:00
Tom de Vries
f9e9e263f5 [gdb/tdep] Add "maint set console-translation-mode <binary|text>" command
On MSYS2, say we record a brief gdb session using TERM=dumb script:
...
$ gdb -q
(gdb) print 1
$1 = 1
(gdb) q
...

When looking at the resulting typescript, we notice something odd:
...
$ gdb -q^M
(gdb) print 1^M
$1 = 1^M^M
(gdb) q^M
...

For some reason, we have "$1 = 1\r\r\n(gdb) ".

Looking at the documentation of _setmode [1], it mentions translation mode
_O_TEXT as a mode in which "\n" is translated into "\r\n" on output.

So, it looks like this translation happens twice.

Add a command "maint set console-translation-mode <binary|text>" command that
allows us to set the translation mode of stdout/stderr to binary, such that we
get instead:
...
$ gdb -q -ex "maint set console-translation-mode binary"^M
(gdb) print 1^M
$1 = 1^M
(gdb) q^M
...

Since we run into this in the testsuite, add
"maint set console-translation-mode binary" to INTERNAL_GDBFLAGS.

Based on "maint set testsuite-mode on/off" from these patches [2][3] by Pierre
Muller.

Compared to that proposal, I dropped the name testsuite-mode, because the
behaviour is not specific to the testsuite.

Also I chose values binary/text instead of on/off because eventually there may
be other translation mode values that we need [4].

Co-Authored-By: Pierre Muller <muller@sourceware.org>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>

[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode
[2] https://sourceware.org/legacy-ml/gdb-patches/2013-09/msg00939.html
[3] https://sourceware.org/legacy-ml/gdb-patches/2013-09/msg00940.html
[4] https://learn.microsoft.com/en-us/cpp/c-runtime-library/translation-mode-constants
2025-06-28 13:03:14 +02:00
GDB Administrator
d62eaecf2e Automatic date update in version.in 2025-06-28 00:02:21 +00:00
Thiago Jung Bauermann
48e0ec7484 GDB: maint: Fix build on FreeBSD
While trying to build current trunk of GDB on FreeBSD 14.3 on aarch64,
I hit this warning converted to an error:

In file included from /home/bauermann/src/binutils-gdb/gdb/maint.c:37:
/home/bauermann/src/binutils-gdb/gdb/maint.h:64:8: error: private field 'm_start_space' is not used [-Werror,-Wunused-private-field]
   64 |   long m_start_space;
      |        ^
1 error generated.
gmake[2]: *** [Makefile:1973: maint.o] Error 1

I used the default compiler on this system:

$ c++ --version
FreeBSD clang version 19.1.7 (https://github.com/llvm/llvm-project.git llvmorg-19.1.7-0-gcd708029e0b2)
Target: aarch64-unknown-freebsd14.3
Thread model: posix
InstalledDir: /usr/bin

The problem is that the only two places that use m_start_space are
guarded by HAVE_USEFUL_SBRK, so also guard the member declaration with
it.

Build-tested on aarch64-unknown-freebsd14.3.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-06-27 17:44:30 -03:00
GDB Administrator
e6fa58449b Automatic date update in version.in 2025-06-27 00:01:37 +00:00
Simon Marchi
a2e3cce344 gdb/solib: C++ify solib_ops
Convert solib_ops into an abstract base class (with abstract methods,
some of them with default implementations) and convert all the existing
solib_ops instances to solib_ops derived classes / implementations.

Prior to this patch, solib_ops is a structure holding function pointers,
of which there are only a handful of global instances (in the
`solib-*.c` files).  When passing an `solib_ops *` around, it's a
pointer to one of these instances.  After this patch, there are no more
global solib_ops instances.  Instances are created as needed and stored
in struct program_space.  These instances could eventually be made to
contain the program space-specific data, which is currently kept in
per-program space registries (I have some pending patches for that).

Prior to this patch, `gdbarch_so_ops` is a gdbarch method that returns a
pointer to the appropriate solib_ops implementation for the gdbarch.
This is replaced with the `gdbarch_make_solib_ops` method, which returns
a new instance of the appropriate solib_ops implementation for this
gdbarch.  This requires introducing some factory functions for the
various solib_ops implementation, to be used as `gdbarch_make_solib_ops`
callbacks.  For instance:

    solib_ops_up
    make_linux_ilp32_svr4_solib_ops ()
    {
      return std::make_unique<linux_ilp32_svr4_solib_ops> ();
    }

The previous code is full of cases of tdep files copying some base
solib_ops implementation, and overriding one or more function pointer
(see ppc_linux_init_abi, for instance).  I tried to convert all of this
is a class hierarchy.  I like that it's now possible to get a good
static view of all the existing solib_ops variants.  The hierarchy looks
like this:

    solib_ops
    ├── aix_solib_ops
    ├── darwin_solib_ops
    ├── dsbt_solib_ops
    ├── frv_solib_ops
    ├── rocm_solib_ops
    ├── svr4_solib_ops
    │   ├── ilp32_svr4_solib_ops
    │   ├── lp64_svr4_solib_ops
    │   ├── linux_ilp32_svr4_solib_ops
    │   │   ├── mips_linux_ilp32_svr4_solib_ops
    │   │   └── ppc_linux_ilp32_svr4_solib_ops
    │   ├── linux_lp64_svr4_solib_ops
    │   │   └── mips_linux_lp64_svr4_solib_ops
    │   ├── mips_nbsd_ilp32_svr4_solib_ops
    │   ├── mips_nbsd_lp64_svr4_solib_ops
    │   ├── mips_fbsd_ilp32_svr4_solib_ops
    │   └── mips_fbsd_lp64_svr4_solib_ops
    └── target_solib_ops
        └── windows_solib_ops

The solib-svr4 code has per-arch specialization to provide a
link_map_offsets, containing the offsets of the interesting fields in
`struct link_map` on that particular architecture.  Prior to this patch,
arches would set a callback returning the appropriate link_map_offsets
by calling `set_solib_svr4_fetch_link_map_offsets`, which also happened
to set the gdbarch's so_ops to `&svr_so_ops`.  I converted this to an
abstract virtual method of `struct svr4_solib_ops`, meaning that all
classes deriving from svr4_solib_ops must provide a method returning the
appropriate link_map_offsets for the architecture.  I renamed
`set_solib_svr4_fetch_link_map_offsets` to `set_solib_svr4_ops`.  This
function is still necessary because it also calls
set_gdbarch_iterate_over_objfiles_in_search_order, but if it was not for
that, we could get rid of it.

There is an instance of CRTP in mips-linux-tdep.c, because both
mips_linux_ilp32_svr4_solib_ops and mips_linux_lp64_svr4_solib_ops need
to derive from different SVR4 base classes (linux_ilp32_svr4_solib_ops
and linux_lp64_svr4_solib_ops), but they both want to override the
in_dynsym_resolve_code method with the same implementation.

The solib_ops::supports_namespaces method is new: the support for
namespaces was previously predicated by the presence or absence of a
find_solib_ns method.  It now needs to be explicit.

There is a new progspace::release_solib_ops method, which is only needed
for rocm_solib_ops.  For the moment, rocm_solib_ops replaces and wraps
the existing svr4_solib_ops instance, in order to combine the results of
the two.  The plan is to have a subsequent patch to allow program spaces to have
multiple solib_ops, removing the need for release_solib_ops.

Speaking of rocm_solib_ops: it previously overrode only a few methods by
copying svr4_solib_ops and overwriting some function pointers.  Now, it
needs to implement all the methods that svr4_solib_ops implements, in
order to forward the call.  Otherwise, the default solib_ops method
would be called, hiding the svr4_solib_ops implementation.  Again, this
can be removed once we have support for multiple solib_ops in a
program_space.

There is also a small change in how rocm_solib_ops is activated.  Prior
to this patch, it's done at the end of rocm_update_solib_list.  Since it
overrides the function pointer in the static svr4_solib_ops, and then
overwrites the host gdbarch, so_ops field, it's something that happens
only once.  After the patch though, we need to set rocm_solib_ops in all
the program spaces that appear.  We do this in
rocm_solib_target_inferior_created and in the new
rocm_solib_target_inferior_execd.  After this, I will explore doing a
change where rocm_solib_ops is only set when we detect the ROCm runtime
is loaded.

Change-Id: I5896b5bcbf8bdb024d67980380feba1ffefaa4c9
Approved-By: Pedro Alves <pedro@palves.net>
2025-06-26 14:08:31 -04:00
Simon Marchi
3cb6bc13e3 gdb/progspace: add solib_ops pointer in program_space
The subsequent C++ification patch in this series will allocate one
instance of solib_ops per program space.  That instance will be held in
struct program_space.  As a small step towards this, add an `solib_ops
*` field to `struct program_space`.  This field represents the solib_ops
currently used to manage the solibs in that program space.  Initialize
it with the result of `gdbarch_so_ops` in `post_create_inferior`, and
use it whenever we need to do some solib stuff, rather than using
`gdbarch_so_ops` directly.

The difficulty here is knowing when exactly to set and unset the solib
ops.  What I have here passes the testsuite on Linux, but with more
testing we will probably discover more spots where it's needed.

The C++ification patch will turn this field into a unique pointer.

With this patch, the message we get when running "info
linker-namespaces" becomes always the same, so update the test in
gdb.base/dlmopen-ns-ids.exp.

Change-Id: Ide8ddc57328895720fcd645d46dc34491f84c656
Approved-By: Pedro Alves <pedro@palves.net>
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
2025-06-26 14:08:31 -04:00
Simon Marchi
aff04ed34f gdb/solib: use solib::ops for operations that concern a single solib
For operations that concern a single solib, use the solib_ops backlink
added in the previous patch (solib::ops), instead of using the solib_ops
from the gdbarch.  This is a small / easy step towards not using
gdbarch_so_ops, which is necessary for the C++ification patch later in
this series.

There is no change in behavior expected.

Change-Id: If80e9ea717a2788bada1cf0940cda3c73933bcff
Approved-By: Pedro Alves <pedro@palves.net>
2025-06-26 14:08:31 -04:00
Simon Marchi
f643d36e9f gdb/solib: add solib -> solib_ops backlink
The subsequent C++ification commit makes it so that one struct solib_ops
is instantiated for each program space.  For some operations, it will
then become necessary to be able to get the right solib_ops instance
from a given solib.  Add an solib -> solib_ops backlink for that.

Change-Id: Ib95407b3fa5fcfba55cf874e0e9dcd2d43a402e4
Approved-By: Pedro Alves <pedro@palves.net>
2025-06-26 14:08:31 -04:00
Simon Marchi
021108382a gdb/solib: fix formatting of "info linker-namespaces" error message
Add spaces after the first period and add a period at the end, resulting
in:

    (gdb) info linker-namespaces
    ️ Current inferior does not support linker namespaces.  Use "info sharedlibrary" instead.

Change-Id: Ib3f1647cedcdb68852a3c63df26ea3e6f791b1b1
Approved-By: Pedro Alves <pedro@palves.net>
2025-06-26 14:08:31 -04:00
Simon Marchi
f9fca5aa58 gdb/testsuite: check that "info shared" and "info linker-namespaces" before running don't crash
While writing my solib_ops C++ification series, I broke this, and it
didn't seem to be caught by the testsuite.  Add a test for those.

The exact message for "info linker-namespaces" varies depending on the
solib_ops of the target architecture (whether ops->num_active_namespaces
is nullptr or not).  For now, just accept any message (a crash will
still be caught).  A later patch in this series will make the message
consistent and update this test.

Change-Id: I6bce2ff317447bbf321fc9cbd2d42c3dcea0c683
Approved-By: Pedro Alves <pedro@palves.net>
2025-06-26 14:08:31 -04:00
Vladimir Mezentsev
221efb6f54 gprofng: need to know that experiment was created on big-endian machine
gprofng/ChangeLog
2025-06-25  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

	* configure.ac: Add AC_C_BIGENDIAN.
	* common/config.h.in: Rebuild.
	* configure: Rebuild.
	* libcollector/collector.c (log_header_write): Save big-endian flag.
	* src/DbeSession.h (is_bigendian): New function.
	* src/DbeSession.cc: Likewise.
	* src/Experiment.cc: Set 'bigendian' and 'need_swap_endian'.
	* src/Experiment.h: New field 'bigendian'.
	* src/LoadObject.cc: Remove an unused variable.
	* src/LoadObject.h: Likewise.
2025-06-26 10:43:50 -07:00
Simon Marchi
3d9bcb9ebe gdb: remove some stray "void"
Fix these little typos from commit 5fe70629ce ("Change file
initialization to use INIT_GDB_FILE macro").

Change-Id: Ib9ae29988dfda1165de47467087f154624916629
2025-06-26 13:26:25 -04:00
Nick Clifton
c72fad491c Updated Spanish translations for opcodes and gas 2025-06-26 15:08:53 +01:00
Andrew Burgess
b95b15404f gdb/testsuite: handle failure to start process for later attach test
Commit:

  commit b239038360
  Date:   Tue Mar 21 13:01:26 2023 +0100

      gdb: linux-namespaces: enter user namespace when appropriate

added a new test gdb.base/user-namespace-attach.exp.  It has been
reported that this test will sometimes fail, like this:

  (gdb) attach 184732
  Attaching to process 184732
  warning: process 184732 is a zombie - the process has already terminated
  ptrace: Operation not permitted.
  (gdb) FAIL: gdb.base/user-namespace-attach.exp: flags=--mount --map-root-user: attach to inferior

the test tries to run the 'unshare' application.  Sometimes though,
the application is present, but the set of flags used is not
supported (maybe due to restrictions on the local machine), so we see
behaviour like this:

  $ unshare --mount --map-root-user /bin/true; echo $?
  unshare: unshare failed: Operation not permitted
  1

Handle this case by first running 'unshare' with the same flags, but
using '/bin/true', if this fails then assume the flags are not
supported, and skip the test.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33108
2025-06-26 13:39:24 +01:00
Tom Tromey
5fe70629ce Change file initialization to use INIT_GDB_FILE macro
This patch introduces a new macro, INIT_GDB_FILE.  This is used to
replace the current "_initialize_" idiom when introducing a per-file
initialization function.  That is, rather than write:

    void _initialize_something ();
    void
    _initialize_something ()
    {
       ...
    }

... now you would write:

    INIT_GDB_FILE (something)
    {
       ...
    }

The macro handles both the declaration and definition of the function.

The point of this approach is that it makes it harder to accidentally
cause an initializer to be omitted; see commit 2711e475 ("Ensure
cooked_index_entry self-tests are run").  Specifically, the regexp now
used by make-init-c seems harder to trick.

New in v2: un-did some erroneous changes made by the script.

The bulk of this patch was written by script.
Regression tested on x86-64 Fedora 41.
2025-06-26 06:15:59 -06:00
GDB Administrator
cdf176bebc Automatic date update in version.in 2025-06-26 00:01:30 +00:00
Srinath Parvathaneni
5103708c01 aarch64: Add supports for FEAT_PoPS feature and DC instructions.
This patch add support for FEAT_PoPS feature which can be enabled
through +pops command line flag.

This patch also adds support for following DC instructions and the
spec can be found here [1].
1. "dc cigdvaps" enabled on passing +memtag+pops command line flags.
2. "dc civaps" enabled on passing +pops command line flag.

[1]: https://developer.arm.com/documentation/ddi0601/2025-03/AArch64-Instructions?lang=en
2025-06-25 13:34:59 +01:00
Andrew Burgess
125881849a gdb: remove final m_stream->emit_style_escape calls from pager_file
After the last commit there were still a couple of calls to
m_stream->emit_style_escape in the pager_file class.  As discussed in
the last commit, these are likely wrong, but I'd not been able to
produce any bugs because of them.

The reason why there are no bugs is that these calls are, I think,
entirely redundant.  Consider this block:

      if (m_wrap_column)
	{
	  /* We are about to insert a newline at an historic
	     location in the WRAP_BUFFER.  Before we do we want to
	     restore the default style.  To know if we actually
	     need to insert an escape sequence we must restore the
	     current applied style to how it was at the WRAP_COLUMN
	     location.  */
	  m_applied_style = m_wrap_style;
	  m_stream->emit_style_escape (ui_file_style ());
	  /* If we aren't actually wrapping, don't output
	     newline -- if chars_per_line is right, we
	     probably just overflowed anyway; if it's wrong,
	     let us keep going.  */
	  m_stream->puts ("\n");
	}

What we know (see previous commit) is that the call:

  m_stream->emit_style_escape (ui_file_style ());

is dangerous as m_stream->m_applied_style is going to be out of sync
with its current state.  Actually, m_stream->m_applied_style is likely
to be the default style as it is not updated elsewhere.  So why does
this not cause problems?

Well, GDB's style output is always done in tightly scoped regions.
That means if we want to print some styled output, and then apply a
wrap point the code might look like this:

  fprintf_styled (gdb_stdout, file_name_style, "some text");
  gdb_stdout->wrap_here (4);

But, after printing 'some text', the style of gdb_stdout will have
returned to the default style.

My claim is that, whenever we encounter a wrap_here call, the stream
in question will _always_ have been returned to the default style.

This means that, in the block above, the call:

  m_stream->emit_style_escape (ui_file_style ());

will never emit anything because it depends on a check against
m_stream->m_applied_style, which will always mean that the above call
does nothing.  But that's OK.  By chance, we'll have always placed the
stream into a default style state anyway, so no harm done.

Similarly, the other call:

  /* Having finished inserting the wrapping we should
     restore the style as it was at the WRAP_COLUMN.  */
  m_stream->emit_style_escape (m_wrap_style);

Tries to return m_stream to the state it was in at the point of the
wrap_here call.  But, as described above, this will always be the
default style, so the above call will do nothing, but that just
happens to be exactly what we want!

So what does this commit do?

Well, I "fix" the above code by removing the
m_stream->emit_style_escape calls and replacing them with calls to
puts, passing in the escape sequence for the required style, but only
if the m_stream style as tracked by pager_file::m_stream_style
indicates this is needed.

Got the reasons given above, this should mean there is no change after
this patch.  We still shouldn't be emitting any extra escape
sequences.  But, should we ever manage to get into a state where we
call wrap_here with a stream in a style other than the default, then
this should mean things work as expected.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
2025-06-25 11:43:46 +01:00