public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed] Fix mi_gdb_exit with secondary MI channels
@ 2020-09-20 15:05 Pedro Alves
  0 siblings, 0 replies; only message in thread
From: Pedro Alves @ 2020-09-20 15:05 UTC (permalink / raw)
  To: gdb-patches

Tests that use a secondary MI channel (i.e., either tests that call
mi_gdb_start with separate-mi-tty, or all tests when
FORCE_SEPARATE_MI_TTY=1 is specified on the make check command line),
don't close GDB correctly.

E.g., if you run gdb.mi/mi-exec-run.exp in a loop:

  while true; do make check TESTS="gdb.mi/mi-exec-run.exp"; done

you can see more than one gdb running at the same time:

  $ ps -ef | grep -v grep | grep "gdb/gdb"
  pedro      40507       1  7 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
  pedro      40562       1  0 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
  pedro      40727       1  0 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory
  pedro      40786       1  0 15:47 ?        00:00:00 /home/pedro/gdb/build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory /home/pedro/gdb/build/gdb/testsuite/../data-directory

This commit fixes it.

gdb/testsuite/ChangeLog:

	* lib/mi-support.exp (mi_uncatched_gdb_exit) Switch to the main
	spawn_id before calling remote_close.  Close secondary MI channel.
---
 gdb/testsuite/lib/mi-support.exp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 5c1fcca4d23..0e7524ed0f6 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -89,6 +89,18 @@ proc mi_uncatched_gdb_exit {} {
 	}
     }
 
+    # Switch back to the main spawn id, so that remote_close below
+    # closes it, and not a secondary channel.  Closing a secondary
+    # channel does not make GDB exit.
+    if {$gdb_spawn_id != $gdb_main_spawn_id} {
+	switch_gdb_spawn_id $gdb_main_spawn_id
+    }
+
+    # Close secondary MI channel, if there's one.
+    if {$mi_spawn_id != $gdb_main_spawn_id} {
+	close -i $mi_spawn_id
+    }
+
     if ![is_remote host] {
 	remote_close host
     }

base-commit: 851257b5fc3a21659cfb2504c03001535756cf4a
prerequisite-patch-id: da39a3ee5e6b4b0d3255bfef95601890afd80709
-- 
2.14.5


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-20 15:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20 15:05 [pushed] Fix mi_gdb_exit with secondary MI channels Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).