+2015-04-07 Pedro Alves <palves@redhat.com>
+
+ * lib/gdb.exp (gdb_finish): Delete persistent gdbserver handling.
+ * lib/gdbserver-support.exp (gdbserver_start): Make
+ $server_spawn_id global.
+ (gdbserver_start): Don't wait for gdbserver's spawn id with
+ expect_background.
+ (close_gdbserver): New procedure.
+ (gdb_exit): Rename the default version and reimplement.
+
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_test_multiple): When processing an argument,
append gdbserver_command " $arguments"
}
+ global server_spawn_id
set server_spawn_id [remote_spawn target $gdbserver_command]
# Wait for the server to open its TCP socket, so that GDB can connect.
break
}
- # We can't just call close, because if gdbserver is local then that means
- # that it will get a SIGHUP. Doing it this way could also allow us to
- # get at the inferior's input or output if necessary, and means that we
- # don't need to redirect output.
- expect_background {
- -i $server_spawn_id
- full_buffer { }
- eof {
- # The spawn ID is already closed now (but not yet waited for).
- wait -i $expect_out(spawn_id)
- }
- }
-
return [list $protocol [$get_remote_address $debughost $portnum]]
}
return [gdbserver_start "" $arguments]
}
+# Close the GDBserver connection.
+
+proc close_gdbserver {} {
+ global server_spawn_id
+
+ # We can't just call close, because if gdbserver is local then that means
+ # that it will get a SIGHUP. Doing it this way could also allow us to
+ # get at the inferior's input or output if necessary, and means that we
+ # don't need to redirect output.
+
+ if {![info exists server_spawn_id]} {
+ return
+ }
+
+ verbose "Quitting GDBserver"
+
+ catch "close -i $server_spawn_id"
+ catch "wait -i $server_spawn_id"
+ unset server_spawn_id
+}
+
+# Hook into GDB exit, and close GDBserver.
+
+if { [info procs gdbserver_gdb_exit] == "" } {
+ rename gdb_exit gdbserver_orig_gdb_exit
+}
+proc gdb_exit {} {
+ global gdb_spawn_id server_spawn_id
+ global gdb_prompt
+
+ if {[info exists gdb_spawn_id] && [info exists server_spawn_id]} {
+ send_gdb "monitor exit\n";
+ gdb_expect {
+ -re "$gdb_prompt $" {
+ exp_continue
+ }
+ -i "$server_spawn_id" eof {
+ wait -i $expect_out(spawn_id)
+ unset server_spawn_id
+ }
+ }
+ }
+ close_gdbserver
+
+ gdbserver_orig_gdb_exit
+}
+
# Start a gdbserver process running HOST_EXEC and pass CHILD_ARGS
# to it. Return 0 on success, or non-zero on failure: 2 if gdbserver
# failed to start or 1 if we couldn't connect to it.