]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: make more use of clean_restart's argument
authorAndrew Burgess <aburgess@redhat.com>
Tue, 7 Oct 2025 09:57:17 +0000 (10:57 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Mon, 1 Dec 2025 14:00:47 +0000 (14:00 +0000)
Commits:

  commit aaad5a3254db53434eaf1cf70384e7ee0dfb886a
  Author: Tom de Vries <tdevries@suse.de>
  Date:   Fri Sep 5 15:36:23 2025 +0200

      [gdb/testsuite] Fix clean_restart <absolute filename> in gdb.base, part 3

  commit 2e61486fcefe8812714dcb0fb787581592675502
  Author: Tom de Vries <tdevries@suse.de>
  Date:   Fri Sep 5 15:36:23 2025 +0200

      [gdb/testsuite] Fix clean_restart <absolute filename> in gdb.base, part 2

  commit 202beb3feebd44fbc1979d9fdb4d74c44e16a417
  Author: Tom de Vries <tdevries@suse.de>
  Date:   Fri Sep 5 15:36:23 2025 +0200

      [gdb/testsuite] Fix clean_restart <absolute filename> 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 <absolute filename>

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 <tdevries@suse.de>
196 files changed:
gdb/testsuite/gdb.base/access-mem-running.exp
gdb/testsuite/gdb.base/annota1.exp
gdb/testsuite/gdb.base/arrayidx.exp
gdb/testsuite/gdb.base/assign.exp
gdb/testsuite/gdb.base/attach-fail-twice.exp
gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp
gdb/testsuite/gdb.base/attach-wait-input.exp
gdb/testsuite/gdb.base/attach.exp
gdb/testsuite/gdb.base/auxv.exp
gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp
gdb/testsuite/gdb.base/basic-edit-cmd.exp
gdb/testsuite/gdb.base/bfp-test.exp
gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
gdb/testsuite/gdb.base/bg-execution-repeat.exp
gdb/testsuite/gdb.base/bigcore.exp
gdb/testsuite/gdb.base/bitfields2.exp
gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp
gdb/testsuite/gdb.base/bp-cond-failure.exp
gdb/testsuite/gdb.base/bp-disabled-by-cond.exp
gdb/testsuite/gdb.base/bp-permanent.exp
gdb/testsuite/gdb.base/break-fun-addr.exp
gdb/testsuite/gdb.base/bt-on-fatal-signal.exp
gdb/testsuite/gdb.base/bt-selected-frame.exp
gdb/testsuite/gdb.base/call-rt-st.exp
gdb/testsuite/gdb.base/call-signal-resume.exp
gdb/testsuite/gdb.base/callexit.exp
gdb/testsuite/gdb.base/catch-syscall.exp
gdb/testsuite/gdb.base/checkpoint.exp
gdb/testsuite/gdb.base/chng-syms.exp
gdb/testsuite/gdb.base/clear_non_user_bp.exp
gdb/testsuite/gdb.base/code-expr.exp
gdb/testsuite/gdb.base/cond-expr.exp
gdb/testsuite/gdb.base/condbreak-multi-context.exp
gdb/testsuite/gdb.base/constvars.exp
gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
gdb/testsuite/gdb.base/corefile-exec-context.exp
gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp
gdb/testsuite/gdb.base/corefile.exp
gdb/testsuite/gdb.base/corefile2.exp
gdb/testsuite/gdb.base/corefile3.exp
gdb/testsuite/gdb.base/default-args.exp
gdb/testsuite/gdb.base/detach-while-running.exp
gdb/testsuite/gdb.base/detach.exp
gdb/testsuite/gdb.base/dfp-test.exp
gdb/testsuite/gdb.base/display.exp
gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
gdb/testsuite/gdb.base/dlmopen.exp
gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp
gdb/testsuite/gdb.base/dprintf-detach.exp
gdb/testsuite/gdb.base/dprintf-execution-x-script.exp
gdb/testsuite/gdb.base/dprintf-pending.exp
gdb/testsuite/gdb.base/dprintf.exp
gdb/testsuite/gdb.base/dso2dso.exp
gdb/testsuite/gdb.base/dtrace-probe.exp
gdb/testsuite/gdb.base/dump.exp
gdb/testsuite/gdb.base/duplicate-bp.exp
gdb/testsuite/gdb.base/eh_return.exp
gdb/testsuite/gdb.base/errno.exp
gdb/testsuite/gdb.base/eval-skip.exp
gdb/testsuite/gdb.base/exe-lock.exp
gdb/testsuite/gdb.base/exec-invalid-sysroot.exp
gdb/testsuite/gdb.base/execl-update-breakpoints.exp
gdb/testsuite/gdb.base/exprs.exp
gdb/testsuite/gdb.base/fileio.exp
gdb/testsuite/gdb.base/find.exp
gdb/testsuite/gdb.base/fixsection.exp
gdb/testsuite/gdb.base/float128.exp
gdb/testsuite/gdb.base/floatn.exp
gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp
gdb/testsuite/gdb.base/fork-print-inferior-events.exp
gdb/testsuite/gdb.base/frame-args.exp
gdb/testsuite/gdb.base/frame-info-consistent.exp
gdb/testsuite/gdb.base/frame-view.exp
gdb/testsuite/gdb.base/fullname.exp
gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
gdb/testsuite/gdb.base/gcore-relro-pie.exp
gdb/testsuite/gdb.base/gcore-relro.exp
gdb/testsuite/gdb.base/gcore-tls-pie.exp
gdb/testsuite/gdb.base/gcore.exp
gdb/testsuite/gdb.base/gdb-index-err.exp
gdb/testsuite/gdb.base/gdb1250.exp
gdb/testsuite/gdb.base/gdb1555.exp
gdb/testsuite/gdb.base/global-var-nested-by-dso.exp
gdb/testsuite/gdb.base/gnu-ifunc.exp
gdb/testsuite/gdb.base/gnu_vector.exp
gdb/testsuite/gdb.base/hashline1.exp
gdb/testsuite/gdb.base/hashline2.exp
gdb/testsuite/gdb.base/hashline3.exp
gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp
gdb/testsuite/gdb.base/hook-stop.exp
gdb/testsuite/gdb.base/huge.exp
gdb/testsuite/gdb.base/infcall-exec.exp
gdb/testsuite/gdb.base/infcall-failure.exp
gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl
gdb/testsuite/gdb.base/infcall-timeout.exp
gdb/testsuite/gdb.base/inferior-args.exp
gdb/testsuite/gdb.base/inferior-died.exp
gdb/testsuite/gdb.base/info-proc.exp
gdb/testsuite/gdb.base/info-program.exp
gdb/testsuite/gdb.base/info_sources_2.exp
gdb/testsuite/gdb.base/internal-string-values.exp
gdb/testsuite/gdb.base/interrupt-daemon-attach.exp
gdb/testsuite/gdb.base/interrupt-daemon.exp
gdb/testsuite/gdb.base/jit-reader-exec.exp
gdb/testsuite/gdb.base/kill-during-detach.exp
gdb/testsuite/gdb.base/killed-outside.exp
gdb/testsuite/gdb.base/langs.exp
gdb/testsuite/gdb.base/lineinc.exp
gdb/testsuite/gdb.base/list-missing-source.exp
gdb/testsuite/gdb.base/list.exp
gdb/testsuite/gdb.base/logical.exp
gdb/testsuite/gdb.base/long_long.exp
gdb/testsuite/gdb.base/longjmp.exp
gdb/testsuite/gdb.base/macscp.exp
gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp
gdb/testsuite/gdb.base/maint.exp
gdb/testsuite/gdb.base/miscexprs.exp
gdb/testsuite/gdb.base/multi-forks.exp
gdb/testsuite/gdb.base/nodebug.exp
gdb/testsuite/gdb.base/nofield.exp
gdb/testsuite/gdb.base/nostdlib.exp
gdb/testsuite/gdb.base/options.exp
gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
gdb/testsuite/gdb.base/paginate-bg-execution.exp
gdb/testsuite/gdb.base/paginate-inferior-exit.exp
gdb/testsuite/gdb.base/patch.exp
gdb/testsuite/gdb.base/pc-not-saved.exp
gdb/testsuite/gdb.base/pie-fork.exp
gdb/testsuite/gdb.base/pointers.exp
gdb/testsuite/gdb.base/pr11022.exp
gdb/testsuite/gdb.base/print-symbol-loading.exp
gdb/testsuite/gdb.base/prologue.exp
gdb/testsuite/gdb.base/ptr-typedef.exp
gdb/testsuite/gdb.base/quit-live.exp
gdb/testsuite/gdb.base/random-signal.exp
gdb/testsuite/gdb.base/readline-ask.exp
gdb/testsuite/gdb.base/readline-commands-eof.exp
gdb/testsuite/gdb.base/relativedebug.exp
gdb/testsuite/gdb.base/remote.exp
gdb/testsuite/gdb.base/reread.exp
gdb/testsuite/gdb.base/restore.exp
gdb/testsuite/gdb.base/return2.exp
gdb/testsuite/gdb.base/run-attach-while-running.exp
gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
gdb/testsuite/gdb.base/run-fail-twice.exp
gdb/testsuite/gdb.base/savedregs.exp
gdb/testsuite/gdb.base/sep.exp
gdb/testsuite/gdb.base/sepsymtab.exp
gdb/testsuite/gdb.base/set-cwd.exp
gdb/testsuite/gdb.base/set-inferior-tty.exp
gdb/testsuite/gdb.base/setshow.exp
gdb/testsuite/gdb.base/settings.exp
gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
gdb/testsuite/gdb.base/shlib-call.exp
gdb/testsuite/gdb.base/shlib-unload.exp
gdb/testsuite/gdb.base/shreloc.exp
gdb/testsuite/gdb.base/sigaltstack.exp
gdb/testsuite/gdb.base/sigchld.exp
gdb/testsuite/gdb.base/siginfo-obj.exp
gdb/testsuite/gdb.base/siginfo-thread.exp
gdb/testsuite/gdb.base/signals-state-child.exp
gdb/testsuite/gdb.base/signals.exp
gdb/testsuite/gdb.base/signull.exp
gdb/testsuite/gdb.base/sigrepeat.exp
gdb/testsuite/gdb.base/sigstep.exp
gdb/testsuite/gdb.base/skip.exp
gdb/testsuite/gdb.base/so-impl-ld.exp
gdb/testsuite/gdb.base/solib-abort.exp
gdb/testsuite/gdb.base/solib-disc.exp
gdb/testsuite/gdb.base/solib-symbol.exp
gdb/testsuite/gdb.base/solib-weak.exp
gdb/testsuite/gdb.base/source-dir.exp
gdb/testsuite/gdb.base/stack-checking.exp
gdb/testsuite/gdb.base/startup-with-shell.exp
gdb/testsuite/gdb.base/step-over-no-symbols.exp
gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp
gdb/testsuite/gdb.base/step-test.exp
gdb/testsuite/gdb.base/style.exp
gdb/testsuite/gdb.base/sym-file.exp
gdb/testsuite/gdb.base/symtab-search-order.exp
gdb/testsuite/gdb.base/testenv.exp
gdb/testsuite/gdb.base/tls-dlobj.exp
gdb/testsuite/gdb.base/tls-multiobj.exp
gdb/testsuite/gdb.base/tls-nothreads.exp
gdb/testsuite/gdb.base/twice.exp
gdb/testsuite/gdb.base/type-opaque.exp
gdb/testsuite/gdb.base/unload.exp
gdb/testsuite/gdb.base/varargs.exp
gdb/testsuite/gdb.base/watch_thread_num.exp
gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
gdb/testsuite/gdb.base/watchpoint-running.exp
gdb/testsuite/gdb.base/watchpoint-solib.exp
gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
gdb/testsuite/gdb.base/watchpoints.exp
gdb/testsuite/gdb.base/with-mf.exp
gdb/testsuite/gdb.base/with.exp

index ca30ec28d470900cbce79a121f04331d525bdbf7..3aafb539892f7e26db14a6da5e462fbbe7780cd2 100644 (file)
@@ -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]} {
index 56708c94d753b193a101e3110371df99650ca7a8..c7cd1e8b0a28a72d36bfe1480d4a2a9441fe7172 100644 (file)
@@ -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
        }
