binutils-gdb/gdb/testsuite/boards/remote-stdio-gdbserver.exp
Pedro Alves 739b3f1d8f Make native gdbserver boards no longer be "remote" (in DejaGnu terms)
This commit finally clears the "isremote" flag in the native-gdbserver
and native-stdio-gdbserver boards.  The goal is to make all "native"
boards be considered not remote in DejaGnu terms, like the
native-extended-gdbserver board is too.

DejaGnu automatically considers boards remote if their names don't
match the local hostname.  That means that native-gdbserver and
native-extended-gdbserver are considered remote by default by DejaGnu,
even though they run locally.  native-extended-gdbserver, however,
overrides its isremote flag to force it to be not remote.  So we are
in that weird state where native-gdbserver is considered remote, and
native-extended-gdbserver is considered not remote.

A recent set of commits fixed all the problems (and some more) exposed
by testing with --target_board=native-gdbserver and
--target_board=native-stdio-gdbserver with isremote forced off on
x86-64 GNU/Linux.  I believe we're good to go now.

The native-stdio-gdbserver.exp/remote-stdio-gdbserver.exp boards
required deep non-obvious modifications unfortunately...  The problem
is that if a board is not remote, then DejaGnu doesn't call
${board}_spawn / ${board}_exec at all, and the
native-stdio-gdbserver.exp board relies on those procedures being
called.  To fix that, this commit redesigns how the stdio boards hook
into the testing framework to spawn gdbserver.  IMO, this is a good
change anyway, because the way its done currently is a bit of a hack,
and the result turns out to be simpler, even.  With this commit, they
now no longer load the "gdbserver" generic config, and hook at the
mi_gdb_target_load/gdb_reload level instead, making them more like
traditional board files.

To share code between native-stdio-gdbserver.exp and
remote-stdio-gdbserver.exp, a new shared stdio-gdbserver-base.exp file
is created.

Instead of having each native board clear isremote manually, boards
source the new "local-board.exp" file.

This also adds a new section to testsuite/README file discussing
local/remote/native, so that we can easily refer to it.

gdb/testsuite/ChangeLog:
2017-10-16  Pedro Alves  <palves@redhat.com>
	    Simon Marchi  <simon.marchi@polymtl.ca>

	* README (Local vs Remote vs Native): New section.
	* boards/local-board.exp: New file, with bits factored out from
	...
	* boards/native-extended-gdbserver.exp: ... here.  Load
	"local-board".
	* boards/native-gdbserver.exp: Load "local-board".
	(${board}_spawn, ${board}_exec): Delete.
	* boards/native-stdio-gdbserver.exp: Most contents factored out to
	...
	* boards/stdio-gdbserver-base.exp: ... this new file.
	* boards/native-stdio-gdbserver.exp: Reimplement, by loading
	"stdio-gdbserver-base" and defining a get_target_remote_pipe_cmd
	procedure.
	* boards/remote-stdio-gdbserver.exp: Load stdio-gdbserver-base
	instead of native-stdio-gdbserver.  Don't set gdb_server_prog nor
	stdio_gdbserver_command.
	(${board}_get_remote_address, ${board}_get_comm_port)
	(${board}_download, ${board}_upload): Delete.
	(get_target_remote_pipe_cmd): New.
2017-10-16 20:24:21 +01:00

82 lines
2.9 KiB
Plaintext

# Copyright 2011-2017 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 "stdio-gdbserver-base"
# 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
}
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 get_target_remote_pipe_cmd { } {
set target_exec [gdbserver_download_current_prog]
set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
return "$rsh_cmd /usr/bin/gdbserver --once stdio $target_exec"
}
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]
}