Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Stephan Rohr <stephan.rohr@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] gdb, remote: Skip sending of 'vCont' package if remote target is empty
Date: Wed,  5 Aug 2026 08:59:18 +0000	[thread overview]
Message-ID: <20260805085919.218925-3-stephan.rohr@intel.com> (raw)
In-Reply-To: <20260805085919.218925-1-stephan.rohr@intel.com>

From: "Rohr, Stephan" <stephan.rohr@intel.com>

If the remote target has no threads that need to be stopped, we can
skip sending the 'vCont' package in 'remote_stop_ns'.
---
 gdb/remote.c                                   |  4 ++++
 .../interrupt-empty-remote-target.exp          | 18 +++++++++++++++++-
 gdb/thread-iter.h                              |  3 +++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 194c4cbd9bb..8be552b4533 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7884,6 +7884,10 @@ remote_target::remote_stop_ns (ptid_t ptid)
 	  }
       }
 
+  /* Skip 'vCont' package if there are no threads to be stopped.  */
+  if (all_non_exited_threads (this, ptid).empty ())
+    return;
+
   if (!rs->supports_vCont.t)
     error (_("Remote server does not support stopping threads"));
 
diff --git a/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp b/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp
index 34437a17d90..c26b535be16 100644
--- a/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp
+++ b/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp
@@ -14,7 +14,8 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Tests that GDB does not assert if interrupting an empty remote target
-# in non-stop mode.
+# in non-stop mode.  Also tests that no 'vCont' package is sent for empty
+# remote targets.
 
 load_lib gdbserver-support.exp
 
@@ -38,3 +39,18 @@ gdb_test_no_output "set non-stop on"
 
 gdb_test "interrupt" \
     "Cannot execute this command without a live selected thread."
+
+gdb_test_no_output "set debug remote on"
+
+# Test that we do not see a 'vCont' package if we interrupt an empty
+# remote target.
+gdb_test_multiple "interrupt -a" "no vCont is sent" {
+    -re -wrap "vCont.*" {
+	fail $gdb_test_name
+    }
+    -re -wrap "" {
+	pass $gdb_test_name
+    }
+}
+
+gdb_test_no_output "set debug remote off"
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index c649560c0e1..cc2b04e7e99 100644
--- a/gdb/thread-iter.h
+++ b/gdb/thread-iter.h
@@ -248,6 +248,9 @@ class all_non_exited_threads_range
   all_non_exited_threads_iterator end () const
   { return all_non_exited_threads_iterator (); }
 
+  bool empty ()
+  { return begin () == end (); }
+
 private:
   process_stratum_target *m_filter_target;
   ptid_t m_filter_ptid;
-- 
2.43.0

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


  parent reply	other threads:[~2026-08-05  9:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  8:59 [PATCH 0/2] gdb: improve interrupting an empty remote target Stephan Rohr
2026-08-05  8:59 ` [PATCH 1/2] gdb: fix assertion when " Stephan Rohr
2026-08-05  8:59 ` Stephan Rohr [this message]
2026-08-17 14:37 ` [PATCH 0/2] gdb: improve " Rohr, Stephan

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=20260805085919.218925-3-stephan.rohr@intel.com \
    --to=stephan.rohr@intel.com \
    --cc=gdb-patches@sourceware.org \
    /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