Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v3 0/2] gdb: improve interrupting an empty remote target
@ 2026-09-11  7:39 Stephan Rohr
  2026-09-11  7:39 ` [PATCH v3 1/2] gdb: fix assertion when " Stephan Rohr
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stephan Rohr @ 2026-09-11  7:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

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

Hi all, Hi Tom,

I fixed the function definition as reported by Tom.  The rest is
unchanged.

Version 2 of the series is at 

https://sourceware.org/pipermail/gdb-patches/2026-September/230158.html

And Tom's feedback:

https://sourceware.org/pipermail/gdb-patches/2026-September/230222.html

v1 of the patch is available at:

https://sourceware.org/pipermail/gdb-patches/2026-August/229186.html

Tom's feedback can be found at:

https://sourceware.org/pipermail/gdb-patches/2026-September/230028.html
https://sourceware.org/pipermail/gdb-patches/2026-September/230029.html

I appreciate your feedback.

Thanks
Stephan

Rohr, Stephan (2):
  gdb: fix assertion when interrupting an empty remote target
  gdb, remote: Skip sending of 'vCont' packet if remote target is empty

 gdb/infcmd.c                                  |  5 +-
 gdb/remote.c                                  |  4 ++
 .../interrupt-empty-remote-target.exp         | 49 +++++++++++++++++++
 gdb/thread-iter.h                             |  3 ++
 4 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp

-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] gdb: fix assertion when interrupting an empty remote target
  2026-09-11  7:39 [PATCH v3 0/2] gdb: improve interrupting an empty remote target Stephan Rohr
@ 2026-09-11  7:39 ` Stephan Rohr
  2026-09-11  7:39 ` [PATCH v3 2/2] gdb, remote: Skip sending of 'vCont' packet if remote target is empty Stephan Rohr
  2026-09-11 13:58 ` [PATCH v3 0/2] gdb: improve interrupting an empty remote target Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Stephan Rohr @ 2026-09-11  7:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

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

GDB asserts when sending an interrupt to an empty remote target, e.g.
use stdio to connect to a remote target in non-stop mode:

  'gdb -ex "set non-stop on" -ex "target extended-remote | gdbserver
   --multi --once -'

Interrupting the target triggers an assertion in 'find_inferior_pid'.
Fix by checking for a valid thread in 'interrupt_target_1' for 'non-stop'
mode.
---
 gdb/infcmd.c                                  |  5 ++-
 .../interrupt-empty-remote-target.exp         | 34 +++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index ed760583dd9..e5eea8996cb 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -3148,7 +3148,10 @@ interrupt_target_1 (bool all_threads)
 	    }
 	}
       else
-	stop_current_target_threads_ns (inferior_ptid);
+	{
+	  ensure_valid_thread ();
+	  stop_current_target_threads_ns (inferior_ptid);
+	}
     }
   else
     target_interrupt ();
diff --git a/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp b/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp
new file mode 100644
index 00000000000..4facbe00533
--- /dev/null
+++ b/gdb/testsuite/gdb.server/interrupt-empty-remote-target.exp
@@ -0,0 +1,34 @@
+# Copyright 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# 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.
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+clean_restart
+
+# Make sure we're disconnected, in case we're testing with an
+# extended-remote board, therefore already connected.
+gdb_test "disconnect" ".*"
+
+gdbserver_start_extended "--once"
+
+gdb_test_no_output "set non-stop on"
+
+gdb_test "interrupt" \
+    "Cannot execute this command without a live selected thread."
-- 
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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] gdb, remote: Skip sending of 'vCont' packet if remote target is empty
  2026-09-11  7:39 [PATCH v3 0/2] gdb: improve interrupting an empty remote target Stephan Rohr
  2026-09-11  7:39 ` [PATCH v3 1/2] gdb: fix assertion when " Stephan Rohr
@ 2026-09-11  7:39 ` Stephan Rohr
  2026-09-11 13:58 ` [PATCH v3 0/2] gdb: improve interrupting an empty remote target Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Stephan Rohr @ 2026-09-11  7:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom

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           | 17 ++++++++++++++++-
 gdb/thread-iter.h                               |  3 +++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index 76cf6b5234f..595384e56bb 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7884,6 +7884,10 @@ remote_target::remote_stop_ns (ptid_t ptid)
 	  }
       }
 
+  /* Skip 'vCont' packet 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 4facbe00533..4c959175433 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
 
@@ -32,3 +33,17 @@ 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.
+set re \
+    [multi_line \
+	 [string_to_regexp {[remote] stop: enter}] \
+	 [string_to_regexp {[remote] stop: exit}] \
+	 ""]
+
+gdb_test_lines "interrupt -a" "no vCont is sent" "^$re$" -re-not "vCont"
+
+gdb_test_no_output "set debug remote off"
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index c649560c0e1..b2a8a7f578d 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 () const
+  { 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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 0/2] gdb: improve interrupting an empty remote target
  2026-09-11  7:39 [PATCH v3 0/2] gdb: improve interrupting an empty remote target Stephan Rohr
  2026-09-11  7:39 ` [PATCH v3 1/2] gdb: fix assertion when " Stephan Rohr
  2026-09-11  7:39 ` [PATCH v3 2/2] gdb, remote: Skip sending of 'vCont' packet if remote target is empty Stephan Rohr
@ 2026-09-11 13:58 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2026-09-11 13:58 UTC (permalink / raw)
  To: Stephan Rohr; +Cc: gdb-patches, tom

> I fixed the function definition as reported by Tom.  The rest is
> unchanged.

Thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-11 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11  7:39 [PATCH v3 0/2] gdb: improve interrupting an empty remote target Stephan Rohr
2026-09-11  7:39 ` [PATCH v3 1/2] gdb: fix assertion when " Stephan Rohr
2026-09-11  7:39 ` [PATCH v3 2/2] gdb, remote: Skip sending of 'vCont' packet if remote target is empty Stephan Rohr
2026-09-11 13:58 ` [PATCH v3 0/2] gdb: improve interrupting an empty remote target Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox