Commit Graph

120718 Commits

Author SHA1 Message Date
Joel Brobecker
50b1dcab86 Set GDB version number to 16.2.
This commit changes gdb/version.in to 16.2.
gdb-16.2-release
2025-02-01 14:14:31 +04:00
GDB Administrator
9f5c7b01ea Automatic date update in version.in 2025-02-01 00:00:31 +00:00
GDB Administrator
06f68b9c9a Automatic date update in version.in 2025-01-31 00:01:41 +00:00
GDB Administrator
a31b440834 Automatic date update in version.in 2025-01-30 00:02:03 +00:00
Simon Marchi
da48c9e23a gdb: include cli/cli-style.h in darwin-nat.c
PR 32610 says:

  File gdb/darwin-nat.c is missing an #include statement of
  "cli/cli-style.h". It is needed because there is a reference to class
  object command_style in the .c file.

I'm not able to build-test this change (I only have access to arm64
macos machines, which GDB doesn't support yet), but I don't think I'm
doing things worse by adding this.

Change-Id: I2a169664ff91b92caf27cb084334f2eb4df46aa5
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32610
2025-01-29 12:04:09 -05:00
Tom de Vries
0ac766802a [gdb/tui] Fix assert in tui_source_window_base::refresh_window
Say we use the executable of test-case gdb.tui/tui-missing-src.exp like this:
...
$ gdb.sh -q -tui outputs/gdb.tui/tui-missing-src/tui-missing-src \
    -ex "b f2"\
    -ex run
...
(from a directory not containing a file called main.c to make sure that the
missing source stays missing) and then issue finish:
...
(gdb) finish
Run till exit from #0  f2 (x=4)
    at f2.c:5
0x0000000000400570 in main ()
    at main.c:7
