+2020-04-02 Tom de Vries <tdevries@suse.de>
+
+ * lib/gdbserver-support.exp (gdbserver_exit): Factor out of ...
+ (gdbserver_gdb_exit): ... here. Add timeout warning.
+ * gdb.multi/multi-target.exp (server_spawn_ids): New global var.
+ (connect_target_extended_remote): Append new server_spawn_id to
+ server_spawn_ids.
+ (cleanup): New proc.
+ (setup, <toplevel>): Call cleanup.
+
2020-04-02 Tom de Vries <tdevries@suse.de>
* gdb.base/main-psymtab.exp: New file.
return
}
-proc connect_target_extended_remote {binfile} {
+# Keep a list of (inferior ID, spawn ID).
+set server_spawn_ids [list]
+
+proc connect_target_extended_remote {binfile num} {
set res [gdbserver_start "--multi" ""]
+ global server_spawn_ids server_spawn_id
+ lappend server_spawn_ids $num $server_spawn_id
set gdbserver_gdbport [lindex $res 1]
return [gdb_target_cmd "extended-remote" $gdbserver_gdbport]
}
}
if {$target == "extended-remote"} {
- if {[connect_target_extended_remote $binfile]} {
+ if {[connect_target_extended_remote $binfile $num]} {
return 0
}
}
return $inf
}
+# Clean up the server_spawn_ids.
+proc cleanup_gdbservers { } {
+ global server_spawn_id
+ global server_spawn_ids
+ foreach { inferior_id spawn_id } $server_spawn_ids {
+ set server_spawn_id $spawn_id
+ gdb_test "inferior $inferior_id"
+ gdbserver_exit 0
+ }
+ set server_spawn_ids [list]
+}
+
# Return true on success, false otherwise.
proc setup {non-stop} {
global gcorefile gcore_created
global binfile
+ cleanup_gdbservers
clean_restart ${binfile}
# multi-target depends on target running in non-stop mode. Force
test_info_inferiors $multi_process
}
}
+
+cleanup_gdbservers
rename mi_gdb_exit gdbserver_orig_mi_gdb_exit
}
-proc gdbserver_gdb_exit { is_mi } {
+# Cleanup gdbserver $server_spawn_id
+
+proc gdbserver_exit { is_mi } {
global gdb_spawn_id server_spawn_id
global gdb_prompt
- global gdbserver_reconnect_p
-
- # Leave GDBserver running if we're exiting GDB in order to
- # reconnect to the same instance of GDBserver again.
- if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} {
- if { $is_mi } {
- gdbserver_orig_mi_gdb_exit
- } else {
- gdbserver_orig_gdb_exit
- }
- return
- }
if {[info exists gdb_spawn_id] && [info exists server_spawn_id]} {
# GDB may be terminated in an expected way or an unexpected way,
wait -i $expect_out(spawn_id)
unset server_spawn_id
}
+ timeout {
+ warning "Timed out waiting for EOF in server after $monitor_exit"
+ }
}
}
}
close_gdbserver
+}
+
+# Local version of gdb_exit that also cleans up gdbserver $server_spawn_id.
+
+proc gdbserver_gdb_exit { is_mi } {
+ global gdb_spawn_id server_spawn_id
+ global gdb_prompt
+ global gdbserver_reconnect_p
+
+ # Leave GDBserver running if we're exiting GDB in order to
+ # reconnect to the same instance of GDBserver again.
+ if {[info exists gdbserver_reconnect_p] && $gdbserver_reconnect_p} {
+ if { $is_mi } {
+ gdbserver_orig_mi_gdb_exit
+ } else {
+ gdbserver_orig_gdb_exit
+ }
+ return
+ }
+
+ gdbserver_exit $is_mi
if { $is_mi } {
gdbserver_orig_mi_gdb_exit