From 64c9b6398c287901119bf282a26c6a27df330663 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Thu, 9 Mar 2023 10:45:03 +0100 Subject: [PATCH] [gdb/testsuite] Fix gdb.server/*.exp for remote target Fix test-cases for target board remote-gdbserver-on-localhost by using gdb_remote_download. Tested on x86_64-linux. --- .../gdb.server/exit-multiple-threads.exp | 16 +++++++++------- gdb/testsuite/gdb.server/reconnect-ctrl-c.exp | 4 +++- .../gdb.server/run-without-local-binary.exp | 4 +++- .../gdb.server/stop-reply-no-thread-multi.exp | 4 +++- .../gdb.server/stop-reply-no-thread.exp | 4 +++- gdb/testsuite/gdb.server/twice-connect.exp | 4 +++- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/gdb.server/exit-multiple-threads.exp b/gdb/testsuite/gdb.server/exit-multiple-threads.exp index 87867f00e66..4e55873b1b5 100644 --- a/gdb/testsuite/gdb.server/exit-multiple-threads.exp +++ b/gdb/testsuite/gdb.server/exit-multiple-threads.exp @@ -35,7 +35,7 @@ standard_testfile # # Places a breakpoint in function 'breakpt' and then continues to the # breakpoint, at which point it runs 'info threads'. -proc prepare_for_test { executable disable_multi_process } { +proc prepare_for_test { executable target_executable disable_multi_process } { global GDBFLAGS save_vars { GDBFLAGS } { @@ -65,7 +65,7 @@ proc prepare_for_test { executable disable_multi_process } { } # Start gdbserver and connect. - set res [gdbserver_start "" $executable] + set res [gdbserver_start "" $target_executable] set gdbserver_protocol [lindex $res 0] set gdbserver_gdbport [lindex $res 1] set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] @@ -83,10 +83,10 @@ proc prepare_for_test { executable disable_multi_process } { # we have multiple-threads. EXECUTABLE is the binary under test, and # DISABLE_MULTI_PROCESS indicates if we should disable GDB's remote # multi-process support. -proc run_exit_test { executable disable_multi_process } { +proc run_exit_test { executable target_executable disable_multi_process } { global decimal - prepare_for_test ${executable} ${disable_multi_process} + prepare_for_test ${executable} $target_executable ${disable_multi_process} # Finally, continue until the process exits, ensure we don't see # any warnings between "Continuing." and the final process has @@ -107,10 +107,10 @@ proc run_exit_test { executable disable_multi_process } { # while we have multiple-threads. EXECUTABLE is the binary under # test, and DISABLE_MULTI_PROCESS indicates if we should disable GDB's # remote multi-process support. -proc run_signal_test { executable disable_multi_process } { +proc run_signal_test { executable target_executable disable_multi_process } { global decimal gdb_prompt - prepare_for_test ${executable} ${disable_multi_process} + prepare_for_test ${executable} $target_executable ${disable_multi_process} set inf_pid [get_valueof "/d" "global_pid" "unknown"] gdb_assert ![string eq ${inf_pid} "unknown"] "read the pid" @@ -142,7 +142,9 @@ foreach_with_prefix test { exit signal } { return -1 } + set target_executable [gdb_remote_download target $executable] + foreach_with_prefix multi_process { 0 1 } { - $func ${executable} ${multi_process} + $func ${executable} $target_executable ${multi_process} } } diff --git a/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp b/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp index c8ef81443e5..6146cc3888e 100644 --- a/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp +++ b/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp @@ -40,6 +40,8 @@ save_vars { GDBFLAGS } { } } +set target_binfile [gdb_remote_download target $binfile] + # Make sure we're disconnected, in case we're testing with an # extended-remote board, therefore already connected. with_test_prefix "preparation" { @@ -70,7 +72,7 @@ proc connect_continue_ctrl_c {} { with_test_prefix "first" { # Start GDBserver. set gdbserver_reconnect_p 1 - set res [gdbserver_start "" $binfile] + set res [gdbserver_start "" $target_binfile] set gdbserver_protocol [lindex $res 0] set gdbserver_gdbport [lindex $res 1] diff --git a/gdb/testsuite/gdb.server/run-without-local-binary.exp b/gdb/testsuite/gdb.server/run-without-local-binary.exp index c390eeb435a..08620e0ec3e 100644 --- a/gdb/testsuite/gdb.server/run-without-local-binary.exp +++ b/gdb/testsuite/gdb.server/run-without-local-binary.exp @@ -23,6 +23,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { return -1 } +set target_binfile [gdb_remote_download target $binfile] + # Test running GDB without providing a local binary for it. In order # to do that, we unset GDBFLAGS before running GDB. We also start # gdbserver "by hand". For more details about this test, see PR @@ -39,7 +41,7 @@ save_vars { GDBFLAGS } { gdb_exit gdb_start - gdb_test_no_output "set remote exec-file $binfile" \ + gdb_test_no_output "set remote exec-file $target_binfile" \ "set remote exec-file" # Make sure we're disconnected, in case we're testing with an diff --git a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp index 042c285d98a..cf6be64fab3 100644 --- a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp +++ b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp @@ -37,6 +37,8 @@ if { [build_executable "failed to prepare" $testfile $srcfile {debug pthreads}] return -1 } +set target_binfile [gdb_remote_download target $binfile] + # Run the tests with different features of GDBserver disabled. # TARGET_NON_STOP is passed to "maint set target-non-stop". proc run_test { target_non_stop disable_feature } { @@ -63,7 +65,7 @@ proc run_test { target_non_stop disable_feature } { if { $disable_feature != "" } { set packet_arg "--disable-packet=${disable_feature}" } - set res [gdbserver_start $packet_arg $binfile] + set res [gdbserver_start $packet_arg $::target_binfile] set gdbserver_protocol [lindex $res 0] set gdbserver_gdbport [lindex $res 1] diff --git a/gdb/testsuite/gdb.server/stop-reply-no-thread.exp b/gdb/testsuite/gdb.server/stop-reply-no-thread.exp index 3ef512bc637..65db483e8de 100644 --- a/gdb/testsuite/gdb.server/stop-reply-no-thread.exp +++ b/gdb/testsuite/gdb.server/stop-reply-no-thread.exp @@ -29,6 +29,8 @@ if { [build_executable "failed to prepare" $testfile $srcfile] == -1 } { return -1 } +set target_binfile [gdb_remote_download target $binfile] + # Run the tests with different features of GDBserver disabled. proc run_test { disable_feature target_nonstop } { global binfile gdb_prompt decimal GDBFLAGS @@ -51,7 +53,7 @@ proc run_test { disable_feature target_nonstop } { if { $disable_feature != "" } { set packet_arg "--disable-packet=${disable_feature}" } - set res [gdbserver_start $packet_arg $binfile] + set res [gdbserver_start $packet_arg $::target_binfile] set gdbserver_protocol [lindex $res 0] set gdbserver_gdbport [lindex $res 1] diff --git a/gdb/testsuite/gdb.server/twice-connect.exp b/gdb/testsuite/gdb.server/twice-connect.exp index 8ff8334f5f2..fd76ea0ce3e 100644 --- a/gdb/testsuite/gdb.server/twice-connect.exp +++ b/gdb/testsuite/gdb.server/twice-connect.exp @@ -29,9 +29,11 @@ if { [build_executable "failed to prepare" $::testfile $::srcfile \ # Don't use $binfile arg, to make sure we use the remote file target:$binfile. clean_restart +set target_binfile [gdb_remote_download target $binfile] + # Start gdbserver, and connect to it, twice. foreach_with_prefix session {first second} { - lassign [gdbserver_start "" "$binfile"] unused gdbserver_address + lassign [gdbserver_start "" "$target_binfile"] unused gdbserver_address gdb_test "disconnect" set res [gdb_target_cmd "remote" $gdbserver_address] gdb_assert { $res == 0 } "gdbserver started" -- 2.30.2