120806 Commits

Author SHA1 Message Date
GDB Administrator
a74df132e3 Automatic date update in version.in 2025-04-18 00:01:40 +00:00
GDB Administrator
6c82a55780 Automatic date update in version.in 2025-04-17 00:00:43 +00:00
GDB Administrator
055279c914 Automatic date update in version.in 2025-04-16 00:01:15 +00:00
GDB Administrator
f92a904726 Automatic date update in version.in 2025-04-15 00:01:28 +00:00
GDB Administrator
3c2c00c32a Automatic date update in version.in 2025-04-14 00:00:41 +00:00
GDB Administrator
5eed5758ae Automatic date update in version.in 2025-04-13 00:00:38 +00:00
GDB Administrator
ebf7dd0ed8 Automatic date update in version.in 2025-04-12 00:00:43 +00:00
GDB Administrator
1936dc6a64 Automatic date update in version.in 2025-04-11 00:01:08 +00:00
GDB Administrator
6ce88ba61e Automatic date update in version.in 2025-04-10 00:01:13 +00:00
GDB Administrator
1549d0525b Automatic date update in version.in 2025-04-09 00:00:42 +00:00
GDB Administrator
565ad7474c Automatic date update in version.in 2025-04-08 00:01:17 +00:00
Keith Seitz
a7abbebc6d gstack: [downstream regression] Output file names and line numbers
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
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32828
2025-04-07 08:40:56 -07:00
Luis Machado
4ffff8e30b Fix build failure for gdbserver's raw_compare self test
Commit 5c89e5539aef2992a2417be55307c9071ffbe89c addressed a SVE/SME gdbserver
crash on gdbserver and added a gdbserver-side self test for a register cache
raw_compare function.

For the GDB 16 branch though, gdbserver's regcache doesn't yet have a
constructor taking a target description, so we need to explicitly initialize
the register cache before the self test can take place.

Also, the self tests are only built if we explicitly pass --enable-unit-tests
to configure. This build error should not manifest on a default build that
doesn't enable self tests.

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

Reviewed-By: Keith Seitz <keiths@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2025-04-07 15:18:43 +01:00
GDB Administrator
0a363b10a1 Automatic date update in version.in 2025-04-07 00:00:52 +00:00
GDB Administrator
3348e9233b Automatic date update in version.in 2025-04-06 00:00:42 +00:00
GDB Administrator
b61f17e695 Automatic date update in version.in 2025-04-05 00:00:52 +00:00
GDB Administrator
d195670d47 Automatic date update in version.in 2025-04-04 00:00:48 +00:00
GDB Administrator
da5c8de5b0 Automatic date update in version.in 2025-04-03 00:00:34 +00:00
Luis Machado
5c89e5539a 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>
2025-04-02 17:07:14 +01:00
Andrew Burgess
a2c8f78df5 gdb: allow selecting default fg/bg colors in tui mode
This commit fixes PR gdb/32797, and pulls in just part of commit:

  commit 6447969d0ac774b6dec0f95a0d3d27c27d158690
  Date:   Sat Oct 5 22:27:44 2024 +0300

    Add an option with a color type.

to the gdb-16-branch.

