]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
10 days agogdb/help: Update help message for target record-core
Guinevere Larsen [Fri, 24 Oct 2025 11:43:46 +0000 (08:43 -0300)] 
gdb/help: Update help message for target record-core

Before this commit, the help message for target record-core is the same
as the help message for target record-full, which is the following:
    Log program while executing and replay execution from log.

For one, having the same message is unhelpful, since it doesn't tell
users what the difference between the two is.  But, more importantly,
that message seems to also be incorrect, since attempting to execute the
inferior forward from a restored file past the end of history will crash
GDB, since there isn't an actual live inferior to run.

To fix this, the help text is updated to the following:
    Load a saved execution log, allowing replay of the last instructions
This message doesn't imply that future execution is supported, while it
shows that replaying within recorded instructions *is* supported.

Approved-By: Tom Tromey <tom@tromey.com>
10 days agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Oct 2025 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

10 days agohppa64: Mostly fix symbol versioning support
John David Anglin [Sun, 26 Oct 2025 22:20:37 +0000 (18:20 -0400)] 
hppa64: Mostly fix symbol versioning support

The dot prefix used for R_PARISC_EPLT relocations causes issues
for symbol version support as no version section is defined for
these symbols.  This causes the linker to exit with an error.

This change modifies the handling of EPLT relocations to use
offsets relative to a __text_seg base symbol.  This symbol is
defined in the same way as the HP linker (a section symbol for
the .dynamic section).

This mostly fixes the symbol versioning support.  There are
still issues caused by the munging of the value and section
of dynamic symbols.  The value modifies the sorting of the
dynamic table by number.  The section changes the type of
text symbols to data symbols.  I don't think the section munging
is actually needed but that's an issue for another patch.

2025-10-26  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (USE_DOT_ELPT_PREFIX): Define.
(struct elf_link_hash_entry): Add text_segment field.
(allocate_global_data_opd): Compute hppa_info.
Condition old dot prefix code on USE_DOT_ELPT_PREFIX.
Add new code to setup __text_seg hash table entry.
(elf64_hppa_finalize_opd): Check hh.  Rework to output
relocation using __text_seg base.
(elf64_hppa_finish_dynamic_sections): Remove duplicate
comment.
(elf_hppa_final_link_relocate): Move code to initialize
the segment base values forward.

10 days agohppa64: Fix linking of linux kernel
John David Anglin [Sun, 26 Oct 2025 20:34:35 +0000 (16:34 -0400)] 
hppa64: Fix linking of linux kernel

Relocation handling is currently brokern for linker and ld script
symbols.

2025-10-26  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (elf64_hppa_check_relocs): Don't set hh to
NULL for linker and ld script symbols.

