]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
6 months ago[gdb/syscalls] Add syscalls {set,get,list,remove}xattrat
Tom de Vries [Thu, 28 Nov 2024 12:53:04 +0000 (13:53 +0100)] 
[gdb/syscalls] Add syscalls {set,get,list,remove}xattrat

In commit 58776901074 ("[gdb/syscalls] Update to linux v6.11") I updated to
linux v6.11, but a recent submission for loongarch [1] used a current trunk
version, so it makes sense to do this as well elsewhere.

Using linux current trunk with update-linux-from-src.sh gets us 4 more
syscalls:
- setxattrat
- getxattrat
- listxattrat
- removexattrat

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2024-November/213613.html

7 months agoAutomatic date update in version.in
GDB Administrator [Thu, 28 Nov 2024 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoFix 32392 [2.44 Regression] gprofng fails to build on i686-linux-gnu
Vladimir Mezentsev [Wed, 27 Nov 2024 03:51:23 +0000 (19:51 -0800)] 
Fix 32392 [2.44 Regression] gprofng fails to build on i686-linux-gnu

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

PR gprofng/32392
* libcollector/libcol_util.c (__collector_util_init): Fix warning.

7 months agogprofng: skip unrecognized input command
Vladimir Mezentsev [Wed, 27 Nov 2024 03:40:16 +0000 (19:40 -0800)] 
gprofng: skip unrecognized input command

gprofng crashes when the GUI sends an invalid command.
Skip unrecognized commands and return an error status to the GUI.

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

* src/ipc.cc (ipc_doWork): Skip unrecognized commands.
* src/ipcio.cc (writeError): New function.
* src/ipcio.h: Add RESPONSE_STATUS_ERROR.

7 months agogdb/testsuite: skip gdb.threads/omp-par-scope.exp with clang
Guinevere Larsen [Mon, 25 Nov 2024 18:15:36 +0000 (15:15 -0300)] 
gdb/testsuite: skip gdb.threads/omp-par-scope.exp with clang

Since 2020 it has been reported to clang[1] that the debug information
around OpenMP is insufficient.  The OpenMP section is not declared
within the correct scope, and instead clang marks as if the section was
a function in the global scope.  This causes several failures in the
test gdb.threads/omp-par-scope.exp when using clang to test GDB.

Since this isn't a true failure of GDB, and there is little expectation
that clang will be able to fix this soon, this commit disables the
aforementioned test when clang is being used.

[1] https://github.com/llvm/llvm-project/issues/44236

Approved-by: Kevin Buettner <kevinb@redhat.com>
7 months ago[gdb/symtab] Fix parent map dump
Tom de Vries [Wed, 27 Nov 2024 17:48:43 +0000 (18:48 +0100)] 
[gdb/symtab] Fix parent map dump

Before the fix for PR symtab/32225, the parent map dump showed a mapping from
section offsets to cooked index entries:
...
  0x0000000000000035 0x3ba9560 (0x34: sp1::A)
...
but now that's no longer the case:
...
  0x00000000406f5405 0x410a04d0 (0x34: sp1::A)
...

Fix this by extending the annotation somewhat, such that we get:
...
map start:
  0x0000000012c52405 0x135fd550
(section: .debug_info, offset: 0x35) -> (0x34: sp1::A)
...

Tested on x86_64-linux.

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

7 months ago[gdb/testsuite] Add gdb.dwarf2/dw2-tu-dwarf-4-5.exp
Tom de Vries [Wed, 27 Nov 2024 17:48:43 +0000 (18:48 +0100)] 
[gdb/testsuite] Add gdb.dwarf2/dw2-tu-dwarf-4-5.exp

Add a regression test for PR symtab/32225.

Tested on x86_64-linux.

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

7 months ago[gdb/symtab] Fix parent map when handling .debug_info and .debug_types
Author: Tom Tromey [Wed, 27 Nov 2024 17:48:43 +0000 (18:48 +0100)] 
[gdb/symtab] Fix parent map when handling .debug_info and .debug_types

Consider test-case:
...
$ cat test.c
namespace sp1 {
  class A {
    int i;
    const int f1 = 1;
    ...
    const int f29 = 1;
  };
}
sp1::A a;
void _start (void) {}
$ cat test2.c
namespace sp2 {
  class B {
    float f;
    const float f1 = 1;
    ...
    const float f29 = 1;
  };
}
sp2::B b;
...
compiled like this:
...
$ g++ test.c -gdwarf-4 -c -g -fdebug-types-section
$ g++ test2.c -gdwarf-5 -c -g -fdebug-types-section
$ g++ -g test.o test2.o -nostdlib
...

Using:
...
$ gdb -q -batch -iex "maint set worker-threads 0" a.out -ex "maint print objfiles"
...
we get a cooked index entry with incorrect parent:
...
    [29] ((cooked_index_entry *) 0x3c57d1a0)
    name:       B
    canonical:  B
    qualified:  sp1::A::B
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x154
    parent:     ((cooked_index_entry *) 0x3c57d110) [A]
...

The problem is that the parent map assumes that all offsets are in the same
section.

Fix this by using dwarf2_section_info::buffer-relative addresses instead,
which get us instead:
...
    [29] ((cooked_index_entry *) 0x3f0962b0)
    name:       B
    canonical:  B
    qualified:  sp2::B
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x154
    parent:     ((cooked_index_entry *) 0x3f096280) [sp2]
...

Tested on x86_64-linux.

PR symtab/32225
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32225

7 months ago[gdb/tdep] s390: Add arch15 record/replay support
Andreas Arnez [Tue, 19 Nov 2024 17:24:06 +0000 (18:24 +0100)] 
[gdb/tdep] s390: Add arch15 record/replay support

Enable recording of the new "arch15" instructions on z/Architecture
targets.

7 months agoPE LD: Merge .CRT .ctors and .dtors into .rdata
Liu Hao [Wed, 27 Nov 2024 14:27:53 +0000 (14:27 +0000)] 
PE LD: Merge .CRT .ctors and .dtors into .rdata

PR 32264

7 months agoTidy up the default ELF linker script
Nick Clifton [Wed, 27 Nov 2024 11:23:38 +0000 (11:23 +0000)] 
Tidy up the default ELF linker script

7 months agoRe: nios2: Remove binutils support for Nios II target
Alan Modra [Tue, 26 Nov 2024 22:12:06 +0000 (08:42 +1030)] 
Re: nios2: Remove binutils support for Nios II target

Remove a now unused config file, regenerate POTFILES to remove nios2
refs, and modify config.bfd to report the target is obsolete.

7 months agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Nov 2024 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agonios2: Remove binutils support for Nios II target.
Sandra Loosemore [Tue, 26 Nov 2024 19:13:07 +0000 (19:13 +0000)] 
nios2: Remove binutils support for Nios II target.

The Nios II architecture has been EOL'ed by the vendor.  This patch
removes all binutils, bfd, gas, binutils, and opcodes support for this
target with the exception of the readelf utility.  (The ELF EM_*
number remains valid and the relocation definitions from the Nios II
ABI will never change in future, so retaining the readelf support
seems consistent with its purpose as a utility that tries to parse the
headers in any ELF file provided as an argument regardless of target.)

7 months agonios2: Remove all GDB support for Nios II targets.
Sandra Loosemore [Tue, 26 Nov 2024 19:13:07 +0000 (19:13 +0000)] 
nios2: Remove all GDB support for Nios II targets.

Intel has EOL'ed the Nios II architecture, and it's time to remove support
from all toolchain components before it gets any more bit-rotten from
lack of maintenance or regular testing.

7 months ago[gdb/syscalls] Update aarch64-linux.xml to linux v6.11
Tom de Vries [Tue, 26 Nov 2024 12:29:12 +0000 (13:29 +0100)] 
[gdb/syscalls] Update aarch64-linux.xml to linux v6.11

Use gdb/syscalls/update-linux.sh to update aarch64-linux.xml.in to linux
v6.11, and update aarch64-linux.xml by running make.

Noteworthy changes are removal of entries:
- arch_specific_syscall
- syscalls
which look like they were added accidentally.

I modified update-linux.sh to keep the copyright start date.  Verified with
shellcheck.

Tested-By: Luis Machado <luis.machado@arm.com>
Approved-By: Luis Machado <luis.machado@arm.com>
7 months agoPR32387 ppc64 TLS optimization bug with -fno-plt code
Alan Modra [Mon, 25 Nov 2024 21:54:19 +0000 (08:24 +1030)] 
PR32387 ppc64 TLS optimization bug with -fno-plt code

The inline plt code emitted by gcc is incompatible with the
linker/ld.so --tls-get-addr-optimize scheme.  This is the runtime
optimisation where the first call to __tls_get_addr results in
__tls_get_addr updating the tls_index pair, then the special linker
stub using that to short-circuit second and subsequent calls for a
given tls symbol.  Enabled by default when the linker sees
__tls_get_addr_opt is preseent, and enabled in ld.so when DT_PPC64_OPT
has PPC64_OPT_TLS set.  Note that this is distinct from link-time tls
optimisation.

PR 32387
* elf64-ppc.c (ppc64_elf_check_relocs): Disable tls_get_addr_opt
on detecting inline plt calls to __tls_get_addr.

7 months ago[gdb/syscalls] Sync with strace v6.12
Tom de Vries [Tue, 26 Nov 2024 09:02:37 +0000 (10:02 +0100)] 
[gdb/syscalls] Sync with strace v6.12

I ran gdb/syscalls/update-linux-defaults.sh with strace sources v6.12, and got
one difference in gdb/syscalls/linux-defaults.xml.in:
...
+  <syscall name="mseal" groups="memory"/>
...

Rerun make to propagate this change to the xml files.

7 months ago[gdb/syscalls] Use update-linux-from-src.sh for arm-linux
Tom de Vries [Tue, 26 Nov 2024 08:49:29 +0000 (09:49 +0100)] 
[gdb/syscalls] Use update-linux-from-src.sh for arm-linux

I tried to use arm-linux.py to regenerate arm-linux.xml.in, but it didn't work.

Fix this by:
- adding handling of arm-linux.xml.in in update-linux-from-src.sh,
- regenerating arm-linux.xml.in using update-linux-from-src.sh and linux 6.11
  sources,
- regenerating arm-linux.xml using make, and
- removing arm-linux.py.

This changes the name "oldolduname" into "olduname".

Tested on arm-linux.  Verified with shellcheck.

7 months ago[gdb/syscalls] Restructure update-linux-from-src.sh
Tom de Vries [Tue, 26 Nov 2024 08:49:29 +0000 (09:49 +0100)] 
[gdb/syscalls] Restructure update-linux-from-src.sh

Restructure update-linux-from-src.sh to do the generation of each line
in the script it self rather than in awk.

Tested on aarch64-linux.  Verified with shellcheck.

7 months ago[gdb/syscalls] Improve update-linux-from-src.sh
Tom de Vries [Tue, 26 Nov 2024 08:49:29 +0000 (09:49 +0100)] 
[gdb/syscalls] Improve update-linux-from-src.sh

Some improvements in gdb/syscalls/update-linux-from-src.sh:
- use bash instead of sh
- use local to distinguish between local and global vars
  (which brings to light that pre uses the global rather than the local
  start_date)
- factor out main and parse_args
- factor out regen
- iterate over *.xml.in instead of *.in

Tested on aarch64-linux.  Verified with shellcheck.

7 months ago[gdb/syscalls] Update to linux v6.11
Tom de Vries [Tue, 26 Nov 2024 08:49:29 +0000 (09:49 +0100)] 
[gdb/syscalls] Update to linux v6.11

Regenerate some gdb/syscalls/*.xml.in files using
gdb/syscalls/update-linux-from-src.sh and linux v6.11 sources.

Regenerate the corresponding gdb/syscalls/*.xml using make.

Tested on aarch64-linux.

7 months agoConvert dwarf2_per_objfile::die_type_hash to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:56 +0000 (13:27 -0500)] 
Convert dwarf2_per_objfile::die_type_hash to new hash table

Convert dwarf2_per_objfile::die_type_hash, which maps debug info
offsets to `type *`, to gdb::unordered_map.

Change-Id: I5c174af64ee46d38a465008090e812acf03704ec
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert dwarf2_cu::call_site_htab to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:55 +0000 (13:27 -0500)] 
Convert dwarf2_cu::call_site_htab to new hash table

Convert one use of htab_t, mapping (unrelocated) pc to call_site
objects, to `gdb::unordered_map<unrelocated_addr, call_site *>`.

Change-Id: I40a0903253a8589dbdcb75d52ad4d233931f6641
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert dwarf_cu::die_hash to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:54 +0000 (13:27 -0500)] 
Convert dwarf_cu::die_hash to new hash table

Convert one use of htab_t, mapping offsets to die_info object, to
`gdb::unordered_set`.

Change-Id: Ic80df22bda551e2d4c2511d167e057f4d6cd2b3e
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert gdb_bfd.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:53 +0000 (13:27 -0500)] 
Convert gdb_bfd.c to new hash table

This converts the BFD cache in gdb_bfd.c to use the new hash table.

Change-Id: Ib6257fe9d4f7f8ef793a2c82d53935a8d2c245a3
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert more DWARF code to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:52 +0000 (13:27 -0500)] 
Convert more DWARF code to new hash table

This converts more code in the DWARF reader to use the new hash table.

Change-Id: I86f8c0072f0a09642de3d6f033fefd0c8acbc4a3
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert all_bfds to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:51 +0000 (13:27 -0500)] 
Convert all_bfds to new hash table

This converts gdb_bfd.c to use the new hash table for all_bfds.

This patch slightly changes the htab_t pretty-printer test, which was
relying on all_bfds.  Note that with the new hash table, gdb-specific
printers aren't needed; the libstdc++ printers suffice -- in fact,
they are better, because the true types of the contents are available.

Change-Id: I48b7bd142085287b34bdef8b6db5587581f94280
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert typedef hash to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:50 +0000 (13:27 -0500)] 
Convert typedef hash to new hash table

This converts the typedef hash to use the new hash table.

This patch found a latent bug in the typedef code.  Previously, the
hash function looked at the type name, but the hash equality function
used types_equal -- but that strips typedefs, meaning that equality of
types did not imply equality of hashes.  This patch fixes the problem
and updates the relevant test.

Change-Id: I0d10236b01e74bac79621244a1c0c56f90d65594
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert abbrevs to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:49 +0000 (13:27 -0500)] 
Convert abbrevs to new hash table

This converts the DWARF abbrevs themselves to use the new hash table.

Change-Id: I0320a733ecefe2cffeb25c068f17322dd3ab23e2
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert abbrev cache to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:48 +0000 (13:27 -0500)] 
Convert abbrev cache to new hash table

This converts the DWARF abbrev cache to use the new hash table.

Change-Id: I5e88cd4030715954db2c43f873b77b6b8e73f5aa
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert gnu-v3-abi.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:47 +0000 (13:27 -0500)] 
Convert gnu-v3-abi.c to new hash table

This converts gnu-v3-abi.c to use the new hash table.

This change shows how a std::vector can easily be made directly from
the hash table, simplifying the earlier approach of constructing a
vector and a hash table at the same time.

Change-Id: Ia0c387a035a52300db6b6f5a3a2e5c69efa01155
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert static links to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:46 +0000 (13:27 -0500)] 
Convert static links to new hash table

This converts the objfile static link table to the new hash map.

Change-Id: If978e895679899ca2af4ef01c12842b4184d88e6
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert type copying to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:45 +0000 (13:27 -0500)] 
Convert type copying to new hash table

This converts the type copying code to use the new hash map.

Change-Id: I35f0a4946dcc5c5eb84820126cf716b600f3302f
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert compile/compile.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:44 +0000 (13:27 -0500)] 
Convert compile/compile.c to new hash table

This converts compile/compile.c to use the new hash table.

Change-Id: I7df3b8d791ece731ae0d1d64cdc91a2e372f5d4f
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert disasm.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:43 +0000 (13:27 -0500)] 
Convert disasm.c to new hash table

This converts disasm.c to use the new hash table.

Change-Id: I2efbe7ecc2964ec49e0b726ad4674e8eafc929f7
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert py-framefilter.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:42 +0000 (13:27 -0500)] 
Convert py-framefilter.c to new hash table

This converts py-framefilter.c to use the new hash table.

Change-Id: I38f4eaa8ebbcd4fd6e5e8ddc462502a92bf62f5e
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert breakpoint.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:41 +0000 (13:27 -0500)] 
Convert breakpoint.c to new hash table

This converts breakpoint.c to use the new hash table.

Change-Id: I6d997a6242969586a7f8f9eb22cc8dd8d3ac97ff
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert dwarf2/macro.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:40 +0000 (13:27 -0500)] 
Convert dwarf2/macro.c to new hash table

This converts dwarf2/macro.c to use the new hash table.

Change-Id: I6af0d1178e2db330fe3a89d57763974145ed17c4
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert target-descriptions.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:39 +0000 (13:27 -0500)] 
Convert target-descriptions.c to new hash table

This converts target-descriptions.c to use the new hash table.

Change-Id: I03dfc6053c9856c5578548afcfdf58abf8b7ec2c
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert linespec.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:38 +0000 (13:27 -0500)] 
Convert linespec.c to new hash table

This converts linespec.c to use the new hash table.

Note that more simplification could perhaps be done.  Currently, the
collectors in this code insert an element into a set and then, if the
element has not been seen before, append it to a vector.  If we know
the order does not matter, or if the results can be sorted later, we
could dispense with the vector.  This would simplify the code some
more.  (This technique is used in the vtable patch, later in this
series.)

Change-Id: Ie6828b1520d918d189ab5140dc8094a609152cf2
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert filename-seen-cache.h to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:37 +0000 (13:27 -0500)] 
Convert filename-seen-cache.h to new hash table

This converts filename-seen-cache.h to use the new hash table.
filename-seen-cache.c is removed.

Change-Id: Iffac1d5e49d1610049b7deeef6e98d49e644366a
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoConvert compile-c-symbols.c to new hash table
Simon Marchi [Mon, 4 Nov 2024 18:27:36 +0000 (13:27 -0500)] 
Convert compile-c-symbols.c to new hash table

This converts compile-c-symbols.c to use the new hash table.

I made it use a set of string_view instead of a set of `symbol *`, to
avoid calling `symbol::natural_name` over and over.  This appears safe
to do, since I don't expect the storage behing the natural names to
change during the lifetime of the map.

Change-Id: Ie9f9334d4f03b9a8ae6886287f82cd435eee217c
Co-Authored-By: Tom Tromey <tom@tromey.com>
Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdbsupport: add unordered_dense.h 4.4.0
Simon Marchi [Mon, 4 Nov 2024 18:27:35 +0000 (13:27 -0500)] 
gdbsupport: add unordered_dense.h 4.4.0

Add a copy of unordered_dense.h from [1].  This file implements an
efficient hash map and hash set with a nice C++ interface (a near
drop-in for std::unordered_map and std::unordered_set).  This is
expected to be used to replace uses of `htab_t`, for improved code
readability and type safety.  Performance-wise, it is preferred to the
std types (std::unordered_map and std::unordered_set) due to it using
open addressing vs closed addressing for the std types.

I chose this particular implementation because it is simple to use, it's
a standalone header and it typically performs well in benchmarks I have
seen (e.g. [2]).  The license being MIT, my understanding is that it's
not a problem to use it and re-distribute it.

Add two additional files, gdbsupport/unordered_map.h and
gdbsupport/unordered_set.h, which make the map and set offered by
gdbsupport/unordered_dense.h available as gdb::unordered_map and
gdb::unordered_set.

[1] https://github.com/martinus/unordered_dense
[2] https://jacksonallan.github.io/c_cpp_hash_tables_benchmark/#conclusion-which-hash-table-to-choose

Change-Id: I0c7469ccf9a14540465479e58b2a5140a2440a7d
Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: make `cooked_index_storage::get_abbrev_table_cache` return a reference
Simon Marchi [Mon, 4 Nov 2024 18:27:34 +0000 (13:27 -0500)] 
gdb: make `cooked_index_storage::get_abbrev_table_cache` return a reference

It can never return nullptr, return a reference instead of a pointer.

Change-Id: Ibc6f16eb74dc16059152982600ca9f426d7f80a4
Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: constification around abbrev_table_cache and abbrev_table
Simon Marchi [Mon, 4 Nov 2024 18:27:33 +0000 (13:27 -0500)] 
gdb: constification around abbrev_table_cache and abbrev_table

Make `abbrev_table_cache::find` const, make it return a pointer to
`const abbrev_table`, adjust the fallouts.

Make `cooked_index_storage::get_abbrev_table_cache` const, make itreturn
a pointer to const `abbrev_table_cache`.

Change-Id: If63b4b3a4c253f3bd640b13bce4a854eb2d75ece
Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: rename abbrev_cache to abbrev_table_cache
Simon Marchi [Mon, 4 Nov 2024 18:27:32 +0000 (13:27 -0500)] 
gdb: rename abbrev_cache to abbrev_table_cache

This cache holds `abbrev_table` objects, so I think it's clearer and
more consistent to name it `abbrev_table_cache`.  Rename it and
everything that goes along with it.

Change-Id: I43448c0aa538dd2c3ae5efd2f7b3e7b827409d8c
Approved-By: Tom Tromey <tom@tromey.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Nov 2024 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agogdb: do better in breakpoint_free_objfile
Andrew Burgess [Mon, 11 Nov 2024 21:45:17 +0000 (21:45 +0000)] 
gdb: do better in breakpoint_free_objfile

The breakpoint_free_objfile function is called from the objfile
destructor, and has the job of removing references to the soon to be
deleted objfile from all breakpoint locations.

The current implementation of breakpoint_free_objfile seems to miss
lots of possible objfile references within bp_location.  Currently we
only check if bp_location::symtab is associated with the objfile in
question, but there's bp_location::section and bp_location::probe,
both of which might reference the soon to be deleted objfile.

Additionally bp_location::symbol and bp_location::msymbol if set will
surely be related to the objfile and should also be cleaned up.

I'm not aware that this causes any problems, but it doesn't seem like
a good idea to retain pointers to deleted state, so I propose that we
improve breakpoint_free_objfile to set these pointers back to nullptr.

In the future I plan to investigate the possibility of merging the
functionality of breakpoint_free_objfile into
disable_breakpoints_in_freed_objfile which is called via the
gdb::observers::free_objfile event.  However, I already have a patch series
in progress which touches this area of GDB, and I'd like to avoid
conflicting with that earlier series:

  https://inbox.sourceware.org/gdb-patches/cover.1724948606.git.aburgess@redhat.com

Once this patch, and that earlier series have landed then I'll see if
I can merge breakpoint_free_objfile, but I don't think that this needs
to block this patch.

There should be no user visible changes after this commit.

7 months agogdb: remove an unnecessary scope block in update_breakpoint_locations
Andrew Burgess [Tue, 5 Nov 2024 13:42:57 +0000 (13:42 +0000)] 
gdb: remove an unnecessary scope block in update_breakpoint_locations

In update_breakpoint_locations there's a scope block which I don't
think adds any value.  There is one local defined within the scope,
the local is currently an 'int' but should be a 'bool', either way
there's no destructor being triggered when we exit the scope.

This commit changes the local to a 'bool', removes the unnecessary
scope, and re-indents the code.

Within the (now removed) scope was a `for' loop.  Inside the loop I
have converted this:

  for (....)
    {
      if (CONDITION)
        {
          /* Body */
        }
    }

