]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
3 hours agoChange contact details for updating the sourceware crontab entry for the binutils. master
Nick Clifton [Mon, 20 Jul 2026 10:38:20 +0000 (11:38 +0100)] 
Change contact details for updating the sourceware crontab entry for the binutils.

14 hours agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

29 hours agoinit-mixed.c count
Alan Modra [Sun, 19 Jul 2026 08:12:39 +0000 (17:42 +0930)] 
init-mixed.c count

The variable isn't a counter so rename it, and use small values that
won't overflow a target with 16-bit int.  Since commit 2e806738bd
there is a possibility of running tests on such targets.

* testsuite/ld-elf/init-mixed.c: Rename "count" to "order"
and use values of 0 to 6 when checking init/fini order.

33 hours agold: testsuite: Associate C identifiers with symbols
Jan Dubiec [Sat, 18 Jul 2026 07:52:54 +0000 (09:52 +0200)] 
ld: testsuite: Associate C identifiers with symbols

Some targets prepend an underscore to C identifier, while others do
not (e.g. H8 vs. ARM). This can cause problems in two situations:
   1. when linking C and assembly code;
   2. when a symbol name is specified on the linker's command line.

This patch resolves both issues by using the asm keyword to associate C
identifiers with the corresponding assembler/linker symbol names in a
target-independent manner.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
33 hours agoconvert dos eol to unix
Alan Modra [Sun, 19 Jul 2026 05:19:21 +0000 (14:49 +0930)] 
convert dos eol to unix

A number of testsuite files have dos CR/LF end of line.  Fix most of
them, so that we are less likely to run into patch failures when
contributors provide patches to these files, such as:
Hunk #1 FAILED at 1 (different line endings).
My version of git, 2.51.0, does not tell you the reason whe running
"git am", just "patch does not apply".

gprofng/examples/mxv-pthreads/README.md is also converted to unix.

38 hours agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 days agogdb: recreate the frame_info_ptr in get_prev_frame_maybe_check_cycle
Andrew Burgess [Thu, 25 Jun 2026 14:58:50 +0000 (14:58 +0000)] 
gdb: recreate the frame_info_ptr in get_prev_frame_maybe_check_cycle

Currently frame_info_ptr caches the frame_id at construction time, see
frame_info_ptr::frame_info_ptr in frame.c.  The problem with this is
that a frame's frame-id might not be known at this point.

The function get_prev_frame_maybe_check_cycle calls get_prev_frame_raw
to create the previous frame, placing the result into a frame_info_ptr
PREV_FRAME.  For frames other than frame 0, compute_frame_id is then
called computing the frame-id.  However, the call to compute_frame_id
only updates the frame_info object itself, the frame_info_ptr
PREV_FRAME is not updated with the new frame-id.

What this means is that in get_prev_frame_maybe_check_cycle, the
PREV_FRAME local has no cached frame-id.

Consider the call stack:

  get_selected_frame
    lookup_selected_frame
      frame_find_by_id
        get_prev_frame
  get_prev_frame_always
    get_prev_frame_always_1
      get_prev_frame_maybe_check_cycle

What we see is that the frame_info_ptr created in
get_prev_frame_maybe_check_cycle, which lacks a cached frame_id, can
be passed all the way back to lookup_selected_frame, where it will be
stored in the SELECTED_FRAME global by a call to select_frame.  The
outer get_selected_frame call (in the above backtrace) will then
return the SELECTED_FRAME global, which lacks a cached frame-id.

If GDB ever tries to reinflate the SELECTED_FRAME frame_info_ptr (or a
copy of it), then we will trigger the assert:
`gdb_assert (frame_id_p (m_cached_id));` which can be found in
`frame_info_ptr::reinflate` in frame.c.

An example of how this can be triggered is included in the updated
test case:

  - The 'up' command sets the selected frame to a frame with
    level > 0.
  - An inferior call invalidates the selected frame.
  - The selected frame is rebuilt following the call-stack above.
    The wrapping frame_info_ptr object doesn't cache the frame-id.
  - The 'frame' command invokes another inferior call for the pretty
    printer, which flushes the frame cache.
  - The frame_info_ptr is reinflated, e.g., to print the next
    argument, and this hits the assertion mentioned above.

There are only 3 places in GDB where new frame_info objects are
created: create_sentinel_frame, create_new_frame, and
get_prev_frame_raw.  Of these, the first two always calculate the
frame_id before placing the frame_info object into a frame_info_ptr.

Only get_prev_frame_raw, which is only called from
get_prev_frame_maybe_check_cycle, creates the frame_info_ptr before
the frame_id is calculated.

There are two places where PREV_FRAME is returned from
get_prev_frame_maybe_check_cycle.  The first is only for frame #0.
The frame_info_ptr::reinflate method doesn't need a frame_id for
frame #0, so the first return is not a problem.

The second return from get_prev_frame_maybe_check_cycle is done after
the frame_id has been calculated, and it is here that the problem can
be fixed.  If we create a new frame_info_ptr to replace PREV_FRAME
then this new frame_info_ptr will have a cached frame_id and the
problem described above will no longer occur.

Co-Authored-By: Rohr, Stephan <stephan.rohr@intel.com>
2 days agogdb: LoongArch: Add internal TLS support
Hui Li [Mon, 13 Jul 2026 10:37:24 +0000 (18:37 +0800)] 
gdb: LoongArch: Add internal TLS support

Implements the LoongArch-specific get_tls_dtv_addr() and uses
svr4_tls_register_tls_methods() to register it, together with
svr4_tls_get_thread_local_address as the get_thread_local_address
gdbarch method, to support internal TLS address lookup.

LoongArch doesn't need get_tls_dtp_offset since musl's DTP_OFFSET
is defined as 0.

This is the LoongArch version of commit c34309bea22
("Internal TLS support for aarch64, x86_64, riscv, ppc64, and s390x").

Depends-On: bfc3ac0d13b
("LoongArch: Support R_LARCH_TLS_DTPREL32/64 used in debug section")

Before:

make check-gdb TESTS="gdb.base/tls-nothreads.exp"
=== gdb Summary ===

  # of expected passes 101
  # of known failures 48

make check-gdb TESTS="gdb.base/tls-dlobj.exp"
=== gdb Summary ===

  # of expected passes 261

After:

make check-gdb TESTS="gdb.base/tls-nothreads.exp"
=== gdb Summary ===

  # of expected passes 302

make check-gdb TESTS="gdb.base/tls-dlobj.exp"
=== gdb Summary ===

  # of expected passes 523

Signed-off-by: Hui Li <lihui@loongson.cn>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2 days ago[pre-commit] Set stages for isort
Tom de Vries [Sat, 18 Jul 2026 08:16:57 +0000 (10:16 +0200)] 
[pre-commit] Set stages for isort

I noticed that isort runs for the manual stage:
...
$ pre-commit run --hook-stage manual
isort...............................................(no files to check)Skipped
...

That happens because unlike any other repo we're currently using, isort's
.pre-commit-hooks.yaml sets stages:
...
stages: [pre-commit, pre-merge-commit, pre-push, manual]
...
overriding the default setting in our .pre-commit-config.yaml:
...
default_stages: [pre-commit]
...

Fix this by adding a stages setting to the isort hook.

2 days agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 days ago[gdb/testsuite] Fix tclint errors
Tom de Vries [Fri, 17 Jul 2026 22:30:57 +0000 (00:30 +0200)] 
[gdb/testsuite] Fix tclint errors

Fix tclint errors in a few files.

2 days ago[gdb/testsuite] Fix check-file-mode errors
Tom de Vries [Fri, 17 Jul 2026 22:30:57 +0000 (00:30 +0200)] 
[gdb/testsuite] Fix check-file-mode errors

Fix check-file-mode errors in a few files.

2 days agogdb: add shadowed field in '-stack-list-locals/variables' mi commands
Ijaz, Abdul B [Fri, 15 Sep 2023 13:18:07 +0000 (15:18 +0200)] 
gdb: add shadowed field in '-stack-list-locals/variables' mi commands

For C/C++/Fortran languages GDB prints same name variable multiple times in
case of variable shadowing and it is confusing for user to identify which
variable belongs to the current scope.  So GDB now prints location information
for shadowed variables and add 'shadowed' field also in '-stack-list-locals'
and '-stack-list-variables' mi commands for super-block shadowed variable.

Suppose we have test.c file

1:int x = 3;
2:  {
3:    int x = 4;
4:    int y = 5;
5:    x = 99; /* break here */
6:  }

The "-stack-list-locals" and "-stack-list-variables" mi commands at the
"break here" line gives the following output:

Before the change:

~~~
(gdb)
-stack-list-locals 0
^done,locals=[name="x",name="y",name="x"]
(gdb)
-stack-list-locals 1
^done,locals=[{name="x",value="4"},{name="y",value="5"},{name="x",value="3"}]
(gdb)
-stack-list-locals 2
^done,locals=[{name="x",type="int",value="4"},{name="y",type="int",value="5"},{name="x",type="int",value="3"}]
(gdb)
-stack-list-variables 0
^done,variables=[{name="x"},{name="y"},{name="x"}]
(gdb)
-stack-list-variables 1
^done,variables=[{name="x",value="4"},{name="y",value="5"},{name="x",value="3"}]
(gdb)
-stack-list-variables 2
^done,variables=[{name="x",type="int",value="4"},{name="y",type="int",value="5"},{name="x",type="int",value="3"}]
~~~