index cd862d8b1cdee36a4155b8559052ca6fb34cfa63..07ce4d98f5aac5fee802c6e50d9dfa46d9dc8e00 100644 (file)
 
 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
 }
index b96588c99de1d426d5fd92741b1411bf33b1d091..b6249972076c2accfeca5cdf50d624a353a9d8fc 100644 (file)
 
 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
index 5e5d73f3e3c082e2c0bb9dcb637221a20dd932d8..7c7b85d6b8ef399c6f69a4f52049e67c41b07e30 100644 (file)
@@ -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
index c43a11c25a0f72753f67f941e1d9c20b51d34e59..02142e7e3b730419d6eff51246728d38947dadb3 100644 (file)
@@ -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.*" \
index 47e3d254ea58069466b01b32b6535d6856d90958..35c8f0c86773fca0b820c4254d3d89f267222d53 100644 (file)
@@ -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
        }
index c4e27a10f17fe708bc1f0982c7d8d4f2958fcd22..5e178c947120494f6f3bdfcc4c2542b5f913745d 100644 (file)
@@ -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'.
index 0bb4c36abbf63589c380079cca8dcb16bea55424..fc9801459a9c0af2139f319e6ae9eba4c8d31fb0 100644 (file)
@@ -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"
 
index 652e8c11c978e1dd1297bfa8e56a2a227bfd8a56..aa80442fd30d674c12860a655533542e382027f3 100644 (file)
@@ -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"
index ad5c9a5626a0335c4fd6c53b5aa076b1bc4b8af2..8f7369d442c9a68c2a76f41dbedbcb882b9f89f6 100644 (file)
@@ -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" {
 
