aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2020-09-20 15:58:26 +0100
committerPedro Alves <pedro@palves.net>2020-09-20 16:02:24 +0100
commitb167e53f05cbddfc22a0e6a362a0aa14a460b31d (patch)
treeb671103e2e84cc6472017cdb28f25bef2032bfa5
parentdbc49e9ffa4c95413f38e31dae652329fd22dda2 (diff)
downloadgdb-b167e53f05cbddfc22a0e6a362a0aa14a460b31d.zip
gdb-b167e53f05cbddfc22a0e6a362a0aa14a460b31d.tar.gz
gdb-b167e53f05cbddfc22a0e6a362a0aa14a460b31d.tar.bz2
Fix mi_gdb_exit with secondary MI channels
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.
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/lib/mi-support.exp12
2 files changed, 17 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 71ec495..85bafba 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2020-09-20 Pedro Alves <pedro@palves.net>
+ * lib/mi-support.exp (mi_uncatched_gdb_exit) Switch to the main
+ spawn_id before calling remote_close. Close secondary MI channel.
+
+2020-09-20 Pedro Alves <pedro@palves.net>
+
* gdb.base/testenv.exp (find_env): Bail out if printing 'envp[$i]'
fails.
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 5c1fcca..0e7524e 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
}