]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: detect when gdbserver has no default executable set
authorAndrew Burgess <aburgess@redhat.com>
Mon, 24 Jul 2023 16:35:54 +0000 (17:35 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Fri, 3 Oct 2025 12:56:46 +0000 (13:56 +0100)
commit5edcbe2277db05b77ebf53f9c30b6c889a8729bc
tree697a0de087befcf3e1bde8361d962c45960b8313
parent823384610d4275799213c5821305f8f0acdc9140
gdb: detect when gdbserver has no default executable set

This commit extends the use of the new qExecAndArgs packet (added in
the previous commit) so that GDB now understands when it is connected
to a remote server that doesn't have a default executable set.  We
don't do much with this information right now, other than produce more
useful text for 'show remote exec-file'.

Here I've connected to a gdbserver with no default executable set,
this is with this patch in place:

  (gdb) target extended-remote | gdbserver --multi --once -
  (gdb) show remote exec-file
  The remote exec-file is unset, the remote has no default executable set.
  (gdb) file /tmp/hello.x
  Reading symbols from /tmp/hello.x...
  (gdb) run
  Starting program: /tmp/hello.x
  Running the default executable on the remote target failed; try "set remote exec-file"?
  (gdb)

The important line is this one:

  The remote exec-file is unset, the remote has no default executable set.

Without this patch we'd get:

  The remote exec-file is unset, the default remote executable will be used.

The new message is clearer that there is no default executable set on
the remote.

In the future I plan to make use of this additional information,
coupled with an understanding (via 'set sysroot') of when gdb and
gdbserver share the same filesystem, to allow GDB to automatically use
the current executable (e.g. loaded with the 'file' command) as the
remote exec-file.  But this is not part of this patch, or this patch
series, just future planned work.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/remote.c
gdb/testsuite/gdb.server/fetch-exec-and-args.exp