gdb_test "echo hello\\n" "hello" "interact with GDB's main UI"
}
+# Get the gdbserver PID.
+set gdbserver_pid 0
+with_spawn_id $gdb_main_spawn_id {
+ gdb_test "interrupt"
+
+ gdb_test_multiple "" "interrupt arrived" {
+ -re "Program received signal SIGINT, Interrupt\\.\r\n" {
+ pass $gdb_test_name
+ }
+ }
+
+ gdb_test_multiple "p server_pid" "" {
+ -re -wrap " = ($decimal)" {
+ set gdbserver_pid $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ gdb_test_multiple continue "" {
+ -re "Continuing\\.\r\n" {
+ pass $gdb_test_name
+ }
+ }
+}
+
+if { $gdbserver_pid == 0 } {
+ return
+}
+
# Now kill the gdbserver.
remote_exec target "kill -9 $gdbserver_pid"
return -1
}
+set target_binfile [gdb_remote_download target $binfile]
+
# Start gdbserver.
-set res [gdbserver_spawn "${binfile}"]
+set res [gdbserver_spawn "${target_binfile}"]
set gdbserver_protocol [lindex $res 0]
set gdbserver_gdbport [lindex $res 1]
set gdbserver_pid [exp_pid -i $server_spawn_id]
+set break_linenr [gdb_get_line_number "@@XX@@ Inferior Starting @@XX@@"]
+
# Generate a python script we will later source.
set file1 [standard_output_file file1.py]
set fd [open "$file1" w]
def do_gdb_stuff ():
gdb.execute ('target $gdbserver_protocol $gdbserver_gdbport')
+ gdb.execute ('break $srcfile:$break_linenr')
+ gdb.execute ('continue')
+ gdb.execute ('p server_pid')
gdb.execute ('continue')
do_gdb_stuff()"
return
}
+# Get the gdbserver PID.
+set gdbserver_pid 0
+
# Wait for the inferior to start up.
with_spawn_id $server_spawn_id {
+ gdb_test_multiple "" "get gdbserver PID" {
+ -re " = ($decimal)\r\n" {
+ set gdbserver_pid $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ if { $gdbserver_pid == 0 } {
+ return
+ }
+
gdb_test_multiple "" "ensure inferior is running" {
-re "@@XX@@ Inferior Starting @@XX@@" {
pass $gdb_test_name