From f2ec452344d49108f3769cb8096806fa7c2d17ee Mon Sep 17 00:00:00 2001
From: Philippe Waroquiers <philippe.waroquiers@skynet.be>
Date: Thu, 27 Dec 2018 00:14:36 +0100
Subject: [PATCH 2/2] Implement FORCE_LOCAL_GDB_QUIT_WAIT in mi mode
Change mi_gdb_exit similarly to gdb_exit.
---
gdb/testsuite/lib/mi-support.exp | 60 +++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
@@ -55,6 +55,8 @@ proc mi_gdb_exit {} {
proc mi_uncatched_gdb_exit {} {
global GDB
global INTERNAL_GDBFLAGS GDBFLAGS
+ global FORCE_LOCAL_GDB_QUIT_WAIT
+ global async
global verbose
global gdb_spawn_id gdb_main_spawn_id
global mi_spawn_id inferior_spawn_id
@@ -91,7 +93,63 @@ proc mi_uncatched_gdb_exit {} {
}
if ![is_remote host] {
- remote_close host
+ # The logic here should be similar to gdb.exp (default_gdb_exit).
+ # See comments/explanations in gdb.exp.
+
+ if { [info exists FORCE_LOCAL_GDB_QUIT_WAIT] } {
+
+ # # Send the interrupt request.
+ # if { $async } {
+ # mi_gdb_test "888-exec-interrupt" "888\\^done" "interrupt"
+ # } else {
+ # send_gdb "\003"
+ # }
+ # mi_expect_interrupt
+ # ??? no idea how to properly interrupt in mi mode.
+ # ??? and should we interrupt in mi mode ?
+
+ # Some mi tests are failing with time out, such as as mi-watch.exp,
+ # with:
+# (gdb)
+# PASS: gdb.mi/mi-watch.exp: mi-mode=separate: wp-type=hw: watchpoint trigger
+# 999-gdb-exit
+# 999^exit
+# =thread-exited,id="1",group-id="i1"
+# =thread-group-exited,id="i1"
+# FAIL: gdb.mi/mi-watch.exp: mi-mode=separate: wp-type=hw: mi quit timeout
+# Executing on host: kill -TERM 0 (timeout = 300)
+# spawn -ignore SIGHUP kill -TERM 0
+ # and I cannot see any difference with a succesful test,
+ # such as mi-return.exp:
+# PASS: gdb.mi/mi-eval.exp: eval A + 3
+# 999-gdb-exit
+# 999^exit
+# =thread-exited,id="1",group-id="i1"
+# =thread-group-exited,id="i1"
+# testcase /bd/home/philippe/gdb/git/build_obvious/gdb/testsuite/../../../obvious/gdb/testsuite/gdb.mi/mi-eval.exp completed in 0 seconds
+
+ send_gdb "999-gdb-exit\n"
+ gdb_expect 30 {
+ -re "y or n.*" {
+ send_gdb "y\n"
+ exp_continue
+ }
+ -re "Undefined command.*$gdb_prompt $" {
+ send_gdb "quit\n"
+ exp_continue
+ }
+ eof { }
+ timeout {
+ fail "mi force quit timeout"
+ set gdb_pid [spawn_id_get_pid $mi_spawn_id]
+ remote_exec host "kill -TERM $gdb_pid"
+ }
+ -re "DOSEXIT code" { }
+ }
+ # wait -i $gdb_spawn_id
+ } else {
+ remote_close host
+ }
}
unset gdb_spawn_id
unset gdb_main_spawn_id
--
2.19.2