to this:

  for (....)
    {
      if (!CONDITION)
        continue;

      /* Body */
    }

which means that the body doesn't need to be indented as much, making
things easier to read.

There should be no functional change after this commit.

Reviewed-By: Klaus Gerlicher <klaus.gerlicher@intel.com>
7 months agogdb: remove bp_location::objfile
Andrew Burgess [Tue, 5 Nov 2024 14:03:17 +0000 (14:03 +0000)] 
gdb: remove bp_location::objfile

The bp_location::objfile member variable is never used, so lets delete
it.

There should be no user visible changes after this commit.

7 months agogdbreplay: Calculate the checksum if missing
Alexandra Hájková [Mon, 18 Nov 2024 16:23:33 +0000 (17:23 +0100)] 
gdbreplay: Calculate the checksum if missing

Recalculate the checksum and replace whatever is at the end
of the packet with the newly calculated checksum. Then
replay the packet with the checksum added.

The motivation for this change is that I'd like to add a TCL test
which starts a communication with gdbsever setting the remotelog file.
Then, it modifies the remotelog, injects an error message instead of
the expected replay to some packet in order to test GDB reacts to
the error response properly.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agoUpdated Bulgarian, Romanian and French translations for various sub-directories....
Nick Clifton [Mon, 25 Nov 2024 15:52:20 +0000 (15:52 +0000)] 
Updated Bulgarian, Romanian and French translations for various sub-directories.  New Georgian translation for the gold sub-directory.

