aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/boards/remote-stdio-gdbserver.exp
blob: ad7e046669b5c39f15e05c308867f1bf0238a3dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright 2011-2016 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This file is a dejagnu "board file" and is used to run the testsuite
# with a remotehost and gdbserver using stdio for communicating through
# ssh. Certain firewalls prevent gdbserver from using the usual mechanism of
# listening on a remote port, so use stdio via ssh instead.
#
# To use this file:
# bash$ cd ${build_dir}/gdb
# bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \
#    REMOTE_USERNAME=... REMOTE_HOSTNAME=... REMOTE_PORTNUM=... \
#    [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"

load_board_description "native-stdio-gdbserver"

# Test machine info. The generic_config gdbserver reads some of these
# values from board_info, so this file must set them there.
if [info exists REMOTE_USERNAME] {
    set_board_info username $REMOTE_USERNAME
} else {
    set_board_info username unspecified_username
}
if [info exists REMOTE_HOSTNAME] {
    set_board_info hostname $REMOTE_HOSTNAME
} else {
    set_board_info hostname unspecified_hostname
}

# The two programs have different syntax to set the remote port, so
# set it as part of the program name rather than in get_remote_login.

if [info exists REMOTE_PORTNUM] {
    set_board_info portnum $REMOTE_PORTNUM
    set_board_info rsh_prog "/usr/bin/ssh -p$REMOTE_PORTNUM"
    set_board_info rcp_prog "/usr/bin/scp -P$REMOTE_PORTNUM"
} else {
    set_board_info rsh_prog /usr/bin/ssh
    set_board_info rcp_prog /usr/bin/scp
}

# Some remote machines don't have writable home directories.
if [info exists REMOTE_TMPDIR] {
    set_board_info remotedir $REMOTE_TMPDIR
}

unset_board_info gdb_server_prog
set_board_info gdb_server_prog "/usr/bin/gdbserver"

# Used to pass a value between ${board}_spawn and ${board}_get_remote_address.
set stdio_gdbserver_command "--unset--"

proc get_remote_login { } {
    set result ""
    if {[board_info [target_info name] exists username]} {
	append result "[board_info [target_info name] username]@"
    }
    if {[board_info [target_info name] exists hostname]} {
	append result "[board_info [target_info name] hostname]"
    }
    return $result
}

proc ${board}_get_remote_address { host port } {
    global stdio_gdbserver_command
    set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
    return "| $rsh_cmd $stdio_gdbserver_command"
}

proc ${board}_get_comm_port { port } {
    return $port
}

proc ${board}_download { board host dest } {
    if { [board_info [target_info name] exists remotedir] } {
	set remotedir "[board_info [target_info name] remotedir]/"
    } else {
	set remotedir ""
    }
    return [standard_download $board $host "$remotedir$dest"]
}

proc ${board}_upload {dest srcfile args} {
    return [standard_upload $dest $srcfile $args]
}

proc ${board}_file { dest op args } {
    if { $op == "delete" } {
	return [remote_exec [get_remote_login] "rm -f $args"]
    }
    return [eval [list standard_file $dest $op] $args]
}