Value returned is $1 = 13
(gdb)
...
and use control-<minus> to decrease the font size (IOW increase the $LINES and
$COLUMNS) on the terminal, we get:
...
gdb/tui/tui-winsource.c:340: internal-error: refresh_window: \
  Assertion `pad_x + view_width <= pad_width || m_pad.get () == nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

The tui_source_window_base class has variable m_pad which keeps track of a
curses pad that is used to display the source code or disassembly efficiently.

The assert in tui_source_window_base::refresh_window triggers while preparing
to display part of the pad.

The problem is that the window is in a state in which the pad is not used,
because m_content.empty () == true.  Instead, it simply shows
"[ No Source Available ]".

Fix this by bailing out of tui_source_window_base::refresh_window before
accessing the m_pad variable, if m_content.empty () == true.

Tested on x86_64-linux.

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

PR tui/32592
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32592

(cherry picked from commit 1c525b0e03)
2025-01-29 09:02:21 +01:00
GDB Administrator
4144c2f88d Automatic date update in version.in 2025-01-29 00:02:05 +00:00
Andrew Burgess
12630d881e gdb/remote: add 'binary-upload' feature to guard 'x' packet use
This mailing list discussion:

  https://inbox.sourceware.org/gdb-patches/CAOp6jLYD0g-GUsx7jhO3g8H_4pHkB6dkh51cbyDT-5yMfQwu+A@mail.gmail.com

highlighted the following issue with GDB's 'x' packet implementation.

Unfortunately, LLDB also has an 'x' packet, but their implementation
is different to GDB's and so targets that have implemented LLDB's 'x'
packet are incompatible with GDB.

The above thread is specifically about the 'rr' tool, but there could
be other remote targets out there that have this problem.

The difference between LLDB and GDB is that GDB expects a 'b' prefix
on the reply data, while LLDB does not.  The 'b' is important as it
allows GDB to distinguish between an empty reply (which will be a 'b'
prefix with no trailing data) and an unsupported packet (which will be
a completely empty packet).  It is not clear to me how LLDB
distinguishes these two cases.

See for discussion of the 'x' packet:

  https://inbox.sourceware.org/gdb-patches/cover.1710343840.git.tankut.baris.aktemur@intel.com/#r

with the part specific to the 'b' marker in:

  https://inbox.sourceware.org/gdb-patches/87msq82ced.fsf@redhat.com/

I propose that we add a new feature 'binary-upload' which can be
reported by a stub in its qSupported reply.  By default this feature
is "off", meaning GDB will not use the 'x' packet unless a stub
advertises this feature.

I have updated gdbserver to send 'binary-upload+', and when I examine
the gdbserver log I can see this feature being sent back, and then GDB
will use the 'x' packet.

When connecting to an older gdbserver, the feature is not sent, and
GDB does not try to use the 'x' packet at all.

I also built the latest version of `rr` and tested using current HEAD
of master, where I see problems like this:

  (rr) x/10i main
     0x401106 <main>:   Cannot access memory at address 0x401106

Then tested using this patched version of GDB, and now I see:

  (rr) x/10i main
     0x401106 <main>:   push   %rbp
     0x401107 <main+1>: mov    %rsp,%rbp
     0x40110a <main+4>: mov    0x2f17(%rip),%rax        # 0x404028 <global_ptr>
     ... etc ...

and looking in the remote log I see GDB is now using the 'm' packet
instead of the 'x' packet.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32593
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
2025-01-28 12:51:20 +00:00
GDB Administrator
7c5dbff66e Automatic date update in version.in 2025-01-28 00:01:46 +00:00
GDB Administrator
650a77a80d Automatic date update in version.in 2025-01-27 00:01:32 +00:00
GDB Administrator
16281822d2 Automatic date update in version.in 2025-01-26 00:00:32 +00:00
GDB Administrator
5bde526b7f Automatic date update in version.in 2025-01-25 00:01:51 +00:00
GDB Administrator
129bc9e4ac Automatic date update in version.in 2025-01-24 00:00:57 +00:00
GDB Administrator
a9c3f13e66 Automatic date update in version.in 2025-01-23 00:02:15 +00:00
Andrew Burgess
2461ea21c7 bfd/doc: use abs_srcdir when creating symlinks
After commit:

  commit bd32be01c9
  Date:   Fri Dec 3 00:23:20 2021 -0500

      bfd: merge doc subdir up a level

And the follow-up commit:

  commit 98b1464bdf
  Date:   Wed Oct 2 22:58:08 2024 +0300

      bfd: fix unnecessary bfd.info regen

There is still a problem building the bfd docs from a release tar
file.

As the release tar file contains the pre-generated .texi files we
expect the bfd/doc build stage to symlink to the pre-existing .texi
files in the source tree.

However, this is still not working as expected if $(srcdir) is
relative.  The problem is this line in REGEN_TEXI:

    test -e $$texi || test ! -f $(srcdir)/$$texi || $(LN_S) $(srcdir)/$$texi $$texi; \

This is executed from the build/bfd/ directory, so if $(srcdir) is
relative, then this will get you from the bfd/ directory in the build
tree to the corresponding bfd/ directory in the src tree.  However,
the symlink is created in the bfd/doc/ build directory.  The relative
path will then fail to take you to the bfd/ directory in the src
tree.

Fix this by using $(abs_srcdir) when creating the symlink.

Approved-By: Nick Clifton <nickc@redhat.com>
2025-01-22 10:58:22 +00:00
GDB Administrator
4434d7d4cc Automatic date update in version.in 2025-01-22 00:01:56 +00:00
GDB Administrator
17bfbe6394 Automatic date update in version.in 2025-01-21 00:01:32 +00:00
GDB Administrator
4912fb7412 Automatic date update in version.in 2025-01-20 00:00:39 +00:00
GDB Administrator
d4db9fab08 Automatic date update in version.in 2025-01-19 00:01:31 +00:00
Joel Brobecker
0631c99c21 Bump GDB's version number to 16.1.90.DATE-git.
This commit changes gdb/version.in to 16.1.90.DATE-git.

This commit also makes the following changes in gdb/testsuite:

	* gdb.base/default.exp: Change $_gdb_minor to 2.
2025-01-18 13:58:42 +04:00
Joel Brobecker
f2a0e51cda Set GDB version number to 16.1.
This commit changes gdb/version.in to 16.1.
gdb-16.1-release
2025-01-18 13:43:52 +04:00
GDB Administrator
a24a5681c5 Automatic date update in version.in 2025-01-18 00:00:36 +00:00
Andrew Burgess
c7fc539d10 gdb: quote inferior arguments, if needed, when opening a core file
This commit fixes an issue with the commit:

  commit d3d13bf876
  Date:   Thu Apr 25 09:36:43 2024 +0100

      gdb: add gdbarch method to get execution context from core file

The above commit improves GDB's ability to display inferior arguments
when opening a core file, however, if an argument includes white
space, then this is not displayed as well as it should be.  For
example:

  (gdb) core-file /tmp/corefile-exec-context.2.core
  [New LWP 4069711]
  Reading symbols from /tmp/corefile-exec-context...
  Core was generated by `/tmp/corefile-exec-context aaaaa bbbbb ccccc ddddd e e e e e'.
  Program terminated with signal SIGABRT, Aborted.
  #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  50	  return ret;
  (gdb) show args
  Argument list to give program being debugged when it is started is "aaaaa bbbbb ccccc ddddd e\ e\ e\ e\ e".
  (gdb)