7 months agogdb/testsuite: force TERM setting for some filename completion tests
Andrew Burgess [Tue, 5 Nov 2024 17:26:13 +0000 (17:26 +0000)] 
gdb/testsuite: force TERM setting for some filename completion tests

Some of the filename completion tests perform mid-line completion.
That is we enter a partial line, then move the cursor back to the
middle of the line and perform completion.

The problem is that, emitting characters into the middle of a terminal
line relies on first emitting some control characters.  And which
control characters are emitted will depend on the current TERM
setting.

When I initially added the mid-line completion tests I setup two
regexp that covered two different terminal types, but PR gdb/32338
identifies additional terminal types that emit different sequences of
control characters.

Rather than trying to handle all possible terminal types, lets just
force the TERM variable to something simple (i.e. "dumb") and then
just support that one case.  The thing being tested for here was that
GDB would complete a filename in the middle of a line, the specific
terminal type was not really important.

I've simplified the regexp used to match the completion in two places,
and I now force TERM to be "dumb" for the mid-line completion tests.
I've tested this by setting my global environment TERM to 'ansi',
'xterm', 'xterm-mono', and 'dumb', and I see no failures in any mode
now.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32338
Tested-By: Tom de Vries <tdevries@suse.de>
7 months agogdb: Add LoongArch process record/replay support in NEWS and doc
Hui Li [Mon, 25 Nov 2024 07:50:42 +0000 (15:50 +0800)] 
gdb: Add LoongArch process record/replay support in NEWS and doc

