]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 14 Feb 2025 00:00:47 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Thu, 13 Feb 2025 00:01:19 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Wed, 12 Feb 2025 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Tue, 11 Feb 2025 00:00:46 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Mon, 10 Feb 2025 00:01:05 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Sun, 9 Feb 2025 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agogdb/tui: use wrefresh if output is not surpressed
Andrew Burgess [Wed, 5 Feb 2025 20:12:03 +0000 (20:12 +0000)] 
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>
5 months agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Feb 2025 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months ago[gdb/corefiles] Fix segfault in core_target_open
Tom de Vries [Fri, 7 Feb 2025 16:06:30 +0000 (17:06 +0100)] 
[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)

5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Feb 2025 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Feb 2025 00:01:00 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Feb 2025 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Feb 2025 00:01:22 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Feb 2025 00:01:20 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Sun, 2 Feb 2025 00:01:13 +0000 (00:01 +0000)] 
Automatic date update in version.in

5 months agoBump GDB's version number to 16.2.90.DATE-git.
Joel Brobecker [Sat, 1 Feb 2025 10:28:15 +0000 (14:28 +0400)] 
Bump GDB's version number to 16.2.90.DATE-git.

This commit changes gdb/version.in to 16.2.90.DATE-git.

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

* gdb.base/default.exp: Change $_gdb_minor to 3.

5 months agoSet GDB version number to 16.2. gdb-16.2-release
Joel Brobecker [Sat, 1 Feb 2025 10:14:31 +0000 (14:14 +0400)] 
Set GDB version number to 16.2.

This commit changes gdb/version.in to 16.2.

5 months agoAutomatic date update in version.in
GDB Administrator [Sat, 1 Feb 2025 00:00:31 +0000 (00:00 +0000)] 
Automatic date update in version.in

