diff mbox

Allow board file to specify remotetimeout

Message ID m3zjc3akn2.fsf@sspiff.org
State New
Headers show

Commit Message

Doug Evans Nov. 7, 2014, 1:01 a.m. UTC
Hi.

I was cross-testing from linux to windows7 with stdio gdbserver,
and ssh was taking longer to connect than the default remotetimeout
of 2 seconds.

This patch adds the ability to specify remotetimeout in the board file.

For reference sake, here's my board file.

---snip---
# To use this file:
# bash$ cd ${build_dir}/gdb
# bash$ make check RUNTESTFLAGS="--target_board=win7"
#
# gdbserver running over ssh.

set REMOTE_HOSTNAME win7
set REMOTE_USERNAME dje
set REMOTE_PORTNUM 22
set REMOTE_TMPDIR /tmp

load_board_description "remote-stdio-gdbserver"

# Path to the gdbserver executable.
unset_board_info gdb_server_prog
set_board_info gdb_server_prog "/usr/bin/gdbserver.exe"

# It takes a few seconds to establish the ssh session.
set_board_info gdb,remotetimeout 15
---snip---

2014-11-06  Doug Evans  <xdje42@gmail.com>

	* README: Document gdb,remotetimeout.
	* lib/gdbserver-support.exp (gdb_target_cmd): Apply remotetimeout if
	specified in board description.
	* lib/mi-support.exp (mi_gdb_target_cmd): Ditto.

Comments

Pedro Alves Nov. 7, 2014, 10:21 a.m. UTC | #1
On 11/07/2014 01:01 AM, Doug Evans wrote:

> I was cross-testing from linux to windows7 with stdio gdbserver,
> and ssh was taking longer to connect than the default remotetimeout
> of 2 seconds.
> 
> This patch adds the ability to specify remotetimeout in the board file.
> 
> For reference sake, here's my board file.

Note you can already put

 set GDBFLAGS "-l 15"

in the board file for this.  See:

https://sourceware.org/gdb/wiki/TestingGDB#Running_GDB_with_a_larger_remote_serial_protocol_timeout

Is there an advantage to this method?

Thanks,
Pedro Alves
Doug Evans Nov. 7, 2014, 3:25 p.m. UTC | #2
On Fri, Nov 7, 2014 at 2:21 AM, Pedro Alves <palves@redhat.com> wrote:
> On 11/07/2014 01:01 AM, Doug Evans wrote:
>
>> I was cross-testing from linux to windows7 with stdio gdbserver,
>> and ssh was taking longer to connect than the default remotetimeout
>> of 2 seconds.
>>
>> This patch adds the ability to specify remotetimeout in the board file.
>>
>> For reference sake, here's my board file.
>
> Note you can already put
>
>  set GDBFLAGS "-l 15"
>
> in the board file for this.  See:
>
> https://sourceware.org/gdb/wiki/TestingGDB#Running_GDB_with_a_larger_remote_serial_protocol_timeout
>
> Is there an advantage to this method?

Yeah, it's documented in testsuite/README so I'll find it next time.  1/2 :-)

I'd long since forgotten about the wiki page.
Having both places being reasonably large, and neither having a reference
to the other, is unfortunate.
[The README mentions the wiki, but without an explicit link
it's not that helpful.]

I'd be happy with gutting testsuite/README and just mentioning the wiki url.
Thoughts?
Pedro Alves Nov. 7, 2014, 4:47 p.m. UTC | #3
On 11/07/2014 03:25 PM, Doug Evans wrote:
> On Fri, Nov 7, 2014 at 2:21 AM, Pedro Alves <palves@redhat.com> wrote:

>> Is there an advantage to this method?
> 
> Yeah, it's documented in testsuite/README so I'll find it next time.  1/2 :-)
> 

:-)

> I'd long since forgotten about the wiki page.
> Having both places being reasonably large, and neither having a reference
> to the other, is unfortunate.
> [The README mentions the wiki, but without an explicit link
> it's not that helpful.]
> 
> I'd be happy with gutting testsuite/README and just mentioning the wiki url.
> Thoughts?

I  ( still [1] ) prefer having the testsuite/README file in the tree
documenting the variables that the testsuite supports, because
those are tied to the specific GDB version in the tree, while
the (whole) wiki doesn't really distinguish that.  IMO, the
wiki serves best for "recipes" and tips.

It looks like testsuite/README doesn't document GDBFLAGS though.
How about we fix that, and use 'set GDBFLAGS "-l 15"' as the
example?

I think the "Writing Tests" section of README could/should be
moved to the wiki, though, e.g., to the GDBTestcaseCookbook page.

[1] https://sourceware.org/ml/gdb-patches/2013-09/msg00192.html

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/testsuite/README b/gdb/testsuite/README
index 9a5059a..0e4b73c 100644
--- a/gdb/testsuite/README
+++ b/gdb/testsuite/README
@@ -367,6 +367,10 @@  gdb,predefined_tsv
 
   The predefined trace state variables the board has.
 
+gdb,remotetimeout
+
+  The value for gdb's "remotetimeout" parameter, for use with gdbserver.
+
 
 Testsuite Organization
 **********************
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 026a937..b99a594 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -39,6 +39,8 @@ 
 #	After GDB starts you should check global $gdbserver_gdbport for the
 #	real port used.  It is not useful if $gdbserver_reconnect_p was not set.
 #
+#   set_board_info gdb,remotetimeout
+#	The value for gdb's "remotetimeout" parameter.
 
 #
 # gdb_target_cmd
@@ -47,6 +49,11 @@ 
 proc gdb_target_cmd { targetname serialport } {
     global gdb_prompt
 
+    if [target_info exists gdb,remotetimeout] {
+	set remotetimeout [target_info gdb,remotetimeout]
+	gdb_test_no_output "set remotetimeout $remotetimeout"
+    }
+
     set serialport_re [string_to_regexp $serialport]
     for {set i 1} {$i <= 3} {incr i} {
 	send_gdb "target $targetname $serialport\n"
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index a7f7aef..0437fa5 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -335,6 +335,19 @@  proc mi_gdb_reinitialize_dir { subdir } {
 proc mi_gdb_target_cmd { targetname serialport } {
     global mi_gdb_prompt
 
+    if [target_info exists gdb,remotetimeout] {
+	set remotetimeout [target_info gdb,remotetimeout]
+	send_gdb "46-gdb-set remotetimeout $remotetimeout\n"
+	gdb_expect 10 {
+	    -re ".*46-gdb-set remotetimeout $remotetimeout\r\n46\\\^done\r\n$mi_gdb_prompt$" {
+		verbose "Setting remotetimeout to $remotetimeout." 2
+	    }
+	    timeout {
+		warning "Couldn't set remotetimeout to $remotetimeout."
+	    }
+	}
+    }
+
     set serialport_re [string_to_regexp $serialport]
     for {set i 1} {$i <= 3} {incr i} {
 	send_gdb "47-target-select $targetname $serialport\n"