At present, process record/replay and reverse debugging has been
implemented on LoongArch. Update the NEWS and doc to record this
new change.

Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
7 months agogdb: LoongArch: Add system call support for process record/replay
Hui Li [Mon, 25 Nov 2024 07:46:00 +0000 (15:46 +0800)] 
gdb: LoongArch: Add system call support for process record/replay

The process record and replay function also need record Linux
system call instruction. This patch adds LoongArch system call
number definitions in gdb/arch/loongarch-syscall.h, and adds
loongarch_linux_syscall_record() in gdb/loongarch-linux-tdep.c
to record system call execute log. With this patch, the main
functions of process record/replay and reverse debugging are
implemented.

The LoongArch system call numbers definitions are obtained from Linux kernel.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/unistd.h

Signed-off-by: Hui Li <lihui@loongson.cn>
Approved-By: Guinevere Larsen <guinevere@redhat.com> (record-full)
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
7 months agogdb: LoongArch: Add basic process record/replay support
Hui Li [Mon, 25 Nov 2024 07:40:03 +0000 (15:40 +0800)] 
gdb: LoongArch: Add basic process record/replay support

GDB provides a special process record and replay target that can
record a log of the process execution, and replay it later with
both forward and reverse execution commands. This patch adds the
basic support of process record and replay on LoongArch, it allows
users to debug basic LoongArch instructions and provides reverse
debugging support.

Here is a simple example on LoongArch:

$ cat test.c
int a = 0;
int main()
  {
    a = 1;
    a = 2;
    return 0;
  }
$ gdb test
...
(gdb) start
...
Temporary breakpoint 1, main () at test.c:4
4     a = 1;
(gdb) record
(gdb) p a
$1 = 0
(gdb) n
5     a = 2;
(gdb) n
6     return 0;
(gdb) p a
$2 = 2
(gdb) rn
5     a = 2;
(gdb) rn

Reached end of recorded history; stopping.
Backward execution from here not possible.
main () at test.c:4
4     a = 1;
(gdb) p a
$3 = 0
(gdb) record stop
Process record is stopped and all execution logs are deleted.
(gdb) c
Continuing.
[Inferior 1 (process 129178) exited normally]

Signed-off-by: Hui Li <lihui@loongson.cn>
Approved-By: Guinevere Larsen <guinevere@redhat.com> (record-full)
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
7 months agogdb: LoongArch: Add instruction definition for process record
Hui Li [Mon, 25 Nov 2024 07:31:34 +0000 (15:31 +0800)] 
gdb: LoongArch: Add instruction definition for process record

GDB provides a special process record function that can record a log
of the process execution. The core of this feature is need to record
the execution of all instructions. This patch adds opcode definitions
and judgments in gdb/arch/loongarch-insn.h. This is preparation for
later patch on LoongArch, there is no effect for the other archs with
this patch.

The LoongArch opcode and mask definitions are obtained from
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=opcodes/loongarch-opc.c
LoongArch instruction description refer to the LoongArch Reference Manual:
https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Signed-off-by: Hui Li <lihui@loongson.cn>
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
7 months agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Nov 2024 00:00:46 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoopcodes: fix Werror=format build breaker in opcodes/riscv-dis.c
Tom de Vries [Sun, 24 Nov 2024 08:21:28 +0000 (09:21 +0100)] 
opcodes: fix Werror=format build breaker in opcodes/riscv-dis.c

I build gdb on arm-linux and ran into:
...
  CC       riscv-dis.lo
opcodes/riscv-dis.c: In function ‘print_insn_args’:
opcodes/riscv-dis.c:743:29: error: format ‘%lu’ expects argument of type \
  ‘long unsigned int’, but argument 4 has type ‘insn_t’ \
  {aka ‘long long unsigned int’} [-Werror=format=]
  743 |                          "%lu", EXTRACT_ZCMT_INDEX (l));
      |                           ~~^
      |                             |
      |                             long unsigned int
      |                           %llu
...

Fix this by printing the insn_t value, which is a uint64_t, using PRIu64.

Tested by finishing the build.

7 months agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Nov 2024 00:00:57 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months ago[sim] Run spellcheck.sh in sim (part 2)
Tom de Vries [Sat, 23 Nov 2024 12:07:38 +0000 (13:07 +0100)] 
[sim] Run spellcheck.sh in sim (part 2)

Run gdb/contrib/spellcheck.sh on directory sim.

Fix these todos:
...
TODO: inbetween -> between, in between, in-between
TODO: behavour -> behavior, behaviour
TODO: firts -> flirts, first
TODO: wich -> which, witch
...