Notice the 'Core was generated by ...' line.  In this case it is not
clear if the "e e e e e" is a single argument containing white space,
or 5 single arguments.

But when we 'show args' it is immediately clear that this is a single
argument, as the white space is now escaped.

This problem was caused by the above commit building the argument
string itself, and failing to consider white space escaping.

This commit changes things around, first we place the arguments into
the inferior, then, to print the 'Core was generated by ...' line, we
ask the inferior for the argument string.  In this way the quoting is
handled just as it is for 'show args'.  The initial output is now:

  (gdb) core-file /tmp/corefile-exec-context.2.core
  [New LWP 4069711]
  Reading symbols from /tmp/corefile-exec-context...
  Core was generated by `/tmp/corefile-exec-context aaaaa bbbbb ccccc ddddd e\ e\ e\ e\ e'.
  Program terminated with signal SIGABRT, Aborted.
  #0  0x00007f4f007af625 in raise () from /lib64/libc.so.6
  (gdb)

Much better.  The existing test is extended to cover this case.

Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
2025-01-17 16:36:26 +00:00
Sergio Durigan Junior
d9f3ef784e gdbserver: Fix build on MIPS
Commit 3470a0e144 inadvertently broke
the build on MIPS because it's passing a non-existent "pid" argument
to "proc->for_each_thread".  This commit fixes the problem by removing
the argument from the call.

Signed-off-by: Sergio Durigan Junior <sergiodj@sergiodj.net>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-01-16 21:48:42 -05:00
GDB Administrator
e1474599f2 Automatic date update in version.in 2025-01-17 00:01:45 +00:00
GDB Administrator
1f3c894d72 Automatic date update in version.in 2025-01-16 00:01:55 +00:00
Tom Tromey
52b81397b1 Fix help formatting for string and filename options
I happened to notice that "help add-inferior" said:

  -execFILENAME
    FILENAME is the file name of the executable to use as the
    main program.

This is missing a space after "-exec".  This patch fixes the bug.

If ok'd on time I plan to check this in to the gdb-16 branch as well.

Approved-by: Kevin Buettner <kevinb@redhat.com>

(cherry picked from commit 6511d20c9d)
2025-01-15 08:25:06 -07:00
GDB Administrator
5746383e8c Automatic date update in version.in 2025-01-15 00:01:32 +00:00
Yang Liu
e371d9089a gdb/jit: fix jit-reader linetable integrity
The custom linetable functionality in GDB's JIT Interface has been broken
since commit 1acc9dca42.

In that commit, linetables were made independent from the objfile, which
requires objfile->section_offsets to be initialized. However, section_offsets
were never initialized in objfiles generated by GDB's JIT Interface
with custom jit-readers, leading to GDB crashes when stepping into JITed code
blocks with the following command already executed:

  jit-reader-load libmygdbjitreader.so

This patch fixes the issue by initializing the minimum section_offsets required
for linetable parsing procedures.

A minimal test is included.  The test sets up some very simple line
table information, which is enough to trigger the bug.  However, the
line table information is crafted such that none of the line table
entries will end up being displayed in GDB's output when the test is
run, as such, none of the expected output actually changes.

It might be nice in the future to extend some of the jit tests to
actually test hitting line table entries added via the jit reader.

Approved-By: Tom Tromey <tom@tromey.com>
2025-01-14 18:03:33 +00:00
GDB Administrator
3babd75807 Automatic date update in version.in 2025-01-14 00:01:44 +00:00
Tom Tromey
183e227b00 Handle case where DAP line can be None
A comment in bugzilla pointed out a bug in my earlier patch to handle
the DAP "linesStartAt1" setting.  In particular, in the backtrace
code, "line" can be None, which would lead to an exception from
export_line.

This patch fixes the problem.

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

(cherry picked from commit 28e5851344)
2025-01-13 07:42:27 -07:00
GDB Administrator
0866754873 Automatic date update in version.in 2025-01-13 00:01:29 +00:00
GDB Administrator
36d2bf9ba1 Automatic date update in version.in 2025-01-12 00:01:34 +00:00
GDB Administrator
97b4f10487 Automatic date update in version.in 2025-01-11 00:00:42 +00:00
GDB Administrator
230ab6b333 Automatic date update in version.in 2025-01-10 00:00:37 +00:00
GDB Administrator
6cd2d77114 Automatic date update in version.in 2025-01-09 00:01:45 +00:00
GDB Administrator
03a4ae4018 Automatic date update in version.in 2025-01-08 00:00:27 +00:00
Tom Tromey
c310e35131 Fix crash in DWARF indexer
Iain pointed out a crash in the DWARF indexer when run on a certain D
program.  The DWARF in this case has a nameless enum class; this
causes an assertion failure.

This patch arranges to simply ignore such types.  The fact that an
enum class is nameless in this case appears to be a compiler bug.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32518
Approved-By: Tom de Vries <tdevries@suse.de>

(cherry picked from commit 66903f1d66)
2025-01-07 07:47:35 -07:00
GDB Administrator
6b0351f121 Automatic date update in version.in 2025-01-07 00:00:56 +00:00
Rainer Orth
4f38faacd9 Fix procfs.c compilation
procfs.c compilation is currently broken on Solaris:

/vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/procfs.c: In member function ‘virtual ptid_t procfs_target::wait(ptid_t, target_waitstatus*, target_wait_flags)’:
/vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/procfs.c:2067:34: error: ‘wait’ is not a member of ‘gdb’; did you mean ‘wait’?
 2067 |               wait_retval = gdb::wait (&wstat);
      |                                  ^~~~
In file included from ../gnulib/import/sys/wait.h:28,
                 from /usr/include/stdlib.h:16,
                 from /usr/gcc/14/include/c++/14.2.0/cstdlib:79,
                 from /vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/../gdbsupport/common-defs.h:99,
                 from /vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/defs.h:26,
                 from <command-line>:
/usr/include/sys/wait.h:85:14: note: ‘wait’ declared here
   85 | extern pid_t wait(int *);
      |              ^~~~
/vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/procfs.c:2154:41: error: ‘wait’ is not a member of ‘gdb’; did you mean ‘wait’?
 2154 |                         int temp = gdb::wait (&wstat);
      |                                         ^~~~
/usr/include/sys/wait.h:85:14: note: ‘wait’ declared here
   85 | extern pid_t wait(int *);
      |              ^~~~
/vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/procfs.c: In function ‘void unconditionally_kill_inferior(procinfo*)’:
/vol/src/gnu/gdb/hg/gdb-16-branch/git/gdb/procfs.c:2566:12: error: ‘wait’ is not a member of ‘gdb’; did you mean ‘wait’?
 2566 |       gdb::wait (NULL);
      |            ^~~~
/usr/include/sys/wait.h:85:14: note: ‘wait’ declared here
   85 | extern pid_t wait(int *);
      |              ^~~~

The use of gdb::wait was introduced in

commit 4e4dfc4728
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Nov 22 17:44:29 2024 +0100

    [gdb] Add gdb::wait

but obviously never tested.

Fixed by including gdbsupport/eintr.h to provide the declaration.

Tested on amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11.

(cherry picked from commit d7bd319e93)
2025-01-06 16:25:40 +01:00
Tom Tromey
093a1b6b81 Handle linesStartAt1 in DAP
The DAP initialize request has a "linesStartAt1" option, where the
client can indicate that it prefers whether line numbers be 0-based or
1-based.

This patch implements this.  I audited all the line-related code in
the DAP implementation.

Note that while a similar option exists for column numbers, gdb
doesn't handle these yet, so nothing is done here.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32468
(cherry picked from commit 8ac42dbf50)
2025-01-06 07:35:21 -07:00
Tom de Vries
2efabd1d9b [gdb/build] Use const_cast in fd_copy
Recent commit 6ab5d62ebc ("[gdb] Fix compilation error in event-top.c") did:
...
 fd_copy (fd_set *dst, const fd_set *src, int n)
 {
   FD_ZERO (dst);
   for (int i = 0; i < n; ++i)
-    if (FD_ISSET (i, src))
+    if (FD_ISSET (i, (fd_set *)src))
...
but according to [1] only const_cast may be used to cast away constness.

Fix this by using const_cast.

Tested by rebuilding on x86_64-linux.

[1] https://en.cppreference.com/w/cpp/language/const_cast

(cherry picked from commit a189db13c4)
2025-01-06 10:04:22 +01:00
GDB Administrator
dcde183ad1 Automatic date update in version.in 2025-01-06 00:02:01 +00:00
GDB Administrator
aebbe069df Automatic date update in version.in 2025-01-05 00:00:40 +00:00
Eli Zaretskii
947a9c38e7 [gdb/readline] Fix link error on MinGW due to missing 'alarm'
The previous solution used symbols that exist only in MinGW64.
  Add a stub implementation of 'alarm' for mingw.org's MinGW.

(cherry picked from commit d46fdacc09)
2025-01-04 12:23:52 +02:00
Eli Zaretskii
9bc042a41b [gdb/selftest] Fix 'help_doc_invariants' self-test
Running selftest help_doc_invariants.
  help doc broken invariant: command 'signal-event' help doc has over-long line
  Self test failed: self-test failed at unittests/command-def-selftests.c:121

  The reason is that doc string of 'signal-event' doesn't have
  newlines at end of its line.  Fix by adding newlines.

(cherry picked from commit c1023d9567)
2025-01-04 12:16:56 +02:00
Eli Zaretskii
bbd194adc6 [gdb] Fix compilation error in event-top.c
CXX    event-top.o
     In file included from d:\usr\include\winsock2.h:69,
		      from ./../gdbsupport/gdb_select.h:30,
		      from event-top.c:43:
     event-top.c: In function 'fd_set* fd_copy(fd_set*, const fd_set*, int)':
     event-top.c:1279:22: error: invalid conversion from 'const fd_set*' to 'fd_set*' [-fpermissive]
      1279 |     if (FD_ISSET (i, src))
	   |                      ^
	   |                      |
	   |                      const fd_set*
     d:\usr\include\winsock.h:164:50: note:   initializing argument 2 of 'int __FD_ISSET(SOCKET, fd_set*)'
       164 | __CRT_ALIAS int __FD_ISSET( SOCKET __fd, fd_set *__set )
	   |                                          ~~~~~~~~^~~~~

  Use an explicit type cast to prevent this.

      * gdb/event-top.c (fd_copy): Type-cast in call to FD_ISSET.

(cherry picked from commit 6ab5d62ebc)
2025-01-04 12:16:29 +02:00
GDB Administrator
67a0e92293 Automatic date update in version.in 2025-01-04 00:01:06 +00:00
GDB Administrator
85c6b4e827 Automatic date update in version.in 2025-01-03 00:01:53 +00:00
Alan Modra
97078538d6 PR 32507, PRIx64 in error messages on 32-bit mingw
People, including me, had forgotten that the bfd_error_handler just
handled standard printf format strings, not MSC %I64 and suchlike.
Using PRIx64 and similar in errors does not work if the host compiler
headers define those formats as the Microsoft %I64 variety.  (We
handled %ll OK, editing it to %I64 on such hosts.)

	PR 32507
	* bfd.c (_bfd_doprnt, _bfd_doprnt_scan): Handle %I64 and %I32
	in input strings if the host defines PRId64 as "I64d".
	Edit %ll to %I64 on detecting PRId64 as "I64d" rather than on
	a preprocessor define.

(cherry picked from commit b38cf91f23)
2025-01-02 19:32:16 +02:00