Home | History | Annotate | Line # | Download | only in boards
      1  1.9  christos # Copyright 2014-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 # against local host, in remote host mode.
     18  1.1  christos #
     19  1.1  christos # This board file is used to emulate the real remote host testing, in
     20  1.1  christos # which file system of host and build are not shared.  This is achieved
     21  1.1  christos # by copying files from source directory to ${host_dir}.
     22  1.1  christos #
     23  1.1  christos # To use this file:
     24  1.1  christos # bash$ cd ${build_dir}/gdb
     25  1.1  christos # bash$ make check RUNTESTFLAGS="--host_board=local-remote-host-native --target_board=local-remote-host-native HOST_DIR=/tmp/foo/"
     26  1.1  christos #
     27  1.1  christos # We set both target board and host board together to test a native gdb
     28  1.1  christos # (host == target) on a remote host (host != build).  $HOST_DIR is the
     29  1.1  christos # directory for copying files to, to avoid messing up your HOME.  When
     30  1.1  christos # it is absent, files are copied to ./remote-host.
     31  1.1  christos 
     32  1.1  christos if { $board_type == "target" } {
     33  1.1  christos     set_board_info compiler gcc
     34  1.1  christos }
     35  1.1  christos 
     36  1.1  christos # We have to explicitly specify GDB with the path to the copy in
     37  1.1  christos # the build directory because otherwise it will be set to the
     38  1.1  christos # result of "transform GDB" since the harness thinks we're using
     39  1.1  christos # a remote host.  See lib/gdb.exp.
     40  1.1  christos set GDB [file join [pwd] "../gdb"]
     41  1.1  christos verbose -log "Overriding setting of GDB to $GDB"
     42  1.1  christos 
     43  1.9  christos set_board_info hostname localhost
     44  1.1  christos 
     45  1.1  christos set_board_info username $env(USER)
     46  1.1  christos 
     47  1.9  christos save_vars {rsh_cmd res} {
     48  1.9  christos     set rsh_cmd \
     49  1.9  christos 	[join \
     50  1.9  christos 	     [list \
     51  1.9  christos 		  [board_info $board rsh_prog] \
     52  1.9  christos 		  -l [board_info $board username] \
     53  1.9  christos 		  [board_info $board hostname]]]
     54  1.9  christos 
     55  1.9  christos     if [info exists HOST_DIR] {
     56  1.9  christos 	set_board_info remotedir $HOST_DIR
     57  1.9  christos     } else {
     58  1.9  christos 	# Set remotedir by default, to force remote_download target to give an
     59  1.9  christos 	# absolute file name.
     60  1.9  christos 	set res [remote_exec build $rsh_cmd pwd]
     61  1.9  christos 	if { [lindex $res 0] != 0 } {
     62  1.9  christos 	    error "Couldn't set remotedir using pwd"
     63  1.9  christos 	}
     64  1.9  christos 	set_board_info remotedir [string trim [lindex $res 1]]
     65  1.9  christos     }
     66  1.9  christos }
     67  1.9  christos 
     68  1.9  christos # The ssh key should be correctly set up that you ssh to localhost
     69  1.1  christos # without having to type password.
     70  1.1  christos set_board_info rsh_prog /usr/bin/ssh
     71  1.1  christos set_board_info rcp_prog /usr/bin/scp
     72  1.1  christos set_board_info file_transfer "rsh"
     73  1.1  christos 
     74  1.1  christos if { $board_type == "host" } {
     75  1.1  christos     set_board_info gdb_opts "-d \"${HOST_DIR}\""
     76  1.1  christos }
     77  1.1  christos 
     78  1.1  christos proc ${board}_spawn { board cmd } {
     79  1.1  christos     global board_info
     80  1.1  christos 
     81  1.1  christos     set remote [board_info $board hostname]
     82  1.1  christos     set username [board_info $board username]
     83  1.1  christos     set RSH [board_info $board rsh_prog]
     84  1.1  christos 
     85  1.1  christos     spawn $RSH -t -l $username $remote $cmd
     86  1.1  christos 
     87  1.9  christos     if { [string match "$::GDB*" $cmd] } {
     88  1.9  christos 	set board_info($board,fileid) $spawn_id
     89  1.1  christos     }
     90  1.1  christos 
     91  1.9  christos     return $spawn_id
     92  1.1  christos }
     93  1.8  christos 
     94  1.8  christos if { $board_type == "host" } {
     95  1.8  christos     set GDBFLAGS "${GDBFLAGS} -iex \"set style enabled off\""
     96  1.8  christos }
     97