From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Gc5xES2cS2pKvCkAWB0awg (envelope-from ) for ; Mon, 06 Jul 2026 08:14:37 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mqBBsEc5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4187A1E098; Mon, 06 Jul 2026 08:14:37 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 570AE1E070 for ; Mon, 06 Jul 2026 08:14:36 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BC834BA23C3 for ; Mon, 6 Jul 2026 12:14:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BC834BA23C3 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mqBBsEc5 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by sourceware.org (Postfix) with ESMTPS id 8495D4BA2E2F for ; Mon, 6 Jul 2026 12:14:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8495D4BA2E2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8495D4BA2E2F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783340049; cv=none; b=BmbDOBTOkOrH4S2gwy0jdraqZvTVKcFDfXgrYEIPmso+4cqeRB7cxHzmQM3/qAw2SjhVwd3jXaBRBIoofcpzRkxhvf22iv5g2vU0Ls1sQ0nOWuUNotBcBvcczfGc1qZFv7BukakTCI+J4wfIJBNNpT1gYnqrYhgmoUBXNakifM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783340049; c=relaxed/simple; bh=zdVVUs1ndawkBNupbDmYnNJm9OeTsFyLZRf3TvV52Qg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XCADRNa1GOZF8UcB+mWUEvfJ9bNAaTaYvv8XzxpwsA+tOZPQ5WineDEdQ464uXdXQ7pykXo9/G1a279ctnNYIGTjfxvXfg1J9K9xvekX7uppAhtDr7wKdqL6CzJp/E3eHe8Re/bigAvguG6gS2PbgC8SdSHKVNKN3bfgIJHlw8k= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=mqBBsEc5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8495D4BA2E2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783340049; x=1814876049; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zdVVUs1ndawkBNupbDmYnNJm9OeTsFyLZRf3TvV52Qg=; b=mqBBsEc5AXrYqGyKueeX9wasE81m31w2sQ8jpmf1S3y2WrhXI1zxc3te cvsBBBFLlle/xzifu/EDfmWd6SGOy50BWD5lCtCJ3ddQW2aVutR3rlvLD bk1mu/QKGCFC+wzBc8HzUdExHK4uVYyokVDOFRqHoyf7peS1BpaFk7elr 1kY6yt2BhZmvB11Sa55+YUV+r9HmbQdcJIWv2tUEYEz8XsrsaJeB3irdB GkhvhmpsSUm29l9EXGCFDRQy9L/w2GFsS7s+1wnM475QDiFmHhWTnwi6H A5RE6lVn3S5qxG3yy7hwuQsgwuJEvqneRZ5NjIh/V+iwutpbDOOzu2sBo Q==; X-CSE-ConnectionGUID: f6O56+XESMezewmIWCpCpA== X-CSE-MsgGUID: U8VlbDmNSeKqxViHp8S0LA== X-IronPort-AV: E=McAfee;i="6800,10657,11838"; a="83834638" X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="83834638" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:14:08 -0700 X-CSE-ConnectionGUID: QIN0SBvkRw+/jHapwQTAtw== X-CSE-MsgGUID: AFYaER9HQzqCujsVap5HwA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,149,1779174000"; d="scan'208";a="258601768" Received: from unknown (HELO localhost) ([10.245.114.180]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2026 05:14:06 -0700 From: Mohamed Bouhaouel 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 Message-ID: <20260706121124.18784-12-mohamed.bouhaouel@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260706121124.18784-1-mohamed.bouhaouel@intel.com> References: <20260706121124.18784-1-mohamed.bouhaouel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: "Bouhaouel, Mohamed" 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