120771 Commits

Author SHA1 Message Date
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
GDB Administrator
96f3f01d9d Automatic date update in version.in 2025-03-08 00:00:36 +00:00
GDB Administrator
8bdaecde02 Automatic date update in version.in 2025-03-07 00:00:49 +00:00
GDB Administrator
fa315f8c30 Automatic date update in version.in 2025-03-06 00:01:03 +00:00
GDB Administrator
a5bfad18c4 Automatic date update in version.in 2025-03-05 00:01:28 +00:00
GDB Administrator
de2c17ad1d Automatic date update in version.in 2025-03-04 00:01:35 +00:00
GDB Administrator
fdf8666844 Automatic date update in version.in 2025-03-03 00:01:14 +00:00
GDB Administrator
7aef96f044 Automatic date update in version.in 2025-03-02 00:00:57 +00:00
GDB Administrator
26f7f82058 Automatic date update in version.in 2025-03-01 00:00:41 +00:00
GDB Administrator
56e453742e Automatic date update in version.in 2025-02-28 00:00:28 +00:00
GDB Administrator
0674100e37 Automatic date update in version.in 2025-02-27 00:01:38 +00:00
GDB Administrator
636e85837a Automatic date update in version.in 2025-02-26 00:00:45 +00:00
GDB Administrator
09774db4f0 Automatic date update in version.in 2025-02-25 00:00:45 +00:00
GDB Administrator
7ea5b42758 Automatic date update in version.in 2025-02-24 00:00:42 +00:00
GDB Administrator
db69753580 Automatic date update in version.in 2025-02-23 00:01:45 +00:00
GDB Administrator
15672434ec Automatic date update in version.in 2025-02-22 00:01:08 +00:00
GDB Administrator
de09906181 Automatic date update in version.in 2025-02-21 00:01:32 +00:00
GDB Administrator
397f62b9d9 Automatic date update in version.in 2025-02-20 00:01:26 +00:00
GDB Administrator
e4ec026513 Automatic date update in version.in 2025-02-19 00:00:48 +00:00
GDB Administrator
bd6f05164f Automatic date update in version.in 2025-02-18 00:01:32 +00:00
GDB Administrator
6d52d7b146 Automatic date update in version.in 2025-02-17 00:00:34 +00:00
GDB Administrator
398b42317e Automatic date update in version.in 2025-02-16 00:01:03 +00:00
GDB Administrator
5429f87550 Automatic date update in version.in 2025-02-15 00:00:40 +00:00
GDB Administrator
944e553674 Automatic date update in version.in 2025-02-14 00:00:47 +00:00
GDB Administrator
d6762792f7 Automatic date update in version.in 2025-02-13 00:01:19 +00:00
GDB Administrator
5baddddfbe Automatic date update in version.in 2025-02-12 00:00:36 +00:00
GDB Administrator
9ef9fb511f Automatic date update in version.in 2025-02-11 00:00:46 +00:00
GDB Administrator
6e3384d4cc Automatic date update in version.in 2025-02-10 00:01:05 +00:00
GDB Administrator
5a14f9e79a Automatic date update in version.in 2025-02-09 00:00:39 +00:00
Andrew Burgess
2b646bb876 gdb/tui: use wrefresh if output is not surpressed
Recent work in the TUI has improved GDB's use of the curses
wnoutrefresh and doupdate mechanism, which improves performance by
batching together updates and then doing a single set of writes to the
screen when doupdate is finally called.

The tui_batch_rendering type is a RAII class which, in its destructor,
calls doupdate to send the batched updates to the screen.

However, if there is no tui_batch_rendering active on the call stack
then any wnoutrefresh calls will remain batched but undisplayed until
the next time doupdate happens to be called.

This problem can be seen in PR gdb/32623.  When an inferior is started
the 'Starting program' message is not immediately displayed to the
user.