11 days agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Oct 2025 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 days agoAutomatic date update in version.in
GDB Administrator [Sat, 25 Oct 2025 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

12 days agoelf: Drop the FIXME comment in set_symbol_value
H.J. Lu [Fri, 24 Oct 2025 21:10:49 +0000 (05:10 +0800)] 
elf: Drop the FIXME comment in set_symbol_value

Since

commit aeaaa9af6359c8e394ce9cf24911fec4f4d23703
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Sep 23 08:52:26 2025 +0800

    elf: Return error on unsorted symbol table if not allowed

returns false when get_link_hash_entry returns NULL, we can drop the FIXME
comment now.

PR ld/33450
* elflink.c (set_symbol_value): Drop the FIXME comment.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
12 days agoBFD: Fix function prototype breakage through stabs.c
Maciej W. Rozycki [Fri, 24 Oct 2025 20:39:46 +0000 (21:39 +0100)] 
BFD: Fix function prototype breakage through stabs.c

Update function prototype templates through stabs.c according to commit
eb92a17c47ea ("bfd: move sec_info from ELF to general section struct"),
which changed the generated prototypes in libbfd.h by hand rather than
by remaking them properly from sources, and causing the build to fail as
soon as libbfd.h has been regenerated.

While at it remove an extraneous character introduced by the same commit
to a comment for a new member of `struct bfd_section'.

12 days agogdb/reverse: update error message for "reverse-" commands
Guinevere Larsen [Thu, 23 Oct 2025 18:05:33 +0000 (15:05 -0300)] 
gdb/reverse: update error message for "reverse-" commands

Before this change, when a user tried to use a command that executes the
inferior in reverse, they would get the following error message:
    Target multi-thread does not support this command.

As an end-user with no knowledge of the internals of GDB would have as a
best guess, that reverse execution as a whole would not be supported in
their system (verified by asking a couple new users).

This commit changes the message to avoid the internal terminology, and
to add a hint that the user may need to create a recording somehow to be
able to execute in reverse.

Approved-By: Tom Tromey <tom@tromey.com>
12 days agoHandle dynamic DW_AT_bit_size
Tom Tromey [Tue, 14 Oct 2025 19:26:30 +0000 (13:26 -0600)] 
Handle dynamic DW_AT_bit_size

gnat-llvm will sometimes emit a structure that that uses
DW_AT_bit_size with an expression to compute the bit size of a record.
I believe this is a DWARF extension.  This patch implements support
for this in gdb.

Reviewed-By: Keith Seitz <keiths@redhat.com>
13 days agogdb: remove TYPE_DATA_LOCATION_ADDR macro
Simon Marchi [Thu, 23 Oct 2025 19:07:01 +0000 (15:07 -0400)] 
gdb: remove TYPE_DATA_LOCATION_ADDR macro

Remove it in favor of using the dynamic_prop::const_val method directly.

Change-Id: I8dea18d7f504d4ec982b6624342f7a301e8fd636
Approved-By: Tom Tromey <tom@tromey.com>
13 days agogdb: remove TYPE_DATA_LOCATION_KIND
Simon Marchi [Thu, 23 Oct 2025 19:07:00 +0000 (15:07 -0400)] 
gdb: remove TYPE_DATA_LOCATION_KIND

Remove it in favor of accessing the dynamic_prop::kind method directly.

Change-Id: I8e5da4443b0df558286ce46eba5754c61f1b95db
Approved-By: Tom Tromey <tom@tromey.com>
13 days agogdb: remove TYPE_DATA_LOCATION_BATON macro
Simon Marchi [Thu, 23 Oct 2025 19:06:59 +0000 (15:06 -0400)] 
gdb: remove TYPE_DATA_LOCATION_BATON macro

It is unused.

Change-Id: Ide860825d8365cfa2370944725c7c999ec2a1cbd
Approved-By: Tom Tromey <tom@tromey.com>
13 days agogdb: remove TYPE_*_PROP macros
Simon Marchi [Thu, 23 Oct 2025 19:06:58 +0000 (15:06 -0400)] 
gdb: remove TYPE_*_PROP macros

Remove the macros in favor of using the dyn_prop member function
directly.

Change-Id: I29758ea408610a2df0a6a226327d1f1af39a178d
Approved-By: Tom Tromey <tom@tromey.com>
13 days agogdb: add gdb_rl_tilde_expand util
Simon Marchi [Thu, 23 Oct 2025 16:34:23 +0000 (12:34 -0400)] 
gdb: add gdb_rl_tilde_expand util

Add gdb_rl_tilde_expand, a wrapper around readline's tilde_expand that
returns a gdb::unique_xmalloc_ptr<char>.  Change all callers of
tilde_expand to use gdb_rl_tilde_expand (even the couple of spots that
release it immediatly, for consistency).  This simplifies a few callers.

The name gdb_tilde_expand is already taken by a home-made implementation
in gdbsupport/gdb_tilde_expand.{h.cc}.  I wonder if we could just use
that one instead of readline's tilde_expand, but that's an orthogonal
question.  I don't know how they differ, and I don't want to introduce
behavior changes in this patch.

Change-Id: I6d34eef19f86473226df4ae56d07dc01912e3131
Approved-By: Tom Tromey <tom@tromey.com>
13 days agogdb: replace use of alloca with std::string in openp
Simon Marchi [Thu, 23 Oct 2025 22:54:56 +0000 (18:54 -0400)] 
gdb: replace use of alloca with std::string in openp

This makes the code simpler and hopefully safer.

Change-Id: I30c7f0bc0c786621858d3f46d138f3b596dc49f5
Approved-By: Tom Tromey <tom@tromey.com>
13 days agold: testsuite: xfail ld-elf/compress1a etc. on Solaris/sparcv9 [PR25802]
Rainer Orth [Fri, 24 Oct 2025 13:57:24 +0000 (15:57 +0200)] 
ld: testsuite: xfail ld-elf/compress1a etc. on Solaris/sparcv9 [PR25802]

A couple of tests FAIL on Solaris/sparcv9:

FAIL: ld-elf/compress1a
FAIL: ld-elf/compressed1a
FAIL: ld-elf/eh5
FAIL: --gc-sections with multiple debug sections for a function section

The symptom is always similar:

compress1.o:(.debug_info+0x10): relocation truncated to fit: R_SPARC_UA32 against `.text'
eh5.o:(.eh_frame+0x3e): relocation truncated to fit: R_SPARC_UA32 against symbol `my_personality_v0' defined in .text section in eh5.o
all-debug-sections.o: in function `debug_info_main':
(.debug_info.text.main+0x4): relocation truncated to fit: R_SPARC_32 against symbol `main' defined in .text.main section in all-debug-sections.o

With the default Solaris/sparcv9 text address of 0x100000000, the
relocations are out of the 32-bit range of R_SPARC_UA32 resp. R_SPARC_32,
so the "relocation truncated to fit" errors are benign.

One could avoid those by linking the affected tests with -Ttext=0x80000000,
matching Solaris /usr/lib/ld/map.below4G, but that doesn't reflect real
usage.  Therefore this patch xfail's those tests.

Tested on sparcv9-sun-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2025-07-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

ld:
PR ld/25802
* testsuite/ld-elf/compress1a.d: xfail on sparcv9-*-solaris2*.
* testsuite/ld-elf/compressed1a.d: Likewise.
* testsuite/ld-elf/eh5.d: Likewise.
* testsuite/ld-gc/all-debug-sections.d: Likewise.

13 days ago[gdb/testsuite] Remove gdb.base/gdbindex-stabs.exp
Tom de Vries [Fri, 24 Oct 2025 13:40:29 +0000 (15:40 +0200)] 
[gdb/testsuite] Remove gdb.base/gdbindex-stabs.exp

On openSUSE Leap 15.6 x86_64 I ran into:
....
(gdb) file gdbindex-stabs^M
Reading symbols from gdbindex-stabs...^M
warning: stabs debug information is not supported.^M
(gdb) list stabs_function^M
(gdb) FAIL: gdb.base/gdbindex-stabs.exp: list stabs_function
...

Fix this by removing the test-case.

Approved-By: Tom Tromey <tom@tromey.com>
13 days agoz80, gas: follow historical assemblers and allow "op A,x" and "op x"
H. Peter Anvin [Fri, 24 Oct 2025 13:12:39 +0000 (15:12 +0200)] 
z80, gas: follow historical assemblers and allow "op A,x" and "op x"

For arithmetic ops, Z80 syntax wants "op A,x" for ADD, ADC and SBC and
"op x" for SUB, AND, OR, XOR, and CP. Many historical assemblers
simply treat them orthogonally; allowing but not requiring the "A,"
operand for any of these operations. This is widely used in legacy
source code, and there is no reason not to.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
13 days agobfd: section merging for PE/COFF images
Jan Beulich [Fri, 24 Oct 2025 13:12:07 +0000 (15:12 +0200)] 
bfd: section merging for PE/COFF images

Leverage the generalized section merging to enable it also when linking
PE/COFF images (from ELF objects).

Sadly the previous hack in bfd_generic_get_relocated_section_contents()
(from "bfd: generalize _bfd_elf_merge_sections()") is getting yet more
bogus.

13 days agobfd: replace _bfd_merge_sections() hook with simple boolean
Jan Beulich [Fri, 24 Oct 2025 13:11:39 +0000 (15:11 +0200)] 
bfd: replace _bfd_merge_sections() hook with simple boolean

There's no need for a hook; what needs doing is uniform, the question is
only whether to perform any merging (i.e. whether other parts of a backend
are capable of dealing with the effects).

Where _bfd_nolink_bfd_merge_sections() was used, false is hardcoded. For
ELF no real target override is permitted; true is hardcoded except for the
cases where bfd_generic_merge_sections() was used as the hook function
before.

13 days agobfd: generalize _bfd_elf_merge_sections()
Jan Beulich [Fri, 24 Oct 2025 13:11:11 +0000 (15:11 +0200)] 
bfd: generalize _bfd_elf_merge_sections()

Except for the ELF class check, which isn't needed anymore when the
generic linker knows how to deal with SEC_MERGE sections, there isn't
anything substantially ELF-specific left in the function.

This also eliminates the need for the "remove_hook" callback.

As a result, section merging itself now works for mixed-class ELF input
objects (issues with dropping of symbols and relocations that were there
before for such cases remain present, though), i.e. the PR ld/19013
testcases need adjusting accordingly: Both now expect identical .rodata
contents. While making the change, add another line of expected output,
to properly match after "#...". Else a mismatch on the important line
isn't properly visible in ld.log.

In set_symbol_from_hash() additionally set BSF_GLOBAL when dealing with a
defined symbol. Without that the if() body ahead of the one being added to
default_indirect_link_order() would not be entered once previously
undefined symbols become defined (suggesting that there is a pre-existing
issue there).

13 days agobfd: simplify _bfd_{link,write,discard}_section_stabs() interface
Jan Beulich [Fri, 24 Oct 2025 13:10:35 +0000 (15:10 +0200)] 
bfd: simplify _bfd_{link,write,discard}_section_stabs() interface

... as well as that of _bfd_stab_section_offset(): As sec_info is now
hanging off of sec, there's no need for the extra 4th parameter anymore.
Along these line struct struct coff_section_tdata's stab_info member then
isn't needed anymore either.

Furthermore there also hasn't been a good reason to have the caller of
_bfd_link_section_stabs() set sec_info_type.

13 days agobfd: simplify _bfd_merged_section_offset() interface
Jan Beulich [Fri, 24 Oct 2025 13:10:09 +0000 (15:10 +0200)] 
bfd: simplify _bfd_merged_section_offset() interface

As sec_info is now hanging off of sec, there's no need for the extra 3rd
parameter anymore; all callers pass as 2nd argument the address of a
section pointer that sec_info can be fetched from.

13 days agobfd: simplify _bfd_{add_merge,write_merged}_section() interface
Jan Beulich [Fri, 24 Oct 2025 13:09:39 +0000 (15:09 +0200)] 
bfd: simplify _bfd_{add_merge,write_merged}_section() interface

As sec_info is now hanging off of sec, there's no need for the extra 4th /
3rd parameter anymore. Along these line struct sec_merge_sec_info's
psecinfo member then isn't needed anymore either.

Furthermore there also hasn't been a good reason to have the caller of
_bfd_add_merge_section() set sec_info_type.

13 days agobfd: move sec_info from ELF to general section struct
Jan Beulich [Fri, 24 Oct 2025 13:09:11 +0000 (15:09 +0200)] 
bfd: move sec_info from ELF to general section struct

This is in preparation of supporting section merging also when the output
isn't ELF (or not of the same class). Note that it's also more consistent
this way, as the related sec_info_type field also live in the same struct.

13 days agobfd: move merge_info from ELF to general link hash table
Jan Beulich [Fri, 24 Oct 2025 13:08:33 +0000 (15:08 +0200)] 
bfd: move merge_info from ELF to general link hash table

This is in prepration of supporting section merging also when the output
isn't ELF (or not of the same class).

13 days agoRemove get_context_stack_depth
Tom Tromey [Fri, 24 Oct 2025 00:04:14 +0000 (18:04 -0600)] 
Remove get_context_stack_depth

Nothing calls get_context_stack_depth, so this patch removes it.

I looked at also removing context_stack::depth but apparently this is
used in coffread.c, and I didn't want to figure out how to make it
local to just that code.

I'm checking this in as obvious.

13 days agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Oct 2025 00:00:30 +0000 (00:00 +0000)] 
Automatic date update in version.in

13 days agoUse bool in buildsym
Tom Tromey [Fri, 17 Oct 2025 01:23:21 +0000 (19:23 -0600)] 
Use bool in buildsym

This changes the buildsym code to use bool rather than int, where
appropriate.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
13 days agoRemove buildsym_compunit::end_compunit_symtab_with_blockvector
Tom Tromey [Fri, 17 Oct 2025 01:17:14 +0000 (19:17 -0600)] 
Remove buildsym_compunit::end_compunit_symtab_with_blockvector

This patch removes buildsym_compunit::end_compunit_symtab_with_blockvector.
This method is only called in one spot and the two methods can easily
be combined.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
13 days agogdb: change find_pcs_for_symtab_line() to return entries instead of PCs
Jan Vrany [Thu, 23 Oct 2025 19:39:44 +0000 (20:39 +0100)] 
gdb: change find_pcs_for_symtab_line() to return entries instead of PCs

This commit changes find_pcs_for_symtab_line() to return complete
linetable entries instead of just PCs.  This is a preparation for adding
more attributes to gdb.LinetableEntry objects.

I also renamed the function to find_linetable_entries_for_symtab_line()
to better reflect what it does.

Approved-By: Tom Tromey <tom@tromey.com>
13 days agoRemove iterate_over_symbols_terminated
Tom Tromey [Thu, 23 Oct 2025 18:13:23 +0000 (12:13 -0600)] 
Remove iterate_over_symbols_terminated

iterate_over_symbols_terminated only has a single caller, in
ada-lang.c.  It's simpler to handle this case directly there.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
13 days agoFree multidicts from blockvector
Tom Tromey [Fri, 17 Oct 2025 17:23:38 +0000 (11:23 -0600)] 
Free multidicts from blockvector

Currently, nothing in the tree ever calls mdict_free.  However, code
does heap-allocate some multidicts.  A simple way to see this is to
use valgrind, run "gdb -readnow" on the executable created by
gdb.dwarf2/struct-with-sig.exp, and then use "file" to clear the
objfile list.  This yields:

==1522843== 144 (16 direct, 128 indirect) bytes in 1 blocks are definitely lost in loss record 905 of 3,005
==1522843==    at 0x4843866: malloc (vg_replace_malloc.c:446)
==1522843==    by 0x48E397: xmalloc (alloc.c:52)
==1522843==    by 0x59DE66: multidictionary* xnew<multidictionary>() (poison.h:102)
==1522843==    by 0x59CFF4: mdict_create_hashed_expandable(language) (dictionary.c:965)
==1522843==    by 0x50A269: buildsym_compunit::finish_block_internal(symbol*, pending**, pending_block*, dynamic_prop const*, unsigned long, unsigned long, int, int) (buildsym.c:221)
==1522843==    by 0x50AE04: buildsym_compunit::end_compunit_symtab_get_static_block(unsigned long, int, int) (buildsym.c:818)
==1522843==    by 0x50C4CF: buildsym_compunit::end_expandable_symtab(unsigned long) (buildsym.c:1037)
==1522843==    by 0x61DBC6: process_full_type_unit (read.c:4970)

This patch fixes the leaks by calling mdict_free when a blockvector is
destroyed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
13 days agoTwo bug fixes in mdict_free
Tom Tromey [Fri, 17 Oct 2025 17:21:50 +0000 (11:21 -0600)] 
Two bug fixes in mdict_free

A heap-allocated multidictionary should be freed by calling
mdict_free.  However, while this function does free the contents of
the dictionary, it neglects to free the dictionary itself.

There's also a second bug, which is that if a multidictionary is
created with no dictionaries, gdb will crash on the first line of
mdict_free:

  enum dict_type type = mdict->dictionaries[0]->vector->type;

So, this patch also adds the type to struct multidictionary, avoiding
this problem.  Note that this does not increase the structure size on
x86-64, because the new member fits into the padding.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 weeks agoRemove Python API checker defines
Tom Tromey [Tue, 21 Oct 2025 16:00:20 +0000 (10:00 -0600)] 
Remove Python API checker defines

The GCC plugin that implements the Python API checker does not appear
to really be maintained.  And, as far as I know, it never really
worked for C++ code anyway.  Considering those factors, and that no
one has tried to run it in years, I think it's time to remove the
macros from the gdb source.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 weeks agoRemove Py_TPFLAGS_CHECKTYPES
Tom Tromey [Tue, 21 Oct 2025 16:04:14 +0000 (10:04 -0600)] 
Remove Py_TPFLAGS_CHECKTYPES

According to 'git annotate', the Py_TPFLAGS_CHECKTYPES was added to
python-internal.h way back when gdb was first ported to Python 3.  It
was a compatibility fix for Python 2.

This is not needed any more, because Python 2 is no longer supported.
This patch removes the vestiges.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 weeks agogdb: update mdebugread.c to use blockvector::block_less_than
Jan Vrany [Thu, 23 Oct 2025 11:01:34 +0000 (12:01 +0100)] 
gdb: update mdebugread.c to use blockvector::block_less_than

This commit updates mdebugread.c to use common blockvector ordering
predicate. It also changes the code to use std::stable_sort as in
buildsym.c. This is probably not necessary but should not hurt and makes
block sorting code more consistent.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: add block ordering predicate for ordering blocks in blockvector
Jan Vrany [Thu, 23 Oct 2025 11:01:34 +0000 (12:01 +0100)] 
gdb: add block ordering predicate for ordering blocks in blockvector

This commit adds blockvector::block_less_than() predicate that defines
required ordering of blocks within blockvector.

It orders blocks so that blocks with lower start address come before
blocks with higher start address.  If two blocks start at the same
address, enclosing (larger) block should come before nested (smaller)
block.

This ordering is depended upon in find_block_in_blockvector(). Although
its comment did not say so, find_block_in_blockvector() is called from
blockvector_for_pc_sect() which is explicit about it. While at it, I
changed the comment of find_block_in_blockvector() to say so explicitly
too.

As Andrew pointed out, buildsym.c sorts block slightly differently,
taking only the start address into account.  The comment there says
blocks with same start address should not be reordered as they are in
correct order already and that order is needed.  It is unclear to me
if buildsym.c arranges blocks starting at the same address in required
order before sorting them or this happens "by chance".  I did modify
buildsym_compunit::make_blockvector() to assert blocks are properly
ordered and running testsuite did not show any regressions.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: use std::vector<> to hold on blocks in struct blockvector
Jan Vrany [Thu, 23 Oct 2025 11:01:34 +0000 (12:01 +0100)] 
gdb: use std::vector<> to hold on blocks in struct blockvector

This patch changes blockvector to be allocated on the heap (using 'new')
and changes internal implementation to use std::vector<> rather than
flexible array to add blocks to existing blockvector. This is needed for
lazy CU expansion and for Python API to build objfiles, compunits and
symtabs dynamically (similarly to JIT reader API).

The downside is higher memory consumption. The size of std::vector is
24 bytes (GCC 14) compared to 8 bytes used currently to store the number
of blocks (m_num_blocks). Stopping gdb at its main(), followed by
"maint expand-symtabs" results in 4593 compunit symtabs so in this case
the overhead is 16*4593 = 73488 bytes which I hope is acceptable.

While at it, add blockvector::append_block() to add more block at the
end of block vector. This is currently used only in mdebugread.c.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Oct 2025 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agohppa64: Fix bfd_put_xx bfd argument in elf_hppa_final_link_relocate
John David Anglin [Wed, 22 Oct 2025 18:21:52 +0000 (14:21 -0400)] 
hppa64: Fix bfd_put_xx bfd argument in elf_hppa_final_link_relocate

2025-10-22  John David Anglin  <danglin@gcc.gnu.org>

bfd/ChangeLog:

* elf64-hppa.c (elf_hppa_final_link_relocate): Change
bfd_put_32 and bfd_put_64 bfd argument from input_bfd
to output_bfd.

2 weeks agoAvoid c-ctype.h in libinproctrace.so
Tom Tromey [Tue, 21 Oct 2025 13:42:40 +0000 (07:42 -0600)] 
Avoid c-ctype.h in libinproctrace.so

libinproctrace.so doesn't link against gnulib, and some versions of
clang won't inline the c-ctype.h functions.  This causes link
failures.

This patch works around the problem by reverting to <ctype.h> in this
case.

Tested-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks agogdb/record: Speeding up recording in RISC-V
timurgol007 [Wed, 8 Oct 2025 15:44:19 +0000 (18:44 +0300)] 
gdb/record: Speeding up recording in RISC-V

I measured that removing saving mem chunks and regs to std::vector before
calling API functions speeds up stepping up to 15%, so I added this
optimization (as Guinevere Larsen <guinevere@redhat.com> recommended in
initial support). It turns out that after this, the m_record_type and
m_error_occured no longer needed, so I removed them too.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
2 weeks ago[gdb/testsuite] Simplify gdb.cp/local-static.exp
Tom de Vries [Wed, 22 Oct 2025 15:32:57 +0000 (17:32 +0200)] 
[gdb/testsuite] Simplify gdb.cp/local-static.exp

Simplify test-case gdb.cp/local-static.exp in the following way.

First rewrite this uplevel into a more usual form:
...
-set print_quoted_re [uplevel 1 "subst_vars \"$print_quoted_re\""]
+set print_quoted_re [uplevel 1 [list subst -nocommands $print_quoted_re]]
...

This requires us to use "subst -nocommands" instead of subst_vars, to allow
backslash substitution, which previously was happening implicitly because of
the way uplevel was used.

Then, declare globals hex and syntax_re, such that we no longer have to use
uplevel:
...
-set print_quoted_re [uplevel 1 [list subst -nocommands $print_quoted_re]]
+set print_quoted_re [subst -nocommands $print_quoted_re]
...

Finally, stop applying backslash substitution, simplifying cxx_scopes_list and
c_scopes_list:
...
-set print_quoted_re [subst -nocommands $print_quoted_re]
+set print_quoted_re [subst_vars $print_quoted_re]
...

While we're at it, simplify some regexps using string_to_regexp in a few places.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: fix loading compressed scripts from `.debug_gdb_scripts`-section
Maximilian Bosch [Fri, 10 Oct 2025 09:20:42 +0000 (11:20 +0200)] 
gdb: fix loading compressed scripts from `.debug_gdb_scripts`-section

The function `gdb_bfd_get_full_section_contents` doesn't implement
decompressing debug sections. This regresses loading `.debug_gdb_scripts`-section
from ELFs that were built with `-ggdb -Wa,--compress-debug-sections`
giving the following warnings on load:

    warning: BFD: /home/ma27/.cache/debuginfod_client/8284e3a74f442359679ee97e96ee1c434e4479b7/debuginfo: unable to get decompressed section .debug_gdb_scripts
    warning: Couldn't read .debug_gdb_scripts section of /home/ma27/.cache/debuginfod_client/8284e3a74f442359679ee97e96ee1c434e4479b7/debuginfo

The problem can be reproduced with a `test.cc` like this:

    __asm__(".pushsection \".debug_gdb_scripts\", \"MS\",%progbits,1\n"
            ".ascii \"\\4gdb.inlined-script.BOOST_OUTCOME_INLINE_GDB_PRETTY_PRINTER_H\\n\"\n"
            ".ascii \"import gdb.printing\\n\"\n"
            ".ascii \"import os\\n\"\n"

            /* a sufficiently long script such that it gets actually
               compressed */

            ".byte 0\n"
            ".popsection\n");
    #include <iostream>
    int main(void) {
        std::cout << "hello world\n";
        return 0;
    }

I compiled the file with
`g++ test.cc -o test-program -ggdb -Wa,--compress-debug-sections` (GCC
version 14.3.0).

As suggested, this refactors gdb_bfd_get_full_section_contents to use
bfd_get_full_section_contents which implements decompression.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks ago[gdb] Drop gdb.stabs exclude from tclint.toml
Tom de Vries [Wed, 22 Oct 2025 07:38:03 +0000 (09:38 +0200)] 
[gdb] Drop gdb.stabs exclude from tclint.toml

Now that gdb/testsuite/gdb.stabs has been removed, drop the corresponding
exclude from gdb/tclint.toml.

Tested by running "pre-commit run --all-files".

2 weeks ago[gdb/testsuite] Add proc subst_vars
Tom de Vries [Wed, 22 Oct 2025 05:36:07 +0000 (07:36 +0200)] 
[gdb/testsuite] Add proc subst_vars

Add proc subst_vars, an alias of subst -nobackslashes -nocommands.

I've used tailcall to implement this:
...
proc subst_vars { str } {
    tailcall subst -nobackslashes -nocommands $str
}
...
but I found that this also works:
...
proc subst_vars { str } {
    return [uplevel 1 [list subst -nobackslashes -nocommands $str]]
}
...

I've found other uses of subst that don't add "-nobackslashes -nocommands",
but really only use subst to do variable substitution.  Also use subst_vars in
those cases.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks ago[gdb/contrib] Handle unknown attribute in dwarf-to-dwarf-assembler.py
Tom de Vries [Wed, 22 Oct 2025 05:28:45 +0000 (07:28 +0200)] 
[gdb/contrib] Handle unknown attribute in dwarf-to-dwarf-assembler.py

I ran gdb/contrib/dwarf-to-dwarf-assembler.py on a hello world compiled with
gcc 15, and ran into:
...
Traceback (most recent call last):
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 642, in <module>
    main(sys.argv)
    ~~~~^^^^^^^^^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 638, in main
    generator.generate()
    ~~~~~~~~~~~~~~~~~~^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 610, in generate
    self.generate_die(die, indent_count)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 589, in generate_die
    die_lines = die.format(self.dwarf_parser.offset_to_die, indent_count)
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 279, in format
    return "\n".join(self.format_lines(offset_die_lookup, indent_count))
                     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 376, in format_lines
    inner_lines = super().format_lines(offset_die_lookup, indent_count + 1)
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 251, in format_lines
    attr_line = attr.format(
        offset_die_lookup, indent_count=indent_count + 1
    )
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 199, in format
    s += self.name + " "
         ~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'str'
...
because of trying to print DWARF v6 attributes DW_AT_language_name (0x90) and
DW_AT_language_version (0x91).

Fix this by printing the number if the name is not known:
...
            {DW_AT_0x90 3 DW_FORM_data1}
            {DW_AT_0x91 202311 DW_FORM_data4}
...

2 weeks ago[gdb/contrib] Fix errno.EOPNOTSUP in dwarf-to-dwarf-assembler.py
Tom de Vries [Wed, 22 Oct 2025 05:28:45 +0000 (07:28 +0200)] 
[gdb/contrib] Fix errno.EOPNOTSUP in dwarf-to-dwarf-assembler.py

When running dwarf-to-dwarf-assembler.py without arguments, I run into:
...
$ ./gdb/contrib/dwarf-to-dwarf-assembler.py
Usage:
python ./asm_to_dwarf_assembler.py <path/to/elf/file>
Traceback (most recent call last):
  File "/data/vries/gdb/binutils-gdb.git/./gdb/contrib/dwarf-to-dwarf-assembler.py", line 621, in main
    filename = argv[1]
               ~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/vries/gdb/binutils-gdb.git/./gdb/contrib/dwarf-to-dwarf-assembler.py", line 642, in <module>
    main(sys.argv)
    ~~~~^^^^^^^^^^
  File "/data/vries/gdb/binutils-gdb.git/./gdb/contrib/dwarf-to-dwarf-assembler.py", line 625, in main
    sys.exit(errno.EOPNOTSUP)
             ^^^^^^^^^^^^^^^
AttributeError: module 'errno' has no attribute 'EOPNOTSUP'. Did you mean: 'EOPNOTSUPP'?
...

Fix this by using errno.EOPNOTSUPP.

2 weeks agoobjcopy: Don't add zstd to the debug compression options if not available
Pietro Monteiro [Mon, 20 Oct 2025 00:14:51 +0000 (20:14 -0400)] 
objcopy: Don't add zstd to the debug compression options if not available

If zstd is not available or was intentionally disabled by the user
don't add it to the list of the available options to compress debug
sections when showing usage.

binutils/
* objcopy.c (copy_usage): Only output
--compress-debug-sections=zstd if HAVE_ZSTD.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Oct 2025 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoAArch64: Fix SME za register description
Luis Machado [Sat, 11 Oct 2025 10:43:48 +0000 (11:43 +0100)] 
AArch64: Fix SME za register description

Peter Maydell and Vacha Bhavsar pointed out that we have an incorrect
description of the SME za register in the documentation.  It is currently
described as a vector of SVL x SVL bytes, but that is incorrect.

What we really have is a 2-dimensional array of bytes, with each dimension
having size SVL.

Change the documentation to reflect that.

Approved-By: Eli Zaretskii <eliz@gnu.org>
2 weeks agoLD/testsuite: Add tests for mapless archive rejection
Maciej W. Rozycki [Tue, 21 Oct 2025 20:02:38 +0000 (21:02 +0100)] 
LD/testsuite: Add tests for mapless archive rejection

Verify that archives are rejected in the link, regular and thin, that
have no symbol map included.  Exclude XCOFF targets from verification
which have handling for such archives implemented and therefore accept
them.  These targets will be handled with a follow-up change.

2 weeks agoLD/testsuite: Add tests for archive handling
Maciej W. Rozycki [Tue, 21 Oct 2025 20:02:38 +0000 (21:02 +0100)] 
LD/testsuite: Add tests for archive handling

Add basic verification for archives to work, regular and thin, in the
link.  Refer to PR binutils/33484 and PR binutils/33485 for targets that
fail these basic checks, where `ar' fails to add subsequent members to
the archive or fails to add symbols from subsequent members to the map
respectively, for thin archives.

NB symbol names chosen such as to avoid a clash with Z80 CPU registers.

2 weeks agogdb: remove support for dbx from GDB
Guinevere Larsen [Wed, 12 Feb 2025 19:07:38 +0000 (16:07 -0300)] 
gdb: remove support for dbx from GDB

With the removal of stabs support, reading a dbx inferior has become a
no-op and GDB is unable to perform sybmolic debugging in such inferiors.
As such, this commit removes the files that work on it with spotty
support.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: Fully remove stabs code from GDB
Guinevere Larsen [Wed, 12 Feb 2025 13:40:06 +0000 (10:40 -0300)] 
gdb: Fully remove stabs code from GDB

This commit is the last in the series removing GDB's support for stabs.
It removes the stabsread.{c|h} files, and removes the last usage of
stabsread stuff in buildsym.  Notably, the header file gdb-stabs.h
remains in the tree as it is misnamed at this point - it is used for
reading dbx objfiles.  It (and dbxread) will be removed in a future
commit.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: Remove stabs support from XCOFF inferiors
Guinevere Larsen [Wed, 29 Jan 2025 12:31:03 +0000 (09:31 -0300)] 
gdb: Remove stabs support from XCOFF inferiors

This commit is the second to last in the series fully removing support
for stabs in GDB, removing it from XCOFF inferiors.  According to IBM's
AIX documentation[1], xcoff binaries can only have stabs or DWARF debug
info, meaning removing stabs seems pretty trivial, as anything that
isn't related to setting base information on the objfile or reading
dwarf can be removed.

The unfortunate part of this removal is that XCOFF minimal symbols are
encoded in stabs, so if an inferior has not been compiled with dwarf
debuginfo, GDB will only be able to do assembly-level debugging.  Due to
this, the xcoff reader now emits a warning if no dwarf is read, saying:
"No usable debug information found".  This change would also add a lot of
regressions to to AIX, so the gdb_compile proc has been changed to not
work when a test tries to compile a test with nodebug.

As a sidenote, gdb-stabs.h can just be removed from rs6000-aix-nat, as
none of the structs or macros defined in the header are used in the nat
file, so that is an unnecessary include.

This commit introduces some known regressions when testing GDB in AIX
systems.  The main ones are:
* inferior function calls now crash with a corrupted stack.  This seems
  to be some fault of dwarf in explaining how to correctly set the frame
  for a function.
* fortran tests can't runto_main: the fortran compiler does not add any
  symbol for MAIN__ in the dwarf information, only in stabs, so the
  fortran_runto_main proc can't set the breakpoint correctly.
* When dealing with c++ class methods, there are cases when we fail to
  properly recognize a method call as a new function.
* When dealing with c++ virtual inheritance, GDB has issues finding a
  derived class's members when it has been downcast to a base class.

[1] https://www.ibm.com/docs/en/aix/7.3?topic=formats-xcoff-object-file-format

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: Remove stabs support for COFF files
Guinevere Larsen [Tue, 28 Jan 2025 11:47:02 +0000 (08:47 -0300)] 
gdb: Remove stabs support for COFF files

This commit continues the removal of stabs by removing support from coff
inferiors.  This is trivial for the most part, just a removal of code
setting things only relevant for stabs, with one exception.

The global variables symnum and within_function were introduced to
coffread.c (and within_function was converted to boolean).  I looked into
making them parameters to the relevant function, but this would require
changes to several otherwise untouched functions, so I kept them as globals
instead.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: Remove stabs support from dbx
Guinevere Larsen [Mon, 27 Jan 2025 14:33:11 +0000 (11:33 -0300)] 
gdb: Remove stabs support from dbx

This commit makes it so reading dbx inferiors will not read stabs
debuginfo from the inferiors.

This has the side effect of making reading DBX inferiors a noop.  It
will be removed in a future commit, however, the present series of
commit is focused on just removing stabs.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: Remove stabs support from ELF files
Guinevere Larsen [Wed, 22 Jan 2025 17:05:01 +0000 (14:05 -0300)] 
gdb: Remove stabs support from ELF files

This commit makes it so that GDB won't read stabs information from ELF
files.  If stabs is detected in an ELF file, the reader now warns the user
that stabs is not supported.

This test would cause two new failures in the test gdb.stabs/weird.exp
(that surprisingly didn't happen in the mips commit).  Rather than fixing
the test that'll be removed soon, I just removed the test instead.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb/mdebug: Remove stabs support from mips inferiors
Guinevere Larsen [Tue, 14 Jan 2025 17:28:18 +0000 (14:28 -0300)] 
gdb/mdebug: Remove stabs support from mips inferiors

Ostensibly, the mdebugread.c is about reading debug information in the
ecoff format, but it also supports stabs-in-ecoff according to comments
in there, and also relied in some stabs facilities for ecoff reading
itself.  This commit takes the first step in removing stabs support by
removing those dependencies from mdebug.  And in order to support
stabs-in-ecoff, mipsread would also call stabsread_new_init.

Removing stabs-in-ecoff is trivial, as the code was well demarcated with
comments mentioning where stabs was read.  Plus the call to
stabsread_new_init in mipsread can be trivially removed.

Another simple removal was the dependence on stabs_end_psymtabs: because
the local variables dependencies_used and includes_used were only touched
by stabs-reading code, they are always 0 in the new version, which means
we can find the exact code path that'd be followed in stabs_end_psymtab
and move the relevant lines to mdebug instead.

After all those, the last remaining dependency is when reading a fortran
common block from an inferior compiled by SGI fortran compilers (and
maybe more).  The block could have no address, meaning it'd need to be
fixed after all the minimal symbols have been read.  This was done by
adding the symbol to the stabs global_sym_chain, then calling
scan_file_globals to fix them up.  This commit copies all the necessary
code for handling the fortran symbols onto mdebug, technically making
some code duplication, but since stabsread will be removed soon, this
shouldn't be too concerning.

This change was tested in the compile farm's mips64 machine (number
230), where it actually seems to have solved some 50 failures in the
testsuite, not including changes in tests from gdb.threads, as those are
often very racy.  I'm not sure if these were true fixes or racy cases,
but since the new version has no newly introduced fails, only fewer of
them, I'm inclined to think this change is at least harmless.

Acked-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: move some stabs functions to gdb/buildsym-legacy.h
Guinevere Larsen [Tue, 28 Jan 2025 18:45:10 +0000 (15:45 -0300)] 
gdb: move some stabs functions to gdb/buildsym-legacy.h

The gdb/stabsread.h and .c files define 2 things that, while originally
intended only for stabs reading, actually end up being used for coff,
ecoff and maybe more debuginfo formats. That is the function "hashname",
and the macro HASHSIZE.  Both are used for small hashtables when reading
some symbols with incomplete information.

With the upcoming removal of stabs code, this code should be moved
somewhere, and the location that looked most reasonable was
gdb/buildsym-legacy.  No change in behavior is expected after this
commit.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb/testsuite/gdb.python/py-symbol.exp: accept either rr static symbol when calling...
Simon Marchi [Tue, 7 Oct 2025 18:42:53 +0000 (14:42 -0400)] 
gdb/testsuite/gdb.python/py-symbol.exp: accept either rr static symbol when calling lookup_static_symbol

Since commit dad36cf91992 ("gdb/dwarf: use dynamic partitioning for
DWARF CU indexing"), we get the intermittent failures:

    python print (gdb.lookup_static_symbol ('rr').line)
    18
    (gdb) FAIL: gdb.python/py-symbol.exp: print line number of rr
    python print (gdb.lookup_static_symbol ('rr').value ())
    99
    (gdb) FAIL: gdb.python/py-symbol.exp: print value of rr

The situation is:

 - The program isn't running.
 - Two compilation units define a static symbol named `rr`.
 - The test does:

     gdb.lookup_static_symbol ('rr')

The test expects this to return one specific (out of the two) `rr`
static symbols.  Since dad36cf91992, the call sometimes returns the
wrong symbol.

The documentation for gdb.lookup_static_symbol says this:

    There can be multiple global symbols with static linkage with the
    same name. This function will only return the first matching symbol
    that it finds. Which symbol is found depends on where GDB is
    currently stopped, as GDB will first search for matching symbols in
    the current object file, and then search all other object files. If
    the application is not yet running then GDB will search all object
    files in the order they appear in the debug information.

cooked_index_functions::search searches index shards linearly and
returns the first matching symbol.  Before dad36cf91992, the work was
split statically among threads, so symbols would end up in shards
deterministically.  Since the first part of the debug info ends up in
the first shard, it happens to work as described in the doc.

Since dad36cf91992, symbols end up in random shards, based on which
thread happened to pop their CU from the work queue.

I don't think that specifying which of the multiple matching static
symbols is returned is really useful, as it unnecessarily restricts the
implementation.  If multiple static symbols match the criteria, I think
it makes sense that you'll get an unspecified one.  Code that needs to
deal with the possibility of multiple static symbols of the same name
should use gdb.lookup_static_symbols.

I propose to remove this guarantee from gdb.lookup_static_symbol.  I
understand that this is a breaking change, but I think it's easy enough
to deal with it.

Update the test to accept either symbol.

Update the doc to say that an unspecified symbol will be returned if the
program is not running and there are multiple matching symbols.  The
previous text also seemed a bit wrong about its use of the term "object
file".  GDB searches a static symbol for the current compilation unit
first.  It then falls back to searching all symbols.

Change-Id: I22f81c186b1483a488ea7614fb81fd102db3c7f1
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Tom de Vries <tdevries@suse.de>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33518
Approved-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2 weeks agoCreate script to convert old tests into Dwarf::assemble calls.
William Ferreira [Sun, 12 Oct 2025 21:15:55 +0000 (18:15 -0300)] 
Create script to convert old tests into Dwarf::assemble calls.

PR testsuite/32261 requests a script that could convert old .S-based
tests (that were made before dwarf.exp existed) into the new
Dwarf::assemble calls in Tcl. This commit is an initial implementation
of such a script. Python was chosen for convenience, and only relies on
a single external library.

Usage: the script operates not on .S files, but on ELF files with DWARF
information. To convert an old test, one must run said test via
`make check-gdb TESTS=testname` in their build directory. This will
produce, as a side effect, an ELF file the test used as an inferior, at
gdb/testsuite/outputs/testname/testname. This ELF file is this script's
input.

Reliability: not counting the limitations listed below, the script seems
functional enough to be worthy of discussion in the mailing list. I have
been testing it with different tests that already use Dwarf::assemble,
to see if the script can produce a similar call to it. Indeed, in most
cases that I've tested (including some more complex ones, marked with an
asterisk below) it is able to produce comparable output to the original
exp file. Of course, it can't reproduce the complex code *before* the
Dwarf::assemble call. Values calculated then are simply inlined.

The following .exp files have been tried in this way and their outputs
highly resemble the original:
- gdb.dwarf2/dynarr-ptr
- gdb.dwarf2/void-type
- gdb.dwarf2/ada-thick-pointer
- gdb.dwarf2/atomic-type
- gdb.dwarf2/dw2-entry-points (*)
- gdb.dwarf2/main-subprogram

The following .exp files work, with caveats addressed in the limitations
section below.
- gdb.dwarf2/cpp-linkage-name
  - Works correctly except for one attribute of the form SPECIAL_expr.
- gdb.dwarf2/dw2-unusual-field-names
  - Same as above, with two instances of SPECIAL_expr.
- gdb.dwarf2/implptr-optimized-out
  - Same as above, with two instances of SPECIAL_expr.
- gdb.dwarf2/negative-data-member-location
  - Same as above, with one instance of SPECIAL_expr.

The following .exp files FAIL, but that is expected:
- gdb.dwarf2/staticvirtual.exp
  - high_pc and low_pc of subprogram "~S" are hardcoded in the original
    .exp file, but they get replaced with a get_func_info call. Since
    the function S::~S is not present in the original, get_func_info
    will fail.

The following .exp files DO NOT WORK with this script:
- gdb.dwarf2/cu-no-addrs
  - `aranges` not supported.
  - Compile unit high_pc and low_pc hardcoded, prone to user error
    due to forgetting to replace with variables.
- gdb.dwarf2/dw2-inline-stepping
  - Same as above.
- gdb.dwarf2/fission-relative-dwo
  - `fission` not supported.
- gdb.dwarf2/dw2-prologue-end and gdb.dwarf2/dw2-prologue-end-2
  - Line tables not supported.

Currently the script has the following known limitations:
- It does not support line tables.
- It does not use $srcfile and other variables in the call to
  Dwarf::assemble (since it can't know where it is safe to substitute).
- It does not support "fission" type DWARFs (in fact I still have no
  clue what those are).
- It does not support cu {label LABEL} {} CUs, mostly because I couldn't
  find the information using pyelftools.
- It sometimes outputs empty CUs at the start and end of the call. This
  might be a problem with my machine, but I've checked with DWARF dumps
  and they are indeed in the input ELF files generated by
  `make check-gdb`.
- It does not support attributes with the forms DW_FORM_block* and
  DW_FORM_exprloc. This is mostly not a concern of the difficulty of
  the implementation, but of it being an incomplete feature and, thus,
  more susceptible to users forgetting to correct its mistakes or
  unfinished values (please see discussion started by Guinevere at
  comment 23 https://sourceware.org/bugzilla/show_bug.cgi?id=32261#c23).
  The incompleteness of this feature is easy to demonstrate: any call to
  gdb_target_symbol, a common tool used in these attributes, needs a
  symbol name that is erased after compilation. There is no way to guess
  where that address being referenced in a DW_OP_addr comes from, and it
  can't be hard coded since it can change depending on the machine
  compiling it.

Please bring up any further shortcomings this script may have with your
expectations.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32261
Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agogdb: remove return value of set_current_source_symtab_and_line
Simon Marchi [Mon, 20 Oct 2025 20:10:41 +0000 (16:10 -0400)] 
gdb: remove return value of set_current_source_symtab_and_line

It is never used.

Change-Id: I9bbc87a232a2d0f074fefa08f3435aac82cd3dcf
Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agoCorrect _bfd_elf_section_for_symbol
Alan Modra [Tue, 21 Oct 2025 09:21:09 +0000 (19:51 +1030)] 
Correct _bfd_elf_section_for_symbol

This function was added in commit 2f0c68f23bb3 as part of the compact
EH support.  By the comments it looks like to code was copied from
bfd_elf_reloc_symbol_deleted_p without sufficient editing, and would
only work for local syms due to the discarded_section test left in
place for global syms.  Fix that, and remove the discard param.

* elf-bfd.h (_bfd_elf_section_for_symbol): Update prototype.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame_entry): Adjust.
* elflink.c (_bfd_elf_section_for_symbol): Remove "discard".
Don't test for discarded_section.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Oct 2025 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoOnly set call site if not empty
Tom Tromey [Sat, 18 Oct 2025 20:33:06 +0000 (14:33 -0600)] 
Only set call site if not empty

In an earlier discussion, I noted that most compunit_symtabs do not
have a call-site hash table, so inlining the object into
compunit_symtab did not make sense.

It turns out that this is not entirely true -- while most
compunit_symtabs do not have any data in this object, the object
itself is always created.  This in turn is a regression introduced by
commit de2b4ab5 ("Convert dwarf2_cu::call_site_htab to new hash
table").

This patch fixes the issue by arranging to only store a call-site hash
table when it is non-empty.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 weeks agogdb: remove unused includes in source.c
Simon Marchi [Sun, 12 Oct 2025 01:48:49 +0000 (21:48 -0400)] 
gdb: remove unused includes in source.c

These two are reported as unused by clangd.

Change-Id: I30fb0b986efd27fc6a24b855aeec86c2720ac934

2 weeks agogdb, gdbserver, gdbsupport: trim trailing whitespaces
Simon Marchi [Sat, 11 Oct 2025 03:59:32 +0000 (23:59 -0400)] 
gdb, gdbserver, gdbsupport: trim trailing whitespaces

I noticed my IDE (VSCode) starting to automatically trim trailing
whitespaces on save, despite the setting for it being disabled.  I
realized that this is because the .editorconfig file now has

    trim_trailing_whitespace = true

for many file types.  If we have this EditorConfig setting forcing
editors to trim trailing whitespaces, I think it would make sense to
clean up trailing whitespaces from our files.  Otherwise, people will
always get spurious whitespace changes when editing these files.

I did a mass cleanup using this command:

$ find gdb gdbserver gdbsupport -type f \( \
    -name "*.c" -o \
    -name "*.h" -o \
    -name "*.cc" -o \
    -name "*.texi" -o \
    -name "*.exp" -o \
    -name "*.tcl" -o \
    -name "*.py" -o \
    -name "*.s" -o \
    -name "*.S" -o \
    -name "*.asm" -o \
    -name "*.awk" -o \
    -name "*.ac" -o \
    -name "Makefile*" -o \
    -name "*.sh" -o \
    -name "*.adb" -o \
    -name "*.ads" -o \
    -name "*.d" -o \
    -name "*.go" -o \
    -name "*.F90" -o \
    -name "*.f90" \
\) -exec sed -ri 's/[ \t]+$//' {} +

I then did an autotools regen, because we don't actually want to change
the Makefile and Makefile.in files that are generated.

Change-Id: I6f91b83e3b8c4dc7d5d51a2ebf60706120efe691

2 weeks agogdb: rename find_line_pc_range -> find_pc_range_for_sal
Simon Marchi [Thu, 16 Oct 2025 00:08:04 +0000 (20:08 -0400)] 
gdb: rename find_line_pc_range -> find_pc_range_for_sal

Change-Id: Ibd1692292dfcad088ae74b797c38a483080f2ec1
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_line_symtab -> find_symtab_for_pc
Simon Marchi [Thu, 16 Oct 2025 00:08:03 +0000 (20:08 -0400)] 
gdb: rename find_pc_line_symtab -> find_symtab_for_pc

Change-Id: I2940e0f80c4b1d63fb1aee85f5753df5fbf4326a
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_sect_line -> find_sal_for_pc_sect
Simon Marchi [Thu, 16 Oct 2025 00:08:02 +0000 (20:08 -0400)] 
gdb: rename find_pc_sect_line -> find_sal_for_pc_sect

Change-Id: I9c2a72de57a4ea9c316fc949db4fb0bf7f78eb4b
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_line -> find_sal_for_pc
Simon Marchi [Thu, 16 Oct 2025 00:08:01 +0000 (20:08 -0400)] 
gdb: rename find_pc_line -> find_sal_for_pc

Change-Id: I293b655e8753fc650f3ec10bb4e34a9632d8e377
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_line_pc_range -> find_line_pc_range_for_pc
Simon Marchi [Thu, 16 Oct 2025 00:08:00 +0000 (20:08 -0400)] 
gdb: rename find_pc_line_pc_range -> find_line_pc_range_for_pc

Change-Id: Iff7590d9d4e914ae74ba4818f338e911f7ab5416
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_sect_compunit_symtab -> find_compunit_symtab_for_pc_sect
Simon Marchi [Thu, 16 Oct 2025 00:07:59 +0000 (20:07 -0400)] 
gdb: rename find_pc_sect_compunit_symtab -> find_compunit_symtab_for_pc_sect

Change-Id: Idb4941f6a24ddd97ee98d35a40bfbe7ceba82ec1
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_compunit_symtab -> find_compunit_symtab_for_pc
Simon Marchi [Thu, 16 Oct 2025 00:07:58 +0000 (20:07 -0400)] 
gdb: rename find_pc_compunit_symtab -> find_compunit_symtab_for_pc

Change-Id: I6eef5db4ae55f3eb0415768207ae3c26b305f773
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_sect_containing_function -> find_symbol_for_pc_sect_maybe_inline
Simon Marchi [Thu, 16 Oct 2025 00:07:57 +0000 (20:07 -0400)] 
gdb: rename find_pc_sect_containing_function -> find_symbol_for_pc_sect_maybe_inline

Use the suffix "maybe_inline" to differentiate it from
find_symbol_for_pc_sect.  find_symbol_for_pc_sect_maybe_inline can
return symbols for inline functions, while find_symbol_for_pc_sect
doesn't.

Change-Id: I6c4ef961383429ee26c8fcc0cc5df2e4e1e24959
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_sect_function -> find_symbol_for_pc_sect
Simon Marchi [Thu, 16 Oct 2025 00:07:56 +0000 (20:07 -0400)] 
gdb: rename find_pc_sect_function -> find_symbol_for_pc_sect

Change-Id: I24d584024053655b469cabc78809abf05f0f0f02
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: rename find_pc_function -> find_symbol_for_pc
Simon Marchi [Thu, 16 Oct 2025 00:07:55 +0000 (20:07 -0400)] 
gdb: rename find_pc_function -> find_symbol_for_pc

Change-Id: I2069be1a6d7c3250cf330574c941bf851c89bab4
Approved-by: Kevin Buettner <kevinb@redhat.com>
2 weeks agogdb: fix slowdown during skeletonless type units processing
Simon Marchi [Wed, 8 Oct 2025 19:01:34 +0000 (15:01 -0400)] 
gdb: fix slowdown during skeletonless type units processing

My commit 6474c699a525 ("gdb/dwarf: sort dwarf2_per_bfd::all_units by
(section, offset)") introduced a pretty bad performance regression in
the "skeletonless type units" step.  I have a pretty big executable
(Blender) compiled with -gsplit-dwarf (to generate .dwo files) and
-fdebug-types-section (to generate type units).  Before the offending
commit:

    Time for "DWARF skeletonless type units": wall 29.126, user 28.507, sys 0.497, user+sys 29.004, 99.6 % CPU

... and after:

    Time for "DWARF skeletonless type units": wall 120.768, user 119.543, sys 0.651, user+sys 120.194, 99.5 % CPU

The reason for the slowdown is that add_type_unit now inserts type units
at the right place in the all_units vector to keep it sorted.  These
repeated insertions in the middle of the vector require shifting a lot
of elements and end up taking a lot of time.

This patch fixes it by doing just one sort at the end of
process_skeletonless_type_units.  The responsibility of keeping the
all_units sorted is delegated to the callers of add_type_unit.  The
other two callers call finalize_all_units right after calling
add_type_unit.

One drawback that is probably not a real one: in
process_skeletonless_type_unit, we call process_type_unit.  If something
in there needs to look up another type unit by (section, offset), it
wouldn't find it.  I don't think that's a real issue though, as type
units are typically self contained.  If a type unit needs to refer to a
type defined in another type unit, it would do so by signature, with
DW_FORM_ref_sig8.  And during the indexing phase, I don't think we even
look at the DW_AT_type of things anyway.

With this patch applied, I am back to:

    Time for "DWARF skeletonless type units": wall 29.277, user 28.632, sys 0.521, user+sys 29.153, 99.6 % CPU

I would like to cherry pick this patch to GDB 17, to avoid shipping GDB
17 with the performance regression.

Change-Id: I2a5b89ebca9e1a4e6248032e144520c9a579f47a
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33526
Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
2 weeks ago[gdb/testsuite] Use gnat_version_compare in gdb.ada
Tom de Vries [Mon, 20 Oct 2025 17:28:29 +0000 (19:28 +0200)] 
[gdb/testsuite] Use gnat_version_compare in gdb.ada

Convert the remaining uses of gcc_major_version in gdb.ada.

Tested on x86_64-linux with gcc 7, gcc 13 and gcc 15.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agoDrop bashism from configure script
Kévin Le Gouguec [Mon, 20 Oct 2025 14:54:39 +0000 (16:54 +0200)] 
Drop bashism from configure script

Results of evaluating 'test "no" == yes' in non-Bash shells range from
unfortunate (dash: "test: no: unexpected operator") to comically wrong
(AdaCore's gsh: returns 0).

2 weeks agolibctf: tests: fix clang 21 uninitialized variable warning
Nick Alcock [Sat, 18 Oct 2025 12:26:24 +0000 (13:26 +0100)] 
libctf: tests: fix clang 21 uninitialized variable warning

The warning is spurious (the variable is unused in this situation),
but clang cannot know that.

libctf/ChangeLog:

* testsuite/libctf-writable/symtypetab-nonlinker-writeout.c:
          Initialize dummy variable.

2 weeks agolibctf: fix unnecessary glibcism in testsuite
Nick Alcock [Fri, 17 Oct 2025 13:05:31 +0000 (14:05 +0100)] 
libctf: fix unnecessary glibcism in testsuite

libctf-regression/open-error-free.c #defines _GNU_SOURCE at its top.
This is already done by config.h if necessary: drop it.

libctf/ChangeLog:

* testsuite/libctf-regression/open-error-free.c: Drop
          unnecessary system-dependent #define.

2 weeks agolibctf: fix libctf/testsuite/libctf-lookup/multidim-array on older arches
Bruce McCulloch [Fri, 17 Oct 2025 13:00:25 +0000 (14:00 +0100)] 
libctf: fix libctf/testsuite/libctf-lookup/multidim-array on older arches

This patch inverts the ordering of nelems on multidimensional arrays on
versions of gcc without the CTF_F_ARRNELEMS flag. This allows those
systems which run older gcc to pass the test without modification to the
multidim-array.lk file.

libctf/ChangeLog:

* testsuite/libctf-lookup/multidim-array.c: Test fixes.

2 weeks ago[gdb/testsuite] Fix gdb.tui/resize-3.exp on ppc64-linux
Tom de Vries [Mon, 20 Oct 2025 09:58:32 +0000 (11:58 +0200)] 
[gdb/testsuite] Fix gdb.tui/resize-3.exp on ppc64-linux

On ppc64-linux, with test-case gdb.tui/resize-3.exp I run into:
...
FAIL: gdb.tui/resize-3.exp: after resize: Assembler for foo is shown
...
because the disassembly window shows:
...
    0 +----------------------------------------------------------------------+
    1 |   0x10000093c <.foo>                      std     r31,-8(r1)         |
    2 |   0x100000940 <.foo+4>                    stdu    r1,-64(r1)         |
    3 |   0x100000944 <.foo+8>                    mr      r31,r1             |
    4 |B+>0x100000948 <.foo+12>                   li      r9,0               |
...
and we grep for "<foo".

Fix this by updating the regexp.

Tested on ppc64-linux and x86_64-linux.

2 weeks ago[gdb/testsuite] Use with_cwd in gdb.src/pre-commit.exp
Tom de Vries [Mon, 20 Oct 2025 09:16:43 +0000 (11:16 +0200)] 
[gdb/testsuite] Use with_cwd in gdb.src/pre-commit.exp

I ran the testsuite and ran into ERRORs in two test-cases,
gdb.trace/save-trace.exp and gdb.threads/tls-sepdebug.exp.

Recently added test-case gdb.src/pre-commit.exp changes the working directory,
and the change stays active in following test-cases, which was not the
intention.

Fix this using with_cwd.

Tested on x86_64-linux.

2 weeks agolibsframe: use const qualifier for sframe_header object
Indu Bhagat [Mon, 20 Oct 2025 04:11:54 +0000 (21:11 -0700)] 
libsframe: use const qualifier for sframe_header object

...where applicable.

For the static functions that do not modify the sframe_header object,
use const.  Ditto for local vars.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
libsframe/
        * sframe.c (sframe_get_hdr_size): Use const qualifier.
        (sframe_header_sanity_check_p): Likewise.
        (flip_sframe): Use const for local var.
        (sframe_decode): Likewise.  While at it, use similar looking var
name.
        (sframe_decoder_get_hdr_size): Use const for local var.
        (sframe_decoder_get_abi_arch): Likewise.
        (sframe_decoder_get_version): Likewise.
        (sframe_decoder_get_fixed_fp_offset): Likewise.
        (sframe_decoder_get_fixed_ra_offset): Likewise.
        (sframe_get_funcdesc_with_addr_internal): Likewise.
        (sframe_decoder_get_num_fidx): Likewise.
        (sframe_encoder_get_hdr_size): Likewise.
        (sframe_encoder_get_abi_arch): Likewise.
        (sframe_encoder_get_version): Likewise.
        (sframe_encoder_get_num_fidx): Likewise.

2 weeks agoinclude: sframe: rename sframe_func_desc_entry to use an explicit v2
Indu Bhagat [Mon, 20 Oct 2025 04:03:27 +0000 (21:03 -0700)] 
include: sframe: rename sframe_func_desc_entry to use an explicit v2

As SFrame format evolves, this will be useful to refer to v2 on-disk
layout directly as the format evolves.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
include/
        * sframe.h (struct sframe_func_desc_entry): Rename to tag v2.

2 weeks agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks ago[gdb/testsuite] Add gdb.src/pre-commit.exp
Tom de Vries [Sun, 19 Oct 2025 12:21:00 +0000 (14:21 +0200)] 
[gdb/testsuite] Add gdb.src/pre-commit.exp

Add a test-case running the pre-commit hooks, as suggested here [1].

[1] https://sourceware.org/pipermail/gdb-patches/2025-October/221441.html

2 weeks agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Oct 2025 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Oct 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 weeks ago[gdb/python] Use PyConfig for python 3.9
Tom de Vries [Fri, 17 Oct 2025 18:27:40 +0000 (20:27 +0200)] 
[gdb/python] Use PyConfig for python 3.9

On ppc64le-linux (AlmaLinux 9.6) with python 3.9 and test-case
gdb.python/py-failed-init.exp I run into:
...
builtin_spawn $gdb -nw -nx -q -iex set height 0 -iex set width 0 \
  -data-directory $build/gdb/data-directory -iex set interactive-mode on^M
Python path configuration:^M
  PYTHONHOME = 'foo'^M
  PYTHONPATH = (not set)^M
  program name = '/usr/bin/python'^M
  isolated = 0^M
  environment = 1^M
  user site = 1^M
  import site = 1^M
  sys._base_executable = '/usr/bin/python'^M
  sys.base_prefix = 'foo'^M
  sys.base_exec_prefix = 'foo'^M
  sys.platlibdir = 'lib64'^M
  sys.executable = '/usr/bin/python'^M
  sys.prefix = 'foo'^M
  sys.exec_prefix = 'foo'^M
  sys.path = [^M
    'foo/lib64/python39.zip',^M
    'foo/lib64/python3.9',^M
    'foo/lib64/python3.9/lib-dynload',^M
  ]^M
Fatal Python error: init_fs_encoding: failed to get the Python codec of the \
  filesystem encoding^M
Python runtime state: core initialized^M
ModuleNotFoundError: No module named 'encodings'^M
^M
Current thread 0x00007fffabe18480 (most recent call first):^M
<no Python frame>^M
ERROR: (eof) GDB never initialized.
Couldn't send python print (1) to GDB.
UNRESOLVED: gdb.python/py-failed-init.exp: gdb-command<python print (1)>
Couldn't send quit to GDB.
UNRESOLVED: gdb.python/py-failed-init.exp: quit
...

The test-case expects gdb to present a prompt, but instead gdb calls exit
with this back trace:
...
(gdb) bt
 #0  0x00007ffff6e4bfbc in exit () from /lib64/glibc-hwcaps/power10/libc.so.6
 #1  0x00007ffff7873fc4 in fatal_error.lto_priv () from /lib64/libpython3.9.so.1.0
 #2  0x00007ffff78aae60 in Py_ExitStatusException () from /lib64/libpython3.9.so.1.0
 #3  0x00007ffff78c0e58 in Py_InitializeEx () from /lib64/libpython3.9.so.1.0
 #4  0x0000000010b6cab4 in py_initialize_catch_abort () at gdb/python/python.c:2456
 #5  0x0000000010b6cfac in py_initialize () at gdb/python/python.c:2540
 #6  0x0000000010b6d104 in do_start_initialization () at gdb/python/python.c:2595
 #7  0x0000000010b6eaac in gdbpy_initialize (extlang=0x11b7baf0 <extension_language_python>)
     at gdb/python/python.c:2968
 #8  0x000000001069d508 in ext_lang_initialization () at gdb/extension.c:319
 #9  0x00000000108f9280 in captured_main_1 (context=0x7fffffffe870)
     at gdb/main.c:1100
 #10 0x00000000108fa3cc in captured_main (context=0x7fffffffe870)
     at gdb/main.c:1372
 #11 0x00000000108fa4d8 in gdb_main (args=0x7fffffffe870) at gdb/main.c:1401
 #12 0x000000001001d1d8 in main (argc=3, argv=0x7fffffffece8) at gdb/gdb.c:38
...

This may be a python issue [1].

The problem doesn't happen if we use the PyConfig approach instead of the
py_initialize_catch_abort approach.

Fix this by using the PyConfig approach starting 3.9 (previously, starting
3.10 to avoid Py_SetProgramName deprecation in 3.11).

It's possible that we have the same problem and need the same fix for 3.8, but
I don't have a setup to check that.  Add a todo in a comment.

Tested on ppc64le-linux.

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://github.com/python/cpython/issues/107827

2 weeks agogdb: restore warning when core file and executable don't match
Andrew Burgess [Fri, 17 Oct 2025 13:19:54 +0000 (14:19 +0100)] 
gdb: restore warning when core file and executable don't match

Consider the following GDB session:

  (gdb) file /path/to/program
  (gdb) core /path/to/corefile
  warning: core file may not match specified executable file.
  ... etc ...
  (gdb)

Notice the warning.  GDB produces this warning when one of the
following conditions is true:

  + The build-id for the core file doesn't match the build-id of the
    executable, or

  + The filename of the executable doesn't match the partial filename
    stored in the PRPSINFO note from the core file.

Unfortunately, this warning was broken by the following two commits:

  commit c97e57bc9d2e081b7c842742933b7262f1d7ce39
  Date:   Wed Oct 8 11:18:07 2025 +0100

      gdb: move core file bfd from program_space into core_target

  commit 84f8be0d9c8ce30bf56eb9e14ce6fe012125fa53
  Date:   Wed Sep 10 11:04:45 2025 +0100

      gdb: remove program_space::core_bfd member function

These commits changed how the validate_files function (in corefile.c),
which is where the warning is emitted, find the core file BFD object.
Prior to the above commits, the core file BFD was stored in the
program_space, and was set by the time validate_files was called.

After the above commits the core file BFD is stored in the inferior's
core_target, and can only be accessed if the core_target has been
pushed onto the inferior's target stack.

Unfortunately, validate_files is called just before core_target is
pushed.  As a result, in validate_files it appears as if there is no
core file loaded, and so no validation is performed.

This commit fixes that by moving the call to validate_files to after
the core_target is pushed.  The warning is now restored.

I was surprised that this wasn't caught in testing.  I was sure we had
a test for that warning.  But, when I look now, I cannot find any such
test, so this commit adds one.

While I'm adding the test, validate_files also has a warning that it
can emit if the core file is older than the executable.  I've made
sure that the test covers this warning too.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks agodoc/python.texi : Adapt to Python 3 print syntax
Jeremy Bryant [Tue, 14 Oct 2025 21:55:39 +0000 (22:55 +0100)] 
doc/python.texi : Adapt to Python 3 print syntax

This change adapts the print syntax to Python 3.
The documentation examples will then work on current installations.
Python 2 was sunsetted in January 2020.

Approved-By: Tom Tromey <tom@tromey.com>
2 weeks ago[gdb/tdep] Fix inferior call return of small char array for ppc64 v1 abi some more
Tom de Vries [Fri, 17 Oct 2025 06:02:02 +0000 (08:02 +0200)] 
[gdb/tdep] Fix inferior call return of small char array for ppc64 v1 abi some more

PR tdep/33534 reports a regression due to commit 13f1820106c ("[gdb/tdep] Fix
inferior call return of small char array for ppc64 v1 abi").

The regression can be reproduced with the test-case introduced in the commit:
gdb.ada/return-small-char-array.exp, on a ppc64-linux setup with v1 elf abi
(cfarm121).

The commit contains two changes to a piece of code in
ppc64_sysv_abi_return_value:
...
   /* Small character arrays are returned, right justified, in r3.  */
-  if (valtype->code () == TYPE_CODE_ARRAY
+  if (tdep->elf_abi == POWERPC_ELF_V1
+      && valtype->code () == TYPE_CODE_ARRAY
       && !valtype->is_vector ()
       && valtype->length () <= 8
-      && valtype->target_type ()->code () == TYPE_CODE_INT
+      && (valtype->target_type ()->code () == TYPE_CODE_INT
+   || valtype->target_type ()->code () == TYPE_CODE_CHAR)
       && valtype->target_type ()->length () == 1)
...

The first change limits the effect of the if clause to the v1 elf abi.  This
change doesn't affect the regression, since it's on a ppc64-linux setup with
v1 elf abi.  Furthermore, it's correct in the sense that the v2 elf abi
doesn't have this kind of special treatment of small character arrays.

The second change is the part that causes the regression.  The code itself
seems correct, in the sense that it enables gdb to recognize small char arrays
in ada.

The regression stems from the following discrepancy.

The comment in gdb states that "small character arrays are returned, right
justified, in r3".  This matches the v1 ABI [1].

OTOH, gcc produces code that is not in agreement with this.  Instead, it
passes the small character arrays in memory, in a caller-allocated storage
buffer pointed at by r3.  This turns out to be an gcc bug [2].

Fix this by treating this as an abi spec bug, and replacing the code handling
the "Small character arrays" case with a comment.

Doing so reveals that there are two problems in the test-case:
- missing fvar-tracking, and
- the "step 2" command doesn't land at the intended line.

Fix these by:
- adding fvar-tracking, and
- setting a breakpoint at the intended line, and continuing to it.

Tested on ppc64-linux (v1 abi), ppc64le-linux (v2 abi), and x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33534

[1] https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html.
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122282

2 weeks agoDon't build libctf tests in source dir
Alan Modra [Fri, 17 Oct 2025 00:34:40 +0000 (11:04 +1030)] 
Don't build libctf tests in source dir

Running the libctf testsuite currently leaves big-struct-ctf.o in
libctf/testsuite/libctf-lookup/.

It ought to be possible to make the binutils source dir read-only,
and putting compiler output in the source dir leads to interesting
effects when testing multiple binutils targets in parallel.

* lib/ctf-lib.exp (run_lookup_test): For "link: objects" compile
objects in tmpdir.