Tested by rebuilding on x86_64-linux.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/contrib] Add two words to common-misspellings.txt
Tom de Vries [Sat, 23 Nov 2024 12:07:38 +0000 (13:07 +0100)] 
[gdb/contrib] Add two words to common-misspellings.txt

While reviewing changes generated by spellcheck.sh for directory sim, I
noticed two more misspellings:
...
arrithemetic->arithmetic
electricaly->electrically
...

Add them to common-misspellings.txt, and fix them in directory sim.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[sim] Run spellcheck.sh in sim (part 1)
Tom de Vries [Sat, 23 Nov 2024 12:07:38 +0000 (13:07 +0100)] 
[sim] Run spellcheck.sh in sim (part 1)

Run gdb/contrib/spellcheck.sh on directory sim.

Fix auto-corrected typos:
...
accessable -> accessible
accidently -> accidentally
accomodate -> accommodate
adress -> address
afair -> affair
agains -> against
agressively -> aggressively
annuled -> annulled
arbitary -> arbitrary
arround -> around
auxillary -> auxiliary
availablity -> availability
clasic -> classic
comming -> coming
controled -> controlled
controling -> controlling
destory -> destroy
existance -> existence
explictly -> explicitly
faciliate -> facilitate
fouth -> fourth
fullfilled -> fulfilled
guarentee -> guarantee
hinderance -> hindrance
independant -> independent
inital -> initial
loosing -> losing
occurance -> occurrence
occured -> occurred
occuring -> occurring
omited -> omitted
oportunity -> opportunity
parallely -> parallelly
permissable -> permissible
postive -> positive
powerfull -> powerful
preceed -> precede
preceeding -> preceding
preceeds -> precedes
primative -> primitive
probaly -> probably
programable -> programmable
propogate -> propagate
propper -> proper
recieve -> receive
reconized -> recognized
refered -> referred
refering -> referring
relevent -> relevant
responisble -> responsible
retreive -> retrieve
safty -> safety
specifiying -> specifying
spontanous -> spontaneous
sqaure -> square
successfull -> successful
supress -> suppress
sytem -> system
thru -> through
transfered -> transferred
trigered -> triggered
unfortunatly -> unfortunately
upto -> up to
usefull -> useful
wierd -> weird
writen -> written
doesnt -> doesn't
isnt -> isn't
...

Manually undid the "andd -> and" transformation in sim/testsuite/cr16/andd.cgs
and sim/cr16/simops.c.

Tested by rebuilding on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[sim] Rename local variable in ARMul_NthReg
Tom de Vries [Sat, 23 Nov 2024 12:07:38 +0000 (13:07 +0100)] 
[sim] Rename local variable in ARMul_NthReg

Rename local variable in ARMul_NthReg from upto to up_to, to avoid being
rewritten by gdb/contrib/spellcheck.sh.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdbsupport] Rerun autoreconf -f
Tom de Vries [Sat, 23 Nov 2024 11:40:36 +0000 (12:40 +0100)] 
[gdbsupport] Rerun autoreconf -f

Rerun autoreconf -f in gdbsupport, reverting "behaviour" -> "behavior" changes
in generated files aclocal.m4 and configure.

7 months ago[gdb/contrib] Add two rules in common-misspellings.txt
Tom de Vries [Sat, 23 Nov 2024 11:20:34 +0000 (12:20 +0100)] 
[gdb/contrib] Add two rules in common-misspellings.txt

Eli mentioned [1] that given that we use US English spelling in our
documentation, we should use "behavior" instead of "behaviour".

In wikipedia-common-misspellings.txt there's a rule:
...
behavour->behavior, behaviour
...
which leaves this as a choice.

Add an overriding rule to hardcode the choice to common-misspellings.txt:
...
behavour->behavior
...
and add a rule to rewrite behaviour into behavior:
...
behaviour->behavior
...
and re-run spellcheck.sh on gdb*.

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2024-November/213371.html

7 months agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Nov 2024 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoSync toplevel configure fixup
Sam James [Fri, 22 Nov 2024 20:55:00 +0000 (20:55 +0000)] 
Sync toplevel configure fixup

Apparently I missed that we needed to sync config/acx.m4. I only
noticed this because our packaging has a grep for certain messages
post-merge.

```
work/binutils/configure: 5814: ACX_PROG_CARGO: not found
```

Fix that by syncing the macro too, which I missed in 987db70acefd0b223a8df2240d4e5ca544cc0a91.

7 months agogdb/record: introduce recoding support for vpor
Guinevere Larsen [Thu, 14 Nov 2024 12:31:00 +0000 (09:31 -0300)] 
gdb/record: introduce recoding support for vpor

This commit adds recording support for the AVX instruction vpor, and the
AVX2 extension. Since the encoding of vpor and vpxor are the same, and
their semantics are basically the same, modulo the mathematical
operation, they are handled by the same switch case block.

This also updates the vpxor function, to test vpor and vpxor, and
updates the name to vpor_xor_test to better reflect what it does.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb/record: Add support for recording vpmovmskb
Guinevere Larsen [Tue, 12 Nov 2024 20:45:05 +0000 (17:45 -0300)] 
gdb/record: Add support for recording vpmovmskb

This commit adds support for recording the AVX instruction vpmovmskb,
and tests to the relevant file. The test didn't really support checking
general purpose registers, so this commit also adds a proc to
gdb.reverse/i386-avx-reverse.exp, which can be used to test them

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb/record: Add support for all vpcmpeq instructions
Guinevere Larsen [Tue, 12 Nov 2024 19:37:32 +0000 (16:37 -0300)] 
gdb/record: Add support for all vpcmpeq instructions

This commit adds support to recording instructions of the form
VPCMPEQ[B|W|D]. They are all encoded in the same way and only
differentiated by the opcode, so they are all processed together. This
commit also updates the test to (quite exhaustively) test the new
instruction.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb/record: add support for vpxor instruction
Guinevere Larsen [Fri, 1 Nov 2024 16:30:49 +0000 (13:30 -0300)] 
gdb/record: add support for vpxor instruction

This commit adds support for recording the instruction vpxor,
introduced in the AVX extension, and extended in AVX2 to use 256 bit
registers. The test gdb.reverse/i386-avx-reverse.exp has been extended
to test this instruction as well.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogdb: Introduce RAII signal handler setter
Guinevere Larsen [Thu, 20 Jun 2024 17:52:35 +0000 (14:52 -0300)] 
gdb: Introduce RAII signal handler setter

This patch is motivated by the wait function for the record-full target,
that would install a custom signal handler for SIGINT, but could throw
an exception and never reset the SIGINT handler.  This is clearly a bad
idea, so this patch introduces the class scoped_signal_handler in a new
.h file.  The file is added to gdbsupport, even though only gdb code is
using it, because it feels like an addition that would be useful for
more than just directly gdb.

The implementation of the RAII class is based on the implementation
on gdb/utils.c. That is, it uses preprocessor ifdefs to probe for
sigaction support, and uses it if possible, defaulting to a raw call to
signal only if sigaction isn't supported. sigaction is preferred based
on the "portability" section of the manual page for the signal function.

There are 3 places where this class can just be dropped in,
gdb/record-full.c, gdb/utils.c and gdb/extension.c. This third place
already had a specialized RAII signal handler setter, but it is
substituted for the new general purpose one.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agogprofng: fix build with -std=gnu23
Vladimir Mezentsev [Thu, 21 Nov 2024 22:48:20 +0000 (14:48 -0800)] 
gprofng: fix build with -std=gnu23

Fix function pointer types accordingly.
Remove unused function pointers.

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

