1 # Copyright 2011-2014 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # This file is a dejagnu "board file" and is used to run the testsuite
17 # with a remotehost and gdbserver using stdio for communicating through
18 # ssh. Certain firewalls prevent gdbserver from using the usual mechanism of
19 # listening on a remote port, so use stdio via ssh instead.
22 # bash$ cd ${build_dir}/gdb
23 # bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \
24 # REMOTE_USERNAME=... REMOTE_HOSTNAME=... REMOTE_PORTNUM=... \
25 # [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"
27 load_board_description "native-stdio-gdbserver"
29 # Test machine info. The generic_config gdbserver reads some of these
30 # values from board_info, so this file must set them there.
31 if [info exists REMOTE_USERNAME] {
32 set_board_info username $REMOTE_USERNAME
34 set_board_info username unspecified_username
36 if [info exists REMOTE_HOSTNAME] {
37 set_board_info hostname $REMOTE_HOSTNAME
39 set_board_info hostname unspecified_hostname
42 # The two programs have different syntax to set the remote port, so
43 # set it as part of the program name rather than in get_remote_login.
45 if [info exists REMOTE_PORTNUM] {
46 set_board_info portnum $REMOTE_PORTNUM
47 set_board_info rsh_prog "/usr/bin/ssh -p$REMOTE_PORTNUM"
48 set_board_info rcp_prog "/usr/bin/scp -P$REMOTE_PORTNUM"
50 set_board_info rsh_prog /usr/bin/ssh
51 set_board_info rcp_prog /usr/bin/scp
54 # Some remote machines don't have writable home directories.
55 if [info exists REMOTE_TMPDIR] {
56 set_board_info remotedir $REMOTE_TMPDIR
59 unset_board_info gdb_server_prog
60 set_board_info gdb_server_prog "/usr/bin/gdbserver"
62 # Used to pass a value between ${board}_spawn and ${board}_get_remote_address.
63 set stdio_gdbserver_command "--unset--"
65 proc get_remote_login { } {
67 if {[board_info [target_info name] exists username]} {
68 append result "[board_info [target_info name] username]@"
70 if {[board_info [target_info name] exists hostname]} {
71 append result "[board_info [target_info name] hostname]"
76 proc ${board}_build_remote_cmd { cmd } {
77 set stdio_gdbserver_template "| @RSH_CMD@ @GDBSERVER_PROG@ @ARGS@ stdio @PROG_AND_ARGS@"
79 # First parse $cmd, picking out the various pieces.
80 set gdbserver_prog [lindex $cmd 0]
82 set len [llength $cmd]
84 for { set i 1 } { $i < $len } { incr i } {
85 set elm [lindex $cmd $i]
99 set prog_and_args [lrange $cmd $i end]
101 set buf $stdio_gdbserver_template
103 set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
104 regsub {@RSH_CMD@} $buf $rsh_cmd buf
105 regsub {@GDBSERVER_PROG@} $buf $gdbserver_prog buf
106 regsub {@ARGS@} $buf $args buf
107 regsub {@PROG_AND_ARGS@} $buf $prog_and_args buf
112 proc ${board}_download { board host dest } {
113 if { [board_info [target_info name] exists remotedir] } {
114 set remotedir "[board_info [target_info name] remotedir]/"
118 return [standard_download $board $host "$remotedir$dest"]
121 proc ${board}_upload {dest srcfile args} {
122 return [standard_upload $dest $srcfile $args]
125 proc ${board}_file { dest op args } {
126 if { $op == "delete" } {
127 return [remote_exec [get_remote_login] "rm -f $args"]
129 return [eval [list standard_file $dest $op] $args]