This commit allows the escape sequences \x1b[39m and \x1b[49m, which
select the default foreground and background colours respectively, to
work correctly.

This fix is just a small part of the above commit.  Only these two
changes are required to fix this bug.  As we are currently preparing
for a 16.3 release, I don't think we should be pulling in the whole of
the above commit.

You can test this commit using:

  export TERM=xterm-256color
  gdb -q -tui -ex 'py print("normal\n\x1b[39mforeground default\n\x1b[0mnormal\n\x1b[49mbackground default\n\x1b[0mnormal\n")'

All of the output text should use the default foreground and
background colors.

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

Approved-By: Tom Tromey <tom@tromey.com>
2025-04-02 16:11:24 +01:00
GDB Administrator
bc997150d8 Automatic date update in version.in 2025-04-02 00:00:39 +00:00
GDB Administrator
27d7403d46 Automatic date update in version.in 2025-04-01 00:01:06 +00:00
GDB Administrator
f3ecdb73cd Automatic date update in version.in 2025-03-31 00:00:46 +00:00
GDB Administrator
9c3d1bb4c8 Automatic date update in version.in 2025-03-30 00:00:26 +00:00
GDB Administrator
24c91baf98 Automatic date update in version.in 2025-03-29 00:01:30 +00:00
Craig Blackmore
c295d55246 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>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32757
2025-03-28 09:57:18 +00:00
GDB Administrator
66150ea536 Automatic date update in version.in 2025-03-28 00:00:37 +00:00
GDB Administrator
0c09aa22ee Automatic date update in version.in 2025-03-27 00:00:33 +00:00
GDB Administrator
b9a7fda110 Automatic date update in version.in 2025-03-26 00:00:51 +00:00
GDB Administrator
21c21807a3 Automatic date update in version.in 2025-03-25 00:00:36 +00:00
GDB Administrator
67e9e439f7 Automatic date update in version.in 2025-03-24 00:01:22 +00:00
GDB Administrator
dcf6d684ce Automatic date update in version.in 2025-03-23 00:01:09 +00:00
GDB Administrator
639b6f1055 Automatic date update in version.in 2025-03-22 00:01:34 +00:00
GDB Administrator
a1bcf87a5f Automatic date update in version.in 2025-03-21 00:01:18 +00:00
GDB Administrator
883f7d18d1 Automatic date update in version.in 2025-03-20 00:00:59 +00:00
GDB Administrator
b4b7d9f112 Automatic date update in version.in 2025-03-19 00:01:50 +00:00
GDB Administrator
f45379953a Automatic date update in version.in 2025-03-18 00:01:12 +00:00
GDB Administrator
d6e18cff1d Automatic date update in version.in 2025-03-17 00:01:53 +00:00
GDB Administrator
3ee680f9eb Automatic date update in version.in 2025-03-16 00:01:13 +00:00
Tom de Vries
5bc76dc8d4 [gdb/tdep] Rewrite i386_canonicalize_syscall
On openSUSE Tumbleweed x86_64, with target board unix/-m32 and test-case
gdb.reverse/recvmsg-reverse.exp, I run into:
...
(gdb) continue^M
Continuing.^M
Process record and replay target doesn't support syscall number 360^M
Process record: failed to record execution log.^M
^M
Program stopped.^M
0xf7fc5575 in __kernel_vsyscall ()^M
(gdb) FAIL: $exp: continue to breakpoint: marker2
...

The syscall number 360 in i386 is for syscall socketpair, as we can see in
arch/x86/entry/syscalls/syscall_32.tbl:
...
<number>  <abi>  <name>      <entry point>
360       i386   socketpair  sys_socketpair
...

Function i386_canonicalize_syscall assumes that any syscall below 500 maps to
an identically valued enum in enum gdb_syscall:
...
static enum gdb_syscall
i386_canonicalize_syscall (int syscall)
{
  enum { i386_syscall_max = 499 };

  if (syscall <= i386_syscall_max)
    return (enum gdb_syscall) syscall;
  else
    return gdb_sys_no_syscall;
}
...

However, that's not the case.  The value of gdb_sys_socketpair is not 360,
but 512:
...
enum gdb_syscall {
  ...
  gdb_sys_getrandom = 355,
  gdb_sys_statx = 383,
  ...
  gdb_sys_socketpair = 512,
...

Consequently, when record_linux_system_call is called with
syscall == i386_canonicalize_syscall (360), we hit the default case here:
....
  switch (syscall)
    {
    ...
    default:
      gdb_printf (gdb_stderr,
                  _("Process record and replay target doesn't "
                    "support syscall number %d\n"), syscall);
      return -1;
      break;
    }
...
rather than hitting the case for gdb_sys_socketpair.

I initially wrote a trivial fix for this, changing the value of
gdb_sys_socketpair to 360.  However, Andreas Schwab pointed out that there are
other functions (ppc_canonicalize_syscall and s390_canonicalize_syscall) that
make assumptions about specific values of enum gdb_syscall, and fixing this
for i386 may break things for ppc or s390.

So instead, I decided to rewrite i386_canonicalize_syscall to match the
approach taken in aarch64_canonicalize_syscall, which allows
gdb_sys_socketpair to keep the same value.

So, fix this by:
- adding a new table file gdb/i386-syscalls.def, using a SYSCALL entry for
  each syscall, generated from arch/x86/entry/syscalls/syscall_32.tbl,
- using gdb/i386-syscalls.def to define enum i386_syscall, and
- using macros SYSCALL_MAP, SYSCALL_MAP_RENAME and UNSUPPORTED_SYSCALL_MAP to
  define the mapping from enum i386_syscall to enum gdb_syscall in
  i386_canonicalize_syscall.

I've created the mapping as follows:
- I used arch/x86/entry/syscalls/syscall_32.tbl to generate an initial mapping
  using SYSCALL_MAP for each syscall,
- I attempted to compile this and used the compilation errors about
  non-existing gdb_sys_ values to change those entries to
  UNSUPPORTED_SYSCALL_MAP, which got me a compiling version,
- I reviewed the UNSUPPORTED_SYSCALL_MAP entries, changing to
  SYSCALL_MAP_RENAME where necessary,
- I then reviewed syscalls below 500 that mapped to a gdb_syscall value below
  500, but not the same, and fixed those using SYSCALL_MAP_RENAME, and
- reviewed the mapping for gdb_syscall entries >= 500.

On the resulting mapping, I was able to do the following sanity check:
...
  for (int i = 0; i < 500; ++i)
    {
      int res = i386_canonicalize_syscall (i);
      if (res == i)
	continue;
      if (res == -1)
	continue;
      if (res >= 500)
	continue;
      gdb_assert_not_reached ("");
    }
}
...
to make sure that any syscall below 500 either:
- maps to the same number,
- is unsupported, or
- maps to a number >= 500.

Coming back to our original problem, the socket pair syscall is addressed by
an entry:
...
      SYSCALL_MAP (socketpair);
...
which maps i386_sys_socketpair (360) to gdb_sys_socketpair (512).

Tested on x86_64-linux with target board unix/-m32.

Approved-By: Guinevere Larsen <guinevere@redhat.com>

PR tdep/32770
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32770

(cherry picked from commit fbfb29b304ef7d3270a918b5fc60c22b0909367e)
2025-03-15 13:17:36 +01:00
GDB Administrator
0230950c6e Automatic date update in version.in 2025-03-15 00:01:04 +00:00
GDB Administrator
7a6ff0051f Automatic date update in version.in 2025-03-14 00:01:23 +00:00
Tom de Vries
55b7a56b1f [gdb/record] Fix out-of-bounds write in aarch64_record_asimd_load_store
After compiling gdb with -fstack-protector-all, and running test-case
gdb.reverse/getrandom.exp on aarch64-linux, we run into
"Stack smashing detected" in function aarch64_record_asimd_load_store.

This is reported in PR record/32784.

This happens due to an out-of-bounds write to local array record_buf_mem:
...
  uint64_t record_buf_mem[24];
...
when recording insn:
...
B+>0xfffff7ff4d10  st1     {v0.16b-v3.16b}, [x0]
...

We can fix this by increasing the array size to 128, but rather than again
hardcoding a size, reimplement record_buf_mem as std::vector.

Tested on aarch64-linux.

Approved-By: Guinevere Larsen <guinevere@redhat.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32784
(cherry picked from commit 51729ea0905d1f688b7fd2ea769e69b29daa1b7c)
2025-03-13 11:15:05 +01:00
GDB Administrator
465465ce9c Automatic date update in version.in 2025-03-13 00:00:41 +00:00
GDB Administrator
b4d832ef2b Automatic date update in version.in 2025-03-12 00:01:24 +00:00
GDB Administrator
5f2f9d4dcc Automatic date update in version.in 2025-03-11 00:01:15 +00:00
Simon Marchi
4996027dbf gdb/dwarf: save DWARF version in dwarf2_loclist_baton, remove it from dwarf2_per_cu
When running:

    $ make check TESTS="gdb.cp/cpexprs-debug-types.exp" RUNTESTFLAGS="--target_board=fission"

I get:

    (gdb) break -qualified main
    /home/smarchi/src/binutils-gdb/gdb/dwarf2/read.h:295: internal-error: version: Assertion `m_dwarf_version != 0' failed.

The problem is that dwarf2_per_cu objects created in the
read_cutu_die_from_dwo code path never have their DWARF version set.  A
seemingly obvious solution would be to add a call to
dwarf2_per_cu::set_version in there (there's a patch in the referenced
PR that does that).  However, this comment in
read_comp_units_from_section is a bit scary:

      /* Init this asap, to avoid a data race in the set_version in
	 cutu_reader::cutu_reader (which may be run in parallel for the cooked
	 index case).  */
      this_cu->set_version (cu_header.version);

I don't know if a DWO file can be read while the cooked indexer runs, so
if it would be a problem here, but I prefer to be safe than sorry.  This
patch side-steps the problem by deleting the DWARF version from
dwarf2_per_cu.

The only users of dwarf2_per_cu::version are the loclists callbacks in
`loc.c`.  Add the DWARF version to dwarf2_loclist_baton and modify those
callbacks to get the version from there instead.  Initialize that new
field in fill_in_loclist_baton.

I like this approach because there is no version field that is possibly
unset now.

I wasn't keen on doing this at first because I thought it would waste
space, but the dwarf2_loclist_baton has 7 bytes of padding at the end
anyway, so we might as well use that.

Cc: Ricky Zhou <ricky@rzhou.org>
Cc: Tom de Vries <tdevries@suse.de>
Cc: Tom Tromey <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32309
Change-Id: I30d4ede7d67da5d80ff65c6122f5868e1098ec52
Approved-By: Tom Tromey <tom@tromey.com>
(cherry picked from commit f62cf22157cf527f1cc5c91854b1be3373024d4a)
2025-03-10 16:24:47 -04:00
GDB Administrator
fbc36742f7 Automatic date update in version.in 2025-03-10 00:00:42 +00:00
Brandon Belew
ebb9d77f35 Fix segfault if target_fileio_read_alloc fails
Check for target_fileio_read_alloc failure in linux_fill_prpsinfo
before dereferencing buffer. This fixes a segfault in the 'gcore'
command when attached to certain remote targets.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32441
Approved-By: Andrew Burgess <aburgess@redhat.com>
(cherry picked from commit cbc6950a6603e184ebc6671f2c252a56013b07c2)
2025-03-09 08:17:55 +04:00
GDB Administrator
94f97a3cdd Automatic date update in version.in 2025-03-09 00:01:12 +00:00