aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp5
-rw-r--r--gdb/testsuite/lib/gdbserver-support.exp17
2 files changed, 22 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 761624f..805b7a2 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2809,6 +2809,11 @@ proc gdb_init { args } {
# especially having color output turned on can cause tests to fail.
setenv GREP_OPTIONS ""
+ # Clear $gdbserver_reconnect_p.
+ global gdbserver_reconnect_p
+ set gdbserver_reconnect_p 1
+ unset gdbserver_reconnect_p
+
return [eval default_gdb_init $args];
}
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 3a098ae..aeeb585 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -218,10 +218,21 @@ proc gdbserver_start { options arguments } {
# Fire off the debug agent.
set gdbserver_command "$gdbserver"
+
+ # If gdbserver_reconnect will be called $gdbserver_reconnect_p must be
+ # set to true already during gdbserver_start.
+ global gdbserver_reconnect_p
+ if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
+ # GDB client could accidentally connect to a stale server.
+ append gdbserver_command " --once"
+ }
+
if { $options != "" } {
append gdbserver_command " $options"
}
+
append gdbserver_command " :$portnum"
+
if { $arguments != "" } {
append gdbserver_command " $arguments"
}
@@ -315,6 +326,12 @@ proc gdbserver_reconnect { } {
global gdbserver_protocol
global gdbserver_gdbport
+ global gdbserver_reconnect_p;
+ if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
+ error "gdbserver_reconnect_p is not set before gdbserver_reconnect"
+ return 0
+ }
+
return [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
}