index 1251868e111c33507bbad9dee9a1efa283d9a62e..49a1305a37ec6c3902314a029c0c00c16b8e8412 100644 (file)
 
 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
 }
index 2e2a8e6d3fbdc2feeb6fad7d498af8ea0bf7c99a..dd34ce88a29f9a0375ad87fc709ba79bb6a3bef3 100644 (file)
@@ -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
index 923092b9ba130abc3c06be1f29975b3a8856f680..f45eb40fec8e19259668ad8997e6ebe6d22af896 100644 (file)
@@ -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
index 7066a636eb315a903e12ab554252f77544fbdf5a..ae1df764b528082c6235d39daf6f214633b70f11 100644 (file)
@@ -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"
 
index b1a42a67b5e1b0ccc0590281e4f788d3550139f8..640f2757f055ddc5ca91aa98940ec48458257e0a 100644 (file)
@@ -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
index 648992c7001b8989a47783a6aab211ddeb7ef776..7b56531bb6e9580ee10a28f943d64fea5763d81f 100644 (file)
@@ -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]
index f33092b5132a4787fa7dfe0e87c54b69f5d0bdf6..f6058514ae48797c660b25f0b04e2f647dfff4c1 100644 (file)
@@ -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
index 371b9e73a31c9209b65bc2aacb9507d59828f0dd..3da460154a4ce8f75913ddaabe9b071c611583aa 100644 (file)
@@ -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
index 71b711d1707eae8ebff3273363474ed7bc65f520..47e1ef69640641ec07fe6d404251f294d1418798 100644 (file)
@@ -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
index 8f833de37ff552e25cfffbe15e4c5dd3148ff99e..e123d94cb36427fdfdd7b00c7b06ac1453211d7c 100644 (file)
 
 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),
index 1ef977469feff15cc98ad329fd37a68a76394467..5ced8115fea96aef41d61b25871c6ccd3bc5ec0c 100644 (file)
@@ -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.
index bbe2a5ab061d2cc2204a4d4d71de3a2a3b54cb65..99332ee848af482feb295e069e5a163aa99112b5 100644 (file)
@@ -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 {
 
index e71b7c2f7ee7a544a71187186108ecb38c4b9e0f..fbe41be54609cfc1651206ed92290b7a308ae699 100644 (file)
@@ -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"
index a74b8afdaa6960e42c9a0299fd23253f4df9e2d2..e30fb421d94ee135017eebcd04af219e1e5785a0 100644 (file)
@@ -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
 }
index e0ce899272b16ad58caac29831484196eea02d9b..0652bd0455b7c0a993f7a48fb851df96f614b006 100644 (file)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-
-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
index 0a1a4f3ca55856ff502229e68210ac38b0cbfcc0..e01cda59097220c1b2675a921347097b017475b3 100644 (file)
@@ -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.
index 55eba5de68eab1d256c5d0f459c15778f43b3092..779b88e500fa8e0ef16113ae46ca2f2088da5829 100644 (file)
@@ -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\\."
index 0f7be07c3dc61bfec9b050d2f2b0b92c7a9aa8e9..d8d52a534a6502bb698acf842e80827b7e015b14 100644 (file)
@@ -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"
index a39304f7b1525582d3e7e8eb0b09732d5c92091f..ce2098aaad4ea69869a23b3fb2a076ed1b7e6225 100644 (file)
@@ -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
index 4b34e32752d8e5a0381fd73d686576ed3e1f192f..119f1d9bd8fda06ef36b344d0b9ca0e74dd06e47 100644 (file)
 
 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"
index c231f4c733304a993812c6fc32215f758efaaabf..b605264e7e01563e11d323539e717f301ee5c5ba 100644 (file)
 
 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
