summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2023-03-17 16:06:39 +0100
committerTom de Vries <tdevries@suse.de>2023-03-17 16:06:39 +0100
commit3741934fdb04cde6661335e160249f9a83e498a7 (patch)
tree8a7791c8b2a0acd7edc43e31b2048c116a40fb29
parent0eb0e0828783c72144676e6a9884d26d960246f8 (diff)
downloadbinutils-gdb-3741934fdb04cde6661335e160249f9a83e498a7.tar.gz
[gdb/testsuite] Set remotedir by default in some boards
When doing a gdb_simple_compile, and downloading the resulting exec $obj to target the result $target_obj may be a relative file path, which may give problems when trying to do: ... remote_exec target $target_obj ... Fix/workaround this on some target boards by setting remotedir by default, and add a corresponding test in gdb.testsuite/board-sanity.exp. This doesn't work for host/target board local-remote-host-native, so xfail this. Tested on x86_64-linux.
-rw-r--r--gdb/testsuite/boards/remote-gdbserver-on-localhost.exp45
-rw-r--r--gdb/testsuite/boards/remote-stdio-gdbserver.exp16
-rw-r--r--gdb/testsuite/gdb.testsuite/board-sanity.exp32
3 files changed, 77 insertions, 16 deletions
diff --git a/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp b/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
index a08d2d19801..530e744c9b4 100644
--- a/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
+++ b/gdb/testsuite/boards/remote-gdbserver-on-localhost.exp
@@ -37,22 +37,35 @@ if { [info exists REMOTE_TARGET_USERNAME] } {
}
set_board_info hostname localhost
-# Handle separate test account.
-if { [board_info $board username] != $env(USER) } {
- # We're pretending that some local user account is remote target.
- # Make things a bit more realistic by restricting file permissions.
-
- # Make sure remote target can't see files on build.
- remote_exec build "chmod go-rx $objdir"
-
- # Make sure build can't see files on remote target. We can't use
- # remote_exec target, because we're in the middle of parsing the
- # target board.
- remote_exec build \
- "[board_info $board rsh_prog] \
- -l [board_info $board username] \
- [board_info $board hostname] \
- chmod go-rx ."
+save_vars {rsh_cmd res} {
+ set rsh_cmd \
+ [join \
+ [list \
+ [board_info $board rsh_prog] \
+ -l [board_info $board username] \
+ [board_info $board hostname]]]
+
+ # Handle separate test account.
+ if { [board_info $board username] != $env(USER) } {
+ # We're pretending that some local user account is remote target.
+ # Make things a bit more realistic by restricting file permissions.
+
+ # Make sure remote target can't see files on build.
+ remote_exec build "chmod go-rx $objdir"
+
+ # Make sure build can't see files on remote target. We can't use
+ # remote_exec target, because we're in the middle of parsing the
+ # target board.
+ remote_exec build $rsh_cmd chmod go-rx ."
+ }
+
+ # Set remotedir by default, to force remote_download target to give an
+ # absolute file name.
+ set res [remote_exec build $rsh_cmd pwd]
+ if { [lindex $res 0] != 0 } {
+ error "Couldn't set remotedir using pwd"
+ }
+ set_board_info remotedir [string trim [lindex $res 1]]
}
proc ${board}_file { dest op args } {
diff --git a/gdb/testsuite/boards/remote-stdio-gdbserver.exp b/gdb/testsuite/boards/remote-stdio-gdbserver.exp
index 53e40d86477..c4e29e402fe 100644
--- a/gdb/testsuite/boards/remote-stdio-gdbserver.exp
+++ b/gdb/testsuite/boards/remote-stdio-gdbserver.exp
@@ -45,6 +45,22 @@ 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
+} else {
+ # Set remotedir by default, to force remote_download target to give an
+ # absolute file name.
+ save_vars {rsh_cmd res} {
+ set rsh_cmd \
+ [join \
+ [list \
+ [board_info $board rsh_prog] \
+ -l [board_info $board username] \
+ [board_info $board hostname]]]
+ set res [remote_exec build $rsh_cmd pwd]
+ if { [lindex $res 0] != 0 } {
+ error "Couldn't set remotedir using pwd"
+ }
+ set_board_info remotedir [string trim [lindex $res 1]]
+ }
}
if [info exists GDBSERVER] {
diff --git a/gdb/testsuite/gdb.testsuite/board-sanity.exp b/gdb/testsuite/gdb.testsuite/board-sanity.exp
index b2b3690d1b5..d6402262f60 100644
--- a/gdb/testsuite/gdb.testsuite/board-sanity.exp
+++ b/gdb/testsuite/gdb.testsuite/board-sanity.exp
@@ -120,3 +120,35 @@ foreach_with_prefix remote {host target} {
test_remote $remote $host_is_target
}
}
+
+proc_with_prefix gdb_simple_compile_and_run {} {
+ set src {
+ int main() {
+ return 0;
+ }
+ }
+
+ set test "compile"
+ if {![gdb_simple_compile board-sanity $src executable]} {
+ fail $test
+ return
+ }
+ pass $test
+
+ set target_obj [gdb_remote_download target $obj]
+ set result [remote_exec target $target_obj]
+ set status [lindex $result 0]
+ set output [lindex $result 1]
+
+ if { [host_info name] == "local-remote-host-native"
+ && [target_info name] == "local-remote-host-native" } {
+ # Setting remotedir on this board has effect on both host and
+ # target, and it seems to broken for host. Xfail this for now.
+ setup_xfail *-*-*
+ }
+ gdb_assert { $status == 0 && $output == "" }
+
+ remote_file build delete $obj
+}
+
+gdb_simple_compile_and_run