From: Mohamed Bouhaouel <mohamed.bouhaouel@intel.com>
To: gdb-patches@sourceware.org
Cc: stephan.rohr@intel.com, markus.t.metzger@intel.com,
pedro@palves.net, aburgess@redhat.com
Subject: [PATCH v3 11/11] gdb, gdbserver: add AlwaysNonStop remote protocol extension
Date: Mon, 6 Jul 2026 14:11:24 +0200 [thread overview]
Message-ID: <20260706121124.18784-12-mohamed.bouhaouel@intel.com> (raw)
In-Reply-To: <20260706121124.18784-1-mohamed.bouhaouel@intel.com>
From: "Bouhaouel, Mohamed" <mohamed.bouhaouel@intel.com>
Add a new RSP extension allowing remote stub to declare that a target
must always operate in non-stop mode.
When a stub advertises "AlwaysNonStop+" in its qSupported response:
* The stub automatically initializes to non-stop mode
* GDB will operate the stub in non-stop mode (with default settings)
* The stub will reject QNonStop:0 requests
* GDB errors if 'maint set target-non-stop off' is explicitly set
---
gdb/NEWS | 8 ++++++++
gdb/doc/gdb.texinfo | 30 +++++++++++++++++++++++++++++-
gdb/remote.c | 27 +++++++++++++++++++++++++++
gdbserver/server.cc | 30 +++++++++++++++++++++++++++++-
gdbserver/target.cc | 6 ++++++
gdbserver/target.h | 6 ++++++
6 files changed, 105 insertions(+), 2 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 343828a85dd..b578bb28843 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -91,6 +91,14 @@
record btrace pt event-tracing on) on a FRED-enabled system and from
Trigger Tracing.
+* New remote protocol extension 'AlwaysNonStop' allows gdbserver to
+ indicate that the target must always operate in non-stop mode and
+ cannot switch to all-stop mode. When a remote stub advertises
+ 'AlwaysNonStop+' in its qSupported reply, GDB will operate the stub
+ in non-stop mode (when 'maint set target-non-stop' is 'auto',
+ the default). GDB will refuse to connect if 'maint set target-non-stop'
+ is explicitly set to 'off'.
+
* Configure changes
** --with-babeltrace has been removed. The babeltrace library was
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index a698b2b8451..dedd5ef3b59 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -42922,7 +42922,8 @@ does not indicate support.
@item maint set target-non-stop off
@value{GDBN} does not control the target in non-stop mode even if the
-target supports it.
+target supports it. Note: connection to targets that require non-stop
+mode (via @samp{AlwaysNonStop+}) will fail with this setting.
@end table
Here is how @code{set non-stop} and @code{maint set target-non-stop}
@@ -45094,6 +45095,11 @@ Reply:
@table @samp
@item OK
The request succeeded.
+
+@item @samp{E @var{nn}}
+The request failed. This may occur if the stub requires non-stop mode
+and advertised @samp{AlwaysNonStop+} support, and GDB attempted to
+switch to all-stop mode with @samp{QNonStop:0}.
@end table
This packet is not probed by default; the remote stub must request it,
@@ -45511,6 +45517,21 @@ multiple-watchpoint-addresses-packet} command (@pxref{Remote
Configuration, set remote multiple-watchpoint-addresses-packet}).
@end table
+@item AlwaysNonStop
+This feature indicates that @value{GDBN} supports remote stubs that
+require non-stop mode operation. If the stub advertises
+@samp{AlwaysNonStop+}, it will run in non-stop mode, similar to
+the setting @code{maint set target-non-stop on}. @value{GDBN} will
+not attempt to switch the target to all-stop mode.
+
+Note: @samp{AlwaysNonStop+} requires @samp{QNonStop+} support.
+If a stub advertises @samp{AlwaysNonStop+} without @samp{QNonStop+},
+the @samp{AlwaysNonStop+} extension will be silently ignored by @value{GDBN}.
+
+Use of this feature is controlled by the @code{set remote
+always-non-stop-feature-packet} command (@pxref{Remote
+Configuration, set remote always-non-stop-feature-packet}).
+
Stubs should ignore any unknown values for
@var{gdbfeature}. Any @value{GDBN} which sends a @samp{qSupported}
packet supports receiving packets of unlimited length (earlier
@@ -45907,6 +45928,13 @@ packet (@pxref{qXfer fdpic loadmap read}).
The remote stub understands the @samp{QNonStop} packet
(@pxref{QNonStop}).
+@item AlwaysNonStop
+The remote stub requires non-stop mode operation, will reject
+@samp{QNonStop:0} requests, and automatically initializes to non-stop
+mode. This feature must be advertised together with @samp{QNonStop+};
+if advertised without it, the feature will be silently ignored by
+@value{GDBN}. @xref{QNonStop}.
+
@item QCatchSyscalls
The remote stub understands the @samp{QCatchSyscalls} packet
(@pxref{QCatchSyscalls}).
diff --git a/gdb/remote.c b/gdb/remote.c
index 7e3537b99df..54a289ace31 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -323,6 +323,9 @@ enum {
/* Support for the QNonStop packet. */
PACKET_QNonStop,
+ /* Support for AlwaysNonStop extension. */
+ PACKET_AlwaysNonStop_feature,
+
/* Support for the QThreadEvents packet. */
PACKET_QThreadEvents,
@@ -1442,6 +1445,8 @@ class remote_target : public process_stratum_target
void check_binary_download (CORE_ADDR addr);
+ bool always_non_stop_p () override;
+
target_xfer_status remote_write_bytes_aux (const char *header,
CORE_ADDR memaddr,
const gdb_byte *myaddr,
@@ -5587,6 +5592,12 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
}
else if (m_features.packet_support (PACKET_QNonStop) == PACKET_ENABLE)
{
+ /* If the target requires non-stop mode, don't try to switch to
+ all-stop mode. */
+ if (m_features.packet_support (PACKET_AlwaysNonStop_feature)
+ == PACKET_ENABLE)
+ error (_("Target requires non-stop mode."));
+
/* Don't assume that the stub can operate in all-stop mode.
Request it explicitly. */
putpkt ("QNonStop:0");
@@ -6133,6 +6144,8 @@ static const struct protocol_feature remote_protocol_features[] = {
{ "multiprocess", PACKET_DISABLE, remote_supported_packet,
PACKET_multiprocess_feature },
{ "QNonStop", PACKET_DISABLE, remote_supported_packet, PACKET_QNonStop },
+ { "AlwaysNonStop", PACKET_DISABLE, remote_supported_packet,
+ PACKET_AlwaysNonStop_feature },
{ "qXfer:siginfo:read", PACKET_DISABLE, remote_supported_packet,
PACKET_qXfer_siginfo_read },
{ "qXfer:siginfo:write", PACKET_DISABLE, remote_supported_packet,
@@ -9817,6 +9830,18 @@ remote_target::check_binary_download (CORE_ADDR addr)
}
}
+/* Determine whether the remote target operates in non-stop mode.
+ Returns true if the target advertises AlwaysNonStop, and supports
+ QNonStop for asynchronous execution and stop notifications. */
+
+bool
+remote_target::always_non_stop_p ()
+{
+ return ((m_features.packet_support (PACKET_QNonStop) == PACKET_ENABLE)
+ && (m_features.packet_support (PACKET_AlwaysNonStop_feature)
+ == PACKET_ENABLE));
+}
+
/* Helper function to resize the payload in order to try to get a good
alignment. We try to write an amount of data such that the next write will
start on an address aligned on REMOTE_ALIGN_WRITES. */
@@ -17073,6 +17098,8 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (PACKET_multi_wp_addr,
"multi-wp-addr", "multiple-watchpoint-addresses", 0);
+ add_packet_config_cmd (PACKET_AlwaysNonStop_feature,
+ "AlwaysNonStop", "always-non-stop-feature", 0);
/* Assert that we've registered "set remote foo-packet" commands
for all packet configs. */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index baccdf00172..fe8240cbe44 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -838,6 +838,17 @@ handle_general_set (char *own_buf)
}
req_str = req ? "non-stop" : "all-stop";
+
+ /* If the target always runs in non-stop mode, reject requests to
+ switch to all-stop mode. */
+ if (req == 0 && target_always_non_stop ())
+ {
+ fprintf (stderr, "Cannot switch to all-stop mode: "
+ "target requires non-stop mode\n");
+ write_enn (own_buf);
+ return;
+ }
+
if (the_target->start_non_stop (req == 1) != 0)
{
fprintf (stderr, "Setting %s mode failed\n", req_str);
@@ -2812,7 +2823,11 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
strcat (own_buf, ";exec-events+");
if (target_supports_non_stop ())
- strcat (own_buf, ";QNonStop+");
+ {
+ strcat (own_buf, ";QNonStop+");
+ if (target_always_non_stop ())
+ strcat (own_buf, ";AlwaysNonStop+");
+ }
if (target_supports_disable_randomization ())
strcat (own_buf, ";QDisableRandomization+");
@@ -2876,6 +2891,19 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (cs.single_inferior_argument)
strcat (own_buf, ";single-inf-arg+");
+ /* If the target requires non-stop mode, initialize it now rather
+ than waiting for GDB to request it via QNonStop:1. */
+ if (target_supports_non_stop () && target_always_non_stop ())
+ {
+ if (the_target->start_non_stop (true) != 0)
+ error ("Cannot initialize target: requires non-stop mode but "
+ "non-stop mode initialization failed.");
+
+ non_stop = true;
+ remote_debug_printf ("Target requires non-stop mode: "
+ "enabled at startup.\n");
+ }
+
/* Reinitialize components as needed for the new connection. */
hostio_handle_new_gdb_connection ();
target_handle_new_gdb_connection ();
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 43ef421df74..170e40e9002 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -498,6 +498,12 @@ process_stratum_target::supports_non_stop ()
return false;
}
+bool
+process_stratum_target::always_non_stop ()
+{
+ return false;
+}
+
bool
process_stratum_target::async (bool enable)
{
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 82eab9d1243..cdd1e26f2d6 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -260,6 +260,9 @@ class process_stratum_target
/* Return true if non-stop mode is supported. */
virtual bool supports_non_stop ();
+ /* Return true if target must run in non-stop mode. */
+ virtual bool always_non_stop ();
+
/* Enables async target events. Returns the previous enable
state. */
virtual bool async (bool enable);
@@ -583,6 +586,9 @@ int kill_inferior (process_info *proc);
#define target_supports_non_stop() \
the_target->supports_non_stop ()
+#define target_always_non_stop() \
+ the_target->always_non_stop ()
+
#define target_async(enable) \
the_target->async (enable)
--
2.43.0
Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
next prev parent reply other threads:[~2026-07-06 12:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 12:11 [PATCH v3 00/11] Add " Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 01/11] gdb, record: fix assertion when remote target is set to non-stop Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 02/11] gdb, remote: fix assertion on reconnect to non-stop target Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 03/11] gdb, remote: fix async handler " Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 04/11] gdb, remote: fix "info program" after " Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 05/11] gdb, remote: fix crash when accessing removed events Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 06/11] gdb, remote: fix ptid matching for process-wide stop events Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 07/11] gdb, dap: fix DAP events if no thread is selected Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 08/11] gdb, testsuite: handle async close in monitor-exit-quit.exp Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 09/11] gdb, testsuite: update attach-deleted-exec.exp to handle async messages Mohamed Bouhaouel
2026-07-06 12:11 ` [PATCH v3 10/11] gdb, testsuite: add kfails for step-over-process-exit.exp Mohamed Bouhaouel
2026-07-06 12:11 ` Mohamed Bouhaouel [this message]
2026-07-06 12:41 ` [PATCH v3 11/11] gdb, gdbserver: add AlwaysNonStop remote protocol extension Eli Zaretskii
2026-07-14 9:28 ` Bouhaouel, Mohamed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260706121124.18784-12-mohamed.bouhaouel@intel.com \
--to=mohamed.bouhaouel@intel.com \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=pedro@palves.net \
--cc=stephan.rohr@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox