]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / boards / remote-gdbserver-on-localhost.exp
1 # Copyright 2015-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 remote gdbserver on localhost.
18 #
19 # To use this file:
20 # bash$ cd ${build_dir}/gdb
21 # bash$ make check RUNTESTFLAGS="--target_board=remote-gdbserver-on-localhost
22 # [ REMOTE_TARGET_USERNAME=<remote_target_username> ]"
23
24 load_generic_config "gdbserver"
25 load_board_description "gdbserver-base"
26
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
29 # password.
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
35 } else {
36 set_board_info username $env(USER)
37 }
38 set_board_info hostname localhost
39
40 save_vars {rsh_cmd res} {
41 set rsh_cmd \
42 [join \
43 [list \
44 [board_info $board rsh_prog] \
45 -l [board_info $board username] \
46 [board_info $board hostname]]]
47
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.
52
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"
57 }
58
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"
63 }
64 }
65
66 # Set remotedir by default, to force remote_download target to give an
67 # absolute file name.
68 set res [remote_exec build $rsh_cmd pwd]
69 if { [lindex $res 0] != 0 } {
70 error "Couldn't set remotedir using pwd"
71 }
72 set_board_info remotedir [string trim [lindex $res 1]]
73 }
74
75 proc ${board}_file { dest op args } {
76 global board_info
77 set username [board_info $dest username]
78
79 if { $op == "absolute" } {
80 set file [lindex $args 0]
81
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]
87 }
88
89 return [remote_file build $op $file]
90 }
91
92 # Fall back to standard_file.
93 return [standard_file $dest $op {*}$args]
94 }
95
96 proc ${board}_spawn { board cmd } {
97 global board_info
98
99 set remote [board_info $board hostname]
100 set username [board_info $board username]
101 set RSH [board_info $board rsh_prog]
102
103 spawn $RSH -t -l $username $remote $cmd
104 set board_info($board,fileid) $spawn_id
105 return $spawn_id
106 }
107
108 # We will be using the standard GDB remote protocol
109 set_board_info gdb_protocol "remote"
110
111 # Use techniques appropriate to a stub
112 set_board_info use_gdb_stub 1
113
114 # This gdbserver can only run a process once per session.
115 set_board_info gdb,do_reload_on_run 1
116
117 # There's no support for argument-passing (yet).
118 set_board_info noargs 1
119
120 set_board_info exit_is_reliable 1