]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/boards/remote-stdio-gdbserver.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / boards / remote-stdio-gdbserver.exp
1 # Copyright 2011-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
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.
20 #
21 # To use this file:
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}]"
26
27 load_board_description "stdio-gdbserver-base"
28
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
33 } else {
34 set_board_info username unspecified_username
35 }
36 if [info exists REMOTE_HOSTNAME] {
37 set_board_info hostname $REMOTE_HOSTNAME
38 } else {
39 set_board_info hostname unspecified_hostname
40 }
41
42 set_board_info rsh_prog /usr/bin/ssh
43 set_board_info rcp_prog /usr/bin/scp
44
45 # Some remote machines don't have writable home directories.
46 if [info exists REMOTE_TMPDIR] {
47 set_board_info remotedir $REMOTE_TMPDIR
48 } else {
49 # Set remotedir by default, to force remote_download target to give an
50 # absolute file name.
51 save_vars {rsh_cmd res} {
52 set rsh_cmd \
53 [join \
54 [list \
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"
61 }
62 set_board_info remotedir [string trim [lindex $res 1]]
63 }
64 }
65
66 if [info exists GDBSERVER] {
67 unset_board_info gdb_server_prog
68 set_board_info gdb_server_prog $GDBSERVER
69 }
70
71 proc get_remote_login { } {
72 set result ""
73 if {[board_info [target_info name] exists username]} {
74 append result "[board_info [target_info name] username]@"
75 }
76 if {[board_info [target_info name] exists hostname]} {
77 append result "[board_info [target_info name] hostname]"
78 }
79 return $result
80 }
81
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"
87 }
88
89 proc ${board}_spawn { board cmd } {
90 global board_info
91
92 set remote [board_info $board hostname]
93 set username [board_info $board username]
94 set RSH [board_info $board rsh_prog]
95
96 spawn $RSH -t -l $username $remote $cmd
97 set board_info($board,fileid) $spawn_id
98 return $spawn_id
99 }