The 'Starting program' message originates from run_command_1 in
infcmd.c, the message is sent to the current_uiout, which will be the
TUI ui_out.  After the message is sent, ui_out::flush() is called,
here's the backtrace when that happens:

  #0  tui_file::flush (this=0x36e4ab0) at ../../src/gdb/tui/tui-file.c:42
  #1  0x0000000001004f4b in pager_file::flush (this=0x36d35f0) at ../../src/gdb/utils.c:1531
  #2  0x0000000001004f71 in gdb_flush (stream=0x36d35f0) at ../../src/gdb/utils.c:1539
  #3  0x00000000006975ab in cli_ui_out::do_flush (this=0x35a50b0) at ../../src/gdb/cli-out.c:250
  #4  0x00000000009fd1f9 in ui_out::flush (this=0x35a50b0) at ../../src/gdb/ui-out.h:263
  #5  0x00000000009f56ad in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at ../../src/gdb/infcmd.c:449
  #6  0x00000000009f599a in run_command (args=0x0, from_tty=1) at ../../src/gdb/infcmd.c:511

And if we check out tui_file::flush (tui-file.c) we can see that this
just calls tui_win_info::refresh_window(), which in turn, just uses
wnoutrefresh to batch any pending output.

The problem is that, in the above backtrace, there is no
tui_batch_rendering active, and so there will be no doupdate call to
flush the output to the screen.

We could add a tui_batch_rendering into tui_file::flush.  And
tui_file::write.  And tui_file::puts .....

... but that all seems a bit unnecessary.  Instead, I propose that
tui_win_info::refresh_window() should be changed.  If suppress_output
is true (i.e. a tui_batch_rendering is active) then we should continue
to call wnoutrefresh().  But if suppress_output is false, meaning that
no tui_batch_rendering is in place, then we should call wrefresh(),
which immediately writes the output to the screen.

Testing but PR gdb/32623 was a little involved.  We need to 'run' the
inferior and check for the 'Starting program' message.  But DejaGNUU
can only check for the message once it knows the message should have
appeared.  But, as the bug is that output is not displayed, we don't
have any output hints that the inferior is started yet...

In the end, I have the inferior create a file in the test's output
directory.  Now DejaGNU can send the 'run' command, and wait for the
file to appear.  Once that happens, we know that the 'Starting
program' message should have appeared.

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

Approved-By: Tom Tromey <tom@tromey.com>
2025-02-08 19:49:07 +00:00
GDB Administrator
655703fa8d Automatic date update in version.in 2025-02-08 00:00:20 +00:00
Tom de Vries
2fc5610642 [gdb/corefiles] Fix segfault in core_target_open
On x86_64-freebsd, with test-case gdb.arch/i386-biarch-core.exp I run into a
segfault here in corelow.c:core_target_open:
...
    {
      gdb::unique_xmalloc_ptr<char> failing_command = make_unique_xstrdup
        (bfd_core_file_failing_command (current_program_space->core_bfd ()));
      if (failing_command != nullptr)
        gdb_printf (_("Core was generated by `%s'.\n"),
                    failing_command.get ());
    }
...
where bfd_core_file_failing_command returns nullptr, so the segfault happens
somewhere during "strdup (nullptr)".

There doesn't seem to be a need to make a copy of the string, so fix this by
dropping the make_unique_xstrdup.

Tested on x86_64-linux.
Tested the test-case on x86_64-freebsd.

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

PR corefiles/32634
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32634

(cherry picked from commit 9dd3d66b79a2907726f407039234ad8677e9df16)
2025-02-07 17:06:30 +01:00
GDB Administrator
8d4e87af56 Automatic date update in version.in 2025-02-07 00:00:39 +00:00
GDB Administrator
74023881d2 Automatic date update in version.in 2025-02-06 00:01:00 +00:00
GDB Administrator
3dd94eccf6 Automatic date update in version.in 2025-02-05 00:00:34 +00:00
GDB Administrator
e649750353 Automatic date update in version.in 2025-02-04 00:01:22 +00:00