mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
739b3f1d8f
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.
148 lines
4.2 KiB
Plaintext
148 lines
4.2 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
|
|
# natively with gdbserver, in extended-remote mode.
|
|
#
|
|
# To use this file:
|
|
# bash$ cd ${build_dir}/gdb
|
|
# bash$ make check RUNTESTFLAGS="--target_board=native-extended-gdbserver"
|
|
|
|
load_generic_config "extended-gdbserver"
|
|
load_board_description "gdbserver-base"
|
|
load_board_description "local-board"
|
|
|
|
set_board_info sockethost "localhost:"
|
|
|
|
# We will be using the extended GDB remote protocol.
|
|
set_board_info gdb_protocol "extended-remote"
|
|
|
|
send_user "configuring for gdbserver local testing (extended-remote)\n"
|
|
|
|
# We must load this explicitly here, and rename the procedures we want
|
|
# to override. If we didn't do this, given that mi-support.exp is
|
|
# loaded later in the test files, the procedures loaded then would
|
|
# override our definitions.
|
|
load_lib mi-support.exp
|
|
|
|
# Overriden in order to start a "gdbserver --multi" instance whenever
|
|
# GDB is started. Note nothing is needed for gdb_exit, since
|
|
# gdbserver is started with --once, causing it to exit once GDB
|
|
# disconnects.
|
|
proc gdb_start { } {
|
|
# Spawn GDB.
|
|
default_gdb_start
|
|
|
|
# And then GDBserver, ready for extended-remote mode.
|
|
gdbserver_start_multi
|
|
|
|
return 0
|
|
}
|
|
|
|
# Likewise, for MI.
|
|
#
|
|
if { [info procs extended_gdbserver_mi_gdb_start] == "" } {
|
|
rename mi_gdb_start extended_gdbserver_mi_gdb_start
|
|
}
|
|
proc mi_gdb_start { args } {
|
|
global gdbserver_reconnect_p
|
|
|
|
# Spawn GDB.
|
|
set res [extended_gdbserver_mi_gdb_start $args]
|
|
if { $res } {
|
|
return $res
|
|
}
|
|
|
|
# And then spawn GDBserver and connect to it in extended-remote
|
|
# mode, unless the test wants to explicitly test reconnection.
|
|
if {![info exists gdbserver_reconnect_p] || !$gdbserver_reconnect_p} {
|
|
mi_gdbserver_start_multi
|
|
}
|
|
return 0
|
|
}
|
|
|
|
# Helper that runs "set remote exec-file" with the last loaded file.
|
|
|
|
proc extended_gdbserver_load_last_file {} {
|
|
global gdb_prompt
|
|
global last_loaded_file
|
|
|
|
send_gdb "set remote exec-file $last_loaded_file\n"
|
|
gdb_expect {
|
|
-re "$gdb_prompt $" {}
|
|
timeout {
|
|
perror "couldn't set the remote exec-file (timed out)."
|
|
return -1
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|
|
|
|
# Overriden in order to set the remote exec-file whenever a file is
|
|
# loaded to gdb.
|
|
#
|
|
if { [info procs extended_gdbserver_gdb_file_cmd] == "" } {
|
|
rename gdb_file_cmd extended_gdbserver_gdb_file_cmd
|
|
}
|
|
proc gdb_file_cmd { arg } {
|
|
if [extended_gdbserver_gdb_file_cmd $arg] {
|
|
return -1
|
|
}
|
|
return [extended_gdbserver_load_last_file]
|
|
}
|
|
|
|
proc gdb_reload { } {
|
|
return [extended_gdbserver_load_last_file]
|
|
}
|
|
|
|
# With the two procedure overrides above, it shouldn't be necessary to
|
|
# override this one too. However, not doing so regresses
|
|
# gdb.base/dbx.exp. See comments above gdb.base/dbx.exp:gdb_file_cmd.
|
|
# Once testing of the "symbol-file"/"exec-file" commands is moved out
|
|
# to a separate non-dbx testcase, we should be able to remove this.
|
|
proc gdb_load { arg } {
|
|
if { $arg != "" } {
|
|
if [gdb_file_cmd $arg] then { return -1 }
|
|
}
|
|
|
|
return [extended_gdbserver_load_last_file]
|
|
}
|
|
|
|
|
|
# Likewise, for MI.
|
|
#
|
|
if { [info procs extended_gdbserver_mi_gdb_load] == "" } {
|
|
rename mi_gdb_load extended_gdbserver_mi_gdb_load
|
|
}
|
|
proc mi_gdb_load { arg } {
|
|
global mi_gdb_prompt
|
|
|
|
set res [extended_gdbserver_mi_gdb_load $arg]
|
|
if { $res } then { return -1 }
|
|
|
|
send_gdb "100-gdb-set remote exec-file $arg\n"
|
|
gdb_expect 10 {
|
|
-re ".*100-gdb-set remote exec-file $arg\r\n100\\\^done\r\n$mi_gdb_prompt$" {
|
|
verbose "set the remote exec-file to $arg."
|
|
}
|
|
timeout {
|
|
perror "couldn't set the remote exec-file (timed out)."
|
|
}
|
|
}
|
|
|
|
return 0
|
|
}
|