Home | History | Annotate | Line # | Download | only in boards
      1  1.11  christos # Copyright 2011-2024 Free Software Foundation, Inc.
      2   1.1  christos 
      3   1.1  christos # This program is free software; you can redistribute it and/or modify
      4   1.1  christos # it under the terms of the GNU General Public License as published by
      5   1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6   1.1  christos # (at your option) any later version.
      7   1.1  christos #
      8   1.1  christos # This program is distributed in the hope that it will be useful,
      9   1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10   1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11   1.1  christos # GNU General Public License for more details.
     12   1.1  christos #
     13   1.1  christos # You should have received a copy of the GNU General Public License
     14   1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15   1.1  christos 
     16   1.1  christos # This file is a dejagnu "board file" and is used to run the testsuite
     17   1.1  christos # with a remotehost and gdbserver using stdio for communicating through
     18   1.1  christos # ssh. Certain firewalls prevent gdbserver from using the usual mechanism of
     19   1.1  christos # listening on a remote port, so use stdio via ssh instead.
     20   1.1  christos #
     21   1.1  christos # To use this file:
     22   1.1  christos # bash$ cd ${build_dir}/gdb
     23   1.1  christos # bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \
     24  1.10  christos #    REMOTE_USERNAME=... REMOTE_HOSTNAME=... \
     25   1.1  christos #    [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"
     26   1.1  christos 
     27   1.8  christos load_board_description "stdio-gdbserver-base"
     28   1.1  christos 
     29   1.1  christos # Test machine info. The generic_config gdbserver reads some of these
     30   1.1  christos # values from board_info, so this file must set them there.
     31   1.1  christos if [info exists REMOTE_USERNAME] {
     32   1.1  christos     set_board_info username $REMOTE_USERNAME
     33   1.1  christos } else {
     34   1.1  christos     set_board_info username unspecified_username
     35   1.1  christos }
     36   1.1  christos if [info exists REMOTE_HOSTNAME] {
     37   1.1  christos     set_board_info hostname $REMOTE_HOSTNAME
     38   1.1  christos } else {
     39   1.1  christos     set_board_info hostname unspecified_hostname
     40   1.1  christos }
     41   1.1  christos 
     42  1.10  christos set_board_info rsh_prog /usr/bin/ssh
     43  1.10  christos set_board_info rcp_prog /usr/bin/scp
     44   1.1  christos 
     45   1.1  christos # Some remote machines don't have writable home directories.
     46   1.1  christos if [info exists REMOTE_TMPDIR] {
     47   1.1  christos     set_board_info remotedir $REMOTE_TMPDIR
     48  1.11  christos } else {
     49  1.11  christos     # Set remotedir by default, to force remote_download target to give an
     50  1.11  christos     # absolute file name.
     51  1.11  christos     save_vars {rsh_cmd res} {
     52  1.11  christos 	set rsh_cmd \
     53  1.11  christos 	    [join \
     54  1.11  christos 		 [list \
     55  1.11  christos 		      [board_info $board rsh_prog] \
     56  1.11  christos 		      -l [board_info $board username] \
     57  1.11  christos 		      [board_info $board hostname]]]
     58  1.11  christos 	set res [remote_exec build $rsh_cmd pwd]
     59  1.11  christos 	if { [lindex $res 0] != 0 } {
     60  1.11  christos 	    error "Couldn't set remotedir using pwd"
     61  1.11  christos 	}
     62  1.11  christos 	set_board_info remotedir [string trim [lindex $res 1]]
     63  1.11  christos     }
     64   1.1  christos }
     65   1.1  christos 
     66  1.10  christos if [info exists GDBSERVER] {
     67  1.11  christos     unset_board_info gdb_server_prog
     68  1.10  christos     set_board_info gdb_server_prog $GDBSERVER
     69  1.10  christos }
     70  1.10  christos 
     71   1.1  christos proc get_remote_login { } {
     72   1.1  christos     set result ""
     73   1.1  christos     if {[board_info [target_info name] exists username]} {
     74   1.1  christos 	append result "[board_info [target_info name] username]@"
     75   1.1  christos     }
     76   1.1  christos     if {[board_info [target_info name] exists hostname]} {
     77   1.1  christos 	append result "[board_info [target_info name] hostname]"
     78   1.1  christos     }
     79   1.1  christos     return $result
     80   1.1  christos }
     81   1.1  christos 
     82   1.8  christos proc get_target_remote_pipe_cmd { } {
     83   1.8  christos     set target_exec [gdbserver_download_current_prog]
     84   1.1  christos     set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
     85  1.10  christos     set gdbserver "[board_info [target_info name] gdb_server_prog]"
     86  1.10  christos     return "$rsh_cmd $gdbserver --once stdio $target_exec"
     87   1.1  christos }
     88   1.1  christos 
     89  1.10  christos proc ${board}_spawn { board cmd } {
     90  1.10  christos     global board_info
     91  1.10  christos 
     92  1.10  christos     set remote [board_info $board hostname]
     93  1.10  christos     set username [board_info $board username]
     94  1.10  christos     set RSH [board_info $board rsh_prog]
     95  1.10  christos 
     96  1.10  christos     spawn $RSH -t -l $username $remote $cmd
     97  1.10  christos     set board_info($board,fileid) $spawn_id
     98  1.10  christos     return $spawn_id
     99  1.10  christos }
    100