1 # Copyright 2011-2024 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=... \
25 # [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"
27 load_board_description "stdio-gdbserver-base"
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 set_board_info rsh_prog /usr/bin/ssh
43 set_board_info rcp_prog /usr/bin/scp
45 # Some remote machines don't have writable home directories.
46 if [info exists REMOTE_TMPDIR] {
47 set_board_info remotedir $REMOTE_TMPDIR
49 # Set remotedir by default, to force remote_download target to give an
51 save_vars {rsh_cmd res} {
55 [board_info $board rsh_prog] \
56 -l [board_info $board username] \
57 [board_info $board hostname]]]
58 set res [remote_exec build $rsh_cmd pwd]
59 if { [lindex $res 0] != 0 } {
60 error "Couldn't set remotedir using pwd"
62 set_board_info remotedir [string trim [lindex $res 1]]
66 if [info exists GDBSERVER] {
67 unset_board_info gdb_server_prog
68 set_board_info gdb_server_prog $GDBSERVER
71 proc get_remote_login { } {
73 if {[board_info [target_info name] exists username]} {
74 append result "[board_info [target_info name] username]@"
76 if {[board_info [target_info name] exists hostname]} {
77 append result "[board_info [target_info name] hostname]"
82 proc get_target_remote_pipe_cmd { } {
83 set target_exec [gdbserver_download_current_prog]
84 set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
85 set gdbserver "[board_info [target_info name] gdb_server_prog]"
86 return "$rsh_cmd $gdbserver --once stdio $target_exec"
89 proc ${board}_spawn { board cmd } {
92 set remote [board_info $board hostname]
93 set username [board_info $board username]
94 set RSH [board_info $board rsh_prog]
96 spawn $RSH -t -l $username $remote $cmd
97 set board_info($board,fileid) $spawn_id