index b4ea0f11754f626310447b807f9c715318579cc3..7301c3407b3f3ffd7d59cd9206215f58bdcc190e 100644 (file)
@@ -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]} {
index 4abd745d76b12993643bfedf11f57ac7fe96a9d1..3fdadbf24b77c9bf33512429776c34ed222df22a 100644 (file)
 
 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
 #
index 2bac0007e26f30f9075a5640e5123b6debd3959b..f7368452dac4e045661fe9052992c83176181817 100644 (file)
@@ -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"
index f6085f793ed9c8d91a78d22f02f0974aef1c7c9e..08110dd090c05d66b713894097fb6e9cdc775d6c 100644 (file)
@@ -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.
index 94ab45478108d1d5e5baccbe2089bc36cd038166..0ee3715e9f7f3a46e76e8c9b23779da84729c0b8 100644 (file)
@@ -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" \
index 6e44df845d0a2fc43dda0568ebfc752a43d81d59..48d3225d2aaa26657d8d80cc301605ee92ab91b0 100644 (file)
@@ -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:"
index 39754600f1c18b7a8e2b2db4a9f5f1e1e9b8e283..41520135c2f5caae2531e909177399d912796d0d 100644 (file)
@@ -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 } {
index 452850966527487930f16410d56890187aed2f77..bee393c983eed0fc67a746d7ba16037c8b71c332 100644 (file)
@@ -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
index ae417ed38fef2ded56251c34a1043562c8457364..e3402fde7d605f3ed116ff13a9d58691b3feabcc 100644 (file)
@@ -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" {
index 34c2adc7d84087a9d68fea6d80bb567253df491e..00820513a8349e1f71253950897efa79611dea5b 100644 (file)
@@ -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]
index c8d4350e86b75edccca1fe4c66da6ed716135d3d..5338855959320a0d129f4a8567343dc365ed5509 100644 (file)
@@ -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
index 11f75dac2835823cba7d29e5302c652fece352f2..622dd29110d47bb012ad700aa493a02189233a8e 100644 (file)
@@ -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
 }
index d635982006951b2bde2625940ea8644d4643fd10..4138367b942f3aef4fdfe58d8af495bf2a029c24 100644 (file)
@@ -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
index 683d33e6cc7f16c55089a0edffc54cebaf42ed36..008f060209496ddffca1b7dfae80224a8a72d14f 100644 (file)
@@ -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.
index f8c4f6cc623c2cf95cbb4f1e52950026ba7f25da..3cc4282c814834eb12e52ad932f04edac38da983 100644 (file)
@@ -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
index 5d8ffa381c38a915b4e91c7e7786089ae88c7cb7..9b233385904bdb151db4817f1eda8384f84acc95 100644 (file)
@@ -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
index 573aa0a919e5f70d9629c8357bca20e03a964938..be8a410bb1d35e7e634a067e7b7ad40cc4d101d0 100644 (file)
@@ -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]
 
index 65de2d5e5e154ba1a5a48049ae63317df19cba9b..a544b425ae758c6169ed375d0f3987bfb1343cbc 100644 (file)
@@ -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
index 8bb705dfe4f118ceaada8b45f3e6977a6c95f505..a0630b5dec03f70bbb520142dcacf8a4ab0d07c5 100644 (file)
@@ -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
 
 #
index 6fb208597920da13743f2bb4ebab0b702606a6b3..d6f7781951b4fe0d46d0ea6cdf552d49093bed89 100644 (file)
@@ -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
index 3b00f6d92ccb0051f51fde9ca3478c1fe37967b9..ad03e53e5436420767495a819c3fb30a1da71276 100644 (file)
@@ -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
 
index 8a73378328f58eb8dff38cf19dce425936ddb1e0..879f338a76b2cdb756eff98ab65ff0f08ac04cc9 100644 (file)
@@ -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
index 67f319551864dd3b1c94e8bc9fbf62a8ed501b54..1cc9eeeab65fe5a5fd6041c79a3b1f1869e81524 100644 (file)
@@ -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"
 
index da5834be9a66625b439a83070bd04fef3ed15336..92956429a1b42994dc5bcb3c6baa815266ada9a0 100644 (file)
@@ -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
index 703f9e95c4f25f404eff2d477f7a688a37c5db88..b08e49598641478e4fbd12da177fc35bd20b881e 100644 (file)
@@ -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"
 