With this patch we obtain:

~~~
(gdb)
-stack-list-locals 0
^done,locals=[name="x",name="y",name="x"]
(gdb)
-stack-list-locals 1
^done,locals=[{name="x",value="4",filename="../test.c",fullname="/home/src/test.c",line="3"},{name="y",value="5"},{name="x",value="3",filename="../test.c",fullname="/home/src/test.c",line="1",shadowed="true"}]
(gdb)
-stack-list-locals 2
^done,locals=[{name="x",type="int",value="4",filename="../test.c",fullname="/home/src/test.c",line="3"},{name="y",type="int",value="5"},{name="x",type="int",value="3",filename="../test.c",fullname="/home/src/test.c",line="1",shadowed="true"}]
(gdb)
-stack-list-variables 0
^done,variables=[{name="x",filename="../test.c",fullname="/home/src/test.c",line="3"},{name="y"},{name="x",filename="../test.c",fullname="/home/src/test.c",line="1",shadowed="true"}]
(gdb)
-stack-list-variables 1
^done,variables=[{name="x",value="4",filename="../test.c",fullname="/home/src/test.c",line="3"},{name="y",value="5"},{name="x",value="3",filename="../test.c",fullname="/home/src/test.c",line="1",shadowed="true"}]
(gdb)
-stack-list-variables 2
^done,variables=[{name="x",type="int",value="4",filename="../test.c",fullname="/home/src/test.c",line="3"},{name="y",type="int",value="5"},{name="x",type="int",value="3",filename="../test.c",fullname="/home/src/test.c",line="1",shadowed="true"}]
~~~

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2 days agogdb: add annotation in 'info locals' command for variables shadowing case
Ijaz, Abdul B [Fri, 15 Sep 2023 13:12:10 +0000 (15:12 +0200)] 
gdb: add annotation in 'info locals' command for variables shadowing case

For C/C++/Fortran/Ada languages GDB prints same name variable multiple
times in case of variable shadowing and it is confusing for user to identify
which variable belongs to the current scope.  So for such cases add location
info to the innermost listed variables and for super block variables add
"shadowed" annotation in the form of "<file.c:line, shadowed>".

Suppose we have

1:int x = 3;
2:  {
3:    int x = 4;
4:    int y = 52;
5:    x = 99; /* break here */
6:  }

Currently:

(gdb) info locals
x = 4
y = 52
x = 3

After applying this patch, we obtain:

(gdb) info locals
x = 4  <file.c:3>
y = 52
x = 3  <file.c:1, shadowed>

The patch adds the location annotations by keeping track of inner block
and already printed variables to identify shadowing.  So, GDB now prints
"<file.c:line, shadowed>" for shadowed super-block variables and
"<file.c:line>" for innermost declarations of such variables only.

The location annotations are printed for shadowed variables in case of
C/C++/Fortran/Ada languages.  In Rust, it is possible to declare a
variable with the same name many times.  So in this case, just the first
instance of the variable is printed.  RUST language test "var_reuse.exp"
fails with rustc compiler version >= 1.73 so XFAIL is added accordingly.

Fix regex expression in the gdb.opt/inline-locals.exp test according to
this change.  The test update is only required due to the existing gdb
known ticket gdb/25695 where this issue is seen with 7.5.0 version on
sles15sp6 but it is not seen anymore on the newer gcc versions e.g.
gcc-11.4.0.

The symtab()/filename() nullptr check was added specifically to avoid
the crash seen in gdb.dwarf2/missing-type-name-for-templates.exp where
template symbols may have no associated source file.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2 days ago[gdb] Add default argument for get_selected_block
Tom de Vries [Fri, 17 Jul 2026 17:28:22 +0000 (19:28 +0200)] 
[gdb] Add default argument for get_selected_block

I noticed that the get_selected_block argument is mostly 0, NULL, or nullptr.

Make nullptr the default argument.

Approved-By: Tom Tromey <tom@tromey.com>
2 days agoAssume an unrecognized gnatmake is very new
Tom Tromey [Wed, 1 Jul 2026 16:05:24 +0000 (10:05 -0600)] 
Assume an unrecognized gnatmake is very new

I don't know why -- though I suspect there may have been a change to
the output of "gnatmake --version" -- but recently some gdb.ada tests
have stopped running when llvm-gnatmake is used.

The llvm-gnatmake I am testing against prints a version string that
isn't recognized by gnat_version_compare.  However, it seems to me
that AdaCore is probably the main place where this can even occur; and
furthermore that without some extra work, it seems reasonable for
gnat_version_compare to assume that an unrecognized gnatmake is "very
new".

2 days agoHandle missing array descriptor in ada_type_of_array
Tom Tromey [Tue, 30 Jun 2026 16:09:48 +0000 (10:09 -0600)] 
Handle missing array descriptor in ada_type_of_array

The test case gdb.ada/mi_var_access.exp was failing with gnat-llvm.
Debugging this, I found that the problem was that with gnat-llvm, the
array descriptor would have a NULL pointer for the bounds when the
array was invalidated.  That is, examining the object in C mode:

    (gdb) p a_string_access
    $1 = {
      P_ARRAY = 0x0,
      P_BOUNDS = 0x0
    }

whereas when using GNAT we see:

    (gdb) print a_string_access
    $1 = {
      P_ARRAY = 0x0,
      P_BOUNDS = 0x402750
    }

This was causing ada_type_of_array to return nullptr; with that
bubbling up to varobj and then MI as a "wrong" type in the MI output.

It seems to me that a null P_BOUNDS is reasonable; and that this case
can be handled in ada_type_of_array by examining the type of P_BOUNDS
without needing the bounds themselves.

The bound values are both set to 0 in this case, because
experimentally this is what is done at runtime in the GNAT-generated
code.  Perhaps an explicitly empty array (1/0) would be better; I am
not certain.

2 days ago[gdb] Fix hard-coded constants in buildsym_compunit::make_blockvector
Tom de Vries [Fri, 17 Jul 2026 14:30:15 +0000 (16:30 +0200)] 
[gdb] Fix hard-coded constants in buildsym_compunit::make_blockvector

I came across some code in buildsym_compunit::make_blockvector that uses
hardcoded constants 0 and 1:
...
      gdb_assert (blockvector->block (0)->is_global_block ());
      gdb_assert (blockvector->block (1)->is_static_block ());
...

Fix this by instead using the symbolic constants GLOBAL_BLOCK and
STATIC_BLOCK.

