]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
2 months agoUpdate copyright dates to include 2025
Tom Tromey [Wed, 2 Apr 2025 19:30:10 +0000 (13:30 -0600)] 
Update copyright dates to include 2025

This updates the copyright headers to include 2025.  I did this by
running gdb/copyright.py and then manually modifying a few files as
noted by the script.

Approved-By: Eli Zaretskii <eliz@gnu.org>
2 months agoRename set-solib-absolute-prefix.exp to x86-set-solib-absolute-prefix.exp
Alexandra Hájková [Mon, 7 Apr 2025 11:55:06 +0000 (13:55 +0200)] 
Rename set-solib-absolute-prefix.exp to x86-set-solib-absolute-prefix.exp

and move it from gdb.base to gdb.arch as it's a target specific test.

Reviewed-by: Maciej W. Rozycki <macro@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
2 months agoLoongArch: Warn about right shifts of negative numbers
Lulu Cai [Wed, 2 Apr 2025 02:23:40 +0000 (10:23 +0800)] 
LoongArch: Warn about right shifts of negative numbers

The GNU Assembler User Guide says that the right shift operator ">>"
in an expression is the same as the C operator.

On LoongArch the assembler directives and instructions do not treat
negative numbers ">>" the same way. The directives treats negative
numbers ">>" as logical right shifts while the instructions treats them
as arithmetic right shifts.

The right shift of negative numbers in the instructions may be changed
from an arithmetic right shift to a logical right shift in the future,
and a warning is issued for this.