index 9607b81aaba55480167d09f54670633a754f2bae..ac682dd0c98a42c23ee8a31fd2036a6c4f2a5311 100644 (file)
@@ -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 } {
index aca51187baad308f2e1880f43d57abe3eaf87d4e..1bcea05d27422930de7cc72990ebab9cc876e7a9 100644 (file)
 
 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]} {
index fe4af579253f4a875e4c97968b023aec6d3489b4..d51614152e6f8a929d25f2cd36bfa8f83b6aad06 100644 (file)
@@ -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.
index 99f5e7df857321fe900baba6a1df933628f07370..085cb4b36f1a57d19d7445476277a3fdcf9f74ca 100644 (file)
 
 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
index cd49df1826a2fb441122dd4476ce70b0d28f46ee..95198a414f144325950fcc77f071bab70ec1ef87 100644 (file)
@@ -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"
 
index b1cc8fb334fc791dc6d90c8882ec45170068f205..d5a0227197e3c8bfc7d6a6f939078440efe265ff 100644 (file)
 
 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
 #
index e2b7354dbc252bfbf949b04869b36b4d4308fd05..b9f7b47396d02e416bfc765a7a38ac14b149b490 100644 (file)
@@ -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"
index aa4fc3c8b19584d9a7323ac002578c35103c9771..23207bed8f2969f63bbba353c27722809c89e455 100644 (file)
 
 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"
index 305685135e0ad491e8668072c25f133ffe867a79..19157972f76d094eae6d9dea1d906fd8be8b80d0 100644 (file)
@@ -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]} {
index b8d3a6c738da9c4c10a3f0db5f03ea9e433d28ea..c6ed0cef1fe0d5f29f85e15da6d196f0e7ced0b6 100644 (file)
@@ -30,8 +30,7 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
     return -1
 }
 
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
 
 if {![runto_main]} {
     return
index 1b39ed8a3fe75146d3f5e7e0956e7b7eddc9d651..f08ed90f1f1a8aaa84bc6715825152a625718406 100644 (file)
@@ -30,8 +30,7 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
     return -1
 }
 
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
 
 if {![runto_main]} {
     return
index cb49ef654d56cf125d7f7981d7108fb013026d0b..65472425b375d11eb94631c503485625934c09a9 100644 (file)
@@ -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"
index 0c6ad87b712368c8e81df760ad1e9286573540e5..4bafa6807c98526190d27b3e3c403ffb6358f8e5 100644 (file)
@@ -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"
index 602c8e9e99dcf0d2d063cdc7526c6c356d5f6455..49cec5ea0ff68bd9f0f536033650f3e178fcc2a9 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 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
index b59404749a9f52294157eb85bf4501ede364303c..b83782f1ffc6f48fa95e5a3a30d1c085066350ab 100644 (file)
@@ -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"
 
index 34ac668080acd353b9dbbbb152873d5ecaa96a17..9c87f00762ddcafdc0fc0de8049ce6926cd2e001 100644 (file)
@@ -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
index d989a48d83a908bc2458322c5593a2e9f199bf2c..e0292c5a1518ab3e6b8a76200efd3aba51b025cf 100644 (file)
@@ -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 } {
index 5a6bfe6c39d6f80b239c43d9ae0421ec05285a23..edf71058ed7efa05f09339d3bcc4329fb5e03b3c 100644 (file)
 
 
 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"
index a7a6e9b774ceadbfd948391d1193d1409df00033..40170db6f7f5d1a8d252378a4dfba5201d9aa9ae 100644 (file)
@@ -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"
index 4d3d352333ca4a371ffe309b6c58f99172c2e41c..229e8de61dde12726b5df47a00e8566dca9556dd 100644 (file)
@@ -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 .*" \
index 27df21059720285199003300ae2edd81b64f0bf5..34c5a60e3c3afbfc8e110da25748917adbf7a51e 100644 (file)
@@ -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"
index a9027608b12cafb7fe167836f2ba1d5a20743417..eab0694c56ef61841fff550bceb64e7e5437a6a2 100644 (file)
@@ -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 } {
index b35383649b716c2c9919909e70462724c342bf4e..e7a647c856ef60cc8abe03044ef058ceefd0ddc3 100644 (file)
@@ -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"
index 2cabbf0d7bc9f915085e9992c60d1dd53a2e0570..16e4323c001a901c3861c7a85b5eb272170cd463 100644 (file)
 
 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
 }
index a3e0a3d4de8f5e254cc641e0e763b48d98c7eba8..f7f65fea2253e7914415a80670c39be872383e4f 100644 (file)
@@ -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]} {
index 480396a1d7dd59b93f143ca6e37f253e5d9f8bbd..3d1bccfe976a71313d842b41e3b50707f1ecd6d7 100644 (file)
@@ -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
 
index f134a0f1d9b3baf76cb2da038d851bd9fb29b40e..ab26371d50102c4c561a9e9af7904fafe423d1c5 100644 (file)
@@ -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]} {
index 62c20032dff917e3784155fe0a6d69cfdbbcd5ea..a9b70d63f317b8f7d6273805da8a885f7a9be765 100644 (file)
@@ -40,8 +40,7 @@ if { [do_compile {-mcpu=native}] != ""
        return -1
 }
 
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
 
 if { ![runto_main] } {
     return -1
index 8e815aee80d4b750b7eec5107bc078f37ec93d71..7843e7565bd1c61f4c1436cfd6db5e97e7363a41 100644 (file)
@@ -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]
 
index f12b4d109c9be2b5e0b030c3a075a2366c8c31ca..39a1f325637081ac4c3a94f5990f83cdde25f934 100644 (file)
@@ -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}]
 
index 508f7c98117ddeef0f6fbea1f203c8da3d419d4b..b7f22399f9420282adee566ee419ff6f80d2f428 100644 (file)
@@ -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]
 
index 9355ce0ee0b1e9754693c3a5f6d4904ab2cd427a..c100197814b771c9400b7c47a38bf1eab49673ad 100644 (file)
@@ -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]} {
index 1c774ce4e4c9dc34e9e7a34b4dc8a1cb2797a7c5..7f4bcc96780fab2b9c1a25932df4a4ac0e7c42d1 100644 (file)
@@ -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
index 01bc9ea4b7147d318adbd0cd3ecdb1e7aeaf9d0f..4d16466160830c59a20bc82667ab80788367ef11 100644 (file)
@@ -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
index b819284477107848707a063db11699d53389b8b5..a4d2241bc6b87fdff3738a6d3a555635ef04cfa5 100644 (file)
@@ -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
 }
index 594cb2be76541df838ddde0aa6650ab6c2e7a31f..eb4937e5018cea36c4256a0d22f097f2fb5100ec 100644 (file)
@@ -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] } {
index eddbcb3ef8756bfe576f83e02795d70bb3366789..5d0e8d0ff4d7cd28a74cbaa54b96f7b86e8ef279 100644 (file)
@@ -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"
index 621a7b999aef77b29f00c8e10edd60b342a05d50..b2c7a13513c4a7731489c43d4288ce71ea3fa7a8 100644 (file)
@@ -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]} {
index 6ac25fccdfb31bc89ed0031dce25ebdbbbf6c8bf..036dd209013558f9cf95f28315d33c2b9d9dca90 100644 (file)
@@ -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"
 
index 83f500b6224464e948259c50795e31c8c1c71b9c..adcaff5489781630b5bd31d29c09a948c6afc04d 100644 (file)
@@ -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"
index adc889480e416eb1c6d07821527f24db3d227279..197c8e54dbf1631bfa5b84318dc8cf0f4a8cac7c 100644 (file)
@@ -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]"
index da24880c2e992f4950b603ad01e292058553c195..b8c38095a0667fb2b4ab270e1e4322f6af8d7700 100644 (file)
@@ -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" \
index aa26140f2841042ceb70c22bbd696d2c233f5eba..8625e44eef46ec3f7c64185d1ebe4561efdf95ae 100644 (file)
@@ -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]
 