The same function has an odd-looking for loop that uses a hard-coded '1' to
skip the global block:
...
       /* The 'J > 1' here is so that we don't place the global block into
   the map.  For CU with gaps, the static block will reflect the
   gaps, while the global block will just reflect the full extent of
   the range.  */
      for (int j = num_blocks; j > 1; )
  {
  --j;
    struct block *b = blockvector->block (j);
...

Fix this by rewriting it into an ordinary descending for loop, and using
symbolic constant GLOBAL_BLOCK to avoid the global block:
...
      for (int j = num_blocks - 1; j > GLOBAL_BLOCK; --j)
  {
    struct block *b = blockvector->block (j);
...

Approved-By: Tom Tromey <tom@tromey.com>
3 days agoPE/COFF: raise normal PE section limit safely
Oleg Tolmatcev [Fri, 17 Jul 2026 13:39:11 +0000 (15:39 +0200)] 
PE/COFF: raise normal PE section limit safely

PE/COFF stores symbol section numbers in a 16-bit field.  Binutils used
signed 16-bit handling there, which limited normal PE objects to 32767
sections even though MSVC and Clang already accept a larger unsigned
range.

Raise the normal PE section limit to 65279, while keeping the PE/COFF
special section-number values for undefined, absolute and debug symbols
working correctly.  Do this by decoding and encoding normal PE symbol
section numbers as unsigned values in the ordinary range, but preserving
the reserved PE constants explicitly.

Also add a gas test that exercises a normal PE object above the old
32767-section limit and checks that objdump reports the high section
number correctly.

bfd/ChangeLog:

* coffcode.h (COFF_DEFAULT_MAX_NSCNS): Define.
(bfd_coff_std_swap_table): Use it for the default maximum section
count.
(ticoff0_swap_table): Likewise.
(ticoff1_swap_table): Likewise.
* peXXigen.c (pe_decode_sym_section_number): New function.
(pe_encode_sym_section_number): New function.
(_bfd_XXi_swap_sym_in): Use pe_decode_sym_section_number.
(_bfd_XXi_swap_sym_out): Use pe_encode_sym_section_number.

include/ChangeLog:

* coff/pe.h (IMAGE_SYM_UNDEFINED): Define.
(IMAGE_SYM_ABSOLUTE): Define.
(IMAGE_SYM_DEBUG): Define.
(IMAGE_SYM_SECTION_MAX): Define.

gas/ChangeLog:

* testsuite/gas/pe/pe.exp: Run large-obj-normal.
* testsuite/gas/pe/large-obj-normal.s: New test.
* testsuite/gas/pe/large-obj-normal.d: New test.

Signed-off-by: Oleg Tolmatcev <oleg.tolmatcev@gmail.com>
3 days agoprune BeOS leftovers
Jan Beulich [Fri, 17 Jul 2026 13:37:56 +0000 (15:37 +0200)] 
prune BeOS leftovers

The target was marked removed by bd3828b0de50 ("Remove support for the
beos file format") in early 2024. Drop leftover entries.

3 days ago[pre-commit] Fix codespell-log hook
Tom de Vries [Fri, 17 Jul 2026 11:18:28 +0000 (13:18 +0200)] 
[pre-commit] Fix codespell-log hook

A recent commit added this top-level setting to .pre-commit-config.yaml:
...
files: '^(gdb|gdbserver|gdbsupport)/'
...

This broke the codespell-log hook, which is a commit-msg hook, which is called
with the commit message as first argument, typically .git/COMMIT_EDITMSG.

However, the top-level files setting filters out .git/COMMIT_EDITMSG, with the
consequence that the commit-msg hook is no longer called.

It seems obvious to me that this is a pre-commit bug: the files field is there
to filter files in the repository, which .git/COMMIT_EDITMSG is not one of.
But upstream disagrees [1].

The fix suggested upstream is to include .git/COMMIT_EDITMSG in the default
files setting.

That indeed works for a regular commit, but not for something like this:
...
$ tmp=$(mktemp)
$ echo 'msg' > $tmp
$ pre-commit run --hook-stage commit-msg --commit-msg-filename $tmp
...
which is roughly what we're using in the regression test.

We can't use .git/COMMIT_EDITMSG in the regression test, because the user may
be editing it, or using it in some other way.

We also cannot use say gdb/testsuite/gdb.src/commit-msg.txt, because using
that filename doesn't detect the regression.

[1] https://github.com/pre-commit/pre-commit/issues/3720

3 days agogas: scrubber handling of string continuation across lines
Jan Beulich [Fri, 17 Jul 2026 07:23:55 +0000 (09:23 +0200)] 
gas: scrubber handling of string continuation across lines

Apparently forever (according to [available] history) two backslashes have
been emitted when, afaict, only one was meant.

3 days agogas: don't recognize '8' and '9' as octal escape chars in strings
Jan Beulich [Fri, 17 Jul 2026 07:23:35 +0000 (09:23 +0200)] 
gas: don't recognize '8' and '9' as octal escape chars in strings

It's not clear why these were covered; it has been like this from the very
beginning of (available) source history. Yet more oddly, an old ia64
testcase actually uses such malformed escape sequences (which are being
adjusted).

3 days agogas: ignore ONLY_STANDARD_ESCAPES in scrubber
Jan Beulich [Fri, 17 Jul 2026 07:23:07 +0000 (09:23 +0200)] 
gas: ignore ONLY_STANDARD_ESCAPES in scrubber

The handling there is broken in several ways:
- It gets in the way of macro parameter names starting with one of the not
  special cased values.
- For perhaps a small set of targets (SINGLE_QUOTE_STRINGS, M68k MRI
  mode): While the "quotechar" static variable allows for string quotation
  by other than '"', the case labels circumventing the warning only (and
  potentially wrongly) cover '"'.

read.c:next_char_of_string() having similar checking in place, drop the
special casing (as as_warn() invocation) from here.

While adjusting macros/macros.exp XFAIL-ary for an affected testcase,
correct the referenced manifest symbol at the same time.

3 days agox86: avoid duplication of testcase expectations in ilp32/
Jan Beulich [Fri, 17 Jul 2026 07:22:09 +0000 (09:22 +0200)] 
x86: avoid duplication of testcase expectations in ilp32/

Besides needlessly consuming space (it's not that much, but still), the
unnecessary duplication also means the need to edit things in two places
when changes are being made.

3 days agox86: accept LOCK on control register accesses only with ModR/M.reg == 0
Jan Beulich [Fri, 17 Jul 2026 07:21:48 +0000 (09:21 +0200)] 
x86: accept LOCK on control register accesses only with ModR/M.reg == 0

Reportedly (e.g. [1]) the LOCK handling is special to %cr0 / %cr8 only.
Deal with it this way also in assembler and disassembler.

For the assembler also introduce a separate feature indicator: Not all
64-bit CPUs support this insn form; only most AMD (and presumably all
Hygon) ones do. Register names %cr9 ... %cr15 thus become invalid outside
of 64-bit mode altogether (unprefixed forms become ordinary symbol names),
while %cr8's availability outside of 64-bit mode now depends on the new
feature indicator.

For the disassembler don't limit this handling to non-64-bit modes. Use
of LOCK is similarly permitted in 64-bit mode. Instead don't handle LOCK
this way when "intel64" was specified as an option.

[1] https://lists.xen.org/archives/html/xen-devel/2026-07/msg00391.html

3 days agoloongarch gcc-4.9 build error
Alan Modra [Fri, 17 Jul 2026 00:07:37 +0000 (09:37 +0930)] 
loongarch gcc-4.9 build error

gas/config/tc-loongarch.c: In function ‘md_apply_fix’:
gas/config/tc-loongarch.c:1886:7: error: a label can only be part of a statement and a declaration is not a statement
       unsigned int subtype;
       ^

* config/tc-loongarch.c (md_apply_fix <BFD_RELOC_LARCH_CFA>):
Avoid gcc-4.9 error.

3 days agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 days agoUse bool in ada_type_of_array
Tom Tromey [Tue, 30 Jun 2026 15:12:42 +0000 (09:12 -0600)] 
Use bool in ada_type_of_array

I found yet another spot in ada-lang.c where a bool is more
appropriate than an int.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
3 days agoDocument remote protocol pid and thread id sizes
Tom Tromey [Thu, 2 Jul 2026 19:32:25 +0000 (13:32 -0600)] 
Document remote protocol pid and thread id sizes

The recent ptid work came from a bug where a problem was observed due
to sign extension.  That bug also suggested documenting the guaranteed
range of thread- and process-ids in the remote protocol.

This patch documents these as being 32-bit values at minimum.  I also
added static asserts to ensure this is true -- note that although
'int' may be 16 bit per the C standard, I doubt gdb would build on
such a host.

I didn't specify a maximum because it is host-dependent.  This is
perhaps something to change, and while I do have some work in this
area, it's quite invasive.  Also, while widening the range here would
be good, it would also be incompatible in a sense, where a newer
protocol implementation may end up using values not supported by older
versions of gdb.  Perhaps one idea would be to simply change these
both to int32_t and move on.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33979
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
4 days agoLoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN or R_LAR...
Xi Ruoyao [Tue, 14 Jul 2026 15:51:32 +0000 (23:51 +0800)] 
LoongArch: only insert align section for ld -r if an input has R_LARCH_ALIGN or R_LARCH_RELAX

Commit 8bf4b69718d4 ("LoongArch: Fix relaxation alignment with ld -r (PR
33236)") has broken the kernel modules on Debian sid.  The expectation
of the kernel is all the source files which would be linked into a
module are compiled with -mno-relax so the module should not contain
R_LARCH_ALIGN, thus the module loader rejects any module containing
R_LARCH_ALIGN.

To restore the correctness of the expectation, only insert the align
section if an input has R_LARCH_ALIGN or R_LARCH_ALIGN (i.e. bytes may
be removed from that input).  Regardless of the kernel modules, it also
does not make too much sense to bloat the output with NOPs and
R_LARCH_ALIGN if no input ever contains R_LARCH_ALIGN and R_LARCH_ALIGN
anyway.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
4 days ago[pre-commit] Bump codespell to v2.4.3
Tom de Vries [Thu, 16 Jul 2026 06:04:22 +0000 (08:04 +0200)] 
[pre-commit] Bump codespell to v2.4.3

Ran "pre-commit autoupdate".  No changes.

4 days agolibctf: bounds-check forward ctt_type before indexing pop[]
Naveed Khan [Mon, 13 Jul 2026 13:16:47 +0000 (18:46 +0530)] 
libctf: bounds-check forward ctt_type before indexing pop[]

init_static_types_internal() walks the CTF type section that comes
directly from an object file's .ctf section.  During the first counting
pass it treats a CTF_K_FORWARD record's ctt_type as the CTF_K_* kind of
the forwarded tag and bumps the corresponding population count:

if (kind == CTF_K_FORWARD)
  pop[tp->ctt_type]++;

pop[] is a fixed-size stack array with CTF_K_MAX + 1 (64) entries, but
ctt_type is a 32-bit value read straight from the file and is never
validated.  A crafted dict whose forward record carries a ctt_type
greater than CTF_K_MAX therefore causes an out-of-bounds write to the
stack at an attacker-controlled index.

The type walk is reachable from ctf_bufopen()/ctf_open(), i.e. whenever
libctf opens a dict: ld while linking CTF, and objdump/nm --ctf.  The
second pass already tolerates an out-of-range ctt_type (ctf_name_table()
has a default case), so only this first-pass index was unguarded.

Reject a ctt_type outside the valid kind range as ECTF_CORRUPT, matching
the existing corruption handling in the same loop.

Reproduced with a 65-byte in-memory dict (one CTF_K_FORWARD record whose
ctt_type is 64) passed to ctf_bufopen().  Before the fix, AddressSanitizer
reports a stack-buffer-overflow at ctf-open.c:759 overflowing pop[64];
after the fix ctf_bufopen() returns ECTF_CORRUPT.  Valid forwards
(ctt_type of CTF_K_STRUCT/UNION/ENUM) and the boundary value CTF_K_MAX
still open successfully.

Signed-off-by: Naveed Khan <naveed@digiscrypt.com>
4 days agoAutomatic date update in version.in
GDB Administrator [Thu, 16 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 days agoaarch64: Remove cast from struct initializer
Alice Carlotti [Wed, 15 Jul 2026 16:44:07 +0000 (17:44 +0100)] 
aarch64: Remove cast from struct initializer

This fixes the error reported when compiling with GCC 4.9:

opcodes/aarch64-opc-2.c:29:3: error: initializer element is not constant
   {AARCH64_OPND_CLASS_INT_REG, "Rd", OPD_F_HAS_INSERTER | OPD_F_HAS_EXTRACTOR, {AARCH64_FIELD (0, 5)}, "an integer register"},
   ^
opcodes/aarch64-opc-2.c:29:3: error: (near initialization for ‘aarch64_operands[1].fields[0]’)

4 days agoreadelf.c gcc-4.9 compile error
Alan Modra [Wed, 15 Jul 2026 21:57:58 +0000 (07:27 +0930)] 
readelf.c gcc-4.9 compile error

gcc-4.9 doesn't like an empty initialiser.

binutils/readelf.c: In function ‘process_relocs’:
binutils/readelf.c:10229:5: error: missing initializer for field ‘sh_name’ of ‘Elf_Internal_Shdr’ [-Werror=missing-field-initializers]
     Elf_Internal_Shdr section = {};

* readelf.c (process_relocs): Avoid gcc-4.9 compile error.

5 days agoAutomatic date update in version.in
GDB Administrator [Wed, 15 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 days ago[gdb/exp] Handle recursive namespace import
Tom de Vries [Tue, 14 Jul 2026 08:43:14 +0000 (10:43 +0200)] 
[gdb/exp] Handle recursive namespace import

Consider test.c, compiled to a.out using "g++ -g test.c":
...
     1  namespace mod_a { int xxx = 10; }
     2  namespace mod_b { using namespace mod_a;
     3                    int yyy = 20; }
     4  int main (void) {
     5    using namespace mod_b;
     6    void (xxx + yyy);
     7    return 0;
     8  }
...

When trying to print the value of variable xxx we get:
...
$ gdb -q -batch a.out -ex start -ex "print xxx"
  ...
Temporary breakpoint 1, main () at test.c:7
7           return 0;
No symbol "xxx" in current context.
...

The symbol xxx is defined in namespace mod_a, so it's available as:
...
(gdb) p mod_a::xxx
$1 = 10
...
and namespace mod_b uses namespace mod_a, so it's available as:
...
(gdb) p mod_b::xxx
$2 = 10
...

Then main uses namespace mod_b so xxx should also be available in main, but
it's not.

The problem happens here in cp_lookup_symbol_via_imports:
...
Thread 1 "gdb" hit Breakpoint 1, cp_lookup_symbol_via_imports (scope=0x5f43d0 "",
    name=0xfffffffface0 "xxx", block=0x2fba5a0, domain=..., search_scope_first=0,
    declaration_only=0, search_parents=1, found_symbols=...)
    at /home/vries/gdb/src/gdb/cp-namespace.c:505
505                   cp_lookup_symbol_via_imports (current->import_src, name,
...

We're about to follow the "using namespace mod_b" statement:
...
(gdb) p *current
$1 = {import_src = 0x2ed2140 "mod_b", import_dest = 0x66e910 "", alias = 0x0,
      declaration = 0x0, next = 0x0, decl_line = 5, searched = 1,
      excludes = {0x0}}
...

But it does so using the current block, which is the function block for main:
...
(gdb) p block->function ().m_name
$7 = 0x2f8bc20 "main()"
...
and the block containing the "using namespace mod_a" statement is the static
block.

Fix this by additionally iterating over the static and global blocks instead
of only using the current block.

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

6 days ago[gdb/exp] Fix ignoring of incorrect namespace prefix
Tom de Vries [Tue, 14 Jul 2026 08:43:14 +0000 (10:43 +0200)] 
[gdb/exp] Fix ignoring of incorrect namespace prefix

Consider test.c, compiled to a.out using "g++ -g test.c":
...
     1  namespace mod_a { int xxx = 10; }
     2  namespace mod_b { using namespace mod_a;
     3                    int yyy = 20; }
     4  int main (void) {
     5    using namespace mod_b;
     6    void (xxx + yyy);
     7    return 0;
     8  }
...

When trying to print the value of non-existent variable mod_a::yyy, we get:
...
$ gdb -q -batch a.out -ex start -ex "print mod_a::yyy"
  ...
Temporary breakpoint 1, main () at test.c:7
7         return 0;
$1 = 20
...

The problem is in cp_lookup_symbol_via_imports, where we decide that the
"using namespace mod_b" from main is applicable in scope mod_a.

More concretely, cp_lookup_symbol_via_imports is called with:
- scope == "mod_a",
- name == "yyy", and
- block.m_function.m_name == "main()",
and when looking at "using namespace mod_b":
...
(gdb) p *current
$12 = {import_src = 0x344018c "mod_b", import_dest = 0x1b477a0 "",
       alias = 0x0, declaration = 0x0, next = 0x0, decl_line = 5,
       searched = 0, excludes = {0x0}}
...
we hit "directive_match = true" because strlen (current->import_dest) == 0.

Fix this by being more strict in the calculation of directive_match:
...
          if (len == 0)
-           directive_match = true;
+           {
+             const char *current_scope = (block->function_block () != nullptr
+                                          ? block->scope ()
+                                          : nullptr /* Don't know.  */);
+             directive_match = (current_scope != nullptr
+                                ? streq (scope, current_scope)
+                                : true /* Assume there's a match.  */);
+           }
...
which gets us:
- current_scope == "", and
- directive_match == false,
because scope == "mod_a", so streq (scope, current_scope) == false.

As is clear from the code, in case we don't know the current scope, we assume
there's a match.  This may be harmless, or this may describe a cornercase we
haven't run into yet.  If so, it's a pre-existing issue.

The new test-case contains regression tests for:
- PR34051, and
- PR34034 for which it contains a kfail.

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

6 days ago[gdb] Break up complex assignment in cp_lookup_symbol_via_imports
Tom de Vries [Tue, 14 Jul 2026 08:43:14 +0000 (10:43 +0200)] 
[gdb] Break up complex assignment in cp_lookup_symbol_via_imports

In cp_lookup_symbol_via_imports, we have a complex assignment:
...
      directive_match = (search_parents
                        ? (startswith (scope, current->import_dest)
                           && (len == 0
                               || scope[len] == ':'
                               || scope[len] == '\0'))
                        : streq (scope, current->import_dest));
...

Writing it like this makes it:
- harder to comment on parts of the expression, and also
- harder to understand and modify it.

Also, len == 0 makes the startswith redundant, so that part of the expression
can be hoisted.  Doing so makes it clear that scope is not compared against in
all cases.

Fix this by breaking this up into three separate assignments:
...
      if (search_parents)
        {
          if (len == 0)
            directive_match = true;
          else
            directive_match = (startswith (scope, current->import_dest)
                               && (scope[len] == ':'
                                   || scope[len] == '\0'));
        }
      else
        directive_match = streq (scope, current->import_dest);
...

Approved-By: Tom Tromey <tom@tromey.com>
6 days agoAutomatic date update in version.in
GDB Administrator [Tue, 14 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 days agox86: Disable XCHG to MOV optimization
H.J. Lu [Sun, 12 Jul 2026 10:24:42 +0000 (18:24 +0800)] 
x86: Disable XCHG to MOV optimization

The -O option was added to x86 assembler by

commit b6f8c7c45229a8a5405079e586bfbaad396d2cbe
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Feb 27 07:36:33 2018 -0800

    x86: Add -O[2|s] assembler command-line options

On x86, some instructions have alternate shorter encodings:

1. When the upper 32 bits of destination registers of

andq $imm31, %r64
testq $imm31, %r64
xorq %r64, %r64
subq %r64, %r64

known to be zero, we can encode them without the REX_W bit:

andl $imm31, %r32
testl $imm31, %r32
xorl %r32, %r32
subl %r32, %r32

This optimization is enabled with -O, -O2 and -Os.
2. Since 0xb0 mov with 32-bit destination registers zero-extends 32-bit
immediate to 64-bit destination register, we can use it to encode 64-bit
mov with 32-bit immediates.  This optimization is enabled with -O, -O2
and -Os.
3. Since the upper bits of destination registers of VEX128 and EVEX128
instructions are extended to zero, if all bits of destination registers
of AVX256 or AVX512 instructions are zero, we can use VEX128 or EVEX128
encoding to encode AVX256 or AVX512 instructions.  When 2 source
registers are identical, AVX256 and AVX512 andn and xor instructions:

VOP %reg, %reg, %dest_reg

can be encoded with

VOP128 %reg, %reg, %dest_reg

This optimization is enabled with -O2 and -Os.
4. 16-bit, 32-bit and 64-bit register tests with immediate may be
encoded as 8-bit register test with immediate.  This optimization is
enabled with -Os.

These optimizations were intended for compiler generated assembly codes.
The optimization changes may take a long time to be put into GCC.  The
similar SSE move encoding optimization for GCC was first proposed in
Feb, 2019:

https://gcc.gnu.org/pipermail/gcc-patches/2019-February/516941.html

It finally went in Mar, 2020:

commit 5358e8f5800daa0012fc9d06705d64bbb21fa07b
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Mar 5 16:45:05 2020 -0800

    i386: Properly encode vector registers in vector move

Such optimizations are useful for compiler generated codes since they
work with released versions of GCC which don't have such optimized
encoding.  We assume that it is safe to use on compiler generated codes.
When we are informed that an assembler optimization introduces a
significant drawback, we will investigate its drawbacks and benefits.
If its drawbacks outweigh its benefits, such optimization should be
removed.

commit 1c3c3e4b3c2ac2eed9abcbce0b9cba1be10ed3f0
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Jun 19 09:47:21 2026 +0200

    x86: optimize XCHG to MOV for same-register forms

breaks valgrind:

https://bugs.kde.org/show_bug.cgi?id=522533

"xchgl %ecx,%ecx" in VALGRIND_GET_NR_CONTEXT, which is defined in
/usr/include/valgrind/valgrind.h:

 #define VALGRIND_GET_NR_CONTEXT(_zzq_rlval)                       \
  { volatile OrigFn* _zzq_orig = &(_zzq_rlval);                   \
    volatile unsigned int __addr;                                 \
    __asm__ volatile(__SPECIAL_INSTRUCTION_PREAMBLE               \
                     /* %EAX = guest_NRADDR */                    \
                     "xchgl %%ecx,%%ecx"                          \
                     : "=a" (__addr)                              \
                     :                                            \
                     : "cc", "memory"                             \
                    );                                            \
    _zzq_orig->nraddr = __addr;                                   \
  }

has special meanings and shouldn't be changed by assembler even when
assembler optimization is enabled.  Since there are no any evidences
to show its benefits, we can't say that it is useful at all.  This
patch disables this optimization, which may be enabled with a different
option.

gas/

PR gas/34343
* config/tc-i386.c (optimize_for_disabled_optimizations): New.
(optimize_encoding): Optimize "xchg %rN, %rN" to "mov %rN, %rN"
only if optimize_for_disabled_optimizations isn't 0.
* testsuite/gas/i386/optimize-2b.d: Updated.
* testsuite/gas/i386/x86-64-optimize-3b.d: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 days ago[gdb/exp] Fix ns var lookup when stopped at inlined fn call
Tom de Vries [Mon, 13 Jul 2026 17:09:35 +0000 (19:09 +0200)] 
[gdb/exp] Fix ns var lookup when stopped at inlined fn call

Consider test.c:
...
     1 namespace mod_a {
     2   int xxx = 10;
     3 }
     4
     5 static inline int __attribute__((always_inline))
     6 inlined () {
     7   return 0;
     8 }
     9
    10 int main () {
    11   using namespace mod_a;
    12   int res = inlined ();
    13   return res + xxx;
    14 }
...
compiled with "g++ test.c -g".

Trying to print variable xxx at line 12 fails:
...
$ gdb -q -batch a.out -ex start -ex "p xxx"
  ...
Temporary breakpoint 1, main () at test.c:12
12   int res = inlined ();
No symbol "xxx" in current context.
...

The problem is here in function using_direct::valid_line:
...
      CORE_ADDR curr_pc = get_frame_pc (get_selected_frame (nullptr));
      symtab_and_line curr_sal = find_sal_for_pc (curr_pc, 0);
      return (decl_line <= curr_sal.line)
     || (decl_line >= boundary);
...
where we're trying to decide whether "using namespace mod_a" is applicable.

The decl_line is 11, as expected.

If curr_sal.line were 12, decl_line <= curr_sal.line would be true, and
using_direct::valid_line would return true.

But instead, curr_sal.line is 7.

This is sort of correct, the current PC maps to that line.  It's just that gdb
steps into inlined functions in two steps, each with identical PC:
- once stopping at the call site (line 12 in this case)
- once stopping at the PC line (line 7 in this case)

The function using_direct::valid_line doesn't apply this logic, and
consequently line 7 is used for both cases.

Fix this by using find_frame_sal instead.

Tested on x86_64-linux.

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

6 days ago[gdb/exp] Limit workaround in using_direct::valid_line to broken GCC versions
Tom de Vries [Mon, 13 Jul 2026 16:13:24 +0000 (18:13 +0200)] 
[gdb/exp] Limit workaround in using_direct::valid_line to broken GCC versions

Consider test.c:
...
     1 namespace mod_a {
     2   int xxx = 10;
     3 }
     4
     5 static void
     6 foo ()
     7 {
     8 }
     9
    10 int
    11 main ()
    12 {
    13   {
    14     foo ();
    15     using namespace mod_a;
    16   }
    17
    18   return mod_a::xxx;
    19 }
...
compiled with "g++ test.c -g".

Attempting to print xxx at line 14 shouldn't find anything (because it's
before the "using namespace mod_a"), but it does:
...
$ gdb -q -batch a.out -ex start -ex "p xxx"
...
Temporary breakpoint 1, main () at test.c:14
14     foo ();
$1 = 10
...

This happens because using_direct::valid_line returns true here:
...
      return (decl_line <= curr_sal.line)
     || (decl_line >= boundary);
...

Since we have decl_line == 15 and curr_sal.line == 14,
"(decl_line <= curr_sal.line)" evaluates to false.

But boundary == 14, so "(decl_line >= boundary)" evaluates to true.

The "(decl_line >= boundary)" bit was added as a workaround for
GCC PR debug/108716.

Since I'm using GCC 15, the workaround is not needed.

Fix this by limiting the workaround to broken GCC versions.

Tested on x86_64-linux, using GCC 15.2, and 7.5.

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

7 days ago[gdb/testsuite] Fix FAIL in gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp
Tom de Vries [Mon, 13 Jul 2026 13:29:14 +0000 (15:29 +0200)] 
[gdb/testsuite] Fix FAIL in gdb.threads/sw-watchpoint-step-over-bp-with-threads.exp

On x86_64-linux, I ran into the following FAIL:
...
(gdb) cont
Continuing.
[Switching to Thread 0x7ffff7cbe6c0 (LWP 3534988)]

Thread 2 "sw-watchpoint-s" hit Watchpoint 3: watched_global

Old value = 0
New value = 1
0x00007ffff7d514bf in futex_wait () at ../sysdeps/nptl/futex-internal.h:146
146       int err = lll_futex_timed_wait (futex_word, expected, NULL, private);
(gdb) PASS: $exp: target-non-stop=auto: displaced-stepping=auto: \
  continue to watchpoint
break 64
No compiled code for line 64 in the current file.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) FAIL: $exp: target-non-stop=auto: displaced-stepping=auto: \
  gdb_breakpoint: set breakpoint at 64
...

[ The FAIL initially reproduced only under heavy system load (simulated using
stress -c $(grep -c ^processor: /proc/cpuinfo)), but then I found that
changing the delay in $srcfile from 1 second to 1 millisecond also reproduced
it fairly reliably.  Using this approach, I managed to reproduce both on
x86_64-linux and aarch64-linux. ]

The test-case tries to set a breakpoint at $srcfile:64, using just "64", but
that doesn't work because the inferior is not stopped in $srcfile.

This can be trivially fixed by using $srcfile:64 instead, and indeed, this is
what this patch does.

However, that fix is only correct if gdb is indeed allowed to report a stop in
thread 2.

This is a question I found difficult to answer.

I found some text in the docs [1] that seems related to the test-case
scenario:
...
Warning: In multi-threaded programs, software watchpoints have only limited
usefulness.  If GDB creates a software watchpoint, it can only watch the value
of an expression in a single thread.  If you are confident that the expression
can only change due to the current thread’s activity (and if you are also
confident that no other thread can become current), then you can use software
watchpoints as usual.  However, GDB may not notice when a non-current thread’s
activity changes the expression. (Hardware watchpoints, in contrast, watch an
expression in all threads.)
...

After reading this text, my impression was that gdb shouldn't report a stop in
thread 2, because:
- GDB "can only watch the value of an expression in a single thread",
- the expression can only change due the current thread's activity (thread 1),
  and
- thread 2 cannot become current, it just spins and there's no breakpoint set
  in the range where it spins.

However, in the test-case I came across the following text:
...
    # The final continue, with the software watchpoint set, so that
    # GDB single-steps all threads (if the target is non-stop).
...

Indeed, the test-case iterates over some dimensions:
...
foreach_with_prefix target-non-stop {auto on off} {
    foreach_with_prefix displaced-stepping {auto on off} {
test ${target-non-stop} ${displaced-stepping}
    }
}
...
and disregarding the auto, the FAIL reproduces with both displaced-stepping on
and off, but only with target-non-stop on.

So we have the default non-stop off, and target-non-stop on.

The documentation says about this [2]:
...
set non-stop off, target operating in non-stop mode

When a thread hits a breakpoint, finishes a step, etc., the target does not
immediately stop all other threads.  If, while processing the event, infrun
decides the stop should be reported to the user, it then explicitly stops all
threads, just before presenting the stop to the user; otherwise, infrun
re-resumes the stopped thread.  This scenario is also called “all-stop on top
of non-stop”.
...

I was not able to deduce why in this situation and in presence of a software
watchpoint all threads should be single stepping, so I asked Claude Code.

It gave the following background information:
- in the pure all-stop case (set non-stop off, target operating in all-stop
  mode), in presence of a software watchpoint:
  - the current thread single-steps
  - the other threads stay stopped
  - consequently, only modifications by the current thread are detected,
- in the all-stop on non-stop case (set non-stop off, target operating in
  non-stop mode), in presence of a software watchpoint:
  - all threads single-step
  - consequently, modifications by any thread are detected, but it's not
    possible to attribute the modification to any specific thread, so gdb
    attributes it to the thread whose stop happens to be processed.

This adequately explains the behavior in the test-case.

I suspect that the warning text in the documentation needs updating, because
AFAICT it doesn't cover the "set non-stop off, target operating in non-stop
mode" behavior described above.

Tested on x86_64-linux.

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

[1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Set-Watchpoints.html
[2] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Maintenance-Commands.html#index-maint-set-target_002dnon_002dstop-mode-_005bon_007coff_007cauto_005d

7 days ago[gdb] More codespell fixes
Tom de Vries [Mon, 13 Jul 2026 13:23:12 +0000 (15:23 +0200)] 
[gdb] More codespell fixes

I did this in gdb/pyproject.toml:
...
+regex = "[a-zA-Z0-9\\-']+"
...
allowing us to detect things like 'gcs_availabe':
...
$ echo gcs_availabe | codespell --regex="[a-zA-Z0-9\-']+" -
1: gcs_availabe
availabe ==> available
...
and ran:
...
$ codespell --toml gdb/pyproject.toml gdb*
...
and manually fixed fallout.

This fixes the following typos:
...
  typdef -> typedef
  bloc -> block
  reenables -> re-enables
  overlayed -> overlaid
  advertized -> advertised
  stript -> script
  reenable -> re-enable
  interruptable -> interruptible
  restire -> restore
  sufix -> suffix
  regisers -> registers
  constrait -> constraint
  attriute -> attribute
  followin -> following
  immedate -> immediate
  constrol -> control
  sting -> string
  vesion -> version
  operatons -> operations
  inheritence -> inheritance
  decsription -> description
  hilighted -> highlighted
  enque -> enqueue
  ouputs -> outputs
...

The "vesion -> version" fix in gdb.dwarf2/dw2-entry-pc.exp allowed a bit of
cleanup.

Tested on x86_64-linux and aarch64-linux.

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

7 days ago[gdb] Use using in compat_x32_clock_t typedef
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Use using in compat_x32_clock_t typedef

In commit 6c85ef111b0 ("[gdb] Use using instead of typedef"), I did:
...
-typedef long __attribute__ ((__aligned__ (4))) compat_x32_clock_t;
+using compat_x32_clock_t = long __attribute__ ((__aligned__ (4)));
...
which I had to revert because clang ignores the attribute in this variant.

Pedro suggested instead using:
...
using compat_x32_clock_t [[gnu::aligned (4)]] = long;
...
which does work with both clang and gcc.

[ Note that it's not a question of how the attribute is worded, this also works:
...
using compat_x32_clock_t __attribute__ ((__aligned__ (4))) = long;
...
It's just a question of where the attribute is placed. ]

Fix this by using Pedro's suggestion.

Suggested-By: Pedro Alves <pedro@palves.net>
Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Convert typedef on separate line
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Convert typedef on separate line

Convert "typedef struct foo { ... } bar" into "using bar = struct foo { ... }".

Variant where typedef is on its own line.

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] convert struct pointer typedefs
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] convert struct pointer typedefs

Convert "typedef struct foo { ... } *bar" to
"struct foo { ... }; using bar = foo *".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Convert typedef of named struct
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Convert typedef of named struct

Convert "typedef struct foo { ... } bar" to "using bar = struct foo { ...}".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Convert anonymous struct typedefs
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Convert anonymous struct typedefs

Convert "typedef struct { ... } foo" into "struct foo { ... }".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Fix redundant struct typedefs
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Fix redundant struct typedefs

Convert "typedef struct foo { ... } foo" into "struct foo { ... }".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Convert function typedefs to using
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Convert function typedefs to using

Convert "typedef void foo ()" to "using foo = void ()".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Convert template typedefs to using
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Convert template typedefs to using

Convert "typedef foo<...> bar" to "using bar = foo<...>".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Convert function pointer typedefs to using
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Convert function pointer typedefs to using

Transform "typedef void (*foo) ()" into "using foo =  void (*) ()".

Generated by a script written by Claude Code.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Use using instead of typedef some more (part 3)
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Use using instead of typedef some more (part 3)

Fix the remaining hits of:
...
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs grep '^[ \t]*typedef .*;.*$' \
    | grep -v WINAPI
...
except for C example in a comment.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Use using instead of typedef some more (part 2)
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Use using instead of typedef some more (part 2)

Result of:
...
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs sed -i \
        '/WINAPI/b l;s/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.()\* ]*\) \([a-zA-Z_0-9]*\) \((.*)\);/\1using \3 = \2 \4;/;:l'
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs sed -i \
        '/WINAPI/b l;s/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.()\* ]*\) (\([a-zA-Z_0-9]*\)) \((.*)\);/\1using \3 = \2 \4;/;:l'
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs sed -i \
        '/WINAPI/b l;s/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.()\* ]*\) (\([a-zA-Z_0-9]*\))\((.*)\);/\1using \3 = \2 \4;/;:l'
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs sed -i \
        '/WINAPI/b l;s/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.()\* ]*\) (\*\([a-zA-Z_0-9]*\)) \((.*)\);/\1using \3 = \2 (*) \4;/;:l'
...
and fixing up this incorrect rewrite:
...
-typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *);
+using void = int td_key_iter_f (thread_key_t, (*) (void *), void *);
...

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Use using instead of typedef some more (part 1)
Tom de Vries [Mon, 13 Jul 2026 13:06:35 +0000 (15:06 +0200)] 
[gdb] Use using instead of typedef some more (part 1)

Result of:
...
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs sed -i \
        's/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.() ]*\) \([a-zA-Z_0-9]*\)\(\[.*\]\);/\1using \3 = \2\4;/'
$ find gdb* -type f -name "*.[ch]" -o -name "*.cc" \
    | egrep -v /testsuite/ \
    | xargs sed -i \
        's/^\([ \t]*\)typedef \([a-zA-Z_0-9:<>,.()\* ]*\) \([a-zA-Z_0-9]*\);/\1using \3 = \2;/'
...
and manually reverting to changes in comments.

Approved-By: Tom Tromey <tom@tromey.com>
7 days ago[gdb] Move ChangeLog files to archive dir
Tom de Vries [Mon, 13 Jul 2026 11:33:42 +0000 (13:33 +0200)] 
[gdb] Move ChangeLog files to archive dir

We stopped updating ChangeLog files in 2021, and they are no longer
maintained.

If I want to see history, I use git log, so I don't use them for any purpose.

And they're in my way when I'm searching for files, grepping, or refactoring
using sed.

Move them out of the way, into a root-level directory named archive
(alternative names: legacy, deprecated, attic, stale, historical,
unmaintained).

Result of:
...
for f in $(find gdb* -name "ChangeLog*"); do
    dir=$(dirname $f)
    f=$(basename $f)
    u=archive/$dir
    mkdir -p $u
    git mv $dir/$f $u/$f
done
...

Also drop ignoring ChangeLog files in some pre-commit tools.

A less impactful but also less effective change would be to move <dir>/ChangeLog
into <dir>/archive/ChangeLog.

7 days ago[pre-commit] Remove duplication in config file
Tom de Vries [Mon, 13 Jul 2026 11:11:06 +0000 (13:11 +0200)] 
[pre-commit] Remove duplication in config file

In a recent commit, I introduced anchor/alias pairs in
.pre-commit-config.yaml, with short non-descriptive names for local use:
...
-    - id: check-include-guards
-      name: check-include-guards
+    - id: &id0 check-include-guards
+      name: *id0
...

Use anchors and aliases a bit more to remove duplication, now using more
descriptive names for non-local uses.

Yaml also supports defining an anchor for more than one field, which result in
cleaner code:
...
+python-files: &python-files
+  types_or: [file]
+  files: '^gdb/.*\.py(\.in)?$'
+
  ...
       - id: black
-        types_or: [file]
-        files: '^gdb/.*\.py(\.in)?$'
+        <<: *python-files
...
but unfortunately pre-commit generates a warning "[WARNING] Unexpected key(s)
present at root: python-files" for this [1].

Also add a default files setting.

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

[1] https://github.com/pre-commit/pre-commit/issues/1481

7 days ago[pre-commit] Bump isort to 9.0.0b1
Tom de Vries [Mon, 13 Jul 2026 07:40:09 +0000 (09:40 +0200)] 
[pre-commit] Bump isort to 9.0.0b1

Ran "pre-commit autoupdate".  No changes in formatting.

7 days ago[gdb/testsuite] Fix isort fail in gdb.python/py-frame.py
Tom de Vries [Mon, 13 Jul 2026 07:40:09 +0000 (09:40 +0200)] 
[gdb/testsuite] Fix isort fail in gdb.python/py-frame.py

Result of:
...
$ pre-commit run isort --all-files
isort...................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing gdb/testsuite/gdb.python/py-frame.py
...

7 days agoAutomatic date update in version.in
GDB Administrator [Mon, 13 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

8 days agoarm: remove stray backslash in warning message
Alan Modra [Sun, 12 Jul 2026 12:56:56 +0000 (22:26 +0930)] 
arm: remove stray backslash in warning message

Fixes an error introduced in 2004 by commit d003868ea7bf.

8 days agoRe: bfd/ELF: fold BFD_RELOC_<arch>_GOTOFF*
Alan Modra [Sun, 12 Jul 2026 12:13:19 +0000 (21:43 +0930)] 
Re: bfd/ELF: fold BFD_RELOC_<arch>_GOTOFF*

Commit 705b90feb82c missed updating some frv and lm32 source files,
resulting in build breakage if generated files in opcodes/ are
regenerated.

8 days agoChange version number to 2.47.50 and regenerate files
Nick Clifton [Sun, 12 Jul 2026 09:50:36 +0000 (10:50 +0100)] 
Change version number to 2.47.50 and regenerate files

8 days agoRe: readelf: Save and dump the original section header values
Alan Modra [Sun, 12 Jul 2026 08:55:35 +0000 (18:25 +0930)] 
Re: readelf: Save and dump the original section header values

This started as removing the imperative "Ignore the.." from
validate_section_info warnings, and making them a little less work for
translators.  I also decided it wasn't worth reporting specifics about
a malloc failure when allocating a relatively small fixed size buffer.
It would be different if some large chunk of file data caused a malloc
fail.

The patch also fixes a potential orig_section_headers buffer overflow,
caused by allocating a single element array when probing, hitting some
early error in process_file_header, then attempting to access it as an
array of e_shnum entries in free_filedata.

* readelf.c (save_original_section_header_values): Use xmalloc
rather than reporting a more specific error.  Drop now unused
function parameters.
(validate_section_info): Delete "dynamic" and "probe" params.
Redo warning messages.  Don't save orig header for fake
section header passing relr dynamic tags.  Avoid possible
arithmetic overflow when checking sh_size.
(get_32bit_section_headers): Don't allocate orig_section_headers
or call validate_section_info when probing.
(get_64bit_section_headers): Likewise.
(process_relocs): Update validate_section_info call when
handling relr.

8 days agoAdd markers to NEWS files for 2.47 release
Nick Clifton [Sun, 12 Jul 2026 09:12:19 +0000 (10:12 +0100)] 
Add markers to NEWS files for 2.47 release

8 days agoAutomatic date update in version.in
GDB Administrator [Sun, 12 Jul 2026 00:00:08 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 days agoH8: Set H8/300H as the default architecture for the H8 family.
Jan Dubiec [Sat, 11 Jul 2026 00:53:03 +0000 (02:53 +0200)] 
H8: Set H8/300H as the default architecture for the H8 family.

H8/300H uses 32-bit addresses in its default advanced mode, whereas
H8/300 uses 16-bit addresses.  Updates affected test cases accordingly.

bfd/
* cpu-h8300.c: Set H8/300H as the default architecture
for the H8 family.
gas/
* config/tc-h8300.c: Set H8/300H as the default architecture
for the H8 family.
* NEWS: Add info about the above change.
ld/
* configure.tgt: Set H8/300H as the default architecture
for the H8 family.
* NEWS: Add info about the above change.
* testsuite/ld-elf/elf.exp: Expect 32-bit addresses/pointers
for H8 on __patchable_function_entries tests.

Signed-off-by: Jan Dubiec <jdx@o2.pl>
9 days agoaarch64-pe fails of tls-debug tests
Alan Modra [Sat, 11 Jul 2026 04:29:32 +0000 (13:59 +0930)] 
aarch64-pe fails of tls-debug tests

These fail to assemble since they use ELF section directives.  There
isn't any need to test for an aarch64 target since that is done in
aarch64.exp.

* testsuite/gas/aarch64/tls-debug.d: Replace aarch64 target test
with is_elf_format.
* testsuite/gas/aarch64/tls-debug-bad.d: Likewise.

9 days agogdb/linux-tdep: change linux_fill_prpsinfo to return bool
Matthieu Longo [Thu, 2 Jul 2026 15:24:31 +0000 (16:24 +0100)] 
gdb/linux-tdep: change linux_fill_prpsinfo to return bool

Change linux_fill_prpsinfo() to return a boolean instead of an integer, since
it only reports success or failure.
Replace the returned integer values 1 and 0 with true and false respectively.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
9 days agoAutomatic date update in version.in
GDB Administrator [Sat, 11 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

9 days agogdb.base/execl-update-breakpoints.exp: Don't execl forever
Pedro Alves [Thu, 27 Nov 2025 18:06:12 +0000 (18:06 +0000)] 
gdb.base/execl-update-breakpoints.exp: Don't execl forever

execl-update-breakpoints.c is compiled as both
execl-update-breakpoints1 and execl-update-breakpoints2.

execl-update-breakpoints1 checks to see if the last character in its
filename is '1', and if so, replace it with '2' and execl the result.

On Windows, this fails to take into account that the filename may have
an ".exe" extension.  The result is that the execl-update-breakpoints1
executable execs itself forever.

This patch fixes it by taking the .exe extension into account.

(Note that neither native Windows nor Cygwin support following execs,
and maybe the testcase will eventually be skipped there, but even
then, if someone enables follow-exec testing there, we'd want it to
handle the .exe extension, so I think it's better to adjust the
testcase than not.)

Now, on e.g. GNU/Linux, if you run execl-update-breakpoints1 manually,
you'll see that it also execs forever, but this time, what happens is
that execl-update-breakpoints1 execs execl-update-breakpoints2, and
then it's execl-update-breakpoints2 that execs itself forever.  There
is no reason for execl-update-breakpoints2 to exec.  It's just that
the testcase is assuming that the process is killed when the testcase
is over.  It's just cleaner if execl-update-breakpoints1 execs
execl-update-breakpoints2, and then execl-update-breakpoints2 just
cleanly exits.  The patch does that too.

And then, the test program should really be erroring out if neither
'1' nor '2' is found at the tail of the executable.  Done too.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Id88830cd8dff2c63dd69b827d4ba79743aa9ebca

9 days agoaarch64: Update FEAT_TPS and FEAT_TPSP system registers
Alice Carlotti [Fri, 10 Jul 2026 14:51:50 +0000 (15:51 +0100)] 
aarch64: Update FEAT_TPS and FEAT_TPSP system registers

The specification has been changed to use individual tpcr* registers,
instead of the original tpmin*/tpmax* pairs.

9 days agoaarch64: Add support for FEAT_SME_FA64
Alice Carlotti [Thu, 9 Jul 2026 17:27:43 +0000 (18:27 +0100)] 
aarch64: Add support for FEAT_SME_FA64

Add "+sme-f64" to the list of architecture extensions.  This has already
been supported in LLVM for several years.

We don't need to update the feature requirements for any opcodes,
because FEAT_SME_FA64 only enables instructions that were already
available in non-streaming mode, and the feature checks don't know what
mode an instruction will be run under.

9 days agoaarch64 doc: Fix description of .unreq directive.
Alice Carlotti [Wed, 18 Feb 2026 17:51:47 +0000 (17:51 +0000)] 
aarch64 doc: Fix description of .unreq directive.

9 days agoaarch64: Fix .unreq of predefined aliases
Alice Carlotti [Wed, 18 Feb 2026 15:03:41 +0000 (15:03 +0000)] 
aarch64: Fix .unreq of predefined aliases

Attempting to free a static reg_entry is invalid, so use
insert_reg_alias to create a dynamic copy of the content.

9 days agoaarch64: Drop "" from hint option hash table
Alice Carlotti [Wed, 18 Feb 2026 14:25:58 +0000 (14:25 +0000)] 
aarch64: Drop "" from hint option hash table

An empty string is the only option where the upper and lower case forms
are identical, so this allows the upper case insertion logic to be
simplified as well.

9 days agoaarch64: Replace FLD_* macros in do_misc_{en|de}coding
Alice Carlotti [Fri, 15 May 2026 02:53:07 +0000 (03:53 +0100)] 
aarch64: Replace FLD_* macros in do_misc_{en|de}coding

Replace the macros with explicit AARCH64_FIELD calls, and extend the
comments to clarify which aliased instructions are involved.

9 days agoaarch64: Remove disassembly restriction on OP_MOV_Z_Zi
Alice Carlotti [Fri, 15 May 2026 02:52:30 +0000 (03:52 +0100)] 
aarch64: Remove disassembly restriction on OP_MOV_Z_Zi

Disassembly for the OP_MOV_Z_Zi opcode artificially rejected a zero
index value, to indicate that the preferred disassembly uses a different
alias.  This is more naturally indicated by specifying the other alias
as a higher priority.

Update the alias priority, and remove the zero check and the now-unused
OP_MOV_Z_Zi enum value.

9 days agoaarch64: Inline all FLD_* uses in aarch64-tbl.h
Alice Carlotti [Fri, 15 May 2026 16:09:41 +0000 (17:09 +0100)] 
aarch64: Inline all FLD_* uses in aarch64-tbl.h

Inline all non-constant field definitions into operand field lists, and
remove the resulting unused FLD_* macros.  For brevity, define FLD as an
alias for AARCH64_FLD in aarch64-gen.c.

9 days agoaarch64: Write AARCH64_FIELD calls to aarch64-opc-2.c
Alice Carlotti [Fri, 15 May 2026 16:09:30 +0000 (17:09 +0100)] 
aarch64: Write AARCH64_FIELD calls to aarch64-opc-2.c

Parse the operand field lists in aarch64-gen.c, and rewrite the content
to aarch64-opc-2.c using AARCH64_FIELD calls.  This allows aarch64-tbl.h
to use shorthand macros without exporting them elsewhere.

9 days agoaarch64: Remove aarch64_field_kind indirection
Alice Carlotti [Wed, 8 Oct 2025 23:37:21 +0000 (00:37 +0100)] 
aarch64: Remove aarch64_field_kind indirection

Replace all uses of the aarch64_field_kind enum with direct uses of an
aarch64_field struct instead.  Add macro defines mapping the old enum
names to their corresponding aarch64_field values, to reduce the initial
diff.  These can be substituted directly into their uses in subsequent
patches.

Once the macro defines are replaced, this should make it simpler to read
the code, because it will no longer be necessary to look in a separate
table to find out which opcode bits a field actually uses.  This has
been a growing problem over the years - originally there was a simpler
correspondence between field names and positions, but as the
architecture has grown it has become harder to guess a field's position
from it's name alone.

10 days agoLoongArch: Support R_LARCH_TLS_DTPREL32/64 used in debug section
mengqinggang [Tue, 7 Jul 2026 18:27:02 +0000 (02:27 +0800)] 
LoongArch: Support R_LARCH_TLS_DTPREL32/64 used in debug section

Simplify R_LARCH_TLS_DTPREL32/64 relocations processing.
Return the offset to TLS block for symbol.

Change R_LARCH_TLS_DTPREL32/64 partial_inplace to false since
LoongArch uses RELA relocations.

10 days agoLoongArch: Emit alignment relocations after relaxed instructions
mengqinggang [Tue, 23 Jun 2026 06:03:52 +0000 (14:03 +0800)] 
LoongArch: Emit alignment relocations after relaxed instructions

Alignment cannot change before relaxed instructions.
Emit alignment relocations only after them.

Similar with https://github.com/llvm/llvm-project/pull/150816.

10 days agoLoongArch: Emit fewer relocations for label subtraction
mengqinggang [Sat, 6 Jun 2026 03:43:57 +0000 (11:43 +0800)] 
LoongArch: Emit fewer relocations for label subtraction

Mark the frag and section to indicate if they have a relaxed instruction.

For label subtraction, if there are no relaxed instructions between addsy
and subsy, do not emit relocations.

10 days agoLoongArch: Do not emit relocation if addsy and subsy are in the same frag
mengqinggang [Thu, 4 Jun 2026 06:05:49 +0000 (14:05 +0800)] 
LoongArch: Do not emit relocation if addsy and subsy are in the same frag

Let relaxed instructions and alignment nops in a single frag.
Do not emit relocation if addsy and subsy are in the same frag.

10 days agoLoongArch: Fix the size of tls desc relocations
mengqinggang [Mon, 6 Jul 2026 00:19:27 +0000 (08:19 +0800)] 
LoongArch: Fix the size of tls desc relocations

Change the size of R_LARCH_TLS_DESC64_* from 8 to 4.

10 days agoAutomatic date update in version.in
GDB Administrator [Fri, 10 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

11 days agogdb/hip: Prepare for DWARF-assembler-based HIP testcases
Pedro Alves [Fri, 3 Oct 2025 16:45:39 +0000 (17:45 +0100)] 
gdb/hip: Prepare for DWARF-assembler-based HIP testcases

Compiling a testcase with debug info (by passing passing "debug" as
gdb_compile option) has the effect of passing -g to the compiler.  -g
in turn enables an LLVM option that is essential for debugging:
'-mllvm -amdgpu-spill-cfi-saved-regs'.

That option affects code generation, and some features of the DWARF
assembler machinery rely on code generated by the compiler without -g
to be the exact same as the code generated with -g.

This patch addresses that by always compiling with the LLVM option
that -g would enable.

Approved-by: Lancelot Six <lancelot.six@amd.com> (amdgpu)
Change-Id: I64a938edf97c85d0ea9fc34b37071daa560de7e7

11 days agoMAINTAINERS: update my email address
Nick Alcock [Mon, 27 Apr 2026 22:10:44 +0000 (23:10 +0100)] 
MAINTAINERS: update my email address

11 days agoAVR: Fix typo / white space in include/opcode/avr.h
Georg-Johann Lay [Thu, 9 Jul 2026 11:07:44 +0000 (13:07 +0200)] 
AVR: Fix typo / white space in include/opcode/avr.h

include/
* opcode/avr.h: Fix typo in comment + trailing space.

11 days agoreadelf: Save and dump the original section header values
H.J. Lu [Thu, 2 Jul 2026 02:14:10 +0000 (10:14 +0800)] 
readelf: Save and dump the original section header values

validate_section_info clears the garbage values in the section header
to avoid crash later.  Save and dump the original section header values
to make the garbage values in the section header visible when dumping
section headers.

Note: orig_section_headers, instead of sane_section_headers, is added to
filedata since filedata->section_headers is used in many places.  Replace
filedata->section_headers with filedata->sane_section_headers requires
a much bigger change.

* readelf.c (filedata): Add orig_section_headers.
(save_original_section_header_values): New.
(validate_section_info): Add a pointer to the original section
header and call save_original_section_header_values to save the
original section header values before clearing the section header
fields.
(get_32bit_section_headers): Allocate the original section header
buffer.  Pass the original section header pointer to
validate_section_info.
(get_64bit_section_headers): Likewise.
(process_section_headers): Dump the original section header
values if they exist.
(process_relocs): Pass a dummy original section pointer to
validate_section_info.
(free_filedata): Free filedata->orig_section_headers.
* testsuite/binutils-all/corrupt-1.elf.bz2: New file.
* testsuite/binutils-all/corrupt-1.r: Likewise.
* testsuite/binutils-all/readelf.exp: Run corrupt-1.elf test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
11 days agogdb: z80: Fix endless loop in frame unwinder and validate saved register types
Ronald Hecht [Mon, 15 Jun 2026 07:04:01 +0000 (09:04 +0200)] 
gdb: z80: Fix endless loop in frame unwinder and validate saved register types

In z80_frame_unwind_cache, the loop scanning for the frame base pointer
(for (;; ++sp)) could run into an endless loop or scan too far if the
termination condition (sp < this_base) was not met due to corrupted
or unexpected stack layouts. This patch introduces a loop_count to
limit the scan to a maximum of 2 * addr_len iterations.

Additionally, when iterating through saved registers to adjust their
offsets into concrete addresses, the code now explicitly checks if
the register actually holds an address using is_addr() before calling
addr(). This prevents potential assertions or undefined behavior for
registers that do not contain valid address data.

gdb/ChangeLog:

* z80-tdep.c (z80_frame_unwind_cache): Limit stack scanning
to 2 * addr_len iterations to prevent endless loops. Check
is_addr() before adjusting saved register addresses.

Approved-By: Kevin Buettner <kevinb@redhat.com>
11 days agoRISC-V: Minor cleanup for opcodes/riscv-opc.c
Nelson Chu [Thu, 9 Jul 2026 03:26:08 +0000 (11:26 +0800)] 
RISC-V: Minor cleanup for opcodes/riscv-opc.c

Unify vendor extension comments.

11 days agoRISC-V: Check for conflicting extensions when the linker merges arch attributes
Ethan Y. C. Liang [Mon, 6 Jul 2026 11:44:28 +0000 (19:44 +0800)] 
RISC-V: Check for conflicting extensions when the linker merges arch attributes

The linker validates the arch of each input when parsing it, but never
checks the merged arch as a whole, so conflicting extensions could
silently slip through.  The merge can even imply extensions that
neither input implies alone, e.g. `c' from one input and `d' from
another imply `zcd', which conflicts with `zcmp'.

After merging the input archs, add the implicit extensions to the
merged arch, then run the conflict checks on it and reject the merge
if any conflict is found.  Add tests for such merges.

11 days agoRISC-V: Release subset lists on all paths when the linker merges arch attributes
Ethan Y. C. Liang [Mon, 6 Jul 2026 11:44:27 +0000 (19:44 +0800)] 
RISC-V: Release subset lists on all paths when the linker merges arch attributes

riscv_merge_arch_attr_info returned early on the error paths without
releasing in_subsets, out_subsets and merged_subsets, so the nodes
already added to them were leaked.  The leaked nodes of in_subsets
and out_subsets also carry over into the next merge.

Route every post-parse error path through a single cleanup exit that
releases all three subset lists, and drop the now-redundant reset of
merged_subsets at entry.

11 days agoRISC-V: Minor cleanup for include/opcode/riscv-opc.h and vendor gas testcases
Nelson Chu [Thu, 9 Jul 2026 00:46:00 +0000 (08:46 +0800)] 
RISC-V: Minor cleanup for include/opcode/riscv-opc.h and vendor gas testcases

For include/opcode/riscv-opc.h, reorder zicfiss and zicfilp stuff, and unify
vendor extension comments.  For gas tescases, unify vendor testcase names.

11 days agoAutomatic date update in version.in
GDB Administrator [Thu, 9 Jul 2026 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in