2 months agoAutomatic date update in version.in
GDB Administrator [Tue, 8 Apr 2025 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months ago[gdb/cli] Use debug info language to pick pygments lexer
Tom de Vries [Mon, 7 Apr 2025 20:40:04 +0000 (22:40 +0200)] 
[gdb/cli] Use debug info language to pick pygments lexer

Consider the following scenario:
...
$ cat hello

int
main (void)
{
  printf ("hello\n");
  return 0;
}
$ gcc -x c hello -g
$ gdb -q -iex "maint set gnu-source-highlight enabled off" a.out
Reading symbols from a.out...
(gdb) start
Temporary breakpoint 1 at 0x4005db: file hello, line 6.
Starting program: /data/vries/gdb/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Temporary breakpoint 1, main () at hello:6
6   printf ("hello\n");
...

This doesn't produce highlighting for line 6, because:
- pygments is used for highlighting instead of source-highlight, and
- pygments guesses the language for highlighting only based on the filename,
  which in this case doesn't give a clue.

Fix this by:
- adding a language parameter to the extension_language_ops.colorize interface,
- passing the language as found in the debug info, and
- using it in gdb.styling.colorize to pick the pygments lexer.

The new test-case gdb.python/py-source-styling-2.exp excercises a slightly
different scenario: it compiles a c++ file with a .c extension, and checks
that c++ highlighting is done instead of c highlighting.

Tested on x86_64-linux.

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

2 months ago[gdb/tui] Don't try deferred curses initialization twice
Tom de Vries [Mon, 7 Apr 2025 20:27:39 +0000 (22:27 +0200)] 
[gdb/tui] Don't try deferred curses initialization twice

I noticed that if deferred curses initialization fails, for instance when
using TERM=dumb, and we try the same again, we run into the same error:
...
$ TERM=dumb gdb -batch -ex "tui enable" -ex "tui enable"
Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
...

I think it's better to try deferred curses initialization only once.

Fix this by changing bool tui_finish_init into a tribool, and using
TRIBOOL_UNKNOWN to represent the "initialization failed" state, such that we
get instead:
...
$ TERM=dumb gdb -batch -ex "tui enable" -ex "tui enable"
Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
Cannot enable the TUI
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2 months ago[lto] Fix symlookup in archives vs shared
Michael Matz [Mon, 31 Mar 2025 13:57:08 +0000 (15:57 +0200)] 
[lto] Fix symlookup in archives vs shared

when a shared library defines 'foo@@FOO' (default version),
a static archive defines 'foo', the shared lib comes in front
of the archive and under effect of --as-needed, and the requesting
object file uses LTO, then the link editor was wrongly including
the definition from the static archive.  It must use the one
from the shared lib, like in the non-LTO or the --no-as-needed case.
See the added testcase that would wrongly print "FAIL" before
this patch.

The problem stems from several connected problems:
(1) only the decorated symbol was entered into first_hash (the hash
    table designed to handle definition order in the pre-LTO-plugin
    phase of the symbol table walks)
(2) in the archive symbol walk only the undecorated name would be
    looked up in first_hash (and hence not found due to (1))
(3) in the archive symbol walk first_hash would only be consulted
    when the linker hash table had a defined symbol.  In pre-LTO
    phase shared lib symbols aren't entered into the linker symbol
    table.

So: add also the undecorated name into first_hash when it stems from
a default version and consult first_hash in the archive walker also
for currently undefined symbols.  If it has an entry which doesn't
point to the archive, then it comes from an earlier library (shared or
static), and so _this_ archive won't provide the definition.

2 months agoxcoff dynamic symbol string sanity
Alan Modra [Mon, 7 Apr 2025 00:37:51 +0000 (10:07 +0930)] 
xcoff dynamic symbol string sanity

Sanity check symbol string table offsets, and tidy structs.  "long"
isn't a good choice for _l_zeroes and _l_offset since it can be 64
bits which blows out the size of the symbol struct unnecessarily.
Also, all of the sizes in internal_ldsym need only be 32 bits, but I
made them size_t because I didn't want to audit all expressions using
them for overflow.

bfd/
* xcofflink.c (_bfd_xcoff_canonicalize_dynamic_symtab): Sanity
check symbol _l_offset.
(xcoff_link_add_dynamic_symbols),
(xcoff_link_check_dynamic_ar_symbols): Likewise.
include/
* coff/xcoff.h (struct internal_ldhdr): Tidy types.
(struct internal_ldsym): Use uint32_t for _l_zeroes and _l_offset.

2 months agoxcoff buffer overflow
Alan Modra [Sun, 6 Apr 2025 08:31:33 +0000 (18:01 +0930)] 
xcoff buffer overflow

Much of the xcoff code is not well protected against fuzzed object file
attacks.  This sanity checks some values in ".loader".

* xcofflink.c (xcoff_get_ldhdr): New function.
(_bfd_xcoff_get_dynamic_symtab_upper_bound),
(_bfd_xcoff_canonicalize_dynamic_symtab),
(_bfd_xcoff_get_dynamic_reloc_upper_bound),
(_bfd_xcoff_canonicalize_dynamic_reloc),
(xcoff_link_add_dynamic_symbols),
(xcoff_link_check_dynamic_ar_symbols): Use xcoff_get_ldhdr.

2 months agobuffer overflow in nds32_elf_do_9_pcrel_reloc
Alan Modra [Sun, 6 Apr 2025 03:51:21 +0000 (13:21 +0930)] 
buffer overflow in nds32_elf_do_9_pcrel_reloc

* elf32-nds32.c (nds32_elf_do_9_pcrel_reloc): Properly bounds
check relocation field.
(nds32_elf_hi20_reloc, nds32_elf_generic_reloc): Likewise.
(nds32_elf_final_link_relocate): Likewise.

2 months agogdb: Introduce user-friendly namespace identifier for "info shared"
Guinevere Larsen [Thu, 13 Mar 2025 13:20:53 +0000 (10:20 -0300)] 
gdb: Introduce user-friendly namespace identifier for "info shared"

GDB has had basic support for linkage namespaces for some time already,
but only in the sense of managing multiple copies of the same shared
object being loaded, and a very fragile way to find the correct copy of
a symbol (see PR shlibs/32054).

This commit is the first step in improving the user experience around
multiple namespace support. It introduces a user-friendly identifier for
namespaces, in the format [[<number>]], that will keep consistent between
dlmopen and dlclose calls. The plan is for this identifier to be usable
in expressions like `print [[1]]::var` to find a specific instance of a
symbol, and so the identifier must not be a valid C++ or Ada namespace
identifier, otherwise disambiguation becomes a problem. Support for
those expressions has not been implemented yet, it is only mentioned to
explain why the identifier looks like this.

This syntax was chosen based on the C attributes, since nothing in GDB
uses a similar syntax that could confuse users. Other syntax options
that were explored were "#<number>" and "@<number>". The former was
abandoned because when printing a frame, the frame number is also
printed with #<number>, so in a lot of the context in which that the
identifier would show up, it appears in a confusing way. The latter
clashes with the array printing syntax, and I believe that the having
"@N::foo" working completely differently to "foo@2" would also lead to a
bad user experience.

The namespace identifiers are stored via a vector inside svr4_info
object. The vector stores the address of the r_debug objects used by
glibc to identify each namespace, and the user-friendly ID is the index
of the r_debug in the vector. This commit also introduces a set storing
the indices of active namespaces. The glibc I used to develop this patch
(glibc 2.40 on Fedora 41) doesn't allow an SO to be loaded into a
deactivated namespace, and requesting a new namespace when a namespace
was previously closed will reuse that namespace. Because of how this is
implemented, this patch lets GDB easily track the exact namespace IDs
that the inferior will see.

Finally, two new solib_ops function pointers were added, find_solib_ns
and num_active_namespaces, to allow code outside of solib-svr4 to find
and use the namespace identifiers and the number of namespaces,
respectively. As a sanity check, the command `info sharedlibrary` has
been changed to display the namespace identifier when the inferior has
more than one active namespace. With this final change, a couple of tests
had to be tweaked to handle the possible new column, and a new test has
been created to make sure that the column appears and disappears as
needed, and that GDB can track the value of the LMID for namespaces.

Approved-by: Kevin Buettner <kevinb@redhat.com>
2 months agobfd: add load config size workaround for i386 XP and earlier
Jeremy Drake [Mon, 7 Apr 2025 11:19:28 +0000 (13:19 +0200)] 
bfd: add load config size workaround for i386 XP and earlier

Per the Microsoft PE documentation, XP and earlier on i686 require the
Size field to be 64, rather than the actual size as required on other
architectures.  I have confirmed Windows 11 accepts either 64 or the
actual size for i386 images, but only the actual size for x86_64 images.

Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
2 months agobfd: fill in PE load config directory entry
Jeremy Drake [Mon, 7 Apr 2025 11:19:19 +0000 (13:19 +0200)] 
bfd: fill in PE load config directory entry

This is filled in with the rva of _load_config_used if defined (much
like _tls_used), and the size is the first 32-bit value at that symbol.

Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
2 months agobfd: adjust a few error messages
Jeremy Drake [Mon, 7 Apr 2025 11:19:10 +0000 (13:19 +0200)] 
bfd: adjust a few error messages

Rationalize the error messages in _bfd_XXi_final_link_postscript().
They now all correctly refer to DataDirectory instead of DataDictionary,
and use unified format strings, so fewer translations are needed.

Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
2 months agobfd: properly use bfd_get_symbol_leading_char() in peXXigen
Jeremy Drake [Mon, 7 Apr 2025 11:18:46 +0000 (13:18 +0200)] 
bfd: properly use bfd_get_symbol_leading_char() in peXXigen

This function returns the leading char to use, so we cannot just assume
it will always be '_' or '\0'.

Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
2 months agobfd/COFF: drop link_add_one_symbol() hook
Jan Beulich [Mon, 7 Apr 2025 10:46:16 +0000 (12:46 +0200)] 
bfd/COFF: drop link_add_one_symbol() hook

The need for this has disappeared with dc12032bca08 ("Remove m68k-aout
and m68k-coff support"); avoid the unnecessary indirection.

Sadly, with ld/pe-dll.c using the wrapper, the removal requires moving
the declaration out of libcoff.h, to properly export the underlying BFD
function.

2 months agonm: fall back to heuristic when ELF symbol has zero size
Jan Beulich [Mon, 7 Apr 2025 10:45:30 +0000 (12:45 +0200)] 
nm: fall back to heuristic when ELF symbol has zero size

Size being set for a symbol isn't a strict requirement in ELF. For ones
not having their size set, fall back to the same logic as used for non-
ELF, non-COFF symbols.

While there switch to using elf_symbol_from() instead of kind of open-
coding it.

2 months agonm: also retrieve size for COFF function symbols
Jan Beulich [Mon, 7 Apr 2025 10:45:11 +0000 (12:45 +0200)] 
nm: also retrieve size for COFF function symbols

Like ELF for all symbols, COFF can record size for at least function
ones. Use that - if available - in preference to the distance-to-next-
symbol heuristic.

To be able to use the new test there, make TI C54x follow TI C4x in
providing .sdef to cover for .def already having different meaning.

2 months agogprofng: Remove duplicate symbols
Claudiu Zissulescu [Mon, 31 Mar 2025 11:17:17 +0000 (14:17 +0300)] 
gprofng: Remove duplicate symbols

Remove all duplicate symbols which can be in SymLst.  The duplication
is due to processing of both static and dynamic symbols.  The
Stabs::removeDupSyms function is called before computing symbol
aliases.

Introduce a new vector function (i.e., truncate()), that truncates a
vector lenght to the given new count.  This functionis used by
removeDupSyms function.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
2 months agogprofng: Refactor readSymSec for using BFD's asymbol struct
Claudiu Zissulescu [Fri, 28 Mar 2025 11:33:26 +0000 (13:33 +0200)] 
gprofng: Refactor readSymSec for using BFD's asymbol struct

This patch refactors a number of gprofng internal functions for using
more BFD data types and functions.
Stabs::readSymSec is a function which reads the symbols of an ELF file
mapping them into an internal structure. To use BFD asymbols, the
Elf::elf_getsym is changed from custom reading of the symbols from
.symtab and .dynsym section to BFD enable functions. A new function is
introduced which returns the number of either static or dynamic symbols,
named Elf::elf_getSymCount. Both Elf functions are used by
Stabs::readSymSec refactoring.

Also, this patch removes reading symbols, SUNW_ldnsym section as it is
only used by now defunct Studio compiler. However, it adds the reading
of both static and dynamic symbols, previously, only either one was
processed.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
2 months agogprofng: Remove check_Relocs() function
Claudiu Zissulescu [Fri, 28 Mar 2025 11:25:19 +0000 (13:25 +0200)] 
gprofng: Remove check_Relocs() function

check_Relocs() function is not anylonger required as it can only
handle Studio compiler relocs, now defunct. Remove this function.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
2 months agoAutomatic date update in version.in
GDB Administrator [Mon, 7 Apr 2025 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

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

2 months agogdbserver: regcache: Update comment in supply_regblock
Thiago Jung Bauermann [Sat, 5 Apr 2025 23:40:08 +0000 (20:40 -0300)] 
gdbserver: regcache: Update comment in supply_regblock

Since commit 84da4a1ea0ae ("gdbserver: refactor the definition and uses of
supply_regblock") there is no case where supply_regblock is passed a
nullptr for the BUF argument, and there is even a gdb_assert to make
sure of it.

Therefore remove that part of the documentation comment.

2 months agoAutomatic date update in version.in
GDB Administrator [Sat, 5 Apr 2025 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agoobjcopy: also check --file-alignment option argument
Jan Beulich [Fri, 4 Apr 2025 08:25:31 +0000 (10:25 +0200)] 
objcopy: also check --file-alignment option argument

... to be a power of two, just like --section-alignment does.

2 months agobinutils: run objcopy set-section-alignment also for COFF
Jan Beulich [Fri, 4 Apr 2025 08:25:16 +0000 (10:25 +0200)] 
binutils: run objcopy set-section-alignment also for COFF

There's no reason to limit this to just ELF. TI C30 and Z8k don't encode
section alignment in the section entries though (which can't be quite
right, or there would need to be another means by which to express
alignment needs), so --set-section-alignment simply has no effect there.

2 months agoobjcopy: constrain --section-alignment to PE binaries again
Jan Beulich [Fri, 4 Apr 2025 08:24:56 +0000 (10:24 +0200)] 
objcopy: constrain --section-alignment to PE binaries again

PR binutils/32732

The --set-section-alignment option is what ought to be used on object
files; --section-alignment should be affecting PE binaries only, and
only the value stored in the header. Sections don't individually have
alignment recorded there; see 6f8f6017a0c4 ("PR27567, Linking PE files
adds alignment section flags to executables").

Undo the core part of 121a3f4b4f4a ("Update objcopy's
--section-alignment option so that it sets the alignment flag on..."),
which includes removing the testcase again, while leaving all secondary
changes in place. (Note that the testcase did fail anyway for
i?86-interix, with objdump saying "option -P/--private not supported by
this file".)

2 months agoar/objcopy: harmonize .exe suffix stripping
Jan Beulich [Fri, 4 Apr 2025 08:20:31 +0000 (10:20 +0200)] 
ar/objcopy: harmonize .exe suffix stripping

With it only being the tail of the name which wants checking, using
lbasename() isn't helpful. Mirror what objcopy.c:main() does to ar.c,
merely chaning the plain int of the local variable to size_t.

2 months agobinutils: properly split ar and ranlib
Jan Beulich [Fri, 4 Apr 2025 08:20:14 +0000 (10:20 +0200)] 
binutils: properly split ar and ranlib

By not linking the exact same object file twice, in particular ranlib can
benefit quite a bit from the compiler eliminating dead code.

2 months agobinutils: properly split objcopy and strip
Jan Beulich [Fri, 4 Apr 2025 08:19:51 +0000 (10:19 +0200)] 
binutils: properly split objcopy and strip

By not linking the exact same object file twice, in particular strip can
benefit quite a bit from the compiler eliminating dead code.

2 months agoMake gdb/guile codespell-clean
Tom Tromey [Thu, 3 Apr 2025 18:11:15 +0000 (12:11 -0600)] 
Make gdb/guile codespell-clean

This cleans up the last codespell reports in the Guile directory and
adds gdb/guile to pre-commit.

It also tells codespell to ignore URLs.  I think this is warranted
because many URLs don't really contain words per se; and furthermore
if any URL-checking is needed at all, it would be for liveness and not
spelling.

Also I was wondering why the codespell config is in contrib and not
gdb/setup.cfg.

Approved-By: Tom de Vries <tdevries@suse.de>
2 months agoMake gdb/python codespell-clean
Tom Tromey [Thu, 3 Apr 2025 18:01:48 +0000 (12:01 -0600)] 
Make gdb/python codespell-clean

This cleans up the last codespell report in the Python directory and
adds gdb/python to pre-commit.

Approved-By: Tom de Vries <tdevries@suse.de>
2 months agoAutomatic date update in version.in
GDB Administrator [Fri, 4 Apr 2025 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agogdb/dwarf: rename cache -> abbrev_cache
Simon Marchi [Wed, 26 Mar 2025 19:55:37 +0000 (15:55 -0400)] 
gdb/dwarf: rename cache -> abbrev_cache

"cache" is just a bit too generic to be clear.

Change-Id: I8bf01c5fe84e076af1afd2453b1a115777630271

2 months agoMany minor typo fixes
Tom Tromey [Thu, 3 Apr 2025 14:33:58 +0000 (08:33 -0600)] 
Many minor typo fixes

I ran codespell on gdb/*.[chyl] and fixed a bunch of simple typos.
Most of what remains is trickier, i.e., spots where a somewhat natural
name of something in the code is flagged as a typo.

Reviewed-By: Tom de Vries <tdevries@suse.de>
2 months ago[gdb/testsuite] Fix xfail in gdb.ada/array_of_variant.exp
Tom de Vries [Thu, 3 Apr 2025 15:13:12 +0000 (17:13 +0200)] 
[gdb/testsuite] Fix xfail in gdb.ada/array_of_variant.exp

In commit af2b87e649b ("[gdb/testsuite] Add xfail for PR gcc/101633"), I added
an xfail that was controlled by variable old_gcc, triggering the xfail for
gcc 7 and before, but not for gcc 8 onwards:
...
set old_gcc [expr [test_compiler_info {gcc-[0-7]-*}]]
...

In commit 1411185a57e ("Introduce and use gnat_version_compare"), this changed
to:
...
set old_gcc [gnat_version_compare <= 7]
...
which still triggered the xfail for gcc 7, because of a bug in
gnat_version_compare.

After that bug got fixed, the xfail was no longer triggered because the gnatmake
version is 7.5.0, and [version_compare {7 5 0} <= {7}] == 0.

We could have the semantics for version_compare where we clip the input
arguments to the length of the shortest, and so we'd have
[version_compare {7 5 0} <= {7}] == [version_compare {7} <= {7}] == 1.

But let's stick with the current version-sort semantics, and fix this by
using [gnat_version_compare < 8] instead.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2 months ago[gdb/testsuite] Add gdb.testsuite/version-compare.exp
Tom de Vries [Thu, 3 Apr 2025 15:13:12 +0000 (17:13 +0200)] 
[gdb/testsuite] Add gdb.testsuite/version-compare.exp

Add a test-case gdb.testsuite/version-compare.exp that excercises proc
version_compare, and a note to proc version_compare that it considers
v1 < v1.0 instead of v1 == v1.0.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2 months agoFix parsing .debug_aranges section for signed addresses.
Martin Simmons [Thu, 27 Mar 2025 16:03:45 +0000 (16:03 +0000)] 
Fix parsing .debug_aranges section for signed addresses.

Some architectures, such as MIPS, have signed addresses and this changes
read_addrmap_from_aranges to record them as signed when required.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32658
Approved-By: Tom Tromey <tom@tromey.com>
2 months agoFix pp.rs test for gccrs
Tom Tromey [Mon, 17 Mar 2025 18:57:34 +0000 (12:57 -0600)] 
Fix pp.rs test for gccrs

gccrs still can't process all of gdb's Rust tests, but I did manage to
manually test it on a few.  In addition to filing some bug reports, I
came up with this patch.

There are two fixes here.  First, gccrs emits tuple field names as
integers ("0", "1", etc) whereas rustc uses a leading double
underscore ("__0", "__1", etc).  This patch changes gdb to accept the
gccrs output, which IMO makes sense (and for which there's already a
rustc feature request).

Second, it changes rust_struct_anon::evaluate to use check_typedef.
This is a gdb necessity in general, so could be described as an
oversight; but in this case it works around the gccrs oddity that most
named types are emitted as DW_TAG_typedef.  I've filed a gccrs bug
report for that.

2 months ago[pre-commit] Add codespell-clean gdb subdirs
Tom de Vries [Thu, 3 Apr 2025 13:56:49 +0000 (15:56 +0200)] 
[pre-commit] Add codespell-clean gdb subdirs

As an alternative to adding the gdb dir to codespell while it's still not
codespell-clean [1], add gdb subdirs which are codespell-clean.

Found using:
...
$ for d in $(find gdb -maxdepth 1 -type d | egrep -v "testsuite|gdb$"); do \
      echo -n "$d: "; \
      codespell --config gdb/contrib/setup.cfg $d 2>/dev/null \
          | wc -l; \
  done 2>&1 \
      | grep ": 0"
gdb/tui: 0
gdb/target: 0
gdb/data-directory: 0
gdb/po: 0
gdb/system-gdbinit: 0
gdb/mi: 0
gdb/syscalls: 0
gdb/arch: 0
gdb/regformats: 0
gdb/compile: 0
...

Verified using:
...
$ pre-commit run codespell --all-files
codespell................................................................Passed
...

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://sourceware.org/pipermail/gdb-patches/2025-March/216781.html

2 months agold/testsuite/ld-pe: Escape dots in regular expressions
LIU Hao [Mon, 31 Mar 2025 07:41:09 +0000 (15:41 +0800)] 
ld/testsuite/ld-pe: Escape dots in regular expressions

Signed-off-by: LIU Hao <lh_mouse@126.com>
ld/ChangeLog:
* testsuite/ld-pe/secidx.d: Escape dots in regular expressions.

2 months agoAutomatic date update in version.in
GDB Administrator [Thu, 3 Apr 2025 00:00:16 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agoClean up cooked_index::done_reading
Tom Tromey [Fri, 28 Mar 2025 16:26:36 +0000 (10:26 -0600)] 
Clean up cooked_index::done_reading

The cooked index worker maintains the state for the various state
transition in the scanner.  It is held by the cooked_index while
scanning is in progress, then deleted once this has completed.

I noticed that none of the arguments to cooked_index::done_reading
were really needed -- the cooked_index already has access to the
worker should it need it.  Removing these parameters makes the code a
bit simpler and also cleans up some confusing code around the use of
the deferred warnings object.

Regression tested on x86-64 Fedora 40.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoUpdate copyright.py
Tom Tromey [Tue, 1 Apr 2025 18:30:33 +0000 (12:30 -0600)] 
Update copyright.py

copyright.py needed an addition for unordered_dense.h.

Then, when running it, I saw it complain about some .pyc files I had
in the source tree.  I don't know why I had these, but the script
should ignore them.

For this, Kévin suggested using "git ls-files" to determine which
files to update -- that should automatically exclude any random files
in the tree.  This version of the patch makes this change.

There were complaints about some sim/ppc files that were renamed.
Ignoring the entire directory seems simpler given the comment.

I also made a few more minor changes:

* Removed the 'CVS' exclusion, as this hasn't been relevant in years.

* Moved the 'copying.c' exclusion to EXCLUDE_LIST

* Changed the script to run from the top level (we could have it
  automatically find this if we really wanted).

After this lands, I plan to run it and check in the result.  The patch
may be too large (and certainly too uninteresting) to post, so if/when
this happens I will send a brief note to the list about it.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agogdb/dwarf2: remove unused includes
Simon Marchi [Wed, 2 Apr 2025 16:42:35 +0000 (12:42 -0400)] 
gdb/dwarf2: remove unused includes

Remove some includes reported as unused by clangd.

Change-Id: I841938c3c6254e4f0d154a1e172c4968ff326333

2 months agogdb: remove unused includes in dbxread.c
Simon Marchi [Wed, 2 Apr 2025 16:36:08 +0000 (12:36 -0400)] 
gdb: remove unused includes in dbxread.c

Remove includes reported as unused by clangd.

Change-Id: I12e5cf254d211f42f3cfdab90d1f42a5986e53a3

2 months agoFix gdbserver crashes on SVE/SME-enabled systems
Luis Machado [Fri, 28 Feb 2025 09:36:42 +0000 (09:36 +0000)] 
Fix gdbserver crashes on SVE/SME-enabled systems

Commit 51e6b8cfd649013ae16a3d00f1451b2531ba6bc9 fixed a
regression for SVE/SME registers on gdb's side by using a <= comparison for
regcache's raw_compare assertion check. We seem to have failed to do the same
for gdbserver's raw_compare counterpart.

With the code as it is, I'm seeing a lot of crashes for gdbserver on a machine
with SVE enabled. For instance, with the following invocation:

make check-gdb RUNTESTFLAGS="--target_board=native-gdbserver" TESTS=gdb.base/break.exp

Running /work/builds/binutils-gdb/gdb/testsuite/../../../../repos/binutils-gdb/gdb/testsuite/gdb.base/break.exp ...
FAIL: gdb.base/break.exp: test_break: run until function breakpoint
FAIL: gdb.base/break.exp: test_break: run until breakpoint set at a line number (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:function(6) breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:function(5) breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:function(4) breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:function(3) breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:function(2) breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:function(1) breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until quoted breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: run until file:linenum breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: breakpoint offset +1
FAIL: gdb.base/break.exp: test_break: step onto breakpoint (the program is no longer running)
FAIL: gdb.base/break.exp: test_break: setting breakpoint at }
FAIL: gdb.base/break.exp: test_break: continue to breakpoint at } (the program is no longer running)
FAIL: gdb.base/break.exp: test_no_break_on_catchpoint: runto: run to main
FAIL: gdb.base/break.exp: test_break_nonexistent_line: runto: run to main
FAIL: gdb.base/break.exp: test_break_default: runto: run to main
FAIL: gdb.base/break.exp: test_break_silent_and_more: runto: run to main
FAIL: gdb.base/break.exp: test_break_line_convenience_var: runto: run to main
FAIL: gdb.base/break.exp: test_break_user_call: runto: run to main
FAIL: gdb.base/break.exp: test_finish_arguments: runto: run to main
FAIL: gdb.base/break.exp: test_next_with_recursion: kill program
FAIL: gdb.base/break.exp: test_next_with_recursion: run to factorial(6)
FAIL: gdb.base/break.exp: test_next_with_recursion: continue to factorial(5) (the program is no longer running)
FAIL: gdb.base/break.exp: test_next_with_recursion: backtrace from factorial(5)
FAIL: gdb.base/break.exp: test_next_with_recursion: next to recursive call (the program is no longer running)
FAIL: gdb.base/break.exp: test_next_with_recursion: next over recursive call (the program is no longer running)
FAIL: gdb.base/break.exp: test_next_with_recursion: backtrace from factorial(5.1)
FAIL: gdb.base/break.exp: test_next_with_recursion: continue until exit at recursive next test (the program is no longer running)
FAIL: gdb.base/break.exp: test_break_optimized_prologue: run until function breakpoint, optimized file
FAIL: gdb.base/break.exp: test_break_optimized_prologue: run until breakpoint set at small function, optimized file (the program is no longer running)
FAIL: gdb.base/break.exp: test_rbreak_shlib: rbreak junk

Adjusting the regcache raw_compare assertion check to use <= fixes
the problem on aarch64-linux on a SVE-capable system.

This patch also adds a simple selftest to gdbserver that validates this
particular case by simulating a raw_compare operation.

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

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoAdd optional filename argument to the linker's --stats option, allowing extra resourc...
Nick Clifton [Wed, 2 Apr 2025 09:56:16 +0000 (10:56 +0100)] 
Add optional filename argument to the linker's --stats option, allowing extra resource use information to be reported.

2 months agoAdd gdb.base/set-solib-absolute-prefix.exp
Alexandra Hajkova [Fri, 27 Oct 2017 19:07:50 +0000 (21:07 +0200)] 
Add gdb.base/set-solib-absolute-prefix.exp

Compile a 32-bit x86 executable and then stop within a system call.
Change the sysroot to a non-existent directory, GDB should try (and
fail) to reload the currently loaded shared libraries.  However, GDB
should retain the symbols for the vDSO library as that is not loaded
from the file system.

Check the backtrace to ensure that the __kernel_vsyscall symbol is
still in the backtrace, this indicates GDB still has the vDSO
symbols available.

This test was present in Fedora for a long time and was
originally written by Jan Kratochvil for this fix
829a902da291e72ad17e8c44fa8d9ead3db41b1f.

Co-Authored-By: Jan Kratochvil <jan.kratochvil@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2 months agoAutomatic date update in version.in
GDB Administrator [Wed, 2 Apr 2025 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agogdb: move addrmap::relocate method to addrmap_fixed
Simon Marchi [Mon, 31 Mar 2025 20:09:42 +0000 (16:09 -0400)] 
gdb: move addrmap::relocate method to addrmap_fixed

The relocate method of addrmap is unnecessarily virtual.  Only
addrmap_fixed provides a meaningful implementation.  Move the method to
addrmap_fixed only and make it non-virtual.

Change-Id: If61d5e70abc12c17d1e600adf0dd0707e77a6ba2
Approved-By: Tom Tromey <tom@tromey.com>
2 months ago[gdb/contrib] Support gdb in codespell section of setup.cfg
Tom de Vries [Tue, 1 Apr 2025 13:47:55 +0000 (15:47 +0200)] 
[gdb/contrib] Support gdb in codespell section of setup.cfg

Add support for the gdb dir in the codespell section of gdb/contrib/setup.cfg,
specifically adding files in the skip line.

This allows us to run codespell from the command line on the gdb dir:
...
$ codespell --config gdb/contrib/setup.cfg gdb 2>/dev/null | wc -l
1665
...
without running into warnings in generated files.

Approved-By: Tom Tromey <tom@tromey.com>
2 months agoUpdate cooked_index comment
Tom Tromey [Tue, 25 Mar 2025 23:11:24 +0000 (17:11 -0600)] 
Update cooked_index comment

This updates the cooked_index comment with some notes about object
lifetimes, in an attempt to make navigating this code a bit simpler.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoAdd cooked_index_worker::done_reading
Tom Tromey [Tue, 25 Mar 2025 23:41:13 +0000 (17:41 -0600)] 
Add cooked_index_worker::done_reading

The two readers currently using cooked_index_worker shared some code.
This patch factors this out into a new "done_reading" method.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoRemove cooked_index_worker::result_type
Tom Tromey [Tue, 25 Mar 2025 13:17:38 +0000 (07:17 -0600)] 
Remove cooked_index_worker::result_type

cooked_index_worker::result_type is an ad hoc tuple type used for
transferring data between phases of the indexer.  It's a bit unwieldy
and another patch I'm working on would be somewhat nicer without it.

This patch removes the type.  Now cooked_index_ephemeral objects are
transferred instead, which is handy because they already hold the
needed state.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoAdd addrmap_mutable::clear
Tom Tromey [Tue, 25 Mar 2025 19:25:39 +0000 (13:25 -0600)] 
Add addrmap_mutable::clear

It was convenient to add a 'clear' method to addrmap_mutable.  The
cleanest way to do this was to change the class to lazily initialize
its 'tree' member.  This also makes addrmap_mutable::operator= a bit
less weird.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoUpdate comments from moved methods
Tom Tromey [Wed, 26 Mar 2025 00:51:51 +0000 (18:51 -0600)] 
Update comments from moved methods

This updates the "See xyz.h" comments for all the methods that were
moved earlier in this series.  Perhaps I should have removed them
instead.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoMove cooked_index_worker to cooked-index-worker.[ch]
Tom Tromey [Mon, 24 Mar 2025 21:34:39 +0000 (15:34 -0600)] 
Move cooked_index_worker to cooked-index-worker.[ch]

This moves the cooked_index_worker class to cooked-index-worker.[ch].

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoChange includes in cooked-index-worker.h
Tom Tromey [Mon, 24 Mar 2025 21:30:07 +0000 (15:30 -0600)] 
Change includes in cooked-index-worker.h

This changes cooked-index-worker.h to include the new header files.
This breaks the circular dependency that would otherwise be introduced
in the next patch.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoMove cooked_index_shard to new files
Tom Tromey [Mon, 24 Mar 2025 21:19:20 +0000 (15:19 -0600)] 
Move cooked_index_shard to new files

This moves cooked_index_shard to a couple of new files,
dwarf2/cooked-index-shard.[ch].  The rationale is the same as the
previous patch: cooked-index.h had to be split to enable other
cleanups.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoMove cooked_index_entry to new files
Tom Tromey [Mon, 24 Mar 2025 21:11:02 +0000 (15:11 -0600)] 
Move cooked_index_entry to new files

This moves cooked_index_entry and some related helper code to a couple
of new files, dwarf2/cooked-index-entry.[ch].

The main rationale for this is that in order to finish this series and
remove "cooked_index_worker::result_type", I had to split
cooked-index.h into multiple parts to avoid circular includes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoMake language_requires_canonicalization 'static'
Tom Tromey [Mon, 31 Mar 2025 22:46:23 +0000 (16:46 -0600)] 
Make language_requires_canonicalization 'static'

language_requires_canonicalization is only called from cooked-index.c,
so mark it as static.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoRename cooked_index_storage
Tom Tromey [Mon, 24 Mar 2025 21:08:37 +0000 (15:08 -0600)] 
Rename cooked_index_storage

This renames cooked_index_storage to cooked_index_worker_result,
making its function more clear.  It also updates the class comment to
as well.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoRename cooked-index-storage.[ch]
Tom Tromey [Mon, 24 Mar 2025 21:03:04 +0000 (15:03 -0600)] 
Rename cooked-index-storage.[ch]

A discussion with Simon made me realize that cooked_index_storage
isn't a very clear name, especially now that it's escaped from read.c.
While it does provide some storage (I guess any object does in a
sense), it is really a helper for cooked_index_worker -- a temporary
object that is destroyed after reading has completed.

This patch renames this file.  Later patches will rename the class and
move cooked_index_worker here, something I think is reasonable given
that cooked_index_storage is really something of a helper class for
cooked_index_worker.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agoPR32829, SEGV on objdump function debug_type_samep
Alan Modra [Tue, 1 Apr 2025 12:06:54 +0000 (22:36 +1030)] 
PR32829, SEGV on objdump function debug_type_samep

u.kenum is always non-NULL, see debug_make_enum_type.

PR 32829
* debug.c (debug_type_samep): Correct incomplete enum test.
(debug_write_type): Remove dead code.

2 months agoubsan: nds32 undefined shift
Alan Modra [Mon, 31 Mar 2025 08:49:28 +0000 (19:19 +1030)] 
ubsan: nds32 undefined shift

Avoid implementation defined behaviour right shift of negative values,
and undefined behaviour left shift of negative values.  While this
change might give different results in the top bit of a bfd_vma
(rightshift is 1), that doesn't matter as only the bottom 8 bits of
the relocation are used.

* elf32-nds32.c (nds32_elf_do_9_pcrel_reloc): Calculate relocation
using a bfd_vma type.

2 months agoFormatting fixes for elf-attrs.c
Alan Modra [Sun, 9 Mar 2025 22:47:11 +0000 (09:17 +1030)] 
Formatting fixes for elf-attrs.c

2 months agoCheck gnatmake version in gnat_version_compare
Tom Tromey [Mon, 31 Mar 2025 17:53:53 +0000 (11:53 -0600)] 
Check gnatmake version in gnat_version_compare

Tom de Vries pointed out that my earlier change to
gnat_version_compare made it actually test gcc's version -- not
gnat's.

This patch changes gnat_version_compare to examine gnatmake's version,
while preserving the nicer API.

Approved-By: Tom de Vries <tdevries@suse.de>
2 months agobinutils/testsuite: don't tail the same input and output file
Clément Chigot [Mon, 31 Mar 2025 08:42:43 +0000 (10:42 +0200)] 
binutils/testsuite: don't tail the same input and output file

The output file could be created before the input is gathered by tail,
erasing the later before it's being proceeded.

This happened on rare cases when performing remote tests on
Ubuntu 24.04.

2 months agobinutils/testsuite: move objdump test output into tmpdir
Clément Chigot [Mon, 31 Mar 2025 08:40:37 +0000 (10:40 +0200)] 
binutils/testsuite: move objdump test output into tmpdir

"objdump.out" is a testsuite trace and thus should be created within the
tmpdir.

2 months agoAutomatic date update in version.in
GDB Administrator [Tue, 1 Apr 2025 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agotestsuite: fix is_aarch32_target
Thiago Jung Bauermann [Fri, 28 Mar 2025 04:03:20 +0000 (01:03 -0300)] 
testsuite: fix is_aarch32_target

Commit

   c221b2f77080 Testsuite: Add gdb_can_simple_compile

changed the source file name extension of the test program from .s to .c
resulting in compile fails.  This, in turn, causes is_aarch32_target
checks to fail.

Change the test source from an assembly program to a C program using
inline assembly.

is_amd64_regs_target had a similar problem, which was fixed by commit

    224d30d39365 testsuite: fix is_amd64_regs_target

This fix — and commit message — are mostly copied from it.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months agogdbserver: Add support for MicroBlaze host microblaze*-*-linux*
Michael Eager [Mon, 31 Mar 2025 16:31:28 +0000 (09:31 -0700)] 
gdbserver: Add support for MicroBlaze host microblaze*-*-linux*

Signed-off-by: David Holsgrove <david.holsgrove@petalogix.com>
Signed-off-by: Nathan Rossi <nathan.rossi@petalogix.com>
Signed-off-by: Mahesh Bodapati <mbodapat@xilinx.com>
Signed-off-by: Gopi Kumar Bulusu <gopi@sankhya.com>
Signed-off-by: Michael Eager <eager@eagercon.com>
2 months ago[gdb/record] Make enum gdb_syscall value names consistent
Tom de Vries [Mon, 31 Mar 2025 18:30:48 +0000 (20:30 +0200)] 
[gdb/record] Make enum gdb_syscall value names consistent

In enum gdb_syscall, there are 3 entries that do not have the gdb_sys_ prefix
...
$ grep gdb_old_ gdb/linux-record.h
  gdb_old_select = 82,
  gdb_old_readdir = 89,
  gdb_old_mmap = 90,
...
like all the other entries:
...
  gdb_sys_restart_syscall = 0,
  gdb_sys_exit = 1,
  gdb_sys_fork = 2,
  gdb_sys_read = 3,
...

The three correspond to these entries in
arch/x86/entry/syscalls/syscall_32.tbl:
...
<number>  <abi>   <name>     <entry point>      [<compat entry point> [noreturn]]
82        i386    select     sys_old_select     compat_sys_old_select
89        i386    readdir    sys_old_readdir    compat_sys_old_readdir
90        i386    mmap       sys_old_mmap       compat_sys_ia32_mmap
...

As we can see, the enum uses the entry point name, but without the sys_
prefix.

There doesn't seem to be a good reason for this.

There's another enum value:
...
  gdb_sys_old_getrlimit = 76,
...
corresponding to:
...
76        i386    getrlimit  sys_old_getrlimit  compat_sys_old_getrlimit
...
where we do use the sys_ prefix.

Fix this by consistenly using the gdb_sys_ prefix in enum gdb_syscall.

No functional changes.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2 months ago[gdb/contrib] Remove spellcheck.sh
Tom de Vries [Mon, 31 Mar 2025 14:53:17 +0000 (16:53 +0200)] 
[gdb/contrib] Remove spellcheck.sh

Now that we've started using codespell, remove gdb/contrib/spellcheck.sh and
associated file gdb/contrib/common-misspellings.txt.

Approved-By: Tom Tromey <tom@tromey.com>
2 months ago[gdb] Check strpbrk against nullptr
Tom de Vries [Mon, 31 Mar 2025 14:12:22 +0000 (16:12 +0200)] 
[gdb] Check strpbrk against nullptr

In noticed two occurrences of "if (strpbrk (...))".

Fix this style issue by checking against nullptr.

2 months agogdbsupport/common-inferior.c: Fix mingw build
Lancelot SIX [Mon, 31 Mar 2025 11:06:06 +0000 (12:06 +0100)] 
gdbsupport/common-inferior.c: Fix mingw build

A recent change (512ca2fca4b "gdb: split up
construct_inferior_arguments") introduced a build failure for mingw:

      CXX      common-inferior.o
    .../gdb/gdbsupport/common-inferior.cc: In function ‘std::string escape_characters(const char*, const char*)’:
    .../gdb/gdbsupport/common-inferior.cc:62:20: error: ‘argv’ was not declared in this scope; did you mean ‘arg’?
       62 |       if (strpbrk (argv[i], special))
          |                    ^~~~
          |                    arg
    .../gdb/gdbsupport/common-inferior.cc:62:25: error: ‘i’ was not declared in this scope
       62 |       if (strpbrk (argv[i], special))
          |                         ^

This patch fixes that.

Change-Id: I07ade607bc4516627b433085b07d9d198d8e4b4a
Approved-By: Tom de Vries <tdevries@suse.de>
2 months agold/PE: Add another mingw UCRT library name to the autoexport exclusion list
Martin Storsjö [Thu, 20 Mar 2025 21:27:05 +0000 (23:27 +0200)] 
ld/PE: Add another mingw UCRT library name to the autoexport exclusion list

Since 2020, mingw-w64 provides a C runtime import library variant
named "libucrtapp" too, exclude this one from autoexports like
the others.

Signed-off-by: Martin Storsjö <martin@martin.st>
2 months ago[pre-commit] Add codespell hook
Tom de Vries [Mon, 31 Mar 2025 07:30:00 +0000 (09:30 +0200)] 
[pre-commit] Add codespell hook

Add a pre-commit codespell hook for directories gdbsupport and gdbserver,
which are codespell-clean:
...
$ pre-commit run codespell --all-files
codespell................................................................Passed
...

A non-trivial question is where the codespell configuration goes.

Currently we have codespell sections in gdbsupport/setup.cfg and
gdbserver/setup.cfg, but codespell doesn't automatically use those because the
pre-commit hook runs codespell at the root of the repository.

A solution would be to replace those 2 setup.cfg files with a setup.cfg in the
root of the repository.  Not ideal because generally we try to avoid adding
files related to subdirectories at the root.

Another solution would be to add two codespell hooks, one using
--config gdbsupport/setup.cfg and one using --config gdbserver/setup.cfg, and
add a third one once we start supporting gdb.  Not ideal because it creates
duplication, but certainly possible.

I went with the following solution: a setup.cfg file in gdb/contrib (alongside
codespell-ignore-words.txt) which is used for both gdbserver and gdbsupport.

So, what can this new setup do for us?  Let's demonstrate by simulating a typo:
...
$ echo "/* aways */" >> gdbsupport/agent.cc
...

We can check unstaged changes before committing:
...
$ pre-commit run codespell --all-files
codespell................................................................Failed
- hook id: codespell
- exit code: 65

gdbsupport/agent.cc:282: aways ==> always, away
...

Likewise, staged changes (no need for the --all-files):
...
$ git add gdbsupport/agent.cc
$ pre-commit run codespell
codespell................................................................Failed
- hook id: codespell
- exit code: 65

gdbsupport/agent.cc:282: aways ==> always, away
...

Or we can try to commit, and run into the codespell failure:
...
$ git commit -a
black................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
isort................................................(no files to check)Skipped
codespell................................................................Failed
- hook id: codespell
- exit code: 65

gdbsupport/agent.cc:282: aways ==> always, away

check-include-guards.................................(no files to check)Skipped
...
which makes the commit fail.

Approved-By: Tom Tromey <tom@tromey.com>
2 months agoAutomatic date update in version.in
GDB Administrator [Mon, 31 Mar 2025 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months ago[gdb/tdep] Fix mmap syscall mapping
Tom de Vries [Sun, 30 Mar 2025 14:45:25 +0000 (16:45 +0200)] 
[gdb/tdep] Fix mmap syscall mapping

There are a few spots where an mmap system call is mapped onto enum
gdb_syscall value gdb_sys_mmap2.

Strictly speaking, this is incorrect.

Fix this by mapping to enum gdb_syscall value gdb_old_mmap instead.

No functional changes: both gdb_old_mmap and gdb_sys_mmap2 are handled the
same in record_linux_system_call.

Tested by rebuilding on x86_64-linux.

2 months ago[gdb] Skip selftest with warning
Tom de Vries [Sun, 30 Mar 2025 06:40:12 +0000 (08:40 +0200)] 
[gdb] Skip selftest with warning

With the selftest register_name, we run into a few warning:
...
$ gdb -q -batch -ex "maint selftest register_name" 2>&1 \
    | grep -B1 warning:
Running selftest register_name::m68hc11.
warning: No frame soft register found in the symbol table.
--
Running selftest register_name::m68hc12.
warning: No frame soft register found in the symbol table.
--
Running selftest register_name::m68hc12:HCS12.
warning: No frame soft register found in the symbol table.
...

We already filter out these architectures in other selftests because of the
same warning.

Do the same in this selftest.

Tested on x86_64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2 months agoAutomatic date update in version.in
GDB Administrator [Sun, 30 Mar 2025 00:00:09 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agogdb: remove disable_breakpoints_in_shlibs function
Andrew Burgess [Fri, 6 Sep 2024 15:18:09 +0000 (16:18 +0100)] 
gdb: remove disable_breakpoints_in_shlibs function

I think there is a problem with the disable_breakpoints_in_shlibs
function: it can disable breakpoint locations without calling
notify_breakpoint_modified.  This means that the Python API's
breakpoint_modified event will not trigger, nor will the MI send a
breakpoint modified event.

I started looking at disable_breakpoints_in_shlibs because of an
earlier commit:

  commit 8c48ec7a6160aed0d1126c623443935e4435cd41
  Date:   Thu Aug 29 12:34:15 2024 +0100

      gdb: handle dprintf breakpoints when unloading a shared library

Currently disable_breakpoints_in_shlibs is only called from one
location, clear_solib in solib.c.  clear_solib also calls
notify_solib_unloaded for every solib in the program_space of
interest, and notify_solib_unloaded will call
disable_breakpoints_in_unloaded_shlib via the solib_unloaded
observer.  These two function, disable_breakpoints_in_shlibs and
disable_breakpoints_in_unloaded_shlib are very similar in what they
do.

I think that we can remove the disable_breakpoints_in_shlibs call, and
instead, tweak how we call disable_breakpoints_in_unloaded_shlib in
order to get the same end result, except that, after this change, we
will call notify_breakpoint_modified, which means the Python API event
will trigger, and the MI events will be emitted.

All that disable_breakpoints_in_shlibs does is disable some
breakpoints.

Meanwhile, disable_breakpoints_in_unloaded_shlib, will disable the
same set of breakpoints, call notify_breakpoint_modified, and
then (for some breakpoint types) print a message telling the user that
the breakpoint has been disabled.  However, this function will ignore
any breakpoints that are already disabled.

As disable_breakpoints_in_shlibs disables the same set of breakpoints,
the result of the current code is that disable_breakpoints_in_shlibs
serves only to prevent the notify_breakpoint_modified call, which I
think is wrong, and to prevent the user message being printed, which I
think is reasonable.

If we remove the disable_breakpoints_in_shlibs call without making any
additional changes, then we start to see some message printed in cases
like this:

  (gdb) start
  The program being debugged has been started already.
  Start it from the beginning? (y or n) y
  warning: Temporarily disabling breakpoints for unloaded shared library "/tmp/shared-lib-test/libfoo.so"
  Temporary breakpoint 3 at 0x40113e: file test.c, line 9.
  Starting program: /tmp/shared-lib-test/test.x

Notice the 'warning:' line, which is new.  I think this is confusing
because, in most cases the breakpoint will be enabled again by the
time the inferior reaches `main` and stops.

In the future I'm interested in exploring if GDB could be smarter
about when to print these 'Temporarily disabling breakpoints ...'
messages so that if the 'start' command does mean a breakpoint is left
disabled, then the user would be informed.  However, I don't propose
doing that work immediately, and certainly not in this commit.  For
now, my intention is to leave things as they are right now, GDB
doesn't warn about disabling breakpoints during an inferior re-start.

To achieve this I think we need to pass a new argument to
disable_breakpoints_in_unloaded_shlib which controls whether we should
print a message about the breakpoint being disabled or not.  With this
added we can now silence the warning when the inferior is
restarted (i.e. when disable_breakpoints_in_unloaded_shlib is called
from clear_solib), but keep the warning for cases like stepping over a
dlclose() call in the inferior.

After this commit, GDB now emits breakpoint modified events (in Python
and/or MI) when a breakpoint is disabled as a result of all shared
libraries being unloaded.  This will be visible in two places that I
can thing of, the 'nosharedlibrary' command, and when an inferior is
restarted.

2 months agox86: Add {noimm8s} pseudo prefix
H.J. Lu [Sat, 22 Mar 2025 15:14:40 +0000 (08:14 -0700)] 
x86: Add {noimm8s} pseudo prefix

Instruction templates with only sign-extended 8-bit immediate operand
also have a second template with full-operand-size immediate operand
under a different opcode.  Add {noimm8s} pseudo prefix to exclude
templates with only sign-extended 8-bit immediate operand.

gas/

PR gas/32811
* config/tc-i386.c (pseudo_prefixes): Add no_imm8s.
(operand_size_match): Return false for templates with only sign-
extended 8-bit immediate operand if {noimm8s} is used.
(parse_insn): Handle Prefix_NoImm8s.
* doc/c-i386.texi: Document {noimm8s}.
* testsuite/gas/i386/pseudos.s: Add tests for {noimm8s}.
* testsuite/gas/i386/x86-64-pseudos.s: Likewise.
* testsuite/gas/i386/pseudos.d: Updated.
* testsuite/gas/i386/x86-64-pseudos.d: Likewise.

opcodes/

PR gas/32811
* opcodes/i386-opc.h (Prefix_NoImm8s): New.
* i386-opc.tbl: Add {noimm8s} pseudo prefix.
* i386-mnem.h: Regenerated.
* i386-tbl.h: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agogprof: Always compile tests with -g
H.J. Lu [Mon, 10 Mar 2025 23:25:33 +0000 (16:25 -0700)] 
gprof: Always compile tests with -g

Always compile gprof testsuite with -g for line number info checked by
tst-gmon-gprof-l.sh.

PR gprof/32779
* testsuite/Makefile.am (GPROF_FLAGS): Add -g.
(COMPILE): Set to "$(CC) $(AM_CFLAGS) $(GPROF_FLAGS)".
(LINK) Set to "$(CC) $(AM_CFLAGS) $(GPROF_FLAGS) $(AM_LDFLAGS)
$(LDFLAGS) -o $@".
* testsuite/Makefile.in: Regenerated.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 months agoAutomatic date update in version.in
GDB Administrator [Sat, 29 Mar 2025 00:00:12 +0000 (00:00 +0000)] 
Automatic date update in version.in

2 months agogdb: reduce breakpoint-modified events for dprintf b/p
Andrew Burgess [Sat, 7 Sep 2024 12:45:40 +0000 (13:45 +0100)] 
gdb: reduce breakpoint-modified events for dprintf b/p

Consider this backtrace within GDB:

  #0  notify_breakpoint_modified (b=0x57d31d0) at ../../src/gdb/breakpoint.c:1083
  #1  0x00000000005b6406 in breakpoint_set_commands (b=0x57d31d0, commands=...) at ../../src/gdb/breakpoint.c:1523
  #2  0x00000000005c8c63 in update_dprintf_command_list (b=0x57d31d0) at ../../src/gdb/breakpoint.c:8641
  #3  0x00000000005d3c4e in dprintf_breakpoint::re_set (this=0x57d31d0) at ../../src/gdb/breakpoint.c:12476
  #4  0x00000000005d6347 in breakpoint_re_set () at ../../src/gdb/breakpoint.c:13298

Whenever breakpoint_re_set is called we re-build the commands that the
dprintf b/p will execute and store these into the breakpoint.  The
commands are re-built in update_dprintf_command_list and stored into
the breakpoint object in breakpoint_set_commands.

Now sometimes these commands can change, dprintf_breakpoint::re_set
explains one case where this can occur, and I'm sure there must be
others.  But in most cases the commands we recalculate will not
change.  This means that the breakpoint modified event which is
emitted from breakpoint_set_commands is redundant.

This commit aims to eliminate the redundant breakpoint modified events
for dprintf breakpoints.  This is done by adding a commands_equal call
to the start of breakpoint_set_commands.

The commands_equal function is a new function which compares two
command_line objects and returns true if they are identical.  Using
this function we can check if the new commands passed to
breakpoint_set_commands are identical to the breakpoint's existing
commands.  If the new commands are equal then we don't need to change
anything on the new breakpoint, and the breakpoint modified event can
be skipped.

The test for this commit stops at a dlopen() call in the inferior,
sets up a dprintf breakpoint, then uses 'next' to step over the
dlopen() call.  When the library loads GDB call breakpoint_re_set,
which calls dprintf_breakpoint::re_set.  But in this case we don't
expect the calculated command string to change, so we don't expect to
see the breakpoint modified event.

2 months agoFix gstack issues
Keith Seitz [Thu, 27 Mar 2025 15:46:39 +0000 (08:46 -0700)] 
Fix gstack issues

With commit fb2ded33c1e519659743047ed7817166545b6d91, I added
Fedora's gstack script to gdb.  Some issues have arisen since
then, and this patch addresses those issues:

. As Sam James recently noted[1], PKGVERSION and VERSION
  need to be quoted.
. A Fedora user reported the misuse of --readnever, which
  causes gstack to omit filename and line number information in the
  backtrace[Red Hat BZ 2354997].

[1] https://inbox.sourceware.org/gdb-patches/d19d6bc17e0a160ce27fc572079f11a587c0e168.1742424869.git.sam@gentoo.org/
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=2354997

3 months agox86: Pass $NOPIE_LDFLAGS to undefined weak tests
Jens Remus [Fri, 28 Mar 2025 14:27:11 +0000 (15:27 +0100)] 
x86: Pass $NOPIE_LDFLAGS to undefined weak tests

Some distributions configure GCC with --enable-default-pie, so that it
defaults to compile with -fPIE and link with -pie, which is unexpected
by some of the tests.  Therefore link the PDE test programs with
$NOPIE_LDFLAGS to disable PIE.

This complements commit a7eaf017f959 ("Use NOPIE_CFLAGS and
NOPIE_LDFLAGS to disable PIE").

ld/testsuite/
PR ld/21090
* ld-x86-64/x86-64.exp (undefined_weak): Use NOPIE_LDFLAGS to
disable PIE for the non-PIE versions of the test.

Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
3 months agold: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF visibility tests
Jens Remus [Fri, 28 Mar 2025 14:27:11 +0000 (15:27 +0100)] 
ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF visibility tests

Some distributions configure GCC with --enable-default-pie, so that it
defaults to compile with -fPIE and link with -pie, which is unexpected
by the test.  Therefore compile the non-PIC sources with $NOPIE_CFLAGS
and link the test programs with $NOPIE_LDFLAGS.

Commit 922109c71828 ("Pass $NOPIE_CFLAGS to ELF visibility tests") added
$NOPIE_CFLAGS when compiling sh1np.o and sh2np.o.  It missed to add it
to mainnp.o.

ld/testsuite/
PR ld/21090
* ld-vsb/vsb.exp (visibility_test): Add support for optional
ldflags argument and use it when linking the test program.
(mainnp.o): Compile with $NOPIE_CFLAGS.
(vnp, vp, vmpnp, vmpp): Link with $NOPIE_LDFLAGS.

Fixes: 922109c71828 ("Pass $NOPIE_CFLAGS to ELF visibility tests")
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
3 months agold: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to even more ELF shared tests
Jens Remus [Fri, 28 Mar 2025 14:27:11 +0000 (15:27 +0100)] 
ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to even more ELF shared tests

Some distributions configure GCC with --enable-default-pie, so that it
defaults to compile with -fPIE and link with -pie, which is unexpected
by the test.  Therefore compile the non-PIC sources with $NOPIE_CFLAGS
and link the test programs with $NOPIE_LDFLAGS.

Commit 9d1c54ed7f3a ("Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF
tests") added $NOPIE_CFLAGS when compiling sh1np.o.  It missed to add it
to sh2np.o and mainnp.o.

ld/testsuite/
PR ld/21090
* ld-shared/shared.exp (shared_test): Add support for optional
ldflags argument and use it when linking the test program.
(sh2np.o, mainnp.o): Compile with $NOPIE_CFLAGS.
(shnp, shp, shmpnp, shmpp): Link with $NOPIE_LDFLAGS.

Fixes: 9d1c54ed7f3a ("Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to more ELF tests")
Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
3 months agold: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to test pr21964-4
Jens Remus [Fri, 28 Mar 2025 14:27:11 +0000 (15:27 +0100)] 
ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to test pr21964-4

Linker test "pr21964-4" fails on s390x on Ubuntu 24.10 but not on
Fedora 41.  The reason is that GCC on Ubuntu is configured with
--enable-default-pie, so that it defaults to compile with -fPIE
and link with -pie, which causes the test to erroneously fail.

ld/testsuite/
PR ld/21090
* ld-elf/shared.exp: Compile pr21964-4 with $NOPIE_CFLAGS and
link with $NOPIE_LDFLAGS.

Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
3 months agold: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to test pr19719
Jens Remus [Fri, 28 Mar 2025 14:27:10 +0000 (15:27 +0100)] 
ld: Pass $NOPIE_CFLAGS and $NOPIE_LDFLAGS to test pr19719

Linker test "pr19719 fun defined" (non PIE) fails on s390x on Fedora 41
but not on Ubuntu 24.10.  The reason is that GCC on Ubuntu is configured
with --enable-default-pie, so that it defaults to compile with -fPIE
and link with -pie, which hides the test fail.

ld/testsuite/
PR ld/21090
* ld-elf/shared.exp: Compile pr19719 (non-PIE) with
$NOPIE_CFLAGS and link with $NOPIE_LDFLAGS.

Bug: https://sourceware.org/PR21090
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
3 months agoRISC-V: Don't show support for 1.9.1 priv spec
Marek Pikuła [Thu, 27 Mar 2025 14:09:15 +0000 (15:09 +0100)] 
RISC-V: Don't show support for 1.9.1 priv spec

The privileged spec 1.9.1 support was removed since binutils 2.43. The
linker only recognizes it and then reports a warning that it may
conflict with other spec versions.

While the support is removed, binutils should still recognize it, but it
shouldn't be exposed to the user in `disassember-options` help.

Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
3 months agodoc/riscv: Add description of disassembler options
Marek Pikuła [Thu, 27 Mar 2025 14:09:14 +0000 (15:09 +0100)] 
doc/riscv: Add description of disassembler options

Up to this point, no mention of RISC-V-specific disassembler options was
mentioned in binutils documentation. This patch includes description for
all of the currently supported options.

Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
3 months agoAutomatic date update in version.in
GDB Administrator [Fri, 28 Mar 2025 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

3 months agogdb: Fix assertion failure when inline frame #0 is duplicated
Craig Blackmore [Thu, 13 Feb 2025 15:53:34 +0000 (15:53 +0000)] 
gdb: Fix assertion failure when inline frame #0 is duplicated

Modifying inline-frame-cycle-unwind.exp to use `bt -no-filters` produces
the following incorrect backtrace:

  #0  inline_func () at .../gdb/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c:49
  #1  normal_func () at .../gdb/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c:32
  #2  0x000055555555517f in inline_func () at .../gdb/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c:50
  #3  normal_func () at .../gdb/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c:32
  Backtrace stopped: previous frame identical to this frame (corrupt stack?)
  (gdb) FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 1: backtrace when the unwind is broken at frame 1

The expected output, which we get with `bt`, is:

  #0  inline_func () at .../gdb/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c:49
  #1  normal_func () at .../gdb/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.c:32
  Backtrace stopped: previous frame identical to this frame (corrupt stack?)
  (gdb) PASS: gdb.base/inline-frame-cycle-unwind.exp: cycle at level 1: backtrace when the unwind is broken at frame 1

The cycle checking in `get_prev_frame_maybe_check_cycle` relies on newer
frame ids having already been computed and stashed.  Unlike other
frames, frame #0's id does not get computed immediately.

The test passes with `bt` because when applying python frame filters,
the call to `bootstrap_python_frame_filters` happens to compute the id
of frame #0.  When `get_prev_frame_maybe_check_cycle` later tries to
stash frame #2's id, the cycle is detected.

The test fails with `bt -no-filters` because frame #0's id has not been
stashed by the time `get_prev_frame_maybe_check_cycle` tries to stash
frame #2's id which succeeds and the cycle is only detected later when
trying to stash frame #4's id.  Doing `stepi` after the incorrect
backtrace would then trigger an assertion failure when trying to stash
frame #0's id because it is a duplicate of #2's already stashed id.

In `get_prev_frame_always_1`, if this_frame is inline frame 0, then
compute and stash its frame id before returning the previous frame.
This ensures that the id of inline frame 0 has been stashed before
`get_prev_frame_maybe_check_cycle` is called on older frames.

The test case has been updated to run both `bt` and `bt -no-filters`.

Co-authored-by: Andrew Burgess <aburgess@redhat.com>
3 months ago[gdb/contrib] Drop two words from codespell-ignore-words.txt
Tom de Vries [Thu, 27 Mar 2025 16:53:52 +0000 (17:53 +0100)] 
[gdb/contrib] Drop two words from codespell-ignore-words.txt

Tom Tromey mentioned [1] that the words "invokable" and "useable"
present in codespell-ignore-words.txt should be dropped.

Do so and fix the following typos:
...
$ codespell --config gdbsupport/setup.cfg gdbsupport
gdbsupport/common-debug.h:218: invokable ==> invocable
gdbsupport/event-loop.cc:84: useable ==> usable
...

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://sourceware.org/pipermail/gdb-patches/2025-March/216584.html