index c1afa184bb54631e1535dd94f3ea379c71059048..ae362a2e991ebdaba0b013057a22add56a571e03 100644 (file)
@@ -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"
index a42fc121bc644d1aeea4bcd53385abbb6f6ba339..88b3cb95ba8b4c03b7ef9f3d4f2c4e62900d6a9d 100644 (file)
@@ -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.*" \
index aa6b675cf80620cfd9fa92b50bcc3d3a454deaf4..6de869ce32cdc72288d3ba27ba08c7952e4bd173 100644 (file)
@@ -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" ".*"
 
index e70f104408d41932e858a355d172541856cd3118..adee4504a4372ec91c437787dcf9c8631c29a199 100644 (file)
@@ -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
 }
index 290606ab5c35130bf4fa394589fb9feaa20125e1..77d9c39d066ccc1ba69520425c58f1ec46da28c4 100644 (file)
@@ -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]} {
index 7ddf5df13398a21d156673df36ea1bf7fafec263..156643aac04977fd8c6e210cdd7fbaf5b6aa7f55 100644 (file)
@@ -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
index ab09d8275efedbd4ad7aceacacc872345f7807bb..4f86aeba752ee9c21418badd6db6c7927f22ec9f 100644 (file)
@@ -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...
 
index c83bce03241c3699cc6b7915c5c3e31b22ec5272..24cb008151cf3c2e4e9de21284021d626d61f87c 100644 (file)
 
 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"
index 9a1b53722606a7d6a83ce89b508e73f27bd7f14a..d73b37d25b475608b58452a9f6ae89004d02fe83 100644 (file)
@@ -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
index 2da274276a9c5cd0a0f5dbf75231f2f8c20dfcb3..3640dfec74b8713c8a705982fb74b67704792ce1 100644 (file)
@@ -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
        }
index f924b095ca3cc0027e82e32c820627cdfaff242b..2641be4016944052d6b0fb5b57f07059d36bd000 100644 (file)
 
 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
 #
index 7ee2c094c66920cb1fdbf0104f53263156d319dd..a28e07a64d1fe5786fa96bb7f9bd581abf797024 100644 (file)
@@ -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
 }
index 99552e6baef7426c93283fa055824b991d012fe3..90661dba0f76421af8a743d00d3a847f7a07e742 100644 (file)
@@ -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$"
index a63bd950026fabaacbf9aa969b64df0674d4f029..1d752818fd7bf7ac03a455ba9ceaa06d8202c896 100644 (file)
@@ -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
index 91d03792a3e77d8b02c8f68c59303d7816a51a55..5d45caf98a7eafae3c116d47388a64dc52ba1003 100644 (file)
@@ -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.
index 7f6d9f6a98173853c4e3222f638ee4794dccdcb1..404eeabd144ee6307566cdfceb4bd76472e42d7b 100644 (file)
@@ -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"  \
index 00b7df4d324a4c46bdf7b222b666cb061453d0c9..4f2af502db64ab2f18be0fa181f4572672d2da33 100644 (file)
@@ -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
 #
index 73bd1c4a93ef977d23892b58aeab7575f18d5592..a9f4ff1bff784216d072830daba600db122fcf33 100644 (file)
@@ -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
index 1582fcf871f51fb3fe0aa0f4b5a3bc80fb2e3ceb..b727ca8ad786efe3e5ae340b6302d13bd52d2d32 100644 (file)
@@ -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, ...}'.
index d7d555ed2e9b84dfed3a25be6429529acfa75035..1fe0c9d0485f80b2c474fdafa98c3e454fe0d483 100644 (file)
 
 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}"
 
index 826fbd9727a9b61b4b6f4f52c7a09a1a7fe105f9..8ea0b40c44e745b70aa79464d3a65d6970f18aef 100644 (file)
@@ -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"
 
index 067f55e149f072bd00c6cb26369a83d9d725c51e..f9b8657b9121939230e6cb499001f1fed90ed3a4 100644 (file)
@@ -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
index d60a0ea9e6df6924d8422a5694de4485b9f3fb51..8d2929f942c04357dc7b0ae0073a6d4aabce2e5c 100644 (file)
@@ -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
index 40f98fc6a29030f46a279e63cf9f013b2d26d51e..6bb49d36d4938a962f54ee6720d57e7264ddc6fc 100644 (file)
@@ -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
index 6cc992bb7f87ee542020db18e56897c491cbaecd..aecb3577b68655e5b0ffb02614aacd1da69e3f34 100644 (file)
@@ -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
index f6abc597c4944792b37e7bfe472fd45eca7c47f8..05743e6d51c0a1a860f0f52fdc8556a3ddb3d42b 100644 (file)
@@ -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
index e761e9355f392181f39c3a41720b3d9c3a779e38..98b75058dcc1305393bf3b61462d6f9aad593d3a 100644 (file)
@@ -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.
index fcc6ad4f0d1622c287ce7455205fe89b43ccbe9c..eeddb142c5957aa640babd07c0438b9083d9390b 100644 (file)
@@ -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
index 9895a2f5209f5a21756083bef99b1c4371700807..729297629715edabd9cd64af8ea7a790ca2f8627 100644 (file)
 
 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
index 70a7d8b059181e9a0276c9d78e8719680e8983d4..887b8c27b4e6ed6815bf2243893fb10f3f6f4bb3 100644 (file)
@@ -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
 }
