1 # Copyright 2015-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 remote gdbserver on localhost.
20 # bash$ cd ${build_dir}/gdb
21 # bash$ make check RUNTESTFLAGS="--target_board=remote-gdbserver-on-localhost
22 # [ REMOTE_TARGET_USERNAME=<remote_target_username> ]"
24 load_generic_config "gdbserver"
25 load_board_description "gdbserver-base"
27 # The sshd should be running on localhost and ssh key should be
28 # correctly set up that you ssh to localhost without having to type
30 set_board_info rcp_prog "/usr/bin/scp"
31 set_board_info rsh_prog "/usr/bin/ssh"
32 set_board_info protocol standard
33 if { [info exists REMOTE_TARGET_USERNAME] } {
34 set_board_info username $REMOTE_TARGET_USERNAME
36 set_board_info username $env(USER)
38 set_board_info hostname localhost
40 save_vars {rsh_cmd res} {
44 [board_info $board rsh_prog] \
45 -l [board_info $board username] \
46 [board_info $board hostname]]]
48 # Handle separate test account.
49 if { [board_info $board username] != $env(USER) } {
50 # We're pretending that some local user account is remote target.
51 # Make things a bit more realistic by restricting file permissions.
53 # Make sure remote target can't see files on build.
54 set res [remote_exec build "chmod go-rx $objdir"]
55 if { [lindex $res 0] != 0 } {
56 error "Couldn't remove permissions for $objdir on build"
59 # Make sure build can't see files on remote target.
60 set res [remote_exec build $rsh_cmd "chmod go-rx ."]
61 if { [lindex $res 0] != 0 } {
62 error "Couldn't remove permissions for . on target"
66 # Set remotedir by default, to force remote_download target to give an
68 set res [remote_exec build $rsh_cmd pwd]
69 if { [lindex $res 0] != 0 } {
70 error "Couldn't set remotedir using pwd"
72 set_board_info remotedir [string trim [lindex $res 1]]
75 proc ${board}_file { dest op args } {
77 set username [board_info $dest username]
79 if { $op == "absolute" } {
80 set file [lindex $args 0]
82 if { [file pathtype $file] == "relative" } {
83 # Make sure we get an absolute file name relative to home
84 # dir of $username, not $env(USER).
85 set pwd [regsub $::env(USER) $::env(HOME) $username]
86 set file [remote_file build join $pwd $file]
89 return [remote_file build $op $file]
92 # Fall back to standard_file.
93 return [standard_file $dest $op {*}$args]
96 proc ${board}_spawn { board cmd } {
99 set remote [board_info $board hostname]
100 set username [board_info $board username]
101 set RSH [board_info $board rsh_prog]
103 spawn $RSH -t -l $username $remote $cmd
104 set board_info($board,fileid) $spawn_id
108 # We will be using the standard GDB remote protocol
109 set_board_info gdb_protocol "remote"
111 # Use techniques appropriate to a stub
112 set_board_info use_gdb_stub 1
114 # This gdbserver can only run a process once per session.
115 set_board_info gdb,do_reload_on_run 1
117 # There's no support for argument-passing (yet).
118 set_board_info noargs 1
120 set_board_info exit_is_reliable 1