PR gprofng/32374
PR gprofng/32373
* common/cpuid.c: Define ATTRIBUTE_UNUSED if necessary.
* libcollector/libcol_util.c (sysinfo): Remove unused pointer.
* src/collector_module.h: Likewise.
* libcollector/dispatcher.c (setitimer): Fix prototype.
* libcollector/linetrace.c (system, grantpt, ptsname): Likewise.
* testsuite/gprofng.display/mttest/mttest.c (dump_arrays): Likewise.
* testsuite/gprofng.display/synprog/endcases.c (xinline_code,
s_inline_code): Likewise.
* testsuite/gprofng.display/synprog/inc_inline.h (ext_inline_code):
Likewise.
* testsuite/gprofng.display/synprog/synprog.c (doabort): Rename nullptr.

7 months agoUse appropriate context flags for Wow64 processes
Hannes Domani [Fri, 22 Nov 2024 19:10:22 +0000 (20:10 +0100)] 
Use appropriate context flags for Wow64 processes

When I implemented debugging of Wow64 processes, I missed that there are
extra ContextFlags defines for them.
It's a bit surprising that the wrong ones actually worked, except that
CONTEXT_EXTENDED_REGISTERS is not available for x86_64, and they are
needed for i686, since that's where the xmm registers are stored.

So this replaces the ContextFlags values with their WOW64_* equivalents.
On gdbserver this also duplicates the fallback logic if the
GetThreadContext call failed with CONTEXT_EXTENDED_REGISTERS.

Fixes these fails:
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm0
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm0
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm1
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm1
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm2
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm2
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm3
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm3
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm4
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm4
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm5
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm5
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm6
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm6
FAIL: gdb.arch/i386-sse.exp: check float contents of %xmm7
FAIL: gdb.arch/i386-sse.exp: check int8 contents of %xmm7
FAIL: gdb.arch/i386-sse.exp: check contents of data[0]
FAIL: gdb.arch/i386-sse.exp: check contents of data[1]
FAIL: gdb.arch/i386-sse.exp: check contents of data[2]
FAIL: gdb.arch/i386-sse.exp: check contents of data[3]
FAIL: gdb.arch/i386-sse.exp: check contents of data[4]
FAIL: gdb.arch/i386-sse.exp: check contents of data[5]
FAIL: gdb.arch/i386-sse.exp: check contents of data[6]
FAIL: gdb.arch/i386-sse.exp: check contents of data[7]

Approved-By: Tom Tromey <tom@tromey.com>
7 months agoSync toplevel configure with GCC
Sam James [Mon, 18 Nov 2024 07:17:08 +0000 (07:17 +0000)] 
Sync toplevel configure with GCC

This syncs us with GCC as of r15-5590-gf34422e06c38eb.

Some changes will need to be propagated to the GCC side (so I've kept those
and not clobbered them) which I will handle shortly.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/python] Handle failure to initialize without exiting
Tom de Vries [Fri, 22 Nov 2024 18:34:24 +0000 (19:34 +0100)] 
[gdb/python] Handle failure to initialize without exiting

I tried out making python initialization fail by passing an incorrect
PYTHONHOME, and got:
...
$ PYTHONHOME=foo ./gdb.sh -q
Python path configuration:
  PYTHONHOME = 'foo'
  ...
Python initialization failed: \
  failed to get the Python codec of the filesystem encoding
Python not initialized
$
...

The relevant part of the code is:
...
static void
gdbpy_initialize (const struct extension_language_defn *extlang)
{
  if (!do_start_initialization () && py_isinitialized && PyErr_Occurred ())
    gdbpy_print_stack ();

   gdbpy_enter enter_py;
...

What happens is:
- gdbpy_enter::gdbpy_enter () is called, where we run into:
  'if (!gdb_python_initialized) error (_("Python not initialized"));'
- the error propagates to gdb's toplevel
- gdb print the error and exits.

It seems unnecesssary that we exit gdb.  We could continue the
session without python support.

Fix this by:
- bailing out of gdbpy_initialize if !do_start_initialization
- bailing out of finalize_python if !gdb_python_initialized

This gets us instead:
...
$ PYTHONHOME=foo gdb -q
Python path configuration:
  PYTHONHOME = 'foo'
  ...
Python initialization failed: \
  failed to get the Python codec of the filesystem encoding
(gdb) python print (1)
Python not initialized
(gdb)
...

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/python] Fix abort on Py_Initialize
Tom de Vries [Fri, 22 Nov 2024 18:34:24 +0000 (19:34 +0100)] 
[gdb/python] Fix abort on Py_Initialize

I tried out making python initialization fail by passing an incorrect
PYTHONHOME with python 3.6, and got:
...
$ PYTHONHOME=foo gdb -q
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000ffff89269c80 (most recent call first):

Fatal signal: Aborted
  ...
Aborted (core dumped)
$
...

This is as per spec: when Py_Initialize () fails, a fatal error is raised
using Py_FatalError.

This can be worked around using:
...
$ PYTHONHOME=foo gdb -q -eiex "set python ignore-environment on"
(gdb)
...
but it would be better if gdb didn't abort.

I found an article [1] describing two solutions:
- try out Py_Initialize in a separate process, and
- catch the abort using a signal handler.

This patch implements the latter solution.

Obviously we cannot call into python anymore after the abort, so we avoid
calling Py_IsInitialized (), and instead use a new variable py_isinitialized.

This gets us instead:
...
$ PYTHONHOME=foo gdb -q
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000fffecfd49c80 (most recent call first):
Python not initialized
$
...

Tested on aarch64-linux.

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

[1] https://stackoverflow.com/questions/7688374/how-to-i-catch-and-handle-a-fatal-error-when-py-initialize-fails

7 months ago[gdb/python] Handle !Py_IsInitialized () in gdbpy_initialize
Tom de Vries [Fri, 22 Nov 2024 18:34:24 +0000 (19:34 +0100)] 
[gdb/python] Handle !Py_IsInitialized () in gdbpy_initialize

I tried out making python initialization fail by passing an incorrect
PYTHONHOME, and got:
...
$ PYTHONHOME=foo gdb -q
Python path configuration:
  PYTHONHOME = 'foo'
  ...
Python Exception <class 'ModuleNotFoundError'>: No module named 'encodings'
Python not initialized
$
...

The relevant part of the code is:
...
static void
gdbpy_initialize (const struct extension_language_defn *extlang)
{
  if (!do_start_initialization () && PyErr_Occurred ())
    gdbpy_print_stack ();

   gdbpy_enter enter_py;
...

What happens is that:
- do_start_initialization returns false because Py_InitializeFromConfig fails,
  leaving us in the !Py_IsInitialized () state
- PyErr_Occurred () returns true
- gdbpy_print_stack is called, which prints
  "Python Exception <class 'ModuleNotFoundError'>: No module named 'encodings"

The problem is that in the Py_IsInitialized () == false state, very few
functions can be called, and PyErr_Occurred is not one of them [1], and
likewise functions in gdbpy_print_stack.

Fix this by:
- guarding the PyErr_Occurred / gdbpy_print_stack part with Py_IsInitialized ().
- handling the !Py_IsInitialized () case by printing the failure PyStatus
  in do_start_initialization

This gets us instead:
...
$ PYTHONHOME=foo ./gdb.sh -q
Python path configuration:
  PYTHONHOME = 'foo'
  ...
Python initialization failed: failed to get the Python codec of the filesystem encoding
Python not initialized
$
...

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
[1] https://docs.python.org/3/c-api/init.html#before-python-initialization

7 months ago[gdbsupport] Handle EINTR in event-pipe.cc
Tom de Vries [Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)] 
[gdbsupport] Handle EINTR in event-pipe.cc

Use gdb syscall wrappers to handle EINTR in event-pipe.cc.

Tested on aarch64-linux.

7 months ago[gdb] Handle EINTR in ser-event.c
Tom de Vries [Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)] 
[gdb] Handle EINTR in ser-event.c

Use gdb syscall wrappers to handle EINTR in ser-event.c.

Tested on aarch64-linux.

7 months ago[gdb] Add gdb::wait
Tom de Vries [Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)] 
[gdb] Add gdb::wait