index 695a3d2c894c1ee589b4a7e1a099ffbce072415d..0fdc800a7b2ce1f4c2772d9d9b5e6709a6521712 100644 (file)
@@ -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
        }
index 736e7798a9add0a8ab05b128e915a4e84f718cc7..e04691057049d16861dcf527838798d914d91818 100644 (file)
@@ -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
 }
index f7bdf084c447ddf27e6f209f874381012b151f85..ce8a599cef52cab61ca2f0f8e01ecaad5dea45a2 100644 (file)
 
 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"
 }
index e33d8bc1f163d379cd52ac1d71256c06aa340a8a..1ec13b8974309408780e0a64b36b3f2ef237139e 100644 (file)
@@ -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
     }
index 16f94676b19cf77ffa4e1c7d542fcb6748516372..afbf58e300ff17f7213c664abc7f9e1b40f06c3c 100644 (file)
@@ -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]
index 0fdfc7661ce14458e5c7596e1643b4041c5b0694..acf334fe5414c1a0ac165b214a5f76f54854224e 100644 (file)
@@ -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."
index 7d78829574e26dc3577a56c75bc8ff17372c61e5..e5dcdd1686aea3ad7b40ec95d60bae1a4c7d815f 100644 (file)
@@ -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
 
index 06c9aea57391d48d7f595b4c0df7bfc62529d0d8..44d774d72ad6c6b1b0efa549a7d23f5b454bc849 100644 (file)
@@ -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 ()
index 1d97726b1f6ac66c793ae10183fa6bbba384f36a..9faea303dcc9b366f79be5ea6ca2ae9496cb72dc 100644 (file)
@@ -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.
index 065cf1b3370b4efc1cd74cee1035d006652658fc..e2eb5166231c95bd7e76cb498bb904c5c71c7005 100644 (file)
@@ -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" \
index b2e58088da87eabd7903b9f541b5dfa550e37e78..167086b605bcef02434bc8050220b6426c3b9dab 100644 (file)
@@ -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
 }
index 5a4fcae59f1bfc0d6983b62d6823bd0a8a0c40ba..184021843b175eb8b03880d02294f64c42e5d691 100644 (file)
@@ -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
index 7b40a5f493a5a9a63ac7f2bc6d073c8fa3b0bc49..a79a7595af7b6ac10e031fecad7a4e4ca62af3f2 100644 (file)
 
 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
     }
 
index 2c75d06b84df953abba4cfbf68742ab145be5794..e5d31e8f29166a47bdbf4443651c36c998a0c9be 100644 (file)
@@ -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.
index 07cbddae1cfd6a747afff316d38017194cc11aa9..97788c7b94158918a38ce2e8a96feaccadcc347b 100644 (file)
@@ -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"
 
index 74b402f9bbe4c5e21547a553963cc381f0f4d6a6..60a8eececb7c3bb94107bf2c574c0589949804c9 100644 (file)
@@ -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
index a07b4670c01d25ebd1a01a95bb373c9c8a85d099..3a3af32814eedd53975ef0a4d82d38f793f1b535 100644 (file)
@@ -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" {
index 1822f1fea3322a672f28376ddbcf4d38554c85a7..749031c30f8e43feeb75fe19f577e71529b9bf6d 100644 (file)
@@ -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]
index 73a200f713d52b73360221fcb7305a62beeebb54..81b1ec169785b27ddee8dff5c601914fc212566d 100644 (file)
@@ -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
index c9b0a96b1bd55947029dd0ce3a22bd8a420c55af..d24cc992f707f6b0a070f9535073bbe0c12a4e9e 100644 (file)
@@ -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" \
index 2d5b62d477645a683fe3cab41366078e97ecba42..516b3876c79c7f76e93c682e45d58b4e2df2374c 100644 (file)
@@ -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
index cd0e903351859ceb44e5abf58483474837b2cfa2..a5eab2597f760802e327d35a60909ffe5f7ec78d 100644 (file)
@@ -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.
index aa4b300ad3421734deecac0021b702e0c8ae492c..abf347d3710bd1e35f6f552f31f1943b518e3947 100644 (file)
@@ -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"
index 4a5cefd53a55bef01a0249d2390d3a4368dd7d88..adba0bdbfc512f21ae1d563d7842be7f79890904 100644 (file)
@@ -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
index e38d04dac11d374aada66c38373b0e07ade00af9..1eb5f74cbcb880bbb13404f74d9cbd7fe8140f93 100644 (file)
@@ -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
index e960291c10142d63ac1d9fea2e7426a65b7acde3..d7c2cc95310d80e6247328e927f4fa440181ca32 100644 (file)
@@ -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
 
index 47013a0f8369b44ca37a15be428f719fe38ca04f..72c9df06443d8944c0f3914715aa86eaad6afdd0 100644 (file)
@@ -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"
index fe9f2d647efc1d896a8bf00711dbdeaa27bac205..844d6c81df6f2aa3172314de9fe6803a56113dab 100644 (file)
@@ -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"]" \
index 52f714001250aca0127ec5696a2db65ddaefad51..58b5a0a72f6285613f2c6177bae718319ffc6806 100644 (file)
@@ -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]"
index 270b4e15e91dca4a9ea83b51eba03b35070060b0..09ef242d848bf29c91cb15c0fb5e3948c149dfac 100644 (file)
@@ -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]"
index 9bcf73086222819af03d47dadbae0144e96f8001..ed8b572dddb83848faf68b582d1485c4b02da6fb 100644 (file)
@@ -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
index 7cd9298ef9d7653b49c54c8d0cb17470ebdcb3b6..6e4b9cb1113c5d66c8db0445557d20baae2a851a 100644 (file)
@@ -58,8 +58,7 @@ proc test_handle_all_print {} {
 }
 test_handle_all_print
 