5 months agoAutomatic date update in version.in
GDB Administrator [Fri, 31 Jan 2025 00:01:41 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Thu, 30 Jan 2025 00:02:03 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 months agogdb: include cli/cli-style.h in darwin-nat.c
Simon Marchi [Wed, 29 Jan 2025 15:45:31 +0000 (10:45 -0500)] 
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

6 months ago[gdb/tui] Fix assert in tui_source_window_base::refresh_window
Tom de Vries [Wed, 29 Jan 2025 08:02:21 +0000 (09:02 +0100)] 
[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 1c525b0e037b895f6d21deaf32dd922dfdd9c822)

6 months agoAutomatic date update in version.in
GDB Administrator [Wed, 29 Jan 2025 00:02:05 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 months agogdb/remote: add 'binary-upload' feature to guard 'x' packet use
Andrew Burgess [Fri, 24 Jan 2025 16:12:55 +0000 (16:12 +0000)] 
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>
6 months agoAutomatic date update in version.in
GDB Administrator [Tue, 28 Jan 2025 00:01:46 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Mon, 27 Jan 2025 00:01:32 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Sun, 26 Jan 2025 00:00:32 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Sat, 25 Jan 2025 00:01:51 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Jan 2025 00:00:57 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Jan 2025 00:02:15 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 months agobfd/doc: use abs_srcdir when creating symlinks
Andrew Burgess [Tue, 21 Jan 2025 13:06:18 +0000 (13:06 +0000)] 
bfd/doc: use abs_srcdir when creating symlinks

After commit:

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

      bfd: merge doc subdir up a level

And the follow-up commit:

  commit 98b1464bdf6306a8ab4614b5e9f76cdb2dd00b33
  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>
6 months agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Jan 2025 00:01:56 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Jan 2025 00:01:32 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Jan 2025 00:00:39 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Jan 2025 00:01:31 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoBump GDB's version number to 16.1.90.DATE-git.
Joel Brobecker [Sat, 18 Jan 2025 09:58:42 +0000 (13:58 +0400)] 
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.

6 months agoSet GDB version number to 16.1. gdb-16.1-release
Joel Brobecker [Sat, 18 Jan 2025 09:43:52 +0000 (13:43 +0400)] 
Set GDB version number to 16.1.

This commit changes gdb/version.in to 16.1.

6 months agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Jan 2025 00:00:36 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agogdb: quote inferior arguments, if needed, when opening a core file
Andrew Burgess [Wed, 15 Jan 2025 11:12:46 +0000 (11:12 +0000)] 
gdb: quote inferior arguments, if needed,  when opening a core file

This commit fixes an issue with the commit:

  commit d3d13bf876aae425ae0eff2ab0f1af9f7da0264a
  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>
6 months agogdbserver: Fix build on MIPS
Sergio Durigan Junior [Thu, 16 Jan 2025 01:08:48 +0000 (20:08 -0500)] 
gdbserver: Fix build on MIPS

Commit 3470a0e144df6c01f8479fa649f43aa907936e7e 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>
6 months agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Jan 2025 00:01:45 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Thu, 16 Jan 2025 00:01:55 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoFix help formatting for string and filename options
Tom Tromey [Mon, 13 Jan 2025 14:26:10 +0000 (07:26 -0700)] 
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 6511d20c9d47093acb3b099ff19854e01bbe9af4)

6 months agoAutomatic date update in version.in
GDB Administrator [Wed, 15 Jan 2025 00:01:32 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agogdb/jit: fix jit-reader linetable integrity
Yang Liu [Sun, 22 Dec 2024 16:33:30 +0000 (00:33 +0800)] 
gdb/jit: fix jit-reader linetable integrity

The custom linetable functionality in GDB's JIT Interface has been broken
since commit 1acc9dca423f78e44553928f0de839b618c13766.

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>
6 months agoAutomatic date update in version.in
GDB Administrator [Tue, 14 Jan 2025 00:01:44 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoHandle case where DAP line can be None
Tom Tromey [Mon, 6 Jan 2025 14:45:33 +0000 (07:45 -0700)] 
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 28e585134434ee2c65df5001e4494c1b4adcd204)

6 months agoAutomatic date update in version.in
GDB Administrator [Mon, 13 Jan 2025 00:01:29 +0000 (00:01 +0000)] 
Automatic date update in version.in

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

6 months agoAutomatic date update in version.in
GDB Administrator [Sat, 11 Jan 2025 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Fri, 10 Jan 2025 00:00:37 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Thu, 9 Jan 2025 00:01:45 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Wed, 8 Jan 2025 00:00:27 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoFix crash in DWARF indexer
Tom Tromey [Mon, 6 Jan 2025 20:34:47 +0000 (13:34 -0700)] 
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 66903f1d66a2648e82250a427a791286e4ed4735)

6 months agoAutomatic date update in version.in
GDB Administrator [Tue, 7 Jan 2025 00:00:56 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months agoFix procfs.c compilation
Rainer Orth [Mon, 6 Jan 2025 15:24:14 +0000 (16:24 +0100)] 
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 4e4dfc4728622d83c5d600949024449e21de868a
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 d7bd319e93a3ab73d7e88ef44550f0be98c6c4b7)

6 months agoHandle linesStartAt1 in DAP
Tom Tromey [Mon, 16 Dec 2024 17:44:55 +0000 (10:44 -0700)] 
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 8ac42dbf5001416e6b741c5361be14186afde5b0)

6 months ago[gdb/build] Use const_cast in fd_copy
Tom de Vries [Mon, 6 Jan 2025 09:04:22 +0000 (10:04 +0100)] 
[gdb/build] Use const_cast in fd_copy

Recent commit 6ab5d62ebc5 ("[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 a189db13c4889548be4439314a956f2ab910166b)

6 months agoAutomatic date update in version.in
GDB Administrator [Mon, 6 Jan 2025 00:02:01 +0000 (00:02 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Sun, 5 Jan 2025 00:00:40 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 months ago[gdb/readline] Fix link error on MinGW due to missing 'alarm'
Eli Zaretskii [Sat, 4 Jan 2025 10:19:55 +0000 (12:19 +0200)] 
[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 d46fdacc0921666ce5e815529151aae07c6f8dd2)

6 months ago[gdb/selftest] Fix 'help_doc_invariants' self-test
Eli Zaretskii [Sat, 4 Jan 2025 10:13:04 +0000 (12:13 +0200)] 
[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 c1023d95672cfd293fd84556baf899713955ee50)

6 months ago[gdb] Fix compilation error in event-top.c
Eli Zaretskii [Sat, 4 Jan 2025 10:09:12 +0000 (12:09 +0200)] 
[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 6ab5d62ebc5df29d3fe1fd81b311c3d3fc12f565)

6 months agoAutomatic date update in version.in
GDB Administrator [Sat, 4 Jan 2025 00:01:06 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Fri, 3 Jan 2025 00:01:53 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoPR 32507, PRIx64 in error messages on 32-bit mingw
Alan Modra [Wed, 1 Jan 2025 12:01:50 +0000 (22:31 +1030)] 
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 b38cf91f230bc3892ab9c3deb4f1b6639c657c47)

6 months agoAutomatic date update in version.in
GDB Administrator [Thu, 2 Jan 2025 00:01:22 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Wed, 1 Jan 2025 00:01:14 +0000 (00:01 +0000)] 
Automatic date update in version.in

6 months agoAutomatic date update in version.in
GDB Administrator [Tue, 31 Dec 2024 00:00:50 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Mon, 30 Dec 2024 00:01:44 +0000 (00:01 +0000)] 
Automatic date update in version.in

7 months agoBump GDB's version number to 16.0.90.DATE-git.
Joel Brobecker [Sun, 29 Dec 2024 03:28:10 +0000 (07:28 +0400)] 
Bump GDB's version number to 16.0.90.DATE-git.

This commit changes gdb/version.in to 16.0.90.DATE-git.

7 months agoSet GDB version number to 16.0.90.
Joel Brobecker [Sun, 29 Dec 2024 03:16:03 +0000 (07:16 +0400)] 
Set GDB version number to 16.0.90.

This commit changes gdb/version.in to 16.0.90.

7 months agogdb/NEWS: modify "Changes since GDB 15" to "Changes in GDB 16"
Joel Brobecker [Sun, 29 Dec 2024 03:08:39 +0000 (07:08 +0400)] 
gdb/NEWS: modify "Changes since GDB 15" to "Changes in GDB 16"

7 months agoSet development mode to "off" by default.
Joel Brobecker [Sun, 29 Dec 2024 02:51:39 +0000 (06:51 +0400)] 
Set development mode to "off" by default.

This is done by setting the "development" variable to "false"
in bfd/development.sh.

7 months agoBump version to 16.0.90.DATE-git.
Joel Brobecker [Sun, 29 Dec 2024 02:51:21 +0000 (06:51 +0400)] 
Bump version to 16.0.90.DATE-git.

Now that the GDB 16 branch has been created,
this commit bumps the version number in gdb/version.in to
16.0.90.DATE-git

For the record, the GDB 16 branch was created
from commit ee29a3c4ac7adc928ae6ed1fed3b59c940a519a4.

7 months agoAutomatic date update in version.in gdb-16-branchpoint
GDB Administrator [Sun, 29 Dec 2024 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Sat, 28 Dec 2024 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agobfd/ELF: refine segment index in filepos assignment diag
Jan Beulich [Fri, 27 Dec 2024 10:37:42 +0000 (11:37 +0100)] 
bfd/ELF: refine segment index in filepos assignment diag

Reporting an internal loop index isn't helpful for the user to determine
which segment the problem is with. Report the PHDR index instead.

7 months agold/testsuite: replace aarch64 uses of load_lib
Jan Beulich [Fri, 27 Dec 2024 10:37:05 +0000 (11:37 +0100)] 
ld/testsuite: replace aarch64 uses of load_lib

Using $srcdir/$subdir directly doesn't work, at least not with expect
5.45, dejagnu 1.6, and an out-of-tree build (I assume it's the latter
aspect which is crucial here). Make use of load_file instead.

7 months agoLoongArch: Reword message for unresolvable relocs
Xi Ruoyao [Wed, 25 Dec 2024 04:41:45 +0000 (12:41 +0800)] 
LoongArch: Reword message for unresolvable relocs

For PDE, "recompiling with -fPIE" just makes no sense.

For PIE, "recompiling with -fPIE" makes sense for unresolvable absolute
relocs, but not unresolveable PC-relative relocs: if the reloc is
already PC-relative, the problem is not the reloc is PC-relative or
absolute, but the reloc is not applicable for external symbols.

If we hit an unresolvable reloc in PDE or an unresolvable PC-relative
reloc in PIE, it means the programmer has somehow wrongly instructed the
compiler to treat external symbols as local symbols.  A misuse of
-mdirect-extern-access can cause the issue, so we can suggest
-mno-direct-extern-access.  And in all cases (DSO/PIE/PDE) a mismatching
symbol visibility can also cause the issue, so we should also suggest to
check the visibility.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
7 months agoLoongArch: Allow R_LARCH_PCALA_HI20 or R_LARCH_PCREL20_S2 against undefined weak...
Xi Ruoyao [Wed, 25 Dec 2024 04:41:44 +0000 (12:41 +0800)] 
LoongArch: Allow R_LARCH_PCALA_HI20 or R_LARCH_PCREL20_S2 against undefined weak symbols for static PIE

In a static PIE, undefined weak symbols should be just resolved to
runtime address 0, like those symbols with non-default visibility.  This
was silently broken in all prior Binutils releases with "-static-pie
-mdirect-extern-access":

    $ cat t.c
    int x (void) __attribute__ ((weak));

    int
    main (void)
    {
      __builtin_printf("%p\n", x);
    }
    $ gcc t.c -static-pie -mdirect-extern-access
    $ ./a.out
    0x7ffff1d64000

Since commit 4cb77761d687 ("LoongArch: Check PC-relative relocations for
shared libraries), the situation has been improved: the linker errors
out instead of silently producing a wrong output file.

But logically, using -mdirect-extern-access for a static PIE perfectly
makes sense, and we should not prevent that even if the programmer uses
weak symbols.  Linux kernel is such an example, and Linux < 6.10 now
fails to build with Binutils trunk.  (The silent breakage with prior
Binutils releases was "benign" due to some blind luck.)

While since the 6.10 release Linux has removed those potentially
undefined weak symbols (due to performance issue), we still should
support weak symbols in -mdirect-extern-access -static-pie and unbreak
building old kernels.

Link: https://lore.kernel.org/loongarch/20241206085810.112341-1-chenhuacai@loongson.cn/
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
7 months agoLoongArch: Fix resolution of undefined weak hidden/protected symbols
Xi Ruoyao [Wed, 25 Dec 2024 04:41:43 +0000 (12:41 +0800)] 
LoongArch: Fix resolution of undefined weak hidden/protected symbols

An undefined weak hidden/protect symbol should be resolved to runtime
address 0, but we were actually resolving it to link-time address 0.  So
in PIE or DSO the runtime address would be incorrect.

Fix the issue by rewriting pcalau12i to lu12i.w, and pcaddi to addi.w.
The latter does not always work because the immediate field of addi.w is
narrower, report an error in the case the addend is too large.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
7 months agoAutomatic date update in version.in
GDB Administrator [Fri, 27 Dec 2024 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoAutomatic date update in version.in
GDB Administrator [Thu, 26 Dec 2024 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agomacro.c:871 heap-buffer-overflow
Alan Modra [Wed, 25 Dec 2024 20:49:24 +0000 (07:19 +1030)] 
macro.c:871 heap-buffer-overflow

PR 32391 commit 9f2e3c21f6 fallout again.  Also fix another 'macro'
may be used uninitialized.

7 months agobuffer overflow in gas/app.c
Alan Modra [Wed, 25 Dec 2024 08:47:24 +0000 (19:17 +1030)] 
buffer overflow in gas/app.c

This testcase:
 .irp x x x "
 .end #
 .endr
manages to access lex[EOF].

xxx: Warning: end of file in string; '"' inserted
xxx:1: Warning: missing closing `"'
gas/app.c:844:16: runtime error: index -1 out of bounds for type 'char [256]
Following that there is a buffer overflow.

Stop this happening, and in other similar places, by checking for EOF.

7 months agoAutomatic date update in version.in
GDB Administrator [Wed, 25 Dec 2024 00:00:15 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agogdb/testsuite: add some xfail in gdb.base/startup-with-shell.exp
Andrew Burgess [Fri, 15 Dec 2023 13:03:26 +0000 (13:03 +0000)] 
gdb/testsuite: add some xfail in gdb.base/startup-with-shell.exp

There are two tests that fail in gdb.base/startup-with-shell.exp when
using the native-extended-remote board.  I plan to fix these issues,
and I've posted a series that does just that:

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

But until that series is reviewed, I thought I'd merge this commit,
which marks the FAIL as XFAIL and links them to the relevant bug
number.

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

Tested-By: Guinevere Larsen <guinevere@redhat.com>
7 months agogdb/freebsd: port core file context parsing to FreeBSD
Andrew Burgess [Mon, 21 Oct 2024 15:41:54 +0000 (16:41 +0100)] 
gdb/freebsd: port core file context parsing to FreeBSD

This commit implements the gdbarch_core_parse_exec_context method for
FreeBSD.

This is much simpler than for Linux.  On FreeBSD, at least the
version (13.x) that I have installer, there are additional entries in
the auxv vector that point directly to the argument and environment
vectors, this makes it trivial to find this information.

If these extra auxv entries are not available on earlier FreeBSD, then
that's fine.  The fallback behaviour will be for GDB to act as it
always has up to this point, you'll just not get the extra
functionality.

Other differences compared to Linux are that FreeBSD has
AT_FREEBSD_EXECPATH instead of AT_EXECFN, the AT_FREEBSD_EXECPATH is
the full path to the executable.  On Linux AT_EXECFN is the command
the user typed, so this can be a relative path.

This difference is handy as on FreeBSD we don't parse the mapped files
from the core file (are they even available?).  So having the EXECPATH
means we can use that as the absolute path to the executable.

However, if the user ran a symlink then AT_FREEBSD_EXECPATH will be
the absolute path to the symlink, not to the underlying file.  This is
probably a good thing, but it does mean there is one case we test on
Linux that fails on FreeBSD.

On Linux if we create a symlink to an executable, then run the symlink
and generate a corefile.  Now delete the symlink and load the core
file.  On Linux GDB will still find (and open) the original
executable.  This is because we use the mapped file information to
find the absolute path to the executable, and the mapped file
information only stores the real file names, not symlink names.

This is a total edge case, I only added the deleted symlink test
originally because I could see that this would work on Linux.  Though
it is neat that Linux finds this, I don't feel too bad that this fails
on FreeBSD.

Other than this, everything seems to work on x86-64 FreeBSD (13.4)
which is all I have setup right now.  I don't see why other
architectures wouldn't work too, but I haven't tested them.

7 months agogdb: improve GDB's ability to auto-load the exec for a core file
Andrew Burgess [Thu, 2 May 2024 14:37:42 +0000 (15:37 +0100)] 
gdb: improve GDB's ability to auto-load the exec for a core file

GDB already has a limited mechanism for auto-loading the executable
corresponding to a core file, this can be found in the function
locate_exec_from_corefile_build_id in corelow.c.

However, this approach uses the build-id of the core file to look in
either the debug directory (for a symlink back to the executable) or
by asking debuginfod.  This is great, and works fine if the core file
is a "system" binary, but often, when I'm debugging a core file, it's
part of my development cycle, so there's no build-id symlink in the
debug directory, and debuginfod doesn't know about the binary either,
so GDB can't auto load the executable....

... but the executable is right there!

This commit builds on the earlier commits in this series to make GDB
smarter.

On GNU/Linux, when we parse the execution context from the core
file (see linux-tdep.c), we already grab the command pointed to by
AT_EXECFN.  If this is an absolute path then GDB can use this to
locate the executable, a build-id check ensures we've found the
correct file.  With this small change GDB suddenly becomes a lot
better at auto-loading the executable for a core file.

But we can do better!  Often the AT_EXECFN is not an absolute path.

If it is a relative path then we check for this path relative to the
core file.  This helps if a user does something like:

  $ ./build/bin/some_prog
  Aborted (core dumped)
  $ gdb -c corefile

In this case the core file in the current directory will have an
AT_EXECFN value of './build/bin/some_prog', so if we look for that
path relative to the location of the core file this might result in a
hit, again, a build-id check ensures we found the right file.

But we can do better still!  What if the user moves the core file?  Or
the user is using some tool to manage core files (e.g. the systemd
core file management tool), and the user downloads the core file to a
location from which the relative path no longer works?

Well in this case we can make use of the core file's mapped file
information (the NT_FILE note).  The executable will be included in
the mapped file list, and the path within the mapped file list will be
an absolute path.  We can search for mapped file information based on
an address within the mapped file, and the auxv vector happens to
include an AT_ENTRY value, which is the entry address in the main
executable.  If we look up the mapped file containing this address
we'll have the absolute path to the main executable, a build-id check
ensures this really is the file we're looking for.

It might be tempting to jump straight to the third approach, however,
there is one small downside to the third approach: if the executable
is a symlink then the AT_EXECFN string will be the name of the
symlink, that is, the thing the user asked to run.  The mapped file
entry will be the name of the actual file, i.e. the symlink target.
When we auto-load the executable based on the third approach, the file
loaded might have a different name to that which the user expects,
though the build-id check (almost) guarantees that we've loaded the
correct binary.

But there's one more thing we can check for!

If the user has placed the core file and the executable into a
directory together, for example, as might happen with a bug report,
then neither the absolute path check, nor the relative patch check
will find the executable.  So GDB will also look for a file with the
right name in the same directory as the core file.  Again, a build-id
check is performed to ensure we find the correct file.

Of course, it's still possible that GDB is unable to find the
executable using any of these approaches.  In this case, nothing
changes, GDB will check in the debug info directory for a build-id
based link back to the executable, and if that fails, GDB will ask
debuginfod for the executable.  If this all fails, then, as usual, the
user is able to load the correct executable with the 'file' command,
but hopefully, this should be needed far less from now on.

7 months agogdb/testsuite: make some of the core file / build-id tests harder
Andrew Burgess [Thu, 24 Oct 2024 21:04:10 +0000 (22:04 +0100)] 
gdb/testsuite: make some of the core file / build-id tests harder

We have a few tests that load core files, which depend on GDB not
auto-loading the executable that matches the core file.  One of these
tests (corefile-buildid.exp) exercises GDB's ability to load the
executable via the build-id links in the debug directory, while the
other two tests are just written assuming that GDB hasn't auto-loaded
the executable.

In the next commit, GDB is going to get better at finding the
executable for a core file, and as a consequence these tests could
start to fail if the testsuite is being run using a compiler that adds
build-ids by default, and is on a target (currently only Linux) with
the improved executable auto-loading.

To avoid these test failures, this commit updates some of the tests.

coredump-filter.exp and corefile.exp are updated to unload the
executable should it be auto-loaded.  This means that the following
output from GDB will match the expected patterns.  If the executable
wasn't auto-loaded then the new step to unload is harmless.

The corefile-buildid.exp test needed some more significant changes.
For this test it is important that the executable be moved aside so
that GDB can't locate it, but we do still need the executable around
somewhere, so that the debug directory can link to it.  The point of
the test is that the executable _should_ be auto-loaded, but using the
debug directory, not using GDB's context parsing logic.

While looking at this test I noticed two additional problems, first we
were creating the core file more times than we needed.  We only need
to create one core file for each test binary (total two), while we
previously created one core file for each style of debug info
directory (total four).  The extra core files should be identical, and
were just overwriting each other, harmless, but still pointless work.

The other problem is that after running an earlier test we modified
the test binary in order to run a later test.  This means it's not
possible to manually re-run the first test as the binary for that test
is destroyed.

As part of the rewrite in this commit I've addressed these issues.

This test does change many of the test names, but there should be no
real changes in what is being tested after this commit.  However, when
the next commit is added, and GDB gets better at auto-loading the
executable for a core file, these tests should still be testing what
is expected.

7 months agogdb: parse and set the inferior environment from core files
Andrew Burgess [Sat, 8 Jun 2024 10:06:02 +0000 (11:06 +0100)] 
gdb: parse and set the inferior environment from core files

Extend the core file context parsing mechanism added in the previous
commit to also store the environment parsed from the core file.

This environment can then be injected into the inferior object.

The benefit of this is that when examining a core file in GDB, the
'show environment' command will now show the environment extracted
from a core file.

Consider this example:

  $ env -i GDB_TEST_VAR=FOO ./gen-core
  Segmentation fault (core dumped)
  $ gdb -c ./core.1669829
  ...
  [New LWP 1669829]
  Core was generated by `./gen-core'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x0000000000401111 in ?? ()
  (gdb) show environment
  GDB_TEST_VAR=foo
  (gdb)

There's a new test for this functionality.

7 months agogdb: add gdbarch method to get execution context from core file
Andrew Burgess [Thu, 25 Apr 2024 08:36:43 +0000 (09:36 +0100)] 
gdb: add gdbarch method to get execution context from core file

Add a new gdbarch method which can read the execution context from a
core file.  An execution context, for this commit, means the filename
of the executable used to generate the core file and the arguments
passed to the executable.

In later commits this will be extended further to include the
environment in which the executable was run, but this commit is
already pretty big, so I've split that part out into a later commit.

Initially this new gdbarch method is only implemented for Linux
targets, but a later commit will add FreeBSD support too.

Currently when GDB opens a core file, GDB reports the command and
arguments used to generate the core file.  For example:

  (gdb) core-file ./core.521524
  [New LWP 521524]
  Core was generated by `./gen-core abc def'.

However, this information comes from the psinfo structure in the core
file, and this struct only allows 80 characters for the command and
arguments combined.  If the command and arguments exceed this then
they are truncated.

Additionally, neither the executable nor the arguments are quoted in
the psinfo structure, so if, for example, the executable was named
'aaa bbb' (i.e. contains white space) and was run with the arguments
'ccc' and 'ddd', then when this core file was opened by GDB we'd see:

  (gdb) core-file ./core.521524
  [New LWP 521524]
  Core was generated by `./aaa bbb ccc ddd'.

It is impossible to know if 'bbb' is part of the executable filename,
or another argument.

However, the kernel places the executable command onto the user stack,
this is pointed to by the AT_EXECFN entry in the auxv vector.
Additionally, the inferior arguments are all available on the user
stack.  The new gdbarch method added in this commit extracts this
information from the user stack and allows GDB to access it.

The information on the stack is writable by the user, so a user
application can start up, edit the arguments, override the AT_EXECFN
string, and then dump core.  In this case GDB will report incorrect
information, however, it is worth noting that the psinfo structure is
also filled (by the kernel) by just copying information from the user
stack, so, if the user edits the on stack arguments, the values
reported in psinfo will change, so the new approach is no worse than
what we currently have.

The benefit of this approach is that GDB gets to report the full
executable name and all the arguments without the 80 character limit,
and GDB is aware which parts are the executable name, and which parts
are arguments, so we can, for example, style the executable name.

Another benefit is that, now we know all the arguments, we can poke
these into the inferior object.  This means that after loading a core
file a user can 'show args' to see the arguments used.  A user could
even transition from core file debugging to live inferior debugging
using, e.g. 'run', and GDB would restart the inferior with the correct
arguments.

Now the downside: finding the AT_EXECFN string is easy, the auxv entry
points directly too it.  However, finding the arguments is a little
trickier.  There's currently no easy way to get a direct pointer to
the arguments.  Instead, I've got a heuristic which I believe should
find the arguments in most cases.  The algorithm is laid out in
linux-tdep.c, I'll not repeat it here, but it's basically a search of
the user stack, starting from AT_EXECFN.

If the new heuristic fails then GDB just falls back to the old
approach, asking bfd to read the psinfo structure for us, which gives
the old 80 character limited answer.

For testing, I've run this series on (all GNU/Linux) x86-64. s390,
ppc64le, and the new test passes in each case.  I've done some very
basic testing on ARM which does things a little different than the
other architectures mentioned, see ARM specific notes in
linux_corefile_parse_exec_context_1 for details.

7 months agoarc: add_to_decodelist
Alan Modra [Tue, 24 Dec 2024 00:58:46 +0000 (11:28 +1030)] 
arc: add_to_decodelist

Given objdump -Mcpu=archs -D or similar, add_to_decodelist adds three
entries to decodelist for each instruction disassembled.  That can
waste a lot of cpu when the list grows large.  What's more,
decodelist is static and nothing clears the list.  So the list
persists from one file to the next if objdump is disassembling
multiple files in one invocation.  Wrong disassembly might result.

To fix this problem, I've moved decodelist to the arc private_data and
made it an array.  I believe that init_disassemble_data will be
called, clearing private_data, for each file disassembled.  That's
certainly true for objdump, and if I can see my way around gdb
constructors, it's also true for gdb.  I don't think there is a
possibility of info.disassembler_options changing unless there is
first a call to init_disassebled_data.  That means all of the option
parsing and bfd mach and e_flags decoding need only be done when
initialising the arc private_data.

* arc-dis.c (addrtypenames_max, addrtypeunknown): Delete..
(get_addrtype): ..substitute values here.  Tidy.
(skipclass_t, linkclass, decodelist): Delete.
(enforced_isa_mask, print_hex): Delete.
(struct arc_disassemble_info): Add decode[], decode_count,
isa_mask, print_hex.
(init_arc_disasm_info): Tidy.
(add_to_decodelist): Delete, replacing with..
(add_to_decode): ..this.  Don't duplicate entries.
(skip_this_opcode): Adjust to suit.
(find_format_from_table, parse_option): Likewise.
(parse_disassembler_options): Likewise.  Move code dealing
with bfd mach and eflags from..
(print_insn_arc): ..here.  Adjust for other changes.

7 months agoPR 32324, Stripping BOLT'ed binaries leads to unwanted behaviour
Alan Modra [Sun, 22 Dec 2024 23:56:02 +0000 (10:26 +1030)] 
PR 32324, Stripping BOLT'ed binaries leads to unwanted behaviour

This patch corrects layout for a PT_LOAD header that doesn't include
the ELF file header but does contain PHDRs and sections requiring
alignment.  The required alignment (which was missing) is placed
before the PHDRs.

7 months agoPR 32391 testcase
Alan Modra [Mon, 23 Dec 2024 03:52:27 +0000 (14:22 +1030)] 
PR 32391 testcase

The new testcase results in these regressions:
hppa64-hp-hpux11.23  +FAIL: Nested macros (PR 32391)
hppa-hp-hpux10  +FAIL: Nested macros (PR 32391)
i386-darwin  +FAIL: Nested macros (PR 32391)

Fix the hppa regressions by ensuring that only symbols start on the
first column.

7 months agoFix error: macro may be used uninitialized
Alan Modra [Fri, 20 Dec 2024 22:03:23 +0000 (08:33 +1030)] 
Fix error: macro may be used uninitialized

PR 32391 commit 9f2e3c21f6 fallout

7 months agoAutomatic date update in version.in
GDB Administrator [Tue, 24 Dec 2024 00:00:13 +0000 (00:00 +0000)] 
Automatic date update in version.in

7 months agoSupport Intel AVX10.2 minmax, vector copy and compare instructions
Haochen Jiang [Mon, 23 Dec 2024 03:32:03 +0000 (11:32 +0800)] 
Support Intel AVX10.2 minmax, vector copy and compare instructions

In this patch, we will support AVX10.2 minmax, vector copy and compare
instructions. This will finish the new instruction form support for
AVX10.2. Most of them are new instructions forms except for vmovd
and vmovw, which are extended usage from the old ones.

gas/ChangeLog:

* NEWS: Mention AVX10.2.
* testsuite/gas/i386/i386.exp: Add AVX10.2 tests.
* testsuite/gas/i386/x86-64.exp: Ditto.
* testsuite/gas/i386/avx10_2-256-5-intel.d: New test.
* testsuite/gas/i386/avx10_2-256-miscs.d: Ditto.
* testsuite/gas/i386/avx10_2-256-miscs.s: Ditto.
* testsuite/gas/i386/avx10_2-512-miscs-intel.d: Ditto.
* testsuite/gas/i386/avx10_2-512-miscs.d: Ditto.
* testsuite/gas/i386/avx10_2-512-miscs.s: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-256-miscs-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-256-miscs.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-256-miscs.s: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-512-miscs-intel.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-512-miscs.d: Ditto.
* testsuite/gas/i386/x86-64-avx10_2-512-miscs.s: Ditto.

opcodes/ChangeLog:

* i386-dis-evex-len.h: Add EVEX_LEN_0F7E_P_1_W_1,
EVEX_LEN_0FD6_P_2_W_0, EVEX_LEN_MAP5_6E and EVEX_LEN_MAP5_7E.
* i386-dis-evex-prefix.h: Add PREFIX_EVEX_0F2E, PREFIX_EVEX_0F2F,
PREFIX_EVEX_0F3A52, PREFIX_EVEX_0F3A53, PREFIX_EVEX_MAP5_2E,
PREFIX_EVEX_MAP5_2F, PREFIX_EVEX_MAP5_6E and PREFIX_EVEX_MAP5_7E.
* i386-dis-evex-w.h: Adjust EVEX_W_0F3A42, EVEX_W_0F7E_P_1
and EVEX_W_0FD6. Add EVEX_W_MAP5_6E_P_1 and EVEX_W_MAP5_7E_P_1.
* i386-dis-evex.h: Add and adjust table entries for AVX10.2.
* i386-dis.c (PREFIX_EVEX_0F2E): New.
(PREFIX_EVEX_0F2F): Ditto.
(PREFIX_EVEX_0F3A52): Ditto.
(PREFIX_EVEX_0F3A53): Ditto.
(PREFIX_EVEX_MAP5_2E): Ditto.
(PREFIX_EVEX_MAP5_2F): Ditto.
(PREFIX_EVEX_MAP5_6E_L_0): Ditto.
(PREFIX_EVEX_MAP5_7E_L_0): Ditto.
(EVEX_LEN_0F7E_P_1_W_1): Ditto.
(EVEX_LEN_0FD6_P_2_W_0): Ditto.
(EVEX_LEN_MAP5_6E): Ditto.
(EVEX_LEN_MAP5_7E): Ditto.
(EVEX_W_MAP5_6E_P_1): Ditto.
(EVEX_W_MAP5_7E_P_1): Ditto.
* i386-opc.tbl: Add AVX10.2 instructions.
* i386-mnem.h: Regenerated.
* i386-tbl.h: Ditto.

Co-authored-by: Jun Zhang <jun.zhang@intel.com>
Co-authored-by: Zewei Mo <zewei.mo@intel.com>
7 months agoAutomatic date update in version.in
GDB Administrator [Mon, 23 Dec 2024 00:00:18 +0000 (00:00 +0000)] 
Automatic date update in version.in