Add gdb::wait, and use it in gdb/procfs.c, making sure that EINTR is handled.

Tested on x86_64-linux.

7 months ago[gdb] Use gdb::waitpid more often
Tom de Vries [Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)] 
[gdb] Use gdb::waitpid more often

Use gdb::waitpid instead of plain waitpid, making sure that EINTR is handled.

Tested on x86_64-linux.

7 months ago[gdbsupport] Add gdb::{waitpid,read,write,close}
Tom de Vries [Fri, 22 Nov 2024 16:44:29 +0000 (17:44 +0100)] 
[gdbsupport] Add gdb::{waitpid,read,write,close}

We have gdb::handle_eintr, which allows us to rewrite:
...
  ssize_t ret;
    do
      {
        errno = 0;
        ret = ::write (pipe[1], "+", 1);
      }
    while (ret == -1 && errno == EINTR);
...
into:
...
  ssize_t ret = gdb::handle_eintr (-1, ::write, pipe[1], "+", 1);
...

However, the call to write got a bit mangled, requiring effort to decode it
back to its original form.

Instead, add a new function gdb::write that allows us to write:
...
  ssize_t ret = gdb::write (pipe[1], "+", 1);
...

Likewise for waitpid, read and close.

Tested on x86_64-linux.

7 months agogdb/disasm: fix demangling when disassembling the current function
Andrew Burgess [Mon, 18 Nov 2024 10:58:26 +0000 (10:58 +0000)] 
gdb/disasm: fix demangling when disassembling the current function

When disassembling function symbols in C++ code, if GDB is asked to
disassemble a function by name then the function name in the header
line can be demangled by turning on `set print asm-demangle on`, e.g.:

  (gdb) disassemble foo_type::some_function
  Dump of assembler code for function _ZN8foo_type13some_functionE7my_type:
     0x0000000000401142 <+0>: push   %rbp
     ... etc ...
  End of assembler dump.
  (gdb) set print asm-demangle on
  (gdb) disassemble foo_type::some_function
  Dump of assembler code for function foo_type::some_function(my_type):
     0x0000000000401142 <+0>: push   %rbp
     ... etc ...                                                        │
  End of assembler dump.                                                │

However, if GDB is disassembling the current function, then this
demangling doesn't work, e.g.:

  (gdb) break foo_type::some_function
  Breakpoint 1 at 0x401152: file mangle.cc, line 16.
  (gdb) run
  Starting program: /tmp/mangle

  Breakpoint 1, foo_type::some_function (this=0x7fffffffa597, obj=...) at mangle.cc:16
  16     obj.update ();
  (gdb) disassemble
  Dump of assembler code for function _ZN8foo_type13some_functionE7my_type:
     0x0000000000401142 <+0>: push   %rbp
     ... etc ...
  End of assembler dump.
  (gdb) set print asm-demangle on
  (gdb) disassemble
  Dump of assembler code for function _ZN8foo_type13some_functionE7my_type:
     0x0000000000401142 <+0>: push   %rbp
     ... etc ...
  End of assembler dump.

This commit fixes this issue, and extends gdb.cp/disasm-func-name.exp,
which was already testing the first case (disassemble by name) to also
cover disassembling the current function.

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/python] Ensure locale is restored in do_start_initialization
Tom de Vries [Fri, 22 Nov 2024 16:34:50 +0000 (17:34 +0100)] 
[gdb/python] Ensure locale is restored in do_start_initialization

I noticed in do_start_initialization:
...
  std::string oldloc = setlocale (LC_ALL, NULL);
  setlocale (LC_ALL, "");
  ...
  if (count == (size_t) -1)
    {
      fprintf (stderr, "Could not convert python path to string\n");
      return false;
    }
  setlocale (LC_ALL, oldloc.c_str ());
...
that the old locale is not restored if the "return false" is triggered.

Fix this by using SCOPE_EXIT.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
7 months agolibiberty: sync with gcc again
Sam James [Fri, 22 Nov 2024 15:47:23 +0000 (15:47 +0000)] 
libiberty: sync with gcc again

This imports the following single commit from GCC as of r15-5586-g77f4b1097e6aec:
961c50410926 Add LTO support

That change slipped in while I was preparing the previous just-pushed sync.

7 months agolibiberty: sync with gcc
Sam James [Mon, 18 Nov 2024 05:53:54 +0000 (05:53 +0000)] 
libiberty: sync with gcc

This imports the following commits from GCC as of r15-5375-gbeec291225be9b:
94bea5dd6c9a libiberity: ANSIfy test-demangle.c
aa84020b2edb libiberty: Fix comment typos
c1b2100e736c libiberty: Restore build with CP_DEMANGLE_DEBUG defined
bb8dd0980b39 libiberty: Fix up > 64K section handling in simple_object_elf_copy_lto_debug_section [PR116614]

Approved-By: Tom Tromey <tom@tromey.com>
7 months ago[gdb/tdep] Simplify amd64_windows_store_arg_in_reg
Tom de Vries [Fri, 22 Nov 2024 12:43:03 +0000 (13:43 +0100)] 
[gdb/tdep] Simplify amd64_windows_store_arg_in_reg

Simplify amd64_windows_store_arg_in_reg by:
- replacing memset with value initialization,
- making valbuf a gdb::array_view, allowing us to:
  - replace memcpy with std::copy, and
  - use valbuf.size () instead of arg->type->size (), and
- dropping the std::min in std::min (type->length (), (ULONGEST) 8), since
  we're already asserting that type->length () <= 8.

Suggested-By: Tom Tromey <tom@tromey.com>
Tested by rebuilding on x86_64-linux.

7 months ago[gdb/testsuite] Require local host in gdb.base/bg-exec-sigint-bp-cond.exp
Tom de Vries [Fri, 22 Nov 2024 12:37:24 +0000 (13:37 +0100)] 
[gdb/testsuite] Require local host in gdb.base/bg-exec-sigint-bp-cond.exp

I noticed that gdb.base/bg-exec-sigint-bp-cond.exp fails for remote host
(concretely, host board local-remote-host and target board
remote-gdbserver-on-localhost):
...
(gdb) c&^M
Continuing.^M
(gdb) bash: line 0: kill: (23834) - Operation not permitted^M
^M
Breakpoint 2, foo () at bg-exec-sigint-bp-cond.c:23^M
23        return 0;^M
...
due to getting gdb's pid like this:
...
    set gdb_pid [exp_pid -i [board_info host fileid]]
...

For remote host using ssh, this returns the pid of the ssh session on build.

Fix this by requiring local host.

Tested on x86_64-linux.

7 months ago[gdb/testsuite] Fix gdb.base/bg-exec-sigint-bp-cond.exp for signal merging
Tom de Vries [Fri, 22 Nov 2024 12:37:24 +0000 (13:37 +0100)] 
[gdb/testsuite] Fix gdb.base/bg-exec-sigint-bp-cond.exp for signal merging

The test-case gdb.base/bg-exec-sigint-bp-cond.exp sends 10 SIGINTS to gdb, and
counts whether 10 have arrived.

Occasionally, less than 10 arrive due to signal merging [1].

This is more likely to happen when building gdb with -fsanitize=thread.

Fix this by instead, sending one SIGINT at a time, and waiting for it to
arrive.

This still makes the test-case fail if the fix fixing the PR that the
test-case was introduced for is reverted.

Tested on aarch64-linux and x86_64-linux.

PR testsuite/32329
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32329

[1] https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html

7 months ago[gdb/build] Workaround tsan select bug
Tom de Vries [Fri, 22 Nov 2024 11:54:57 +0000 (12:54 +0100)] 
[gdb/build] Workaround tsan select bug

When building gdb with -O0 and -fsanitize-thread, I run into a large number of
timeouts caused by gdb hanging, for instance:
...
(gdb) continue^M
Continuing.^M
[Inferior 1 (process 378) exited normally]^M
FAIL: gdb.multi/stop-all-on-exit.exp: continue until exit (timeout)
...