-clean_restart
-gdb_load $binfile
+clean_restart $testfile
 
 if {[runto_main]} {
 
index 9ad772ffeb735f522b46b56b48838da4a6dfc26e..5cb0ea6b576118c84a1cef00da4b271b837cd40a 100644 (file)
@@ -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.
 #
index 8fa92af5177507e2230a910fb94df62e7ca47587..a01cdb8ebb6f0d2518e51dd53d8f04d77ee89e7f 100644 (file)
@@ -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
index 2df5dd0c27c433fa9fcb88e9396784607b593265..b69117349d86b711381e3207069b41fbe84f9fcd 100644 (file)
@@ -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"
 
index 0eef01c9e6be92117514881062f3c967ea97f83e..c6fa26b5fef3840ddabc320178c2e155a967eaca 100644 (file)
@@ -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
     }
index 1e309e53654a703d587a0a4a14808e1081e6eadb..2315397d44790a572c7795cdf30c1fba9d235540 100644 (file)
@@ -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.
index ab162a9d41652b091c6107e309a94a0bdb33d3d2..69702294327e6b469b33d1443987a8309197ad44 100644 (file)
@@ -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
index 880f632c96378e7c1ba3463eb9237a7fe609e3fb..221a1fae54f3aa996a7f19df67e1d0f91758cd9e 100644 (file)
@@ -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]} {
index 4d3494cbc6744a9f4efed35e00429f51e67668f5..2990aafc734c3eebdbc227679493ba17dfdac309 100644 (file)
@@ -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.
index f9b8856ad69c8798453b51be855be9f95ec37122..343eba4a8ae9cf42b57c582584cb7c801850da06 100644 (file)
@@ -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
 
index 1a82c1875ddc61995e8ef526d5be4d1c2664e428..2fb351f184b58607c55f013b02c9b5b52c109c14 100644 (file)
@@ -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"
index 15fc677dda187abef5b8c7132a38a6ea461ad9ea..286c12ab850c82726174107bfdfc4f6f2b058d39 100644 (file)
 
 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
 }
index 6872369c9889091df51ecb1484edcaca3ef1ae90..0887a5a5c7cfc8a2a3efe0c23f5ca7569b36f06c 100644 (file)
@@ -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"
index 24e3bf779edb4ba94eeff47e7f2940f8c144cb8e..b5fbfbbf4c8eba6fad1a7e127f96fa772fa2ed44 100644 (file)
@@ -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
index b10465fbd33996554fa92fc7296fb860d2503b07..8e2071120f354cf656e03f76612e9fedde56006f 100644 (file)
@@ -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"
index 372d52ccd83b60872af0be1b1a59e1bc0db0601c..1fb793dee8abf596e597d494c32efcacd5c8ed45 100644 (file)
 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
index 222f17ee0969c6ad9e7d79eb90570bf3796c57e5..eff13fa864cfafe34ef85e964af6964cb6099dbe 100644 (file)
@@ -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 {
index 13febdac2dbd134803661f6c33af9c67a5002b78..0d521c15beddc5e6b18d33d5679e935c06a9b7d5 100644 (file)
@@ -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
index aca9ca19917d6620a89eacf98e939bbc3199c53d..70db420fd2dced024fba4d6a52bf054206f514dc 100644 (file)
@@ -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]} {
index 540a48f9805900c6935c503b6df40bc0c0aa9813..a8fb3206497477bc22a7e30d264d22f61bc55908 100644 (file)
@@ -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
 
index 9b707993eb0b20e4af59b6c42ab161404738ede6..858cfc7d6d83021050df0c73e945a6ffcde4150e 100644 (file)
@@ -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 } {
index 14bbfc9040b91b86e2b9b7a009685568fc1f55be..87aac16caeed6ce842b1616aaaa72c261160f802 100644 (file)
@@ -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 } {
index fe3ce8098df57011b3e3c183b49a37ad10945d3a..dee7425c31ced7eb55aba6ecf42e31362c245f8c 100644 (file)
@@ -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 } {
index 83d271db5bd26a2e6db29ddc5df06bee1e97b3ab..6445f901e57e3d0c3275378697eaa68f56e10da7 100644 (file)
@@ -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.
index f5d8582924fa0ee038ed1547289dac67c9f6b6c4..dc4406a703993c68c57641001e64807ba1ebf68d 100644 (file)
@@ -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]} {
index b2d848d55da96433b0333422a22f1d86bd95f068..7024faa3158620dc961581242c3979071737d5ae 100644 (file)
@@ -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
 
index d25ae26c6e42355d152ffb8aae3a87abd0eef3d1..ef07d4cade8b649078c73ea3aa0e2c5e0c1d1c00 100644 (file)
@@ -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"
index 0c6d828e5d4622d79babd7ffeef8cdabb0e3a361..20315839086dd1784f471974330e30d9c2c10290 100644 (file)
@@ -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
 }
index afdb82e69b9785df22e964716830688276fc0f0e..a2a6f7a408295c01c24eec1b2bb30b744cbcc7f4 100644 (file)
@@ -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"
 
index 61c1f8cceece9ea7757e714049c96da8c2bd8615..cb68e187e82f4fc77a1cb645195441bfa4b6fcec 100644 (file)
@@ -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"
index 7f58a83b3d971ddc25b695169110142507e32756..906bd18ee5f3332ddbe20f1b53976cce7e2090c1 100644 (file)
@@ -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
index 163ec3bdee7597f5da66182ab8df00b591234f06..765ab7ada6a056d4d4e82326d32c801e555a67c2 100644 (file)
@@ -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
index 41f2b5c46a2db140ca8b7f19bc237b3a1bc93344..e7d1a0f71bfeabd32af17dee07acb36ee263aeee 100644 (file)
@@ -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} {
index 3ac5e1d8a38e15506bd89561e40ec349fedb4123..9c0e67cdbaa8f12ccae00bdb9f7cbee030bb3639 100644 (file)
@@ -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\\)"
index 6bbec98316f227691134ed714b4fe89e1473c639..d70196cb533c6fd7f98edfcc6c88a77ed1d1c289 100644 (file)
@@ -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