[PATCH v2] gdb: tests: set remotetimeout to gdb_load_timeout for remote targets

Mike Frysinger
2011-06-19T19:04:46Z

From: Jie Zhang <jie.zhang@analog.com>

Rather than relying on the default remotetimeout value (which might be
too small for some slower devices), use the existing gdb_load_timeout
config option to set it.

This adds two new helpers for getting/setting the remotetimout to keep
the new logic simple.

Signed-off-by: Jie Zhang <jie.zhang@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
v2
- turn the remotetimeout logic into get/set helpers

gdb/testsuite/config/monitor.exp | 16 +++++++++++++++-
gdb/testsuite/lib/gdb.exp | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/gdb/testsuite/config/monitor.exp b/gdb/testsuite/config/monitor.exp
index be98f1a..ca11600 100644
--- a/gdb/testsuite/config/monitor.exp
+++ b/gdb/testsuite/config/monitor.exp
@@ -226,6 +226,12 @@ proc gdb_load { arg } {
set loadtimeout 1600
}

+ if [is_remote target] {
+ set oldremotetimeout [get_remotetimeout]
+ set_remotetimeout $loadtimeout
+ }
+
+ set load_ok 0
send_gdb $command;
gdb_expect $loadtimeout {
-re "\[Ff\]ailed.*$gdb_prompt $" {
@@ -235,7 +241,7 @@ proc gdb_load { arg } {
}
-re "$gdb_prompt $" {
verbose "Loaded $farg into $GDB\n"
- return 0;
+ set load_ok 1
}
timeout {
if { $verbose > 1 } {
@@ -243,6 +249,14 @@ proc gdb_load { arg } {
}
}
}
+
+ if [is_remote target] {
+ set_remotetimeout $oldremotetimeout
+ }
+
+ if { $load_ok == 1 } {
+ return 0;
+ }
}

# Make sure we don't have an open connection to the target.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 9684724..ffc80af 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3614,6 +3614,42 @@ proc get_sizeof { type default } {
return [get_integer_valueof "sizeof (${type})" $default]
}

+proc get_remotetimeout { } {
+ global gdb_prompt
+ global decimal
+
+ send_gdb "show remotetimeout\n"
+ gdb_expect {
+ -re "Timeout limit to wait for target to respond is ($decimal).*$gdb_prompt $" {
+ return $expect_out(1,string);
+ }
+ timeout {
+ if { $verbose > 1 } {
+ perror "Timed out trying to get remotetimeout."
+ }
+ }
+ }
+
+ # Pick the default that gdb uses
+ return 300
+}
+
+proc set_remotetimeout { timeout } {
+ global gdb_prompt
+
+ send_gdb "set remotetimeout $timeout\n";
+ gdb_expect {
+ -re "$gdb_prompt $" {
+ verbose "Set remotetimeout to $timeout\n"
+ }
+ timeout {
+ if { $verbose > 1 } {
+ perror "Timed out trying to set remotetimeout."
+ }
+ }
+ }
+}
+
# Log gdb command line and script if requested.
if {[info exists TRANSCRIPT]} {
rename send_gdb real_send_gdb
--
1.7.5.3