What happens is the following:
- two inferiors are added, stopped at main
- inferior 1 is setup to exit after 1 second
- inferior 2 is setup to exit after 10 seconds
- the continue command is issued
- because of set schedule-multiple on, both inferiors continue
- the first inferior exits
- gdb sends a SIGSTOP to the second inferior
- the second inferior receives the SIGSTOP, and raises a SIGCHILD
- gdb calls select, and blocks
- the signal arrives, and interrupts select
- ThreadSanitizers signal handler is called, which marks the signal pending
  internally
- select returns -1 with errno == EINTR
- gdb calls select again, and blocks
- gdb hangs, waiting for gdb's sigchild_handler to be called

This is a bug [1] in ThreadSanitizer.  When select is called with
timeout == nullptr, it is blocking but ThreadSanitizer doesn't consider it so,
and consequently doesn't see the need to call sigchild_handler.

Work around this by:
- instead of using the blocking select variant, forcing a small timeout and
- upon timeout calling a function that ThreadSanitizer does consider
  blocking: usleep, forcing sigchild_handler to be called.

Tested on x86_64-linux.

PR build/32295
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32295

[1] https://github.com/google/sanitizers/issues/1813

7 months ago[gdb] Add gdb_select variant for looping
Tom de Vries [Fri, 22 Nov 2024 11:54:57 +0000 (12:54 +0100)] 
[gdb] Add gdb_select variant for looping

In interruptible_select we run gdb_select in a loop:
...
  do
    {
      res = gdb_select (n, readfds, writefds, exceptfds, timeout);
    }
  while (res == -1 && errno == EINTR);
...
but man select tells us that:
- if using select() within a loop, the sets (readfds, writefds and
  exceptfds) must be reinitialized before each call, and
- timeout should be considered to be undefined after select() returns.

Add a gdb_select variant:
...
static int
gdb_select (int n,
    const fd_set *req_readfds, fd_set *ret_readfds,
    const fd_set *req_writefds, fd_set *ret_writefds,
    const fd_set *req_exceptfds, fd_set *ret_exceptfds,
    const struct timeval *req_timeout, struct timeval *ret_timeout)
...
that keeps requested and returned values separate, ensuring that the requested
values stay constant.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
7 months agold/PE: Handle MS style import libraries for files named *.exe too
Martin Storsjö [Fri, 6 Sep 2024 13:18:02 +0000 (16:18 +0300)] 
ld/PE: Handle MS style import libraries for files named *.exe too

When handling MS style import libraries (also called short import
libraries, or ILF), we need to detect the kind of library.

So far, this has been done by looking at the member file names
in the import library - in an MS style import library, all the
member files for a specific library have the same member file
name - the name of the runtime module to link against. Usually
this is a DLL - thus we do a case insensitive comparison and
check if the suffix is .dll.

However, an .exe can also export symbols which can be linked
against in the same way. In particular, if linking against
WDK (Windows Driver Kit) import libraries, e.g. wdmsec.lib, the
import libraries can provide imports for ntoskrnl.exe.

Instead of specifically checking for *.dll (and *.exe, etc),
invert the condition and skip archive members named *.o and *.obj.
For any remaining archive members, that do contain .idata
sections, apply the renaming. (The renaming is also mostly
harmless if applied where it isn't needed; if archive members
already have unique file names, their relative ordering should
remain intact except for very contrieved cases.)

Signed-off-by: Martin Storsjö <martin@martin.st>
7 months agoRISC-V: Support SiFive extensions: xsfvqmaccdod, xsfvqmaccqoq and xsfvfnrclipxfqf
Nelson Chu [Wed, 20 Nov 2024 08:30:39 +0000 (16:30 +0800)] 
RISC-V: Support SiFive extensions: xsfvqmaccdod, xsfvqmaccqoq and xsfvfnrclipxfqf

Those SiFive extensions have been published on the web for a while, and we plan
to implement intrinsics in GCC for those instructions soon.

NOTE: The original patch was written by Nelson when he was still working at
SiFive, and Kito rebased it to the trunk. Therefore, I kept the author as Nelson
with his SiFive email.

Document links:
xsfvqmaccdod: https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
xsfvqmaccqoq: https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
xsfvfnrclipxfqf: https://www.sifive.com/document-file/fp32-to-int8-ranged-clip-instructions

Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Nov 2024 00:00:17 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoDon't put JIT_READER_DIR into help text
Tom Tromey [Wed, 13 Nov 2024 15:49:53 +0000 (08:49 -0700)] 
Don't put JIT_READER_DIR into help text

The 80-column-help-string self-test can fail if gdb's install
directory is too long, because the help for "jit-reader-load" includes
JIT_READER_DIR.

This help text is actually somewhat misleading, though.
JIT_READER_DIR is not actually used directly -- instead the relocated
variant is used.

This patch adds a new "show jit-reader-directory" command and changes
the help text to refer to this instead.  I considered adding a "set"
command as well, but since absolute paths are acceptable here, and
since this is a very niche command anyway, I figured there was no need
to bother.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32357
Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
7 months agogdb/build-id: protect against weirdly short build-ids
Andrew Burgess [Mon, 18 Nov 2024 16:19:43 +0000 (16:19 +0000)] 
gdb/build-id: protect against weirdly short build-ids

While looking at build_id_to_bfd_suffix (in gdb/build-id.c) I realised
that GDB would likely not do what we wanted if a build-id was ever a
single byte.

Right now, build-ids generated by the GNU linker are 32 bytes, but
there's nothing that forces this to be the case, it's pretty easy to
create a fake, single byte, build-id.  Given that the build-id is an
external input (read from the objfile), GDB should protect itself
against these edge cases.

The problem with build_id_to_bfd_suffix is that this function creates
the path used to lookup either the debug information, or an
executable, based on its build-id.  So a 3-byte build-id 0xaabbcc will
look in the path: `$DEBUG_FILE_DIRECTORY/.build-id/aa/bbcc.debug`.
However, a single byte build-id 0xaa, will look in the file:
`$DEBUG_FILE_DIRECTORY/.build-id/aa/.debug` which doesn't seem right.

Worse, when looking for an objfile given a build-id GDB will look for
a file called `$DEBUG_FILE_DIRECTORY/.build-id/aa/` with a trailing
'/' character.

I propose that, in build_id_to_bfd_suffix we just return early if the
build-id is 1 byte (or less) with a return value that indicates no
separate file was found.

For testing I made use of the DWARF assembler.  I needed to update the
build-id creation proc, the existing code assumes that the build-id is
a multiple of 4 bytes, so I added some additional padding to ensure
that the generated note was a multiple of 4 bytes, even if the
build-id was not.

I added a test with a 1 byte build-id, and also for the case where the
build-id has zero length.  The zero length case already does what
you'd expect (no debug is loaded) as the bfd library rejects the
build-id when loading it from the objfile, but adding this additional
test is pretty cheap.

Approved-By: Kevin Buettner <kevinb@redhat.com>
7 months agotestsuite: skip confirmation in 'gdb_reinitialize_dir'
Rohr, Stephan [Thu, 19 Sep 2024 10:55:19 +0000 (12:55 +0200)] 
testsuite: skip confirmation in 'gdb_reinitialize_dir'

Some shells automatically confirm the 'dir' command:

  (gdb) dir
  Reinitialize source path to empty? (y or n)
    [answered Y; input not from terminal]
  Source directories searched: $cdir;$cwd
  (gdb) y
  dir <...>/gdb/testsuite/gdb.base
  Undefined command: "y".  Try "help".

For example, this reprdocues in a MinGW32 environment with
'TERM=dumb'.  Skip sending 'y' if the command is already confirmed.

Approved-By: Tom Tromey <tom@tromey.com>