From: Andrew Burgess Date: Tue, 7 Oct 2025 09:57:17 +0000 (+0100) Subject: gdb/testsuite: make more use of clean_restart's argument X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25902bd0baaf58ae86ac46f7d1d71f3f9ee62c1c;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: make more use of clean_restart's argument Commits: commit aaad5a3254db53434eaf1cf70384e7ee0dfb886a Author: Tom de Vries Date: Fri Sep 5 15:36:23 2025 +0200 [gdb/testsuite] Fix clean_restart in gdb.base, part 3 commit 2e61486fcefe8812714dcb0fb787581592675502 Author: Tom de Vries Date: Fri Sep 5 15:36:23 2025 +0200 [gdb/testsuite] Fix clean_restart in gdb.base, part 2 commit 202beb3feebd44fbc1979d9fdb4d74c44e16a417 Author: Tom de Vries Date: Fri Sep 5 15:36:23 2025 +0200 [gdb/testsuite] Fix clean_restart in gdb.base, part 1 were made to work around the changes to clean_restart in commit: commit cba778b944af90c362a618af0630877736a54baa Date: Sun Sep 7 11:53:30 2025 +0200 [gdb/testsuite] Error out on clean_restart These commits added a lot of calls to gdb_load which can be removed in many cases by passing $testfile to clean_restart, or by switching to use prepare_for_testing to compile the test executable. In this commit I've gone through the gdb.base/ directory and removed as many of the gdb_load calls as possible. I was only looking for places where the gdb_load call immediately follows the call to clean_restart. And I did skip a few where it was not as simple as just passing $testfile. Where possible I've updated tests to use calls to prepare_for_testing, and simply removed the clean_restart call altogether (this is done as part of prepare_for_testing). This is, I think, the best solution. In other cases I've removed the gdb_load call, and passed $testfile to clean_restart. I've preferred $::testfile to adding a 'global' declaration, and in some cases switching to testfile has allowed me to remove the 'global binfile' as an additional cleanup. I ran the complete set of tests that I touched and I didn't see any regressions, so I don't believe I broke anything. I know that there are probably gdb_load calls that can be cleaned up in other testsuite sub-directories, if/when this patch is merged I'll take a look at those too. Reviewed-By: Tom de Vries --- diff --git a/gdb/testsuite/gdb.base/access-mem-running.exp b/gdb/testsuite/gdb.base/access-mem-running.exp index ca30ec28d47..3aafb539892 100644 --- a/gdb/testsuite/gdb.base/access-mem-running.exp +++ b/gdb/testsuite/gdb.base/access-mem-running.exp @@ -25,15 +25,14 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug}] == -1} { # non-stop, or all-stop mode. proc test { non_stop } { - global srcfile binfile + global srcfile global gdb_prompt global GDBFLAGS global decimal save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop $non_stop\"" - clean_restart - gdb_load $binfile + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 56708c94d75..c7cd1e8b0a2 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -528,13 +528,13 @@ proc thread_test {} { global gdb_prompt old_gdb_prompt global decimal set srcfile watch_thread_num.c - set binfile [standard_output_file ${testfile}-watch_thread_num] + set filename ${testfile}-watch_thread_num + set binfile [standard_output_file $filename] set gdb_prompt $old_gdb_prompt - if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } { + if { [prepare_for_testing "prepare" $filename $srcfile \ + {debug nowarnings pthreads}] == 0 } { - clean_restart - gdb_load $binfile if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp index cd862d8b1cd..07ce4d98f5a 100644 --- a/gdb/testsuite/gdb.base/arrayidx.exp +++ b/gdb/testsuite/gdb.base/arrayidx.exp @@ -19,14 +19,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/assign.exp b/gdb/testsuite/gdb.base/assign.exp index b96588c99de..b6249972076 100644 --- a/gdb/testsuite/gdb.base/assign.exp +++ b/gdb/testsuite/gdb.base/assign.exp @@ -27,15 +27,9 @@ standard_testfile all-types.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - - -clean_restart -gdb_load $binfile - +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} # # set it up at a breakpoint so we can play with the variable values diff --git a/gdb/testsuite/gdb.base/attach-fail-twice.exp b/gdb/testsuite/gdb.base/attach-fail-twice.exp index 5e5d73f3e3c..7c7b85d6b8e 100644 --- a/gdb/testsuite/gdb.base/attach-fail-twice.exp +++ b/gdb/testsuite/gdb.base/attach-fail-twice.exp @@ -77,8 +77,7 @@ proc test_good_attach {test} { } proc_with_prefix test {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile # GDB used to have a bug on Windows where failing to attach once # made a subsequent "attach" or "run" hang. So it's important for diff --git a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp index c43a11c25a0..02142e7e3b7 100644 --- a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp +++ b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp @@ -36,8 +36,7 @@ proc do_test {} { # Attach to the parent, run it to a known point, extract the # child's PID, and detach. with_test_prefix "parent" { - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "attach $parent_pid" \ "Attaching to program.*, process $parent_pid.*" \ @@ -57,8 +56,7 @@ proc do_test {} { # Start over, and attach to the child this time. with_test_prefix "child" { - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "attach $child_pid" \ "Attaching to program.*, process $child_pid.*" \ diff --git a/gdb/testsuite/gdb.base/attach-wait-input.exp b/gdb/testsuite/gdb.base/attach-wait-input.exp index 47e3d254ea5..35c8f0c8677 100644 --- a/gdb/testsuite/gdb.base/attach-wait-input.exp +++ b/gdb/testsuite/gdb.base/attach-wait-input.exp @@ -39,12 +39,11 @@ if {[build_executable "failed to build" $testfile $srcfile debug]} { # Start the program running, and return its PID, ready for attaching. -proc start_program {binfile} { +proc start_program {testfile} { global gdb_prompt global decimal - clean_restart - gdb_load $binfile + clean_restart $testfile if {![runto setup_done]} { return 0 @@ -74,12 +73,11 @@ proc start_program {binfile} { proc test { editing } { global gdb_prompt - global binfile global decimal with_test_prefix "editing $editing" { - set testpid [start_program $binfile] + set testpid [start_program $::testfile] if {$testpid == ""} { return } diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index c4e27a10f17..5e178c94712 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -56,8 +56,7 @@ proc_with_prefix do_attach_failure_tests {} { global escapedbinfile global srcfile - clean_restart - gdb_load $binfile + clean_restart $::testfile # Figure out a regular expression that will match the sysroot, # noting that the default sysroot is "target:", and also noting @@ -216,8 +215,7 @@ proc_with_prefix do_attach_tests {} { global timeout global decimal - clean_restart - gdb_load $binfile + clean_restart $::testfile # Figure out a regular expression that will match the sysroot, # noting that the default sysroot is "target:", and also noting @@ -521,8 +519,7 @@ proc_with_prefix do_attach_exec_mismatch_handling_tests {} { global binfile2 global binfile3 - clean_restart - gdb_load $binfile + clean_restart $::testfile # Start two programs that can be attached to. # The first program contains a 'int bidule' variable, the second a 'float bidule'. diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp index 0bb4c36abbf..fc9801459a9 100644 --- a/gdb/testsuite/gdb.base/auxv.exp +++ b/gdb/testsuite/gdb.base/auxv.exp @@ -41,8 +41,7 @@ set core_works [expr {[isnative] && ! [is_remote target]}] # Run GDB on the test program up to where it will dump core. -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp index 652e8c11c97..aa80442fd30 100644 --- a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp +++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp @@ -52,8 +52,7 @@ proc prepare_test {has_cfi} { return false } - clean_restart - gdb_load $binfile-$extension + clean_restart $::testfile-$extension if { ![runto callback] } { fail "has_cfi=$has_cfi: Can't run to callback" diff --git a/gdb/testsuite/gdb.base/basic-edit-cmd.exp b/gdb/testsuite/gdb.base/basic-edit-cmd.exp index ad5c9a5626a..8f7369d442c 100644 --- a/gdb/testsuite/gdb.base/basic-edit-cmd.exp +++ b/gdb/testsuite/gdb.base/basic-edit-cmd.exp @@ -68,8 +68,7 @@ save_vars { env(EDITOR) } { "try edit when no symbol file is loaded" # Now start with a test binary. - clean_restart - gdb_load $binfile + clean_restart $testfile with_test_prefix "before starting inferior" { diff --git a/gdb/testsuite/gdb.base/bfp-test.exp b/gdb/testsuite/gdb.base/bfp-test.exp index 1251868e111..49a1305a37e 100644 --- a/gdb/testsuite/gdb.base/bfp-test.exp +++ b/gdb/testsuite/gdb.base/bfp-test.exp @@ -18,14 +18,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp index 2e2a8e6d3fb..dd34ce88a29 100644 --- a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp +++ b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp @@ -34,8 +34,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { # AFTER_KILL_COND is appended to the breakpoint condition, after "kill # -SIGINT $gdb_pid". proc test { {after_kill_cond ""} } { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.exp b/gdb/testsuite/gdb.base/bg-execution-repeat.exp index 923092b9ba1..f45eb40fec8 100644 --- a/gdb/testsuite/gdb.base/bg-execution-repeat.exp +++ b/gdb/testsuite/gdb.base/bg-execution-repeat.exp @@ -30,11 +30,9 @@ set linenum [gdb_get_line_number "set break here"] proc test {continue_cmd} { global gdb_prompt - global binfile global linenum - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp index 7066a636eb3..ae1df764b52 100644 --- a/gdb/testsuite/gdb.base/bigcore.exp +++ b/gdb/testsuite/gdb.base/bigcore.exp @@ -113,12 +113,11 @@ proc check_heap { dir heap } { # The bulk of the testcase. DUMPER indicates who is supposed to dump # the core. It can be either "kernel", or "gdb". proc test {dumper} { - global binfile timeout corefile gdb_prompt + global timeout corefile gdb_prompt # Run GDB on the bigcore program up-to where it will dump core. - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/bitfields2.exp b/gdb/testsuite/gdb.base/bitfields2.exp index b1a42a67b5e..640f2757f05 100644 --- a/gdb/testsuite/gdb.base/bitfields2.exp +++ b/gdb/testsuite/gdb.base/bitfields2.exp @@ -233,8 +233,7 @@ proc bitfield_set {} { } } -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test_no_output "set print sevenbit-strings" runto_main diff --git a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp index 648992c7001..7b56531bb6e 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp +++ b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp @@ -118,8 +118,7 @@ proc do_test {} { # "attach". with_test_prefix "run" { - clean_restart - gdb_load $binfile + clean_restart $testfile if {![runto_main]} { return -1 @@ -130,8 +129,7 @@ with_test_prefix "run" { with_test_prefix "attach" { if {[can_spawn_for_attach]} { - clean_restart - gdb_load $binfile + clean_restart $testfile set test_spawn_id [spawn_wait_for_attach $binfile] set testpid [spawn_id_get_pid $test_spawn_id] diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.exp b/gdb/testsuite/gdb.base/bp-cond-failure.exp index f33092b5132..f6058514ae4 100644 --- a/gdb/testsuite/gdb.base/bp-cond-failure.exp +++ b/gdb/testsuite/gdb.base/bp-cond-failure.exp @@ -45,8 +45,7 @@ if { [is_address_zero_readable] } { } proc run_test { cond_eval access_type bpexpr nloc } { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { ![runto_main] } { return -1 diff --git a/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp b/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp index 371b9e73a31..3da460154a4 100644 --- a/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp +++ b/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp @@ -52,8 +52,7 @@ set exit_bp_line [gdb_get_line_number "BP before exit" $srcfile] # Restart the inferior, which should unload the shared library, GDB # should mark the b/p as disabled due to its condition again. proc run_test { hit_cond } { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp index 71b711d1707..47e1ef69640 100644 --- a/gdb/testsuite/gdb.base/bp-permanent.exp +++ b/gdb/testsuite/gdb.base/bp-permanent.exp @@ -40,10 +40,9 @@ proc test {always_inserted sw_watchpoint} { global line_bp global hex decimal global gdb_prompt - global srcfile binfile + global srcfile - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/break-fun-addr.exp b/gdb/testsuite/gdb.base/break-fun-addr.exp index 8f833de37ff..e123d94cb36 100644 --- a/gdb/testsuite/gdb.base/break-fun-addr.exp +++ b/gdb/testsuite/gdb.base/break-fun-addr.exp @@ -33,20 +33,15 @@ set testfile1 "break-fun-addr1" set srcfile1 ${testfile1}.c -set binfile1 [standard_output_file ${testfile1}] -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug}] != "" } { - untested "failed to compile first testcase" - return -1 +if { [prepare_for_testing "prepare" $testfile1 $srcfile1] != 0 } { + return } # Start the debugger with the first executable, put a breakpoint # on the first instruction of function "main" ("*main"), then # run to that breakpoint. -clean_restart -gdb_load $binfile1 - with_test_prefix "${testfile1}" { gdb_test "break *main" \ @@ -65,9 +60,8 @@ set testfile2 "break-fun-addr2" set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug}] != "" } { - untested "failed to compile second testcase" - return -1 +if { [build_executable "build" $testfile2 $srcfile2] != 0 } { + return } # Now, keeping the same GDB process (so as to keep the same breakpoint), diff --git a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp index 1ef977469fe..5ced8115fea 100644 --- a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp +++ b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp @@ -61,8 +61,7 @@ foreach test_data {{SEGV "Segmentation fault"} \ # Restart GDB. save_vars { GDB } { set GDB [gdb_no_core] - clean_restart - gdb_load $binfile + clean_restart $testfile } # Capture the pid of GDB. diff --git a/gdb/testsuite/gdb.base/bt-selected-frame.exp b/gdb/testsuite/gdb.base/bt-selected-frame.exp index bbe2a5ab061..99332ee848a 100644 --- a/gdb/testsuite/gdb.base/bt-selected-frame.exp +++ b/gdb/testsuite/gdb.base/bt-selected-frame.exp @@ -22,10 +22,7 @@ if { [build_executable "failed to prepare" $testfile $srcfile debug] } { } proc check_selected_frame_after_bt { bt_cmd stack_pattern } { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile with_test_prefix $bt_cmd { diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp index e71b7c2f7ee..fbe41be5460 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.exp +++ b/gdb/testsuite/gdb.base/call-rt-st.exp @@ -25,22 +25,18 @@ require {!target_info exists gdb,cannot_call_functions} standard_testfile .c +set allow_float_test [allow_float_test] + set flags {} lappend flags debug lappend flags nowarnings lappend_include_file flags $srcdir/lib/unbuffer_output.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $flags] != "" } { - untested "failed to compile" - return -1 +# Build executable, and start GDB. +if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } { + return } -set allow_float_test [allow_float_test] - -# Start with a fresh gdb. - -clean_restart -gdb_load $binfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp index a74b8afdaa6..e30fb421d94 100644 --- a/gdb/testsuite/gdb.base/call-signal-resume.exp +++ b/gdb/testsuite/gdb.base/call-signal-resume.exp @@ -29,9 +29,8 @@ require {!target_info exists gdb,cannot_call_functions} standard_testfile call-signals.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } proc get_dummy_frame_number { } { @@ -45,11 +44,6 @@ proc get_dummy_frame_number { } { return "" } -# Start with a fresh gdb. - -clean_restart -gdb_load $binfile - if { ![runto_main] } { return 0 } diff --git a/gdb/testsuite/gdb.base/callexit.exp b/gdb/testsuite/gdb.base/callexit.exp index e0ce899272b..0652bd0455b 100644 --- a/gdb/testsuite/gdb.base/callexit.exp +++ b/gdb/testsuite/gdb.base/callexit.exp @@ -13,22 +13,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . - -standard_testfile .c - -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} - # Some targets can't do function calls, so don't even bother with this # test. require {!target_info exists gdb,cannot_call_functions} -# Start with a fresh gdb. +standard_testfile .c -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if { ![runto_main] } { return 0 diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp index 0a1a4f3ca55..e01cda59097 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -588,7 +588,7 @@ proc test_catch_syscall_multi_arch_1 { } proc test_catch_syscall_multi_arch {} { - global binfile + global testfile set arch1 "i386" set arch2 "i386:x86-64" @@ -630,8 +630,7 @@ proc test_catch_syscall_multi_arch {} { test_catch_syscall_multi_arch_1 $arch1 $arch2 $syscall1_name \ $syscall2_name $syscall_number - clean_restart - gdb_load $binfile + clean_restart $testfile } proc do_syscall_tests_without_xml {} { @@ -802,21 +801,18 @@ fill_all_syscalls_numbers # Execute the tests, using XML support gdb_exit if { [allow_xml_test] } { - clean_restart - gdb_load $binfile + clean_restart $testfile do_syscall_tests # Now, we have to see if GDB displays a warning when we # don't set the data-directory but try to use catch syscall # anyway. For that, we must restart GDB first. - clean_restart - gdb_load $binfile + clean_restart $testfile test_catch_syscall_fail_nodatadir } # Restart gdb -clean_restart -gdb_load $binfile +clean_restart $testfile # Execute the tests, without XML support. In this case, GDB will # only display syscall numbers, and not syscall names. diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp index 55eba5de68e..779b88e500f 100644 --- a/gdb/testsuite/gdb.base/checkpoint.exp +++ b/gdb/testsuite/gdb.base/checkpoint.exp @@ -290,8 +290,7 @@ gdb_test "restart 10" "has no checkpoints" "no more checkpoint 10" # Now let's try setting a large number of checkpoints (>600) # -clean_restart -gdb_load $binfile +clean_restart $testfile runto_main gdb_breakpoint $break1_loc @@ -357,8 +356,7 @@ gdb_test "kill" "" "kill all one with many checkpoints" \ # with_test_prefix "delete checkpoint 0" { - clean_restart - gdb_load $binfile + clean_restart $testfile runto_main gdb_test "checkpoint" "Checkpoint 1: fork returned pid $decimal\\." diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp index 0f7be07c3dc..d8d52a534a6 100644 --- a/gdb/testsuite/gdb.base/chng-syms.exp +++ b/gdb/testsuite/gdb.base/chng-syms.exp @@ -20,9 +20,9 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + {debug additional_flags=-DVARIABLE=var1}] != 0 } { + return } set oldtimeout $timeout @@ -36,9 +36,6 @@ proc expect_to_stop_here { ident } { gdb_test "" "Breakpoint \[0-9\]*, stop_here .*" "running to stop_here $ident" } -clean_restart -gdb_load $binfile - gdb_test "break stop_here if (var1 == 42)" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "setting conditional breakpoint on function" diff --git a/gdb/testsuite/gdb.base/clear_non_user_bp.exp b/gdb/testsuite/gdb.base/clear_non_user_bp.exp index a39304f7b15..ce2098aaad4 100644 --- a/gdb/testsuite/gdb.base/clear_non_user_bp.exp +++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp @@ -37,18 +37,13 @@ proc get_first_maint_bp_num { } { return "" } -standard_testfile .c - # This testcase just needs a "Hello world" source file, reuse # gdb.base/main.c instead of adding a new one. -if { [gdb_compile "${srcdir}/${subdir}/main.c" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} +standard_testfile main.c -# Start with a fresh gdb. -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/code-expr.exp b/gdb/testsuite/gdb.base/code-expr.exp index 4b34e32752d..119f1d9bd8f 100644 --- a/gdb/testsuite/gdb.base/code-expr.exp +++ b/gdb/testsuite/gdb.base/code-expr.exp @@ -24,14 +24,10 @@ standard_testfile cvexpr.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/cond-expr.exp b/gdb/testsuite/gdb.base/cond-expr.exp index c231f4c7333..b605264e7e0 100644 --- a/gdb/testsuite/gdb.base/cond-expr.exp +++ b/gdb/testsuite/gdb.base/cond-expr.exp @@ -33,15 +33,9 @@ standard_testfile int-type.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - - -clean_restart -gdb_load $binfile - +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return +} if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/condbreak-multi-context.exp b/gdb/testsuite/gdb.base/condbreak-multi-context.exp index b4ea0f11754..7301c3407b3 100644 --- a/gdb/testsuite/gdb.base/condbreak-multi-context.exp +++ b/gdb/testsuite/gdb.base/condbreak-multi-context.exp @@ -51,10 +51,9 @@ set loc_index(C) 0 proc find_location_contexts { } { global loc_name loc_index fill - global decimal hex gdb_prompt binfile + global decimal hex gdb_prompt - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return @@ -129,10 +128,9 @@ proc check_bp_locations {bpnum states cond {msg ""}} { # starting GDB, but before running to main. proc_with_prefix scenario_1 { start_before } { - global warning decimal fill bkptno_num_re binfile + global warning decimal fill bkptno_num_re - clean_restart - gdb_load $binfile + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { @@ -242,10 +240,9 @@ proc setup_bps { bpnum1_name bpnum2_name } { # starting GDB, but before running to main. proc_with_prefix scenario_2 { start_before } { - global binfile bkptno_num_re + global bkptno_num_re - clean_restart - gdb_load $binfile + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { @@ -291,10 +288,9 @@ proc_with_prefix scenario_2 { start_before } { # starting GDB, but before running to main. proc_with_prefix scenario_3 { start_before } { - global binfile bkptno_num_re loc_index warning + global bkptno_num_re loc_index warning - clean_restart - gdb_load $binfile + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { @@ -369,10 +365,9 @@ proc_with_prefix scenario_3 { start_before } { # bother with a run to main in this case. proc_with_prefix scenario_4 { start_before } { - global binfile bkptno_num_re loc_index warning + global bkptno_num_re loc_index warning - clean_restart - gdb_load $binfile + clean_restart $::testfile if { $start_before } { if {![runto_main temporary]} { diff --git a/gdb/testsuite/gdb.base/constvars.exp b/gdb/testsuite/gdb.base/constvars.exp index 4abd745d76b..3fdadbf24b7 100644 --- a/gdb/testsuite/gdb.base/constvars.exp +++ b/gdb/testsuite/gdb.base/constvars.exp @@ -29,15 +29,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - - # # set it up at a breakpoint so we can play with the variable values # diff --git a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp index 2bac0007e26..f7368452dac 100644 --- a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp +++ b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp @@ -43,10 +43,9 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { # DISPLACED indicates whether to use displaced-stepping. proc do_test {displaced breakpoint_always_inserted} { global gdb_prompt decimal - global srcfile binfile + global srcfile - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "set displaced-stepping $displaced" gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted" diff --git a/gdb/testsuite/gdb.base/corefile-exec-context.exp b/gdb/testsuite/gdb.base/corefile-exec-context.exp index f6085f793ed..08110dd090c 100644 --- a/gdb/testsuite/gdb.base/corefile-exec-context.exp +++ b/gdb/testsuite/gdb.base/corefile-exec-context.exp @@ -51,8 +51,7 @@ remote_exec build "mv $corefile $corefile_1" # Load the core file and confirm that the full executable name is # seen. -clean_restart -gdb_load $binfile +clean_restart $testfile set saw_generated_line false gdb_test_multiple "core-file $corefile_1" "load core file no args" { -re "^Core was generated by `[string_to_regexp $binfile]'\\.\r\n" { @@ -81,8 +80,7 @@ remote_exec build "mv $corefile $corefile_2" # Load the core file and confirm that the full executable name and # argument list are seen. -clean_restart -gdb_load $binfile +clean_restart $testfile set saw_generated_line false gdb_test_multiple "core-file $corefile_2" "load core file with args" { -re "^Core was generated by `[string_to_regexp $binfile] $args'\\.\r\n" { @@ -157,8 +155,7 @@ remote_exec build "mv $corefile $corefile_3" # Restart, load the core file, and check the environment variable # shows up. -clean_restart -gdb_load $binfile +clean_restart $testfile # Check for environment variable VAR_NAME in the environment, its # value should be VAR_VALUE. diff --git a/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp index 94ab4547810..0ee3715e9f7 100644 --- a/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp +++ b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp @@ -93,8 +93,7 @@ save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS) } { # LD_PRELOAD. append_environment_default ASAN_OPTIONS verify_asan_link_order 0 - clean_restart - gdb_load $binfile + clean_restart $testfile # Start GDB with the modified environment, this means that, when # using remote targets, gdbserver will also use the preload @@ -187,8 +186,7 @@ with_timeout_factor 3 { # Restart GDB. This time we are _not_ using the preload library. We # no longer need it as we are only analysing the core file now. -clean_restart -gdb_load $binfile +clean_restart $testfile # Load the core file. gdb_test "core-file $corefile" \ diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp index 6e44df845d0..48d3225d2aa 100644 --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp @@ -107,8 +107,7 @@ foreach_with_prefix coreopt {--core= -core= "-c "} { # Now restart normally. -clean_restart -gdb_load $binfile +clean_restart $testfile # Test basic corefile recognition via core-file command. @@ -212,8 +211,7 @@ set coremmap_data_backup_filename \ remote_exec host "mv ${coremmap_data_filename} \ ${coremmap_data_backup_filename}" -clean_restart -gdb_load $binfile +clean_restart $testfile # Load the core file and check we get a warning about the # coremmap.data file being missing. @@ -242,8 +240,7 @@ remote_exec host "mv ${coremmap_data_backup_filename} \ # Test that we can unload the core with the "detach" command. proc_with_prefix corefile_detach {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile gdb_test "core-file $::corefile" "Core was generated by .*" "load core" gdb_test "detach" "No core file now\\." "detach core" @@ -265,8 +262,7 @@ proc corefile_test_run {} { return } - clean_restart - gdb_load $::binfile + clean_restart $::testfile gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again" set re "Local core dump file:" diff --git a/gdb/testsuite/gdb.base/corefile2.exp b/gdb/testsuite/gdb.base/corefile2.exp index 39754600f1c..41520135c2f 100644 --- a/gdb/testsuite/gdb.base/corefile2.exp +++ b/gdb/testsuite/gdb.base/corefile2.exp @@ -171,8 +171,7 @@ with_test_prefix "renamed binfile" { # Restart and run to the abort call. -clean_restart -gdb_load $binfile +clean_restart $testfile if {![runto_main]} { return @@ -196,8 +195,7 @@ if {!$core_supported} { gdb_test_no_output "maint print core-file-backed-mappings" \ "maint print core-file-backed-mapping with no core file" -clean_restart -gdb_load $binfile +clean_restart $testfile set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/corefile3.exp b/gdb/testsuite/gdb.base/corefile3.exp index 45285096652..bee393c983e 100644 --- a/gdb/testsuite/gdb.base/corefile3.exp +++ b/gdb/testsuite/gdb.base/corefile3.exp @@ -47,8 +47,7 @@ set backup_filename \ [standard_output_file coredir.[getpid]/coremmap.data.backup] remote_exec host "mv ${data_filename} ${backup_filename}" -clean_restart -gdb_load $binfile +clean_restart $testfile # Load the core file. The 'coremap.data' file cannot be found by GDB, # but all the mappings for that file are r/w and should be present in diff --git a/gdb/testsuite/gdb.base/default-args.exp b/gdb/testsuite/gdb.base/default-args.exp index ae417ed38fe..e3402fde7d6 100644 --- a/gdb/testsuite/gdb.base/default-args.exp +++ b/gdb/testsuite/gdb.base/default-args.exp @@ -25,8 +25,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile # Basic/core tests using user-visible commands. with_test_prefix "basics" { diff --git a/gdb/testsuite/gdb.base/detach-while-running.exp b/gdb/testsuite/gdb.base/detach-while-running.exp index 34c2adc7d84..00820513a83 100644 --- a/gdb/testsuite/gdb.base/detach-while-running.exp +++ b/gdb/testsuite/gdb.base/detach-while-running.exp @@ -45,8 +45,7 @@ proc test {} { if {$is_remote} { append ::GDBFLAGS " -ex \"maint set target-non-stop on\"" } - clean_restart - gdb_load $binfile + clean_restart $::testfile } set test_spawn_id [spawn_wait_for_attach $binfile] diff --git a/gdb/testsuite/gdb.base/detach.exp b/gdb/testsuite/gdb.base/detach.exp index c8d4350e86b..53388559593 100644 --- a/gdb/testsuite/gdb.base/detach.exp +++ b/gdb/testsuite/gdb.base/detach.exp @@ -25,9 +25,8 @@ if { ! [istarget "*-*-linux*"] } { standard_testfile attach.c set escapedbinfile [string_to_regexp ${binfile}] -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } proc do_detach_tests {} { @@ -42,9 +41,6 @@ proc do_detach_tests {} { gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach, $pass" } -clean_restart -gdb_load $binfile - global pass set pass "one" do_detach_tests diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp index 11f75dac283..622dd29110d 100644 --- a/gdb/testsuite/gdb.base/dfp-test.exp +++ b/gdb/testsuite/gdb.base/dfp-test.exp @@ -22,15 +22,10 @@ standard_testfile .c # Try to compile the test case. If we can't, assume the # toolchain does not yet provide DFP support and bail out. -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quiet debug}] != "" } { - unsupported "decimal floating point not supported for this target." - verbose "Skipping DFP tests." - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {quiet debug}] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index d6359820069..4138367b942 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -52,8 +52,7 @@ if {!$use_gdb_stub} { gdb_test "kill" ".*" "kill again" gdb_test "detach" ".*" "detach again" - clean_restart - gdb_load $binfile + clean_restart $testfile } # Ok, on to real life diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp index 683d33e6cc7..008f0602094 100644 --- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp @@ -126,8 +126,7 @@ proc get_first_so_ns {} { # Run the tests relating to the command "info sharedlibrary", to # verify that the namespace ID is consistent. proc test_info_shared {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { ![runto_main] } { return @@ -177,8 +176,7 @@ proc test_info_shared {} { # Also tests that the namespace ID is only printed at the correct # times. proc_with_prefix test_conv_vars {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile gdb_test "print \$_linker_namespace_count" "0" \ "0 namespace before starting inferior" @@ -221,8 +219,7 @@ proc_with_prefix test_conv_vars {} { # Restarting GDB so that we can test setting a breakpoint # using the convenience variable, while a proper bp syntax # isn't implemented for namespaces - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return } @@ -238,8 +235,7 @@ proc_with_prefix test_conv_vars {} { # Run several tests relating to the command "info namespaces". proc test_info_linker_namespaces {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile # Check that "info linker-namespaces" while the inferior is not running # doesn't crash. diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp index f8c4f6cc623..3cc4282c814 100644 --- a/gdb/testsuite/gdb.base/dlmopen.exp +++ b/gdb/testsuite/gdb.base/dlmopen.exp @@ -183,8 +183,7 @@ proc test_dlmopen {} { # Setup for calling 'test_dlmopen', this is the version of the test # that doesn't use 'attach'. proc test_dlmopen_no_attach {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { ![runto_main] } { return @@ -209,8 +208,7 @@ proc test_dlmopen_with_attach {} { return } - clean_restart - gdb_load $::binfile + clean_restart $::testfile # Start the test program. set test_spawn_id [spawn_wait_for_attach $::binfile] @@ -300,8 +298,7 @@ proc_with_prefix test_solib_unmap_events { } { return } - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { ![runto_main] } { return @@ -396,8 +393,7 @@ proc_with_prefix test_solib_unmap_events { } { # Check that we can 'next' over the dlclose calls without GDB giving any # warnings or errors. proc_with_prefix test_next_over_dlclose {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { ![runto_main] } { return diff --git a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp index 5d8ffa381c3..9b233385904 100644 --- a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp +++ b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp @@ -25,11 +25,10 @@ if {[build_executable "failed to prepare" \ set dp_location [gdb_get_line_number "set dprintf here"] proc test { style } { - global gdb_prompt binfile dp_location + global gdb_prompt dp_location with_test_prefix "$style" { - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/dprintf-detach.exp b/gdb/testsuite/gdb.base/dprintf-detach.exp index 573aa0a919e..be8a410bb1d 100644 --- a/gdb/testsuite/gdb.base/dprintf-detach.exp +++ b/gdb/testsuite/gdb.base/dprintf-detach.exp @@ -33,12 +33,11 @@ if {[build_executable "failed to prepare for dprintf-detach" \ proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected_dprintf } { set test_prefix "bai=${breakpoint_always_inserted} ds=${dprintf_style} dd=${disconnected_dprintf}" - global binfile decimal gdb_prompt escapedbinfile + global decimal gdb_prompt escapedbinfile with_test_prefix "$test_prefix" { # Start with a clean gdb - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "set breakpoint always-inserted ${breakpoint_always_inserted}" gdb_test_no_output "set dprintf-style ${dprintf_style}" @@ -69,8 +68,7 @@ proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected gdb_exit # Check that the process still exists by attaching a new gdb to it. - clean_restart - gdb_load $binfile + clean_restart $::testfile set test "re-attach to inferior" set is_gdbserver [target_is_gdbserver] diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp index 65de2d5e5e1..a544b425ae7 100644 --- a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp +++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp @@ -93,8 +93,7 @@ do_test "" $test # Restart GDB and 'source' the script; this will (still) run the program # due to the 'run' command in the script. -clean_restart -gdb_load $binfile +clean_restart $testfile do_test "source $x_file" "load and run script using source command" # This should leave us at the gdb prompt; Run program again using diff --git a/gdb/testsuite/gdb.base/dprintf-pending.exp b/gdb/testsuite/gdb.base/dprintf-pending.exp index 8bb705dfe4f..a0630b5dec0 100644 --- a/gdb/testsuite/gdb.base/dprintf-pending.exp +++ b/gdb/testsuite/gdb.base/dprintf-pending.exp @@ -60,8 +60,7 @@ with_test_prefix "without symbols" { gdb_test "" ".*x=3.*x=4.*x=3.*" "run to resolved dprintf" } -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_load_shlib $lib_sl # diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp index 6fb20859792..d6f7781951b 100644 --- a/gdb/testsuite/gdb.base/dprintf.exp +++ b/gdb/testsuite/gdb.base/dprintf.exp @@ -71,11 +71,9 @@ gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, gdb" # Restart GDB and set set up for testing. proc restart {} { - global binfile global bp_location1 dp_location1 - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return -1 @@ -100,7 +98,6 @@ proc test_dprintf {pattern msg} { # Test the "call" style. proc test_call {} { - global binfile global bp_location1 # Now switch styles and rerun; in the absence of redirection the @@ -151,7 +148,6 @@ if {![target_info exists gdb,noinferiorio]} { # Test the "agent" style. proc test_agent {} { - global binfile global gdb_prompt restart diff --git a/gdb/testsuite/gdb.base/dso2dso.exp b/gdb/testsuite/gdb.base/dso2dso.exp index 3b00f6d92cc..ad03e53e543 100644 --- a/gdb/testsuite/gdb.base/dso2dso.exp +++ b/gdb/testsuite/gdb.base/dso2dso.exp @@ -37,25 +37,21 @@ set libdso1 $testfile-dso1 set srcfile_libdso1 $srcdir/$subdir/$libdso1.c set binfile_libdso1 [standard_output_file $libdso1.so] -if { [gdb_compile_shlib $srcfile_libdso2 $binfile_libdso2 \ - [list debug]] != "" } { - untested "failed to compile shared library 2" - return -1 +if { [build_executable "build shlib 1" $binfile_libdso1 \ + $srcfile_libdso1 {debug shlib}] != 0 } { + return } -if { [gdb_compile_shlib $srcfile_libdso1 $binfile_libdso1 \ - [list debug]] != "" } { - untested "failed to compile shared library 1" - return -1 +if { [build_executable "build shlib 2" $binfile_libdso2 \ + $srcfile_libdso2 {debug shlib}] != 0 } { + return } -if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ - [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug shlib=$binfile_libdso2 shlib=$binfile_libdso1]] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $binfile_libdso2 gdb_load_shlib $binfile_libdso1 diff --git a/gdb/testsuite/gdb.base/dtrace-probe.exp b/gdb/testsuite/gdb.base/dtrace-probe.exp index 8a73378328f..879f338a76b 100644 --- a/gdb/testsuite/gdb.base/dtrace-probe.exp +++ b/gdb/testsuite/gdb.base/dtrace-probe.exp @@ -18,7 +18,7 @@ load_lib "dtrace.exp" # Run the tests. # This returns -1 on failure to compile or start, 0 otherwise. proc dtrace_test {} { - global testfile hex srcfile binfile + global testfile hex srcfile standard_testfile @@ -27,8 +27,7 @@ proc dtrace_test {} { return -1 } - clean_restart - gdb_load $binfile + clean_restart $testfile if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index 67f31955186..1cc9eeeab65 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -41,14 +41,10 @@ proc print_zero_all { } { # this causes addresses to be out of range for IHEX. lappend options {nopie} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $options] != 0 } { + return } -clean_restart -gdb_load $binfile - gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \ "inaccessible memory is reported" diff --git a/gdb/testsuite/gdb.base/duplicate-bp.exp b/gdb/testsuite/gdb.base/duplicate-bp.exp index da5834be9a6..92956429a1b 100644 --- a/gdb/testsuite/gdb.base/duplicate-bp.exp +++ b/gdb/testsuite/gdb.base/duplicate-bp.exp @@ -22,10 +22,8 @@ if { [build_executable "failed to prepare" ${testfile}] } { # Setup for the test, create COUNT breakpoints at the function BREAKPT. proc test_setup { count } { global srcfile - global binfile - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/eh_return.exp b/gdb/testsuite/gdb.base/eh_return.exp index 703f9e95c4f..b08e4959864 100644 --- a/gdb/testsuite/gdb.base/eh_return.exp +++ b/gdb/testsuite/gdb.base/eh_return.exp @@ -71,8 +71,7 @@ if { $address == -1 } { return 0 } -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_assert [gdb_breakpoint "*$address" no-message] "set breakpoint on address" diff --git a/gdb/testsuite/gdb.base/errno.exp b/gdb/testsuite/gdb.base/errno.exp index 9607b81aaba..ac682dd0c98 100644 --- a/gdb/testsuite/gdb.base/errno.exp +++ b/gdb/testsuite/gdb.base/errno.exp @@ -45,8 +45,9 @@ standard_testfile proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} { - clean_restart - gdb_load $::binfile + set filename [file tail $::binfile] + + clean_restart $filename if {![runto_main]} { return } @@ -177,8 +178,7 @@ proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} { return } - clean_restart - gdb_load $::binfile + clean_restart $filename set core_loaded [gdb_core_cmd $corefile "load corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp index aca51187baa..1bcea05d274 100644 --- a/gdb/testsuite/gdb.base/eval-skip.exp +++ b/gdb/testsuite/gdb.base/eval-skip.exp @@ -34,13 +34,9 @@ standard_testfile int-type.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile { debug nowarnings }] != 0 } { + return +} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/exe-lock.exp b/gdb/testsuite/gdb.base/exe-lock.exp index fe4af579253..d51614152e6 100644 --- a/gdb/testsuite/gdb.base/exe-lock.exp +++ b/gdb/testsuite/gdb.base/exe-lock.exp @@ -22,14 +22,10 @@ standard_testfile arrayidx.c # don't find the $binfile for 'file delete $binfile'. append binfile $EXEEXT -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - # Sanity-check: Verify that the executable exists. This is just to # make sure that, when we verify later that the file does not exist, # it really has been deleted. diff --git a/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp b/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp index 99f5e7df857..085cb4b36f1 100644 --- a/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp +++ b/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp @@ -19,31 +19,29 @@ standard_testfile foll-exec.c -global binfile -set binfile [standard_output_file "foll-exec"] +set testfile "foll-exec" +set binfile [standard_output_file $testfile] set testfile2 "execd-prog" set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] set compile_options debug -# build the first test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable $compile_options] != "" } { - untested "failed to compile secondary testcase" - return -1 +# Build the executable which will be exec'd. +if { [build_executable "build exec'd file" $testfile2 $srcfile2 $compile_options] != 0 } { + return } if { [is_remote target] } { gdb_remote_download target $binfile2 } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $compile_options] != "" } { - untested "failed to compile main testcase" - return -1 +# Build the test executable, which performs the exec. +if { [prepare_for_testing "prepare" $testfile $srcfile $compile_options] != 0 } { + return } proc do_exec_sysroot_test {} { - global binfile srcfile srcfile2 testfile testfile2 global gdb_prompt gdb_test_no_output "set sysroot /a/path/that/does/not/exist" @@ -68,7 +66,4 @@ proc do_exec_sysroot_test {} { } } -# Start with a fresh gdb -clean_restart -gdb_load $binfile do_exec_sysroot_test diff --git a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp index cd49df1826a..95198a414f1 100644 --- a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp +++ b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp @@ -23,8 +23,10 @@ standard_testfile # unmapped address in the second binary. set objfile ${binfile}.o -set exec1 ${binfile}1 -set exec2 ${binfile}2 +set testfile1 ${testfile}1 +set testfile2 ${testfile}2 +set exec1 [standard_output_file $testfile1] +set exec2 [standard_output_file $testfile2] if { [gdb_compile [file join $srcdir $subdir $srcfile] $objfile \ object [list debug]] != "" } { @@ -41,8 +43,7 @@ if { [gdb_compile $objfile $exec1 executable {debug text_segment=0x1000000}] != # First check whether the address of "main" in exec1 is readable in # exec2. If it is, then skip the test as unsupported. -clean_restart -gdb_load $exec1 +clean_restart $testfile1 if {![runto_main]} { return -1 } @@ -56,8 +57,7 @@ gdb_test_multiple "p/x &main" $test { } } -clean_restart -gdb_load $exec2 +clean_restart $testfile2 if {![runto_main]} { return -1 } @@ -83,11 +83,9 @@ if {!$cannot_access} { # "breakpoint always-inserted" mode. proc test { always_inserted } { - global exec1 global gdb_prompt - clean_restart - gdb_load $exec1 + clean_restart $::testfile1 gdb_test_no_output "set breakpoint always-inserted $always_inserted" diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp index b1cc8fb334f..d5a0227197e 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -21,14 +21,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - # # set it up at a breakpoint so we can play with the variable values # diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp index e2b7354dbc2..b9f7b47396d 100644 --- a/gdb/testsuite/gdb.base/fileio.exp +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -41,8 +41,7 @@ system "rm -rf [standard_output_file *.fileio.test]" set oldtimeout $timeout set timeout [expr {$timeout + 60}] -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp index aa4fc3c8b19..23207bed8f2 100644 --- a/gdb/testsuite/gdb.base/find.exp +++ b/gdb/testsuite/gdb.base/find.exp @@ -17,14 +17,11 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + {debug nowarnings}] != 0 } { + return } -clean_restart -gdb_load $binfile - gdb_test "break $srcfile:stop_here" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint function in file" diff --git a/gdb/testsuite/gdb.base/fixsection.exp b/gdb/testsuite/gdb.base/fixsection.exp index 305685135e0..19157972f76 100644 --- a/gdb/testsuite/gdb.base/fixsection.exp +++ b/gdb/testsuite/gdb.base/fixsection.exp @@ -22,18 +22,17 @@ set libfile "fixsectshr" set libsrc ${srcdir}/${subdir}/${libfile}.c set lib_sl [standard_output_file ${libfile}.sl] -set lib_opts [list debug nowarnings] +set lib_opts [list debug nowarnings shlib] set exec_opts [list debug nowarnings shlib=$lib_sl] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile $srcdir/$subdir/$srcfile $binfile \ - executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib ${lib_sl} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/float128.exp b/gdb/testsuite/gdb.base/float128.exp index b8d3a6c738d..c6ed0cef1fe 100644 --- a/gdb/testsuite/gdb.base/float128.exp +++ b/gdb/testsuite/gdb.base/float128.exp @@ -30,8 +30,7 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/floatn.exp b/gdb/testsuite/gdb.base/floatn.exp index 1b39ed8a3fe..f08ed90f1f1 100644 --- a/gdb/testsuite/gdb.base/floatn.exp +++ b/gdb/testsuite/gdb.base/floatn.exp @@ -30,8 +30,7 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp index cb49ef654d5..65472425b37 100644 --- a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp +++ b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp @@ -41,8 +41,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} $opts] } { } proc do_test {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile gdb_locate_shlib $::shlib_path gdb_test_no_output "set follow-fork-mode child" gdb_test_no_output "set detach-on-fork off" diff --git a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp index 0c6ad87b712..4bafa6807c9 100644 --- a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp +++ b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp @@ -73,8 +73,7 @@ set i 0 foreach_with_prefix print_inferior_events { "on" "off" } { foreach_with_prefix follow_fork_mode { "child" "parent" } { foreach_with_prefix detach_on_fork { "on" "off" } { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_test_no_output "set print inferior-events $print_inferior_events" gdb_test_no_output "set follow-fork-mode $follow_fork_mode" gdb_test_no_output "set detach-on-fork $detach_on_fork" diff --git a/gdb/testsuite/gdb.base/frame-args.exp b/gdb/testsuite/gdb.base/frame-args.exp index 602c8e9e99d..49cec5ea0ff 100644 --- a/gdb/testsuite/gdb.base/frame-args.exp +++ b/gdb/testsuite/gdb.base/frame-args.exp @@ -14,13 +14,10 @@ # along with this program. If not, see . standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if {![runto break_me]} { return diff --git a/gdb/testsuite/gdb.base/frame-info-consistent.exp b/gdb/testsuite/gdb.base/frame-info-consistent.exp index b59404749a9..b83782f1ffc 100644 --- a/gdb/testsuite/gdb.base/frame-info-consistent.exp +++ b/gdb/testsuite/gdb.base/frame-info-consistent.exp @@ -97,8 +97,7 @@ proc compare_frames {frames} { proc test {enable} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile gdb_test_no_output "maint frame-unwinder $enable DEBUGINFO" diff --git a/gdb/testsuite/gdb.base/frame-view.exp b/gdb/testsuite/gdb.base/frame-view.exp index 34ac668080a..9c87f00762d 100644 --- a/gdb/testsuite/gdb.base/frame-view.exp +++ b/gdb/testsuite/gdb.base/frame-view.exp @@ -28,8 +28,7 @@ if { [build_executable "failed to prepare" \ # "select-frame view". proc test_select_frame_view { with_pretty_printer } { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { $with_pretty_printer } { require allow_python_tests diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp index d989a48d83a..e0292c5a151 100644 --- a/gdb/testsuite/gdb.base/fullname.exp +++ b/gdb/testsuite/gdb.base/fullname.exp @@ -45,8 +45,7 @@ set line [gdb_get_line_number "set breakpoint 1 here"] # Initialize GDB after getting the line number, to make sure # symbols aren't loaded. -clean_restart -gdb_load $binfile +clean_restart $testfile set msg "set breakpoint by full path before loading symbols - built absolute" if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } { @@ -71,8 +70,7 @@ if { [gdb_compile [relative_filename [pwd] [build_standard_output_file tmp-${sr return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile set msg "set breakpoint by full path before loading symbols - built relative" if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } { @@ -101,8 +99,7 @@ with_cwd [standard_output_file {}] { } } -clean_restart -gdb_load $binfile +clean_restart $testfile set msg "set breakpoint by full path before loading symbols - built other" if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } { diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp index 5a6bfe6c39d..edf71058ed7 100644 --- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp +++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp @@ -17,20 +17,16 @@ standard_testfile .c -# The ${binfile} basename needs to exceed 80 characters (`sizeof (psargs)') + +# The executable basename needs to exceed 80 characters (`sizeof (psargs)') # plus some additional data to overwrite the stack frame. set pattern 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 -append binfile -${pattern} - -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} -# Start with a fresh gdb. +set filename ${testfile}-${pattern} -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $filename $srcfile] != 0 } { + return +} gdb_test_no_output "set args ${pattern}" \ "set buffer exceeding arguments" diff --git a/gdb/testsuite/gdb.base/gcore-relro-pie.exp b/gdb/testsuite/gdb.base/gcore-relro-pie.exp index a7a6e9b774c..40170db6f7f 100644 --- a/gdb/testsuite/gdb.base/gcore-relro-pie.exp +++ b/gdb/testsuite/gdb.base/gcore-relro-pie.exp @@ -52,8 +52,7 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} { # Now restart gdb with the unstripped binary and load the corefile. -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test "core ${gcorefile}" \ "Core was generated by .*" "re-load generated corefile" diff --git a/gdb/testsuite/gdb.base/gcore-relro.exp b/gdb/testsuite/gdb.base/gcore-relro.exp index 4d3d352333c..229e8de61dd 100644 --- a/gdb/testsuite/gdb.base/gcore-relro.exp +++ b/gdb/testsuite/gdb.base/gcore-relro.exp @@ -34,8 +34,7 @@ set objfile [standard_output_file ${testfile}.o] } with_test_prefix "first session" { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_load_shlib ${binfile_lib} if {![runto lib]} { @@ -50,8 +49,7 @@ with_test_prefix "first session" { # Now restart gdb and load the corefile. with_test_prefix "second session" { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_load_shlib ${binfile_lib} gdb_test "core ${gcorefile}" "Core was generated by .*" \ diff --git a/gdb/testsuite/gdb.base/gcore-tls-pie.exp b/gdb/testsuite/gdb.base/gcore-tls-pie.exp index 27df2105972..34c5a60e3c3 100644 --- a/gdb/testsuite/gdb.base/gcore-tls-pie.exp +++ b/gdb/testsuite/gdb.base/gcore-tls-pie.exp @@ -56,8 +56,7 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} { # Now restart gdb with the unstripped binary and load the corefile. -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test "core ${gcorefile}" \ "Core was generated by .*" "re-load generated corefile" diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp index a9027608b12..eab0694c56e 100644 --- a/gdb/testsuite/gdb.base/gcore.exp +++ b/gdb/testsuite/gdb.base/gcore.exp @@ -58,8 +58,7 @@ if {!$core_supported} { } # Now restart gdb and load the corefile. -clean_restart -gdb_load $binfile +clean_restart $testfile set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/gdb-index-err.exp b/gdb/testsuite/gdb.base/gdb-index-err.exp index b35383649b7..e7a647c856e 100644 --- a/gdb/testsuite/gdb.base/gdb-index-err.exp +++ b/gdb/testsuite/gdb.base/gdb-index-err.exp @@ -90,15 +90,13 @@ foreach_with_prefix flag { "" "-dwarf-5" } { } # Add the index section to the executable. - clean_restart - gdb_load $binfile.$extension + clean_restart $testfile.$extension gdb_assert {[ensure_gdb_index ${binfile}.${extension} ${flag}] == 1} \ "add index to executable" # Reload the executable (which now has an index), and try to # generate and index from it. This will fail. - clean_restart - gdb_load $binfile.$extension + clean_restart $testfile.$extension gdb_test "save gdb-index ${flag} $already_indexed_dir" \ "Error while writing index for `[string_to_regexp $binfile.$extension]': Cannot use an index to create the index" \ "try to generate an index from a binary with an index" diff --git a/gdb/testsuite/gdb.base/gdb1250.exp b/gdb/testsuite/gdb.base/gdb1250.exp index 2cabbf0d7bc..16e4323c001 100644 --- a/gdb/testsuite/gdb.base/gdb1250.exp +++ b/gdb/testsuite/gdb.base/gdb1250.exp @@ -24,14 +24,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto abort {allow-pending}]} { return } diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp index a3e0a3d4de8..f7f65fea225 100644 --- a/gdb/testsuite/gdb.base/gdb1555.exp +++ b/gdb/testsuite/gdb.base/gdb1555.exp @@ -28,14 +28,15 @@ set execsrc "${srcdir}/${subdir}/${srcfile}" remote_exec build "rm -f ${binfile}" -if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" - || [gdb_compile $execsrc ${binfile} executable \ - [list debug shlib=${libobj}]] != "" } { - return -1 +if { [build_executable "build shlib" $libobj $libsrc {debug shlib}] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $execsrc\ + [list debug shlib=${libobj}]] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $libobj if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp index 480396a1d7d..3d1bccfe976 100644 --- a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp +++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp @@ -25,25 +25,22 @@ set lib2name $testfile-solib2 set srcfile_lib2 $srcdir/$subdir/$lib2name.c set binfile_lib2 [standard_output_file $lib2name.so] -if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \ - [list debug]] != "" } { - untested "failed to compile shared library 1" - return -1 + +if { [build_executable "build shlib 1" $binfile_lib1 \ + $srcfile_lib1 [list debug shlib]] != 0 } { + return } -if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \ - [list debug]] != "" } { - untested "failed to compile shared library 2" - return -1 +if { [build_executable "build shlib 2" $binfile_lib2 \ + $srcfile_lib2 [list debug shlib]] != 0 } { + return } -if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \ - [list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug shlib=$binfile_lib1 shlib=$binfile_lib2]] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $binfile_lib1 gdb_load_shlib $binfile_lib2 diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp index f134a0f1d9b..ab26371d501 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc.exp +++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp @@ -89,15 +89,14 @@ proc build {resolver_attr resolver_debug final_debug} { # ifunc is resolved. For the description of RESOLVER_ATTR, # RESOLVER_DEBUG and FINAL_DEBUG, see the "build" procedure above. proc_with_prefix set-break {resolver_attr resolver_debug final_debug} { - global binfile libfile lib_so + global libfile lib_so global hex decimal global gdb_prompt set suffix [make_binsuffix $resolver_attr $resolver_debug $final_debug] set lib_so [standard_output_file ${libfile}-$suffix.so] - clean_restart - gdb_load $binfile-$suffix + clean_restart $::testfile-$suffix gdb_load_shlib ${lib_so} if {![runto_main]} { @@ -196,7 +195,7 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} { # Misc GNU ifunc tests. For the description of RESOLVER_ATTR, # RESOLVER_DEBUG and FINAL_DEBUG, see the "build" procedure above. proc misc_tests {resolver_attr resolver_debug final_debug} { - global srcdir subdir srcfile binfile + global srcdir subdir srcfile global libsrc lib_so libfile global exec_opts executable global hex gdb_prompt @@ -224,8 +223,7 @@ proc misc_tests {resolver_attr resolver_debug final_debug} { # Start with a fresh gdb. - clean_restart - gdb_load $binfile-$suffix + clean_restart $::testfile-$suffix gdb_load_shlib ${lib_so} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp index 62c20032dff..a9b70d63f31 100644 --- a/gdb/testsuite/gdb.base/gnu_vector.exp +++ b/gdb/testsuite/gdb.base/gnu_vector.exp @@ -40,8 +40,7 @@ if { [do_compile {-mcpu=native}] != "" return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile if { ![runto_main] } { return -1 diff --git a/gdb/testsuite/gdb.base/hashline1.exp b/gdb/testsuite/gdb.base/hashline1.exp index 8e815aee80d..7843e7565bd 100644 --- a/gdb/testsuite/gdb.base/hashline1.exp +++ b/gdb/testsuite/gdb.base/hashline1.exp @@ -37,8 +37,7 @@ if { [gdb_compile $compile_name "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile] diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp index f12b4d109c9..39a1f325637 100644 --- a/gdb/testsuite/gdb.base/hashline2.exp +++ b/gdb/testsuite/gdb.base/hashline2.exp @@ -34,8 +34,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}] diff --git a/gdb/testsuite/gdb.base/hashline3.exp b/gdb/testsuite/gdb.base/hashline3.exp index 508f7c98117..b7f22399f94 100644 --- a/gdb/testsuite/gdb.base/hashline3.exp +++ b/gdb/testsuite/gdb.base/hashline3.exp @@ -35,8 +35,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile] diff --git a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp index 9355ce0ee0b..c100197814b 100644 --- a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp +++ b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp @@ -25,17 +25,17 @@ standard_testfile ${main_src} ${lib_src} set lib_basename hbreak-in-shr-unsupported-shr.so set lib_so [standard_output_file ${lib_basename}] -set lib_opts "debug" +set lib_opts [list debug shlib] set exec_opts [list debug shlib=${lib_so}] -if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib_src} ${lib_so} $lib_opts] != "" - || [gdb_compile ${srcdir}/${subdir}/${main_src} ${binfile} executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_so $lib_src $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $main_src $exec_opts] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $lib_so if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp index 1c774ce4e4c..7f4bcc96780 100644 --- a/gdb/testsuite/gdb.base/hook-stop.exp +++ b/gdb/testsuite/gdb.base/hook-stop.exp @@ -35,10 +35,9 @@ proc define_hook_stop {commands} { # caller's caller directly. proc setup {commands} { - global srcfile binfile + global srcfile - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return -code return diff --git a/gdb/testsuite/gdb.base/huge.exp b/gdb/testsuite/gdb.base/huge.exp index 01bc9ea4b71..4d164661608 100644 --- a/gdb/testsuite/gdb.base/huge.exp +++ b/gdb/testsuite/gdb.base/huge.exp @@ -42,8 +42,7 @@ for { set size $max } { $size >= $min } { set size [expr {$size / 2}] } { require {expr {$compilation_succeeded}} # Start with a fresh gdb. -clean_restart -gdb_load $binfile +clean_restart $testfile save_vars { timeout } { set timeout 30 diff --git a/gdb/testsuite/gdb.base/infcall-exec.exp b/gdb/testsuite/gdb.base/infcall-exec.exp index b8192844771..a4d2241bc6b 100644 --- a/gdb/testsuite/gdb.base/infcall-exec.exp +++ b/gdb/testsuite/gdb.base/infcall-exec.exp @@ -23,12 +23,11 @@ set srcfile2 "${testfile2}.c" set binfile2 [standard_output_file $testfile2] # Build the two executables for the test. -if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} { - untested "could not build $binfile" +if {[build_executable "build exec'd file" $testfile2 $srcfile2] != 0} { return -1 } -if {[gdb_compile $srcdir/$subdir/$srcfile2 $binfile2 executable debug] != ""} { - untested "could not build $binfile2" + +if {[prepare_for_testing "prepare" $testfile $srcfile] != 0} { return -1 } @@ -36,9 +35,6 @@ if { [is_remote target] } { set binfile2 [gdb_remote_download target $binfile2] } -clean_restart -gdb_load $binfile - if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/infcall-failure.exp b/gdb/testsuite/gdb.base/infcall-failure.exp index 594cb2be765..eb4937e5018 100644 --- a/gdb/testsuite/gdb.base/infcall-failure.exp +++ b/gdb/testsuite/gdb.base/infcall-failure.exp @@ -39,8 +39,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart - gdb_load $::binfile + clean_restart $::testfile } if { ![runto_main] } { diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl index eddbcb3ef87..5d0e8d0ff4d 100644 --- a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl +++ b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl @@ -56,9 +56,6 @@ proc I2A { n } { proc start_nested_structs_test { lang types } { global testfile global srcfile - global binfile - global subdir - global srcdir global compile_flags standard_testfile infcall-nested-structs.c @@ -75,15 +72,11 @@ proc start_nested_structs_test { lang types } { append testfile "-" "$t" } - if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } { - unresolved "failed to compile" + if { [prepare_for_testing "prepare for testing" \ + $testfile $srcfile $flags] } { return 0 } - # Start with a fresh gdb. - clean_restart - gdb_load $binfile - # Make certain that the output is consistent gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" diff --git a/gdb/testsuite/gdb.base/infcall-timeout.exp b/gdb/testsuite/gdb.base/infcall-timeout.exp index 621a7b999ae..b2c7a13513c 100644 --- a/gdb/testsuite/gdb.base/infcall-timeout.exp +++ b/gdb/testsuite/gdb.base/infcall-timeout.exp @@ -41,8 +41,7 @@ proc run_test { target_async target_non_stop non_stop unwind } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart - gdb_load $::binfile + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/inferior-args.exp b/gdb/testsuite/gdb.base/inferior-args.exp index 6ac25fccdfb..036dd209013 100644 --- a/gdb/testsuite/gdb.base/inferior-args.exp +++ b/gdb/testsuite/gdb.base/inferior-args.exp @@ -41,10 +41,9 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ # that are problematic, STUB_SUITABLE is false. proc do_test { method startup_with_shell inferior_args expected_results \ stub_suitable } { - global binfile hex + global hex - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "set startup-with-shell $startup_with_shell" diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp index 83f500b6224..adcaff54897 100644 --- a/gdb/testsuite/gdb.base/inferior-died.exp +++ b/gdb/testsuite/gdb.base/inferior-died.exp @@ -25,8 +25,7 @@ if { [build_executable "failed to build" ${testfile} ${testfile}.c] } { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop on\"" - clean_restart - gdb_load $binfile + clean_restart $testfile } gdb_test_no_output "set detach-on-fork off" diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp index adc889480e4..197c8e54dbf 100644 --- a/gdb/testsuite/gdb.base/info-proc.exp +++ b/gdb/testsuite/gdb.base/info-proc.exp @@ -63,8 +63,7 @@ if {[istarget "*-*-linux*"]} { } set gcorefile [standard_output_file $testfile.gcore] if {[gdb_gcore_cmd $gcorefile "save a core file"]} { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_test "core $gcorefile" "Core was generated by.*" \ "core [file tail $gcorefile]" diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp index da24880c2e9..b8c38095a06 100644 --- a/gdb/testsuite/gdb.base/info-program.exp +++ b/gdb/testsuite/gdb.base/info-program.exp @@ -35,8 +35,7 @@ standard_testfile proc do_test { threads non-stop } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart - gdb_load $::binfile-$threads + clean_restart $::testfile-$threads } gdb_test "info program" \ diff --git a/gdb/testsuite/gdb.base/info_sources_2.exp b/gdb/testsuite/gdb.base/info_sources_2.exp index aa26140f284..8625e44eef4 100644 --- a/gdb/testsuite/gdb.base/info_sources_2.exp +++ b/gdb/testsuite/gdb.base/info_sources_2.exp @@ -23,20 +23,15 @@ set is_remote_target [is_remote target] standard_testfile -test.c -lib.c set solib_name [standard_output_file ${testfile}-lib.so] -if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile2} ${solib_name} \ - {debug}] != "" } { - untested "failed to compile shared library" - return -1 -} -if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \ - [list debug shlib=${solib_name} ]] != ""} { - untested "failed to compile executable" - return -1 +if { [build_executable "build shlib" $solib_name $srcfile2 {debug shlib}] != 0 } { + return } -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug shlib=${solib_name} ]] != 0} { + return +} set solib_name [gdb_load_shlib $solib_name] diff --git a/gdb/testsuite/gdb.base/internal-string-values.exp b/gdb/testsuite/gdb.base/internal-string-values.exp index c1afa184bb5..ae362a2e991 100644 --- a/gdb/testsuite/gdb.base/internal-string-values.exp +++ b/gdb/testsuite/gdb.base/internal-string-values.exp @@ -250,8 +250,7 @@ proc_with_prefix test_internal_var { } { return } - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { fail "could not run to main" diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp b/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp index a42fc121bc6..88b3cb95ba8 100644 --- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp +++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp @@ -36,8 +36,7 @@ proc do_test {} { # Attach to the parent, run it to a known point, extract the # child's PID, and detach. with_test_prefix "parent" { - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "attach $parent_pid" \ "Attaching to program.*, process $parent_pid.*" \ @@ -61,8 +60,7 @@ proc do_test {} { with_test_prefix "child" { global gdb_prompt - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "attach $child_pid" \ "Attaching to program.*, process $child_pid.*" \ diff --git a/gdb/testsuite/gdb.base/interrupt-daemon.exp b/gdb/testsuite/gdb.base/interrupt-daemon.exp index aa6b675cf80..6de869ce32c 100644 --- a/gdb/testsuite/gdb.base/interrupt-daemon.exp +++ b/gdb/testsuite/gdb.base/interrupt-daemon.exp @@ -27,11 +27,9 @@ if {[build_executable "failed to build" $testfile $srcfile {debug}]} { # The test proper. proc do_test {} { - global binfile global gdb_prompt - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "set follow-fork-mode child" ".*" diff --git a/gdb/testsuite/gdb.base/jit-reader-exec.exp b/gdb/testsuite/gdb.base/jit-reader-exec.exp index e70f104408d..adee4504a43 100644 --- a/gdb/testsuite/gdb.base/jit-reader-exec.exp +++ b/gdb/testsuite/gdb.base/jit-reader-exec.exp @@ -25,10 +25,8 @@ set testfile2 "jit-reader-execd" set srcfile2 ${testfile2}.c set binfile2 [standard_output_file ${testfile2}] -if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" \ - executable {debug}] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build exec'd file" $testfile2 $srcfile2] != 0 } { + return } if { [is_remote target] } { @@ -37,15 +35,10 @@ if { [is_remote target] } { set compile_options [list debug additional_flags=-DPROGRAM=\"$binfile2\"] -if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ - executable $compile_options] != ""} { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $compile_options] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/kill-during-detach.exp b/gdb/testsuite/gdb.base/kill-during-detach.exp index 290606ab5c3..77d9c39d066 100644 --- a/gdb/testsuite/gdb.base/kill-during-detach.exp +++ b/gdb/testsuite/gdb.base/kill-during-detach.exp @@ -76,8 +76,7 @@ set checkpoint_line [gdb_get_line_number "Checkpoint here"] proc run_test { exit_p checkpoint_p } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"set non-stop on\"" - clean_restart - gdb_load $::binfile + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/killed-outside.exp b/gdb/testsuite/gdb.base/killed-outside.exp index 7ddf5df1339..156643aac04 100644 --- a/gdb/testsuite/gdb.base/killed-outside.exp +++ b/gdb/testsuite/gdb.base/killed-outside.exp @@ -42,12 +42,10 @@ proc get_value {var msg} { # and then quits GDB. proc test {cmds_after_kill} { - global binfile global gdb_prompt global decimal - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto done]} { return diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp index ab09d8275ef..4f86aeba752 100644 --- a/gdb/testsuite/gdb.base/langs.exp +++ b/gdb/testsuite/gdb.base/langs.exp @@ -93,8 +93,7 @@ if {[runto csub]} { gdb_continue_to_end "first session" } -clean_restart -gdb_load $binfile +clean_restart $testfile # Try exercising the "minimal" language a bit... diff --git a/gdb/testsuite/gdb.base/lineinc.exp b/gdb/testsuite/gdb.base/lineinc.exp index c83bce03241..24cb008151c 100644 --- a/gdb/testsuite/gdb.base/lineinc.exp +++ b/gdb/testsuite/gdb.base/lineinc.exp @@ -80,15 +80,10 @@ standard_testfile .c -if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable \ - {debug macros}] != ""} { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug macros}] != 0 } { + return } -clean_restart -gdb_load $binfile - # Any command that causes GDB to read the debugging info for the # lineinc.c compilation unit will do here. set test_name "tolerate macro info with multiple #inclusions per line" diff --git a/gdb/testsuite/gdb.base/list-missing-source.exp b/gdb/testsuite/gdb.base/list-missing-source.exp index 9a1b5372260..d73b37d25b4 100644 --- a/gdb/testsuite/gdb.base/list-missing-source.exp +++ b/gdb/testsuite/gdb.base/list-missing-source.exp @@ -43,8 +43,7 @@ if { [gdb_compile "${srcfile}" "${binfile}" \ remote_file host delete $srcfile # Now start GDB, run to main and try to list the source. -clean_restart -gdb_load $binfile +clean_restart $testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index 2da274276a9..3640dfec74b 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -383,10 +383,7 @@ proc test_only_end {} { } proc test_list_invalid_args {} { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "list -INVALID" \ "invalid explicit location argument, \"-INVALID\"" \ "first use of \"list -INVALID\"" @@ -394,8 +391,7 @@ proc test_list_invalid_args {} { "invalid explicit location argument, \"-INVALID\"" \ "second use of \"list -INVALID\"" - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \ "first use of \"list +INVALID\"" gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \ @@ -499,10 +495,7 @@ proc build_pattern { range_spec } { proc test_list {command listsize1 listsize2 linerange1 linerange2} { with_test_prefix "$command after stop: $listsize1, $listsize2" { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/logical.exp b/gdb/testsuite/gdb.base/logical.exp index f924b095ca3..2641be40169 100644 --- a/gdb/testsuite/gdb.base/logical.exp +++ b/gdb/testsuite/gdb.base/logical.exp @@ -27,15 +27,10 @@ standard_testfile int-type.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile { debug nowarnings }] != 0 } { + return } -clean_restart -gdb_load $binfile - - # # set it up at a breakpoint so we can play with the variable values # diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp index 7ee2c094c66..a28e07a64d1 100644 --- a/gdb/testsuite/gdb.base/long_long.exp +++ b/gdb/testsuite/gdb.base/long_long.exp @@ -22,17 +22,10 @@ require {!target_info exists no_long_long} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug nowarnings]] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return } -# use this to debug: -#log_user 1 - -clean_restart -gdb_load $binfile - if {![runto known_types]} { return } diff --git a/gdb/testsuite/gdb.base/longjmp.exp b/gdb/testsuite/gdb.base/longjmp.exp index 99552e6baef..90661dba0f7 100644 --- a/gdb/testsuite/gdb.base/longjmp.exp +++ b/gdb/testsuite/gdb.base/longjmp.exp @@ -26,8 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb } proc do_test { with_probes } { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if { !$with_probes } { gdb_test "maint ignore-probes libc ^longjmp$" diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index a63bd950026..1d752818fd7 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -29,8 +29,7 @@ if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \ return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile # Ask GDB to show the current definition of MACRO, and return a list diff --git a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp index 91d03792a3e..5d45caf98a7 100644 --- a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp +++ b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp @@ -201,8 +201,7 @@ gdb_test "maint info blocks" [make_blocks_result normal_func \ inline_func_a inline_func_b] \ "maint info blocks using stored \$pc, inferior still running" -clean_restart -gdb_load $binfile +clean_restart $testfile # Use the recorded $pc value to check inline frames when the inferior # is not executing. diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 7f6d9f6a981..404eeabd144 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -72,8 +72,7 @@ with_test_prefix "warnings" { foreach cmd {"per-command" "per-command time"} { with_test_prefix $cmd { # GDB only warns once, so restart between commands. - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_test "mt set $cmd on" "$maybe_per_command_warning" gdb_test "mt set $cmd off" "command started" gdb_test_no_output "mt set $cmd on" \ diff --git a/gdb/testsuite/gdb.base/miscexprs.exp b/gdb/testsuite/gdb.base/miscexprs.exp index 00b7df4d324..4f2af502db6 100644 --- a/gdb/testsuite/gdb.base/miscexprs.exp +++ b/gdb/testsuite/gdb.base/miscexprs.exp @@ -39,15 +39,11 @@ set additional_flags "additional_flags=${storage}" standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug ${additional_flags} nowarnings]] != 0 } { + return } -clean_restart -gdb_load $binfile - - # # set it up at a breakpoint so we can play with the variable values # diff --git a/gdb/testsuite/gdb.base/multi-forks.exp b/gdb/testsuite/gdb.base/multi-forks.exp index 73bd1c4a93e..a9f4ff1bff7 100644 --- a/gdb/testsuite/gdb.base/multi-forks.exp +++ b/gdb/testsuite/gdb.base/multi-forks.exp @@ -21,18 +21,10 @@ set flags {} lappend flags debug lappend_include_file flags $srcdir/lib/unbuffer_output.c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $flags] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } { + return } -# Start with a fresh gdb - -clean_restart -gdb_load $binfile - -global gdb_prompt - # This is a test of gdb's ability to follow the parent, child or both # parent and child of multiple Unix fork() system calls. @@ -104,8 +96,7 @@ proc continue_to_exit_bp_loc {} { # parent's branch. foreach mode { "child" "parent" } { - clean_restart - gdb_load $binfile + clean_restart $testfile runto_main gdb_test_no_output "set follow-fork $mode" @@ -137,8 +128,7 @@ foreach mode { "child" "parent" } { # Start with a fresh gdb -clean_restart -gdb_load $binfile +clean_restart $testfile runto_main gdb_breakpoint $exit_bp_loc diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp index 1582fcf871f..b727ca8ad78 100644 --- a/gdb/testsuite/gdb.base/nodebug.exp +++ b/gdb/testsuite/gdb.base/nodebug.exp @@ -31,16 +31,10 @@ if {[test_compiler_info "xlc-*"]} { lappend exec_opts additional_flags=-qstatsym } -if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart -gdb_load $binfile - # Run to FUNC and unload symbols from system shared libraries, to # avoid conflicts with the minsyms in the program. E.g., # intl/plural-exp.h has 'enum expression_operator {..., mult, ...}'. diff --git a/gdb/testsuite/gdb.base/nofield.exp b/gdb/testsuite/gdb.base/nofield.exp index d7d555ed2e9..1fe0c9d0485 100644 --- a/gdb/testsuite/gdb.base/nofield.exp +++ b/gdb/testsuite/gdb.base/nofield.exp @@ -15,17 +15,13 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } set eol "\r\n" set sp "\[ \t\]*" -clean_restart -gdb_load $binfile - gdb_test "ptype struct not_empty" \ "type = struct not_empty {$eol${sp}void \\*e;$eol${sp}void \\*u;$eol}" diff --git a/gdb/testsuite/gdb.base/nostdlib.exp b/gdb/testsuite/gdb.base/nostdlib.exp index 826fbd9727a..8ea0b40c44e 100644 --- a/gdb/testsuite/gdb.base/nostdlib.exp +++ b/gdb/testsuite/gdb.base/nostdlib.exp @@ -31,7 +31,8 @@ foreach_with_prefix pie { "nopie" "pie" } { # OPTS and BINFILE are used by the COMPILE string (defined above) # when it is evaluated below. set opts [list debug additional_flags=-nostdlib $pie] - set binfile [standard_output_file $testfile-$pie] + set filename $testfile-$pie + set binfile [standard_output_file $filename] set board [target_info name] if {[board_info $board exists mathlib]} { @@ -51,8 +52,7 @@ foreach_with_prefix pie { "nopie" "pie" } { return -1 } - clean_restart - gdb_load $binfile + clean_restart $filename gdb_breakpoint "*marker" diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp index 067f55e149f..f9b8657b912 100644 --- a/gdb/testsuite/gdb.base/options.exp +++ b/gdb/testsuite/gdb.base/options.exp @@ -204,9 +204,7 @@ proc_with_prefix test-print {{prefix ""}} { "-vtbl" } - global binfile - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return @@ -317,9 +315,7 @@ proc_with_prefix test-backtrace {} { "backtrace no-fil" \ "backtrace no-filters" - global binfile - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp index d60a0ea9e6d..8d2929f942c 100644 --- a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp +++ b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp @@ -25,14 +25,13 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { # does not cause a pagination prompt. proc test_ctrlc_while_target_running_does_not_paginate {} { - global binfile srcfile + global srcfile global gdb_prompt set testline [gdb_get_line_number "after sleep"] with_test_prefix "ctrlc target running" { - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/paginate-bg-execution.exp b/gdb/testsuite/gdb.base/paginate-bg-execution.exp index 40f98fc6a29..6bb49d36d49 100644 --- a/gdb/testsuite/gdb.base/paginate-bg-execution.exp +++ b/gdb/testsuite/gdb.base/paginate-bg-execution.exp @@ -26,12 +26,10 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { # command without getting caught in pagination. proc test_bg_execution_pagination_return {} { - global binfile global decimal with_test_prefix "paginate" { - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp index 6cc992bb7f8..aecb3577b68 100644 --- a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp +++ b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp @@ -24,13 +24,11 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug] == -1} { # Test paginating while printing about the inferior having exited. # proc test_paginate_inferior_exited {} { - global binfile global gdb_prompt pagination_prompt global inferior_exited_re with_test_prefix "paginate" { - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/patch.exp b/gdb/testsuite/gdb.base/patch.exp index f6abc597c49..05743e6d51c 100644 --- a/gdb/testsuite/gdb.base/patch.exp +++ b/gdb/testsuite/gdb.base/patch.exp @@ -34,8 +34,7 @@ with_test_prefix "exec" { gdb_test "p extern_global = 2" " = 2" "modify value" gdb_test "p extern_global" " = 2" "value modified" - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_test "p extern_global" " = 2" "value modified persisted" } @@ -44,8 +43,7 @@ with_test_prefix "exec" { # Generate a core file. with_test_prefix "gcore" { - clean_restart - gdb_load $binfile + clean_restart $testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/pc-not-saved.exp b/gdb/testsuite/gdb.base/pc-not-saved.exp index e761e9355f3..98b75058dcc 100644 --- a/gdb/testsuite/gdb.base/pc-not-saved.exp +++ b/gdb/testsuite/gdb.base/pc-not-saved.exp @@ -60,8 +60,7 @@ gdb_assert { ![string equal $pc unknown] } \ "check we read the frame's PC" # Restart and load the Python unwinder script. -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test_no_output "source ${remote_python_file}" "load python file" # Tell the Python unwinder to use the frame-id we cached above. diff --git a/gdb/testsuite/gdb.base/pie-fork.exp b/gdb/testsuite/gdb.base/pie-fork.exp index fcc6ad4f0d1..eeddb142c59 100644 --- a/gdb/testsuite/gdb.base/pie-fork.exp +++ b/gdb/testsuite/gdb.base/pie-fork.exp @@ -27,10 +27,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile $opts]} { } proc setup_test {detach_on_fork {follow_fork_mode "parent"}} { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp index 9895a2f5209..72929762971 100644 --- a/gdb/testsuite/gdb.base/pointers.exp +++ b/gdb/testsuite/gdb.base/pointers.exp @@ -27,14 +27,9 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 - } - -clean_restart -gdb_load $binfile - +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return +} # # set it up at a breakpoint so we can play with the variable values diff --git a/gdb/testsuite/gdb.base/pr11022.exp b/gdb/testsuite/gdb.base/pr11022.exp index 70a7d8b0591..887b8c27b4e 100644 --- a/gdb/testsuite/gdb.base/pr11022.exp +++ b/gdb/testsuite/gdb.base/pr11022.exp @@ -17,16 +17,10 @@ require allow_hw_watchpoint_tests standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart -gdb_load $binfile - if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp index 695a3d2c894..0fdc800a7b2 100644 --- a/gdb/testsuite/gdb.base/print-symbol-loading.exp +++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp @@ -35,8 +35,7 @@ if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_load_shlib ${binfile_lib} if {![runto lib]} { @@ -92,11 +91,10 @@ test_load_core full # Now test the sharedlibrary command. proc test_load_shlib { print_symbol_loading } { - global binfile global gdb_prompt with_test_prefix "shlib ${print_symbol_loading}" { - clean_restart - gdb_load $binfile + clean_restart $::testfile + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.base/prologue.exp b/gdb/testsuite/gdb.base/prologue.exp index 736e7798a9a..e0469105704 100644 --- a/gdb/testsuite/gdb.base/prologue.exp +++ b/gdb/testsuite/gdb.base/prologue.exp @@ -18,14 +18,10 @@ require allow_cplus_tests standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/ptr-typedef.exp b/gdb/testsuite/gdb.base/ptr-typedef.exp index f7bdf084c44..ce8a599cef5 100644 --- a/gdb/testsuite/gdb.base/ptr-typedef.exp +++ b/gdb/testsuite/gdb.base/ptr-typedef.exp @@ -15,16 +15,10 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# Get things started. - -clean_restart -gdb_load $binfile - if {![runto marker1]} { untested "couldn't run to marker1" } diff --git a/gdb/testsuite/gdb.base/quit-live.exp b/gdb/testsuite/gdb.base/quit-live.exp index e33d8bc1f16..1ec13b89743 100644 --- a/gdb/testsuite/gdb.base/quit-live.exp +++ b/gdb/testsuite/gdb.base/quit-live.exp @@ -95,8 +95,7 @@ proc quit_with_live_inferior {appear_how extra_inferior quit_how} { set test_spawn_id "" if {$appear_how != "attach-nofile"} { - clean_restart - gdb_load $binfile + clean_restart $testfile } else { clean_restart } diff --git a/gdb/testsuite/gdb.base/random-signal.exp b/gdb/testsuite/gdb.base/random-signal.exp index 16f94676b19..afbf58e300f 100644 --- a/gdb/testsuite/gdb.base/random-signal.exp +++ b/gdb/testsuite/gdb.base/random-signal.exp @@ -49,8 +49,7 @@ proc do_test {} { # while gdb is processing the internal software watchtpoint # single-step. With remote debugging, the ctrl-c reaches GDB first. with_test_prefix "run" { - clean_restart - gdb_load $binfile + clean_restart $testfile if {![runto_main]} { return -1 @@ -63,8 +62,7 @@ with_test_prefix "run" { # reaches GDB first. Test that as well. with_test_prefix "attach" { if {[can_spawn_for_attach]} { - clean_restart - gdb_load $binfile + clean_restart $testfile set test_spawn_id [spawn_wait_for_attach $binfile] set testpid [spawn_id_get_pid $test_spawn_id] diff --git a/gdb/testsuite/gdb.base/readline-ask.exp b/gdb/testsuite/gdb.base/readline-ask.exp index 0fdfc7661ce..acf334fe541 100644 --- a/gdb/testsuite/gdb.base/readline-ask.exp +++ b/gdb/testsuite/gdb.base/readline-ask.exp @@ -27,8 +27,7 @@ setenv TERM dumb # INPUTRC gets reset for the next testfile. setenv INPUTRC $inputrc -clean_restart -gdb_load $binfile +clean_restart $testfile if { ![readline_is_used] } { unsupported "completion doesn't work when readline isn't used." diff --git a/gdb/testsuite/gdb.base/readline-commands-eof.exp b/gdb/testsuite/gdb.base/readline-commands-eof.exp index 7d78829574e..e5dcdd1686a 100644 --- a/gdb/testsuite/gdb.base/readline-commands-eof.exp +++ b/gdb/testsuite/gdb.base/readline-commands-eof.exp @@ -43,8 +43,7 @@ if { ![readline_supports_eof_flag] } { # arrived. If it is then GDB will start displaying extra blank lines # after each line of input. proc run_test {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile gdb_breakpoint main diff --git a/gdb/testsuite/gdb.base/relativedebug.exp b/gdb/testsuite/gdb.base/relativedebug.exp index 06c9aea5739..44d774d72ad 100644 --- a/gdb/testsuite/gdb.base/relativedebug.exp +++ b/gdb/testsuite/gdb.base/relativedebug.exp @@ -17,16 +17,10 @@ require {!target_info exists gdb,nosignals} libc_has_debug_info standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# Get things started. - -clean_restart -gdb_load $binfile - runto_main # pause () -> SIGALRM -> handler () -> abort () diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp index 1d97726b1f6..9faea303dcc 100644 --- a/gdb/testsuite/gdb.base/remote.exp +++ b/gdb/testsuite/gdb.base/remote.exp @@ -164,8 +164,7 @@ gdb_load_timed $binfile "limit" 0 # Get the size of random_data table (defaults to 48K). set sizeof_random_data [get_sizeof "random_data" 48*1024] -clean_restart -gdb_load $binfile +clean_restart $testfile # # Part THREE: Check the upload behavior. diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp index 065cf1b3370..e2eb5166231 100644 --- a/gdb/testsuite/gdb.base/reread.exp +++ b/gdb/testsuite/gdb.base/reread.exp @@ -106,8 +106,7 @@ foreach_with_prefix opts { "" "pie" } { gdb_rename_execfile ${binfile1} ${binfile} # Restart GDB entirely. - clean_restart - gdb_load $binfile + clean_restart $testfile # Set a breakpoint on foo and run to it. gdb_test "break foo" \ diff --git a/gdb/testsuite/gdb.base/restore.exp b/gdb/testsuite/gdb.base/restore.exp index b2e58088da8..167086b605b 100644 --- a/gdb/testsuite/gdb.base/restore.exp +++ b/gdb/testsuite/gdb.base/restore.exp @@ -96,8 +96,7 @@ restore_tests set timeout $prev_timeout # Test PR cli/23785 -clean_restart -gdb_load $binfile +clean_restart $testfile if { ![runto_main] } { return -1 } diff --git a/gdb/testsuite/gdb.base/return2.exp b/gdb/testsuite/gdb.base/return2.exp index 5a4fcae59f1..184021843b1 100644 --- a/gdb/testsuite/gdb.base/return2.exp +++ b/gdb/testsuite/gdb.base/return2.exp @@ -103,8 +103,7 @@ proc return2_tests { } { # Start with a fresh gdb. -clean_restart -gdb_load $binfile +clean_restart $testfile set timeout 30 return2_tests diff --git a/gdb/testsuite/gdb.base/run-attach-while-running.exp b/gdb/testsuite/gdb.base/run-attach-while-running.exp index 7b40a5f493a..a79a7595af7 100644 --- a/gdb/testsuite/gdb.base/run-attach-while-running.exp +++ b/gdb/testsuite/gdb.base/run-attach-while-running.exp @@ -22,9 +22,10 @@ standard_testfile -set binfile_threads ${binfile}-threads -set binfile_nothreads ${binfile}-nothreads +set testfile_threads ${testfile}-threads +set testfile_nothreads ${testfile}-nothreads unset binfile +unset testfile # Valid parameter / axis values: # @@ -60,8 +61,7 @@ proc_with_prefix test { non-stop threaded run-or-attach } { set ::GDBFLAGS "$::GDBFLAGS -ex \"maint set target-non-stop on\"" } - clean_restart - gdb_load $::binfile + clean_restart $::testfile } if { ![runto_main] } { @@ -90,7 +90,8 @@ proc_with_prefix test { non-stop threaded run-or-attach } { gdb_run_cmd gdb_test "" "Breakpoint $::decimal, .*main.*" "hit main breakpoint after re-run" } elseif { ${run-or-attach} == "attach" } { - set test_spawn_id [spawn_wait_for_attach $::binfile] + set binfile [standard_output_file $::testfile] + set test_spawn_id [spawn_wait_for_attach $binfile] set test_pid [spawn_id_get_pid $test_spawn_id] gdb_test_multiple "attach $test_pid" "attach to process" { @@ -110,12 +111,12 @@ foreach_with_prefix threaded {0 1} { set options [list debug additional_flags=-DWITH_THREADS=$threaded \ additional_flags=-std=gnu99] if { $threaded } { - set binfile $binfile_threads + set testfile $testfile_threads lappend options pthreads } else { - set binfile $binfile_nothreads + set testfile $testfile_nothreads } - if { [build_executable "failed to prepare" ${binfile} ${srcfile} $options] } { + if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } { continue } diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp index 2c75d06b84d..e5d31e8f291 100644 --- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp +++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp @@ -56,8 +56,7 @@ proc do_test { action1 action2 } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\"" - clean_restart - gdb_load $::binfile + clean_restart $::testfile } # Ensure we are at least after the getpid call, should we need it. diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp index 07cbddae1cf..97788c7b941 100644 --- a/gdb/testsuite/gdb.base/run-fail-twice.exp +++ b/gdb/testsuite/gdb.base/run-fail-twice.exp @@ -43,8 +43,7 @@ proc test_run {testname} { proc_with_prefix test {} { global gdb_prompt binfile - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "set confirm off" diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp index 74b402f9bbe..60a8eececb7 100644 --- a/gdb/testsuite/gdb.base/savedregs.exp +++ b/gdb/testsuite/gdb.base/savedregs.exp @@ -29,15 +29,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# get things started -clean_restart -gdb_load $binfile - # Advance to main if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/sep.exp b/gdb/testsuite/gdb.base/sep.exp index a07b4670c01..3a3af32814e 100644 --- a/gdb/testsuite/gdb.base/sep.exp +++ b/gdb/testsuite/gdb.base/sep.exp @@ -19,15 +19,11 @@ if { [is_remote host] } { standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { - untested "failed to compile" - return -1 -} - set location [gdb_get_line_number "say_hello" "sep-proc.c"] -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile {debug nowarnings}] != 0 } { + return +} # Try to display the source code inside a file which is included by # another source file. The purpose of this test is to verify that @@ -46,8 +42,7 @@ gdb_test "list sep-proc.c:$location" \ # Try the same, but this time with a breakpoint. We need to exit # GDB to make sure that we havn't loaded the full symbols yet when # we test the breakpoint insertion. -clean_restart -gdb_load $binfile +clean_restart $testfile set test "breakpoint inside included file" gdb_test_multiple "break sep-proc.c:$location" "$test" { diff --git a/gdb/testsuite/gdb.base/sepsymtab.exp b/gdb/testsuite/gdb.base/sepsymtab.exp index 1822f1fea33..749031c30f8 100644 --- a/gdb/testsuite/gdb.base/sepsymtab.exp +++ b/gdb/testsuite/gdb.base/sepsymtab.exp @@ -31,8 +31,7 @@ if {[gdb_gnu_strip_debug $binfile no-main]} { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile set command "info sym main" set command_regex [string_to_regexp $command] diff --git a/gdb/testsuite/gdb.base/set-cwd.exp b/gdb/testsuite/gdb.base/set-cwd.exp index 73a200f713d..81b1ec16978 100644 --- a/gdb/testsuite/gdb.base/set-cwd.exp +++ b/gdb/testsuite/gdb.base/set-cwd.exp @@ -184,9 +184,7 @@ proc_with_prefix test_cwd_reset { } { } test_cd_into_dir -clean_restart -gdb_load $binfile +clean_restart $testfile test_tilde_expansion -clean_restart -gdb_load $binfile +clean_restart $testfile test_cwd_reset diff --git a/gdb/testsuite/gdb.base/set-inferior-tty.exp b/gdb/testsuite/gdb.base/set-inferior-tty.exp index c9b0a96b1bd..d24cc992f70 100644 --- a/gdb/testsuite/gdb.base/set-inferior-tty.exp +++ b/gdb/testsuite/gdb.base/set-inferior-tty.exp @@ -22,10 +22,7 @@ if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] == } proc test_set_inferior_tty { command } { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "$command hello" "set inferior-tty to hello" gdb_test "show inferior-tty" \ diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp index 2d5b62d4776..516b3876c79 100644 --- a/gdb/testsuite/gdb.base/setshow.exp +++ b/gdb/testsuite/gdb.base/setshow.exp @@ -29,8 +29,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}] proc_with_prefix test_setshow_annotate {} { # Start with a fresh gdb - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -79,8 +78,7 @@ proc_with_prefix test_setshow_annotate {} { } proc_with_prefix test_setshow_args {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp index cd0e9033518..a5eab2597f7 100644 --- a/gdb/testsuite/gdb.base/settings.exp +++ b/gdb/testsuite/gdb.base/settings.exp @@ -528,11 +528,10 @@ proc_with_prefix test-enum {} { # string settings tests. proc test-string {variant} { global gdb_prompt - global srcfile binfile + global srcfile # Load symbols for the completion test below. - clean_restart - gdb_load $binfile + clean_restart $::testfile # Use these variables to make sure we don't call the wrong command # by mistake. diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp index aa4b300ad34..abf347d3710 100644 --- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp +++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp @@ -89,10 +89,9 @@ proc do_prepare_inferior { } { # VAR_NAME_MATCH. If empty, defaults, to $var_value. proc do_test { var_value { var_name "" } { var_name_match "" } { var_value_match "" } } { - global binfile test_var_name + global test_var_name - clean_restart - gdb_load $binfile + clean_restart $::testfile if { $var_name == "" } { set var_name $test_var_name @@ -145,10 +144,7 @@ with_test_prefix "strange named var" { # fashions. proc test_set_unset_vars { } { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile with_test_prefix "set 3 environment variables" { # Set some environment variables @@ -205,10 +201,9 @@ with_test_prefix "test set/unset of vars" { # Test that unsetting works. proc test_unset { } { - global hex decimal binfile gdb_prompt + global hex decimal gdb_prompt - clean_restart - gdb_load $binfile + clean_restart $::testfile do_prepare_inferior @@ -237,8 +232,7 @@ proc test_unset { } { } with_test_prefix "set-then-unset" { - clean_restart - gdb_load $binfile + clean_restart $::testfile # Test if setting and then unsetting $HOME works. gdb_test_no_output "set environment HOME = test" "set HOME as test" diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 4a5cefd53a5..adba0bdbfc5 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -42,7 +42,7 @@ set lib2src ${srcdir}/${subdir}/${srcfile3} set lib1 [standard_output_file shr1.sl] set lib2 [standard_output_file shr2.sl] -set lib_opts "debug" +set lib_opts {debug shlib} set exec_opts {} lappend exec_opts debug @@ -50,17 +50,18 @@ lappend exec_opts shlib=$lib1 lappend exec_opts shlib=$lib2 lappend_include_file exec_opts $srcdir/lib/unbuffer_output.c -if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != "" - || [gdb_compile_shlib ${lib2src} ${lib2} $lib_opts] != "" - || [gdb_compile ${srcfile} ${binfile} executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib 1" $lib1 $lib1src $lib_opts] != 0 } { + return } -# Start with a fresh gdb. +if { [build_executable "build shlib 2" $lib2 $lib2src $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return +} -clean_restart -gdb_load $binfile gdb_load_shlib $lib1 gdb_load_shlib $lib2 @@ -162,8 +163,7 @@ gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \ # Start with a fresh gdb. -clean_restart -gdb_load $binfile +clean_restart $testfile # PR's 16495, 18213 # test that we can re-set breakpoints in shared libraries diff --git a/gdb/testsuite/gdb.base/shlib-unload.exp b/gdb/testsuite/gdb.base/shlib-unload.exp index e38d04dac11..1eb5f74cbcb 100644 --- a/gdb/testsuite/gdb.base/shlib-unload.exp +++ b/gdb/testsuite/gdb.base/shlib-unload.exp @@ -69,8 +69,7 @@ proc_with_prefix test_bp_modified_events {} { return } - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -115,8 +114,7 @@ proc_with_prefix test_bp_modified_events {} { # Check that GDB disables dprintf breakpoints within a shared library # when the shared library is unloaded. proc_with_prefix test_dprintf_after_unload {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -145,8 +143,7 @@ proc_with_prefix test_dprintf_after_unload {} { # inferior. We should not get an error about re-setting the dprintf # breakpoint. proc_with_prefix test_dprintf_with_rerun {} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return @@ -241,8 +238,7 @@ proc_with_prefix test_silent_nosharedlib {} { } foreach_with_prefix type { breakpoint dprintf } { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp index e960291c101..d7c2cc95310 100644 --- a/gdb/testsuite/gdb.base/shreloc.exp +++ b/gdb/testsuite/gdb.base/shreloc.exp @@ -35,7 +35,7 @@ set binfile [standard_output_file $testfile] set lib1_sl [standard_output_file shreloc1.sl] set lib2_sl [standard_output_file shreloc2.sl] -set lib_opts "debug" +set lib_opts {debug shlib} set exec_opts [list debug shlib=$lib1_sl shlib=$lib2_sl] if {([istarget "*pc-cygwin"] || [istarget "*pc-mingw32"]) } { @@ -52,21 +52,18 @@ if {[test_compiler_info "xlc-*"]} { } -if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} { - untested "could not build $lib1_sl." - return -1 -} elseif { [gdb_compile_shlib $lib2src $lib2_sl $lib_opts] != ""} { - untested "could not build $lib1_s2." - return -1 -} elseif { [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { - untested "could not build $binfile." - return -1 +if { [build_executable "build shlib 1" $lib1_sl $lib1src $lib_opts] != 0} { + return } -# Start with a fresh gdb. +if { [build_executable "build shlib " $lib2_sl $lib2src $lib_opts] != 0} { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0} { + return +} -clean_restart -gdb_load $binfile gdb_load_shlib $lib1_sl gdb_load_shlib $lib2_sl diff --git a/gdb/testsuite/gdb.base/sigaltstack.exp b/gdb/testsuite/gdb.base/sigaltstack.exp index 47013a0f836..72c9df06443 100644 --- a/gdb/testsuite/gdb.base/sigaltstack.exp +++ b/gdb/testsuite/gdb.base/sigaltstack.exp @@ -27,15 +27,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# get things started -clean_restart -gdb_load $binfile - # Pass all the alarms straight through (but verbosely) gdb_test "handle SIGALRM print pass nostop" gdb_test "handle SIGVTALRM print pass nostop" diff --git a/gdb/testsuite/gdb.base/sigchld.exp b/gdb/testsuite/gdb.base/sigchld.exp index fe9f2d647ef..844d6c81df6 100644 --- a/gdb/testsuite/gdb.base/sigchld.exp +++ b/gdb/testsuite/gdb.base/sigchld.exp @@ -20,13 +20,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - runto_main gdb_test "b [gdb_get_line_number "good, not blocked"]" \ diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp index 52f71400125..58b5a0a72f6 100644 --- a/gdb/testsuite/gdb.base/siginfo-obj.exp +++ b/gdb/testsuite/gdb.base/siginfo-obj.exp @@ -118,8 +118,7 @@ with_test_prefix "validate modified siginfo fields" { # Test siginfo preservation in core files. if {$gcore_created} { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_test "core $gcorefile" "Core was generated by.*" \ "core [file tail $gcorefile]" diff --git a/gdb/testsuite/gdb.base/siginfo-thread.exp b/gdb/testsuite/gdb.base/siginfo-thread.exp index 270b4e15e91..09ef242d848 100644 --- a/gdb/testsuite/gdb.base/siginfo-thread.exp +++ b/gdb/testsuite/gdb.base/siginfo-thread.exp @@ -22,14 +22,10 @@ require supports_get_siginfo_type standard_testfile .c -if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \ - "${binfile}" executable {debug}] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug pthreads}] != 0 } { + return } -clean_restart -gdb_load $binfile - # Advance to main if {![runto_main]} { return 0 @@ -93,8 +89,7 @@ gdb_test "p \$_siginfo.si_signo == $ssi_signo" " = 0" \ # Test siginfo preservation in core files. if {$gcore_created} { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_test "core $gcorefile" "Core was generated by.*" \ "core [file tail $gcorefile]" diff --git a/gdb/testsuite/gdb.base/signals-state-child.exp b/gdb/testsuite/gdb.base/signals-state-child.exp index 9bcf7308622..ed8b572dddb 100644 --- a/gdb/testsuite/gdb.base/signals-state-child.exp +++ b/gdb/testsuite/gdb.base/signals-state-child.exp @@ -97,8 +97,7 @@ remote_close target # Now run the program through gdb, and dump its initial signal actions # and mask in "gdb.txt". -clean_restart -gdb_load $binfile +clean_restart $testfile if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp index 7cd9298ef9d..6e4b9cb1113 100644 --- a/gdb/testsuite/gdb.base/signals.exp +++ b/gdb/testsuite/gdb.base/signals.exp @@ -58,8 +58,7 @@ proc test_handle_all_print {} { } test_handle_all_print -clean_restart -gdb_load $binfile +clean_restart $testfile if {[runto_main]} { diff --git a/gdb/testsuite/gdb.base/signull.exp b/gdb/testsuite/gdb.base/signull.exp index 9ad772ffeb7..5cb0ea6b576 100644 --- a/gdb/testsuite/gdb.base/signull.exp +++ b/gdb/testsuite/gdb.base/signull.exp @@ -32,14 +32,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -clean_restart -gdb_load $binfile - # # Run to `main' where we begin our tests. # diff --git a/gdb/testsuite/gdb.base/sigrepeat.exp b/gdb/testsuite/gdb.base/sigrepeat.exp index 8fa92af5177..a01cdb8ebb6 100644 --- a/gdb/testsuite/gdb.base/sigrepeat.exp +++ b/gdb/testsuite/gdb.base/sigrepeat.exp @@ -24,15 +24,10 @@ require {!target_info exists gdb,nosignals} standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return } -# get things started -clean_restart -gdb_load $binfile - # Advance to main if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp index 2df5dd0c27c..b69117349d8 100644 --- a/gdb/testsuite/gdb.base/sigstep.exp +++ b/gdb/testsuite/gdb.base/sigstep.exp @@ -38,10 +38,7 @@ set other_handler_location [gdb_get_line_number "other handler location"] # Restart GDB, set a display showing $PC, and run to main. proc restart {} { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test "display/i \$pc" diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp index 0eef01c9e6b..c6fa26b5fef 100644 --- a/gdb/testsuite/gdb.base/skip.exp +++ b/gdb/testsuite/gdb.base/skip.exp @@ -308,9 +308,8 @@ with_test_prefix "step using -fi + -fu" { } with_test_prefix "skip delete completion" { - global binfile - clean_restart - gdb_load $binfile + clean_restart $::testfile + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp index 1e309e53654..2315397d447 100644 --- a/gdb/testsuite/gdb.base/so-impl-ld.exp +++ b/gdb/testsuite/gdb.base/so-impl-ld.exp @@ -21,20 +21,17 @@ set libfile "solib1" set libsrc $srcdir/$subdir/$libfile.c set lib_sl [standard_output_file $libfile.sl] -set lib_opts debug +set lib_opts {debug shlib} set exec_opts [list debug shlib=$lib_sl] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile $srcdir/$subdir/$srcfile $binfile \ - executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } { + return } -# Start with a fresh gdb +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return +} -clean_restart -gdb_load $binfile gdb_load_shlib $lib_sl # This program implicitly loads SOM shared libraries. diff --git a/gdb/testsuite/gdb.base/solib-abort.exp b/gdb/testsuite/gdb.base/solib-abort.exp index ab162a9d416..69702294327 100644 --- a/gdb/testsuite/gdb.base/solib-abort.exp +++ b/gdb/testsuite/gdb.base/solib-abort.exp @@ -24,7 +24,7 @@ set srcfile_lib ${srcdir}/${subdir}/${libname}.c set binfile_lib [standard_output_file ${libname}.so] # Note: no debugging info here, since this will assure that the solib # name is printed in the stack trace. -set lib_flags {} +set lib_flags {shlib} # Binary file. set testfile "solib-abort" @@ -32,14 +32,14 @@ set srcfile ${srcdir}/${subdir}/${testfile}.c set binfile [standard_output_file ${testfile}] set bin_flags [list debug shlib=${binfile_lib}] -if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" - || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { - untested "failed to compile" - return -1 +if { [build_executable "build solib" $binfile_lib $srcfile_lib \ + $lib_flags] != 0 } { + return } -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile $bin_flags] != 0 } { + return +} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/solib-disc.exp b/gdb/testsuite/gdb.base/solib-disc.exp index 880f632c963..221a1fae54f 100644 --- a/gdb/testsuite/gdb.base/solib-disc.exp +++ b/gdb/testsuite/gdb.base/solib-disc.exp @@ -39,13 +39,14 @@ remote_exec build "rm -f ${binfile}" set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"] -if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" - || [gdb_compile $execsrc ${binfile} executable $exec_opts] != "" } { - return -1 +if { [build_executable "build solib" $libobj $libsrc {debug shlib}] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $execsrc $exec_opts] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $libobj if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp index 4d3494cbc67..2990aafc734 100644 --- a/gdb/testsuite/gdb.base/solib-symbol.exp +++ b/gdb/testsuite/gdb.base/solib-symbol.exp @@ -21,21 +21,22 @@ require allow_shlib_tests set libname "solib-symbol-lib" set srcfile_lib ${srcdir}/${subdir}/${libname}.c set binfile_lib [standard_output_file ${libname}.so] -set lib_flags [list debug ldflags=-Wl,-Bsymbolic] +set lib_flags [list debug shlib ldflags=-Wl,-Bsymbolic] # Binary file. set testfile "solib-symbol-main" set srcfile ${srcdir}/${subdir}/${testfile}.c set binfile [standard_output_file ${testfile}] set bin_flags [list debug shlib=${binfile_lib}] -if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != "" - || [gdb_compile ${srcfile} ${binfile} executable $bin_flags] != "" } { - untested "failed to compile" - return -1 +if { [build_executable "build solib" $binfile_lib $srcfile_lib \ + $lib_flags] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $bin_flags] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $binfile_lib # Set a breakpoint in the binary. diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp index f9b8856ad69..343eba4a8ae 100644 --- a/gdb/testsuite/gdb.base/solib-weak.exp +++ b/gdb/testsuite/gdb.base/solib-weak.exp @@ -84,8 +84,7 @@ proc do_test { lib1opts lib2opts lib1first } { } with_test_prefix $testopts { - clean_restart - gdb_load $binfile + clean_restart $testfile gdb_load_shlib $lib1 gdb_load_shlib $lib2 diff --git a/gdb/testsuite/gdb.base/source-dir.exp b/gdb/testsuite/gdb.base/source-dir.exp index 1a82c1875dd..2fb351f184b 100644 --- a/gdb/testsuite/gdb.base/source-dir.exp +++ b/gdb/testsuite/gdb.base/source-dir.exp @@ -119,8 +119,7 @@ proc test_truncated_comp_dir {} { } } - clean_restart - gdb_load $binfile + clean_restart $::testfile if { [ishost *-*-mingw*] } { gdb_test_no_output "set directories \$cdir;\$cwd" diff --git a/gdb/testsuite/gdb.base/stack-checking.exp b/gdb/testsuite/gdb.base/stack-checking.exp index 15fc677dda1..286c12ab850 100644 --- a/gdb/testsuite/gdb.base/stack-checking.exp +++ b/gdb/testsuite/gdb.base/stack-checking.exp @@ -16,14 +16,11 @@ standard_testfile .c -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug additional_flags=-fstack-check nowarnings]] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile \ + [list debug additional_flags=-fstack-check nowarnings]] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.base/startup-with-shell.exp b/gdb/testsuite/gdb.base/startup-with-shell.exp index 6872369c988..0887a5a5c7c 100644 --- a/gdb/testsuite/gdb.base/startup-with-shell.exp +++ b/gdb/testsuite/gdb.base/startup-with-shell.exp @@ -40,10 +40,9 @@ run_on_host \ # Initial setup for simple test (wildcard expansion, variable substitution). proc initial_setup_simple { startup_with_shell run_args } { - global hex decimal binfile unique_file + global hex decimal unique_file - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_test_no_output "set startup-with-shell $startup_with_shell" gdb_test_no_output "set print characters unlimited" diff --git a/gdb/testsuite/gdb.base/step-over-no-symbols.exp b/gdb/testsuite/gdb.base/step-over-no-symbols.exp index 24e3bf779ed..b5fbfbbf4c8 100644 --- a/gdb/testsuite/gdb.base/step-over-no-symbols.exp +++ b/gdb/testsuite/gdb.base/step-over-no-symbols.exp @@ -45,10 +45,8 @@ proc get_pc { msg } { proc test_step_over { displaced } { global hex - global binfile - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return -1 diff --git a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp index b10465fbd33..8e2071120f3 100644 --- a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp +++ b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp @@ -29,15 +29,13 @@ set linenum_for_user_bp [gdb_get_line_number "break for user-bp test here"] set linenum_for_step_resume [gdb_get_line_number "break for step-resume test here"] proc test {non_stop displaced always_inserted} { - global binfile global linenum_for_user_bp global linenum_for_step_resume global GDBFLAGS save_vars { GDBFLAGS } { set GDBFLAGS "$GDBFLAGS -ex \"set non-stop $non_stop\"" - clean_restart - gdb_load $binfile + clean_restart $::testfile } gdb_test_no_output "set displaced-stepping $displaced" diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp index 372d52ccd83..1fb793dee8a 100644 --- a/gdb/testsuite/gdb.base/step-test.exp +++ b/gdb/testsuite/gdb.base/step-test.exp @@ -19,13 +19,10 @@ standard_testfile .c remote_exec build "rm -f ${binfile}" -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "failed to compile" - return -1 -} -clean_restart -gdb_load $binfile +if { [prepare_for_testing "prepare" $testfile $srcfile] != 0 } { + return +} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp index 222f17ee096..eff13fa864c 100644 --- a/gdb/testsuite/gdb.base/style.exp +++ b/gdb/testsuite/gdb.base/style.exp @@ -885,8 +885,7 @@ proc previous_line_is_ok { str } { # prompt, the previous line disables styling as expected. proc test_pagination_prompt_styling {} { with_ansi_styling_terminal { - clean_restart - gdb_load $::binfile + clean_restart $::testfile } if {![runto_main]} { @@ -982,8 +981,7 @@ proc test_pagination_prompt_styling {} { # default style once the logging file has finished. proc test_pagination_continue_styling_1 { length } { with_ansi_styling_terminal { - clean_restart - gdb_load $::binfile + clean_restart $::testfile } set filename [string repeat "ax" $length] @@ -1038,8 +1036,7 @@ proc test_pagination_continue_styling { } { # Check to see if the Python styling of disassembler output is # expected or not, this styling requires Python support in GDB, and # the Python pygments module to be available. -clean_restart -gdb_load $binfile +clean_restart $testfile if {[allow_python_tests] && [gdb_py_module_available "pygments"]} { set python_disassembly_styling true } else { diff --git a/gdb/testsuite/gdb.base/sym-file.exp b/gdb/testsuite/gdb.base/sym-file.exp index 13febdac2db..0d521c15bed 100644 --- a/gdb/testsuite/gdb.base/sym-file.exp +++ b/gdb/testsuite/gdb.base/sym-file.exp @@ -71,8 +71,7 @@ gdb_load_shlib ${lib_so} proc do_test { remove_expr } { global lib_basename lib_syms srcfile srcfile3 - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/symtab-search-order.exp b/gdb/testsuite/gdb.base/symtab-search-order.exp index aca9ca19917..70db420fd2d 100644 --- a/gdb/testsuite/gdb.base/symtab-search-order.exp +++ b/gdb/testsuite/gdb.base/symtab-search-order.exp @@ -21,20 +21,18 @@ set srcfile2 $srcdir/$subdir/$srcfile2 set lib1src $srcdir/$subdir/$srcfile3 set lib1 [standard_output_file symtab-search-order-1.sl] -set lib_opts "debug" +set lib_opts {debug shlib} set exec_opts [list debug shlib=$lib1] -if { [gdb_compile_shlib $lib1src $lib1 $lib_opts] != "" - || [gdb_compile [list $srcfile $srcfile2] $binfile executable \ - $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib1 $lib1src $lib_opts] != 0 } { + return } -# Start with a fresh gdb. +if { [prepare_for_testing "prepare" $testfile [list $srcfile $srcfile2] \ + $exec_opts] != 0 } { + return +} -clean_restart -gdb_load $binfile gdb_load_shlib $lib1 if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp index 540a48f9805..a8fb3206497 100644 --- a/gdb/testsuite/gdb.base/testenv.exp +++ b/gdb/testsuite/gdb.base/testenv.exp @@ -88,10 +88,7 @@ proc find_env {varname} { # starting with TEST_GDB. proc_with_prefix test_set_unset_env {} { - global binfile - - clean_restart - gdb_load $binfile + clean_restart $::testfile # First test with no TEST_GDB_VAR. with_test_prefix "test1" { @@ -139,7 +136,6 @@ proc_with_prefix test_set_unset_env {} { } proc_with_prefix test_inherit_env_var {} { - global binfile global bp_line global env @@ -152,8 +148,7 @@ proc_with_prefix test_inherit_env_var {} { save_vars {env(TEST_GDB_GLOBAL)} { set env(TEST_GDB_GLOBAL) "Global environment value" - clean_restart - gdb_load $binfile + clean_restart $::testfile gdb_breakpoint $bp_line diff --git a/gdb/testsuite/gdb.base/tls-dlobj.exp b/gdb/testsuite/gdb.base/tls-dlobj.exp index 9b707993eb0..858cfc7d6d8 100644 --- a/gdb/testsuite/gdb.base/tls-dlobj.exp +++ b/gdb/testsuite/gdb.base/tls-dlobj.exp @@ -56,8 +56,7 @@ proc gdb_test_with_xfail { cmd re cond} { } proc do_tests {force_internal_tls} { - clean_restart - gdb_load $::binfile + clean_restart $::testfile if {![runto_main]} { return } @@ -289,8 +288,7 @@ proc do_tests {force_internal_tls} { return } - clean_restart - gdb_load $::binfile + clean_restart $::testfile set core_loaded [gdb_core_cmd $corefile "load corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/tls-multiobj.exp b/gdb/testsuite/gdb.base/tls-multiobj.exp index 14bbfc9040b..87aac16caee 100644 --- a/gdb/testsuite/gdb.base/tls-multiobj.exp +++ b/gdb/testsuite/gdb.base/tls-multiobj.exp @@ -26,8 +26,10 @@ set lib2obj [standard_output_file "${testfile}2-lib.so"] set lib3obj [standard_output_file "${testfile}3-lib.so"] proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { - clean_restart - gdb_load $::binfile + set filename [file tail $::binfile] + + clean_restart $filename + if {![runto_main]} { return } @@ -129,8 +131,7 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { return } - clean_restart - gdb_load $::binfile + clean_restart $filename set core_loaded [gdb_core_cmd $corefile "load corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/tls-nothreads.exp b/gdb/testsuite/gdb.base/tls-nothreads.exp index fe3ce8098df..dee7425c31c 100644 --- a/gdb/testsuite/gdb.base/tls-nothreads.exp +++ b/gdb/testsuite/gdb.base/tls-nothreads.exp @@ -18,8 +18,10 @@ source $srcdir/$subdir/tls-common.exp.tcl standard_testfile proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { - clean_restart - gdb_load $::binfile + set filename [file tail $::binfile] + + clean_restart $filename + if {![runto_main]} { return } @@ -102,12 +104,12 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { } with_test_prefix "stripped" { - set binfile_stripped "${::binfile}.stripped" + set filename_stripped "${filename}.stripped" + set binfile_stripped [standard_output_file $filename_stripped] set objcopy [gdb_find_objcopy] set cmd "$objcopy --strip-debug ${::binfile} $binfile_stripped" if {![catch {exec {*}$cmd} cmd_output]} { - clean_restart - gdb_load $binfile_stripped + clean_restart $filename_stripped if {![runto_main]} { return } @@ -157,8 +159,7 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} { return } - clean_restart - gdb_load $::binfile + clean_restart $filename set core_loaded [gdb_core_cmd $corefile "load corefile"] if { $core_loaded == -1 } { diff --git a/gdb/testsuite/gdb.base/twice.exp b/gdb/testsuite/gdb.base/twice.exp index 83d271db5bd..6445f901e57 100644 --- a/gdb/testsuite/gdb.base/twice.exp +++ b/gdb/testsuite/gdb.base/twice.exp @@ -25,16 +25,10 @@ close $fileid gdb_remote_download host ${srcdir}/${subdir}/twice.c -if { [gdb_compile $local_srcfile "${binfile}" executable $options] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $local_srcfile $options] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart -gdb_load $binfile - if {[runto_main]} { # Test that GDB can still detect whether we have line numbers # even if we're executing code in an include file. diff --git a/gdb/testsuite/gdb.base/type-opaque.exp b/gdb/testsuite/gdb.base/type-opaque.exp index f5d8582924f..dc4406a7039 100644 --- a/gdb/testsuite/gdb.base/type-opaque.exp +++ b/gdb/testsuite/gdb.base/type-opaque.exp @@ -26,14 +26,15 @@ set execsrc "${srcdir}/${subdir}/${srcfile}" remote_exec build "rm -f ${binfile}" -if { [gdb_compile_shlib $libsrc $libobj {debug}] != "" - || [gdb_compile $execsrc ${binfile} executable \ - [list debug shlib=${libobj}]] != "" } { - return -1 +if { [build_executable "build shlib" $libobj $libsrc {debug shlib}] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $execsrc \ + [list debug shlib=${libobj}]] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib ${libobj} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp index b2d848d55da..7024faa3158 100644 --- a/gdb/testsuite/gdb.base/unload.exp +++ b/gdb/testsuite/gdb.base/unload.exp @@ -40,18 +40,21 @@ set lib_dlopen2 [shlib_target_file ${libname2}] set lib_syms [shlib_symbol_file ${libname}] set lib_syms2 [shlib_symbol_file ${libname2}] -set lib_opts debug +set lib_opts {debug shlib} set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\" additional_flags=-DSHLIB_NAME2=\"${lib_dlopen2}\"] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != "" - || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib 1" $lib_sl $libsrc $lib_opts] != 0 } { + return +} + +if { [build_executable "build shlib 2" $lib_sl2 $libsrc2 $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $lib_sl gdb_load_shlib $lib_sl2 diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp index d25ae26c6e4..ef07d4cade8 100644 --- a/gdb/testsuite/gdb.base/varargs.exp +++ b/gdb/testsuite/gdb.base/varargs.exp @@ -40,17 +40,10 @@ if {[support_complex_tests]} { lappend flags "additional_flags=-DTEST_COMPLEX" } -# build the first test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ - executable $flags] != "" } { - untested "failed to compile" - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile $flags] != 0 } { + return } -# Start with a fresh gdb. - -clean_restart -gdb_load $binfile gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set print address off" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp index 0c6d828e5d4..20315839086 100644 --- a/gdb/testsuite/gdb.base/watch_thread_num.exp +++ b/gdb/testsuite/gdb.base/watch_thread_num.exp @@ -27,13 +27,10 @@ require allow_hw_watchpoint_access_tests standard_testfile .c -if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - return -1 +if { [prepare_for_testing "prepare" $testfile $srcfile {debug pthreads}] != 0 } { + return } -clean_restart -gdb_load $binfile - if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp index afdb82e69b9..a2a6f7a4082 100644 --- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp +++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp @@ -35,8 +35,7 @@ gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior # A clean restart is needed to force the hardware watchpoint setup # logic to run post attach rather than post inferior launch. -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach twice" diff --git a/gdb/testsuite/gdb.base/watchpoint-running.exp b/gdb/testsuite/gdb.base/watchpoint-running.exp index 61c1f8cceec..cb68e187e82 100644 --- a/gdb/testsuite/gdb.base/watchpoint-running.exp +++ b/gdb/testsuite/gdb.base/watchpoint-running.exp @@ -43,8 +43,7 @@ proc test {stop_mode hw} { # default. append ::GDBFLAGS " -ex \"maint set target-non-stop on\"" } - clean_restart - gdb_load $::binfile + clean_restart $::testfile } gdb_test_no_output "set can-use-hw-watchpoints $hw" diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp index 7f58a83b3d9..906bd18ee5f 100644 --- a/gdb/testsuite/gdb.base/watchpoint-solib.exp +++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp @@ -40,17 +40,17 @@ set lib_sl [standard_output_file $libname] set lib_dlopen [shlib_target_file ${libname}] set lib_syms [shlib_symbol_file ${libname}] -set lib_opts debug +set lib_opts {debug shlib} set exec_opts [list debug shlib_load additional_flags=-DSHLIB_NAME=\"${lib_dlopen}\"] -if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != "" - || [gdb_compile $srcfile $binfile executable $exec_opts] != ""} { - untested "failed to compile" - return -1 +if { [build_executable "build shlib" $lib_sl $libsrc $lib_opts] != 0 } { + return +} + +if { [prepare_for_testing "prepare" $testfile $srcfile $exec_opts] != 0 } { + return } -clean_restart -gdb_load $binfile gdb_load_shlib $lib_sl runto_main diff --git a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp index 163ec3bdee7..765ab7ada6a 100644 --- a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp +++ b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp @@ -125,12 +125,11 @@ if {!$hw_watchpoints_supported} { delete_breakpoints proc test {always_inserted} { - global srcfile binfile + global srcfile with_test_prefix "always-inserted $always_inserted" { - clean_restart - gdb_load $binfile + clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/watchpoints.exp b/gdb/testsuite/gdb.base/watchpoints.exp index 41f2b5c46a2..e7d1a0f71bf 100644 --- a/gdb/testsuite/gdb.base/watchpoints.exp +++ b/gdb/testsuite/gdb.base/watchpoints.exp @@ -53,8 +53,7 @@ with_test_prefix "before inferior start" { # This will turn hardware watchpoints back on and delete the watchpoint # we just created. - clean_restart - gdb_load $binfile + clean_restart $testfile # Disable hardware watchpoints if necessary. if {!$allow_hw_watchpoint_tests_p} { diff --git a/gdb/testsuite/gdb.base/with-mf.exp b/gdb/testsuite/gdb.base/with-mf.exp index 3ac5e1d8a38..9c0e67cdbaa 100644 --- a/gdb/testsuite/gdb.base/with-mf.exp +++ b/gdb/testsuite/gdb.base/with-mf.exp @@ -29,8 +29,7 @@ if { [ensure_gdb_index $binfile] == -1 } { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile gdb_test "with language ada -- print g_s" \ " = \\(a => 1, b => 2, c => 3\\)" diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp index 6bbec98316f..d70196cb533 100644 --- a/gdb/testsuite/gdb.base/with.exp +++ b/gdb/testsuite/gdb.base/with.exp @@ -25,8 +25,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { return -1 } -clean_restart -gdb_load $binfile +clean_restart $testfile # Test "maint with". VALUES is a list of values. A nested "with" is # performed with each combination of pair of values from this list. @@ -179,8 +178,7 @@ with_test_prefix "user-defined" { # Check repeating. with_test_prefix "repeat" { - clean_restart - gdb_load $binfile + clean_restart $testfile # "with" with no command reinvokes the previous command. @@ -214,8 +212,7 @@ with_test_prefix "repeat" { # Basic run control. with_test_prefix "run control" { - clean_restart - gdb_load $binfile + clean_restart $testfile if {![runto_main]} { return