public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/27] Many small testsuite cleanups
@ 2023-01-25 22:45 Tom Tromey
  2023-01-25 22:45 ` [PATCH 01/27] Use ordinary calling convention for clean_restart Tom Tromey
                   ` (27 more replies)
  0 siblings, 28 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches

I noticed a few things in the test suite that looked off, so I wrote
some patches to clean it up.  Each patch should be reasonably
self-explanatory.

I started this because I was vaguely considering changing code like
this:

    if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
	return -1
    }

to some kind of require-like thing.  The idea here is that there are a
number of things that "shouldn't fail" -- gdb_compile,
prepare_for_testing, clean_restart, runto, runto_main -- each with
their own error return convention, where existing tests take failure
to mean immediately stop.

Instead of this, we could have a namespace that knows the conventions
for each supported proc and then works a bit like require, so:

    critical prepare_for_testing ...

This could then be a central spot to issue an unsupported (or untested
if we go that way).

Tested on x86-64 Fedora 36.

Tom



^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/27] Use ordinary calling convention for clean_restart
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 02/27] Use clean_restart in gdb.dlang Tom Tromey
                   ` (26 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

clean_restart accepts a single optional argument.  Rather than using
{args} and handling the argument by hand, change it to use Tcl's own
argument-checking.
---
 gdb/testsuite/lib/gdb.exp        | 11 +++--------
 gdb/testsuite/lib/mi-support.exp | 11 +++--------
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index e2af5a252b7..7c539ce15e6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -7432,20 +7432,16 @@ proc build_executable { testname executable {sources ""} {options {debug}} } {
 }
 
 # Starts fresh GDB binary and loads an optional executable into GDB.
-# Usage: clean_restart [executable]
+# Usage: clean_restart [EXECUTABLE]
 # EXECUTABLE is the basename of the binary.
 # Return -1 if starting gdb or loading the executable failed.
 
-proc clean_restart { args } {
+proc clean_restart {{executable ""}} {
     global srcdir
     global subdir
     global errcnt
     global warncnt
 
-    if { [llength $args] > 1 } {
-	error "bad number of args: [llength $args]"
-    }
-
     gdb_exit
 
     # This is a clean restart, so reset error and warning count.
@@ -7465,8 +7461,7 @@ proc clean_restart { args } {
 
     gdb_reinitialize_dir $srcdir/$subdir
 
-    if { [llength $args] >= 1 } {
-	set executable [lindex $args 0]
+    if {$executable != ""} {
 	set binfile [standard_output_file ${executable}]
 	return [gdb_load ${binfile}]
     }
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index b6da2c4baf0..767ea72ff70 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1008,20 +1008,16 @@ proc mi_run_with_cli {args} {
 }
 
 # Starts fresh GDB binary and loads an optional executable into GDB.
-# Usage: mi_clean_restart [executable]
+# Usage: mi_clean_restart [EXECUTABLE]
 # EXECUTABLE is the basename of the binary.
 # Return -1 if starting gdb or loading the executable failed.
 
-proc mi_clean_restart { args } {
+proc mi_clean_restart {{executable ""}} {
     global srcdir
     global subdir
     global errcnt
     global warncnt
 
-    if { [llength $args] > 1 } {
-	error "bad number of args: [llength $args]"
-    }
-
     gdb_exit
 
     # This is a clean restart, so reset error and warning count.
@@ -1034,8 +1030,7 @@ proc mi_clean_restart { args } {
 
     mi_gdb_reinitialize_dir $srcdir/$subdir
 
-    if { [llength $args] >= 1 } {
-	set executable [lindex $args 0]
+    if {$executable != ""} {
 	set binfile [standard_output_file ${executable}]
 	return [mi_gdb_load ${binfile}]
     }
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 02/27] Use clean_restart in gdb.dlang
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
  2023-01-25 22:45 ` [PATCH 01/27] Use ordinary calling convention for clean_restart Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 03/27] Eliminate spurious returns from the test suite Tom Tromey
                   ` (25 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.dlang to use clean_restart more consistently.
---
 gdb/testsuite/gdb.dlang/demangle.exp        | 5 +----
 gdb/testsuite/gdb.dlang/expression.exp      | 5 +----
 gdb/testsuite/gdb.dlang/primitive-types.exp | 5 +----
 gdb/testsuite/gdb.dlang/properties.exp      | 5 +----
 4 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/gdb/testsuite/gdb.dlang/demangle.exp b/gdb/testsuite/gdb.dlang/demangle.exp
index 111042cbe78..c0ae92537e6 100644
--- a/gdb/testsuite/gdb.dlang/demangle.exp
+++ b/gdb/testsuite/gdb.dlang/demangle.exp
@@ -195,10 +195,7 @@ proc test_d_demangling {} {
     test_demangling "_D3std6socket23UnknownAddressReference6__ctorMFPS4core3sys5posix3sys6socket8sockaddrkZC3std6socket23UnknownAddressReference" "std.socket.UnknownAddressReference.this(core.sys.posix.sys.socket.sockaddr*, uint)"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
+clean_restart
 
 if [set_lang_d] {
     gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.dlang/expression.exp b/gdb/testsuite/gdb.dlang/expression.exp
index 2f80b3390a0..c7aeec52d25 100644
--- a/gdb/testsuite/gdb.dlang/expression.exp
+++ b/gdb/testsuite/gdb.dlang/expression.exp
@@ -127,10 +127,7 @@ proc test_d_expressions {} {
     gdb_test "print \[1, 2\] ~ \[2, 3\]" " = \\\{1, 2, 2, 3\\\}"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
+clean_restart
 
 if [set_lang_d] {
     test_d_integer_literals
diff --git a/gdb/testsuite/gdb.dlang/primitive-types.exp b/gdb/testsuite/gdb.dlang/primitive-types.exp
index 3fd6d2d6e41..7b284bad2f0 100644
--- a/gdb/testsuite/gdb.dlang/primitive-types.exp
+++ b/gdb/testsuite/gdb.dlang/primitive-types.exp
@@ -49,10 +49,7 @@ proc test_builtin_d_types_accepted {} {
     gdb_test "ptype dchar" "type = dchar"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
+clean_restart
 
 if [set_lang_d] {
     test_builtin_d_types_accepted
diff --git a/gdb/testsuite/gdb.dlang/properties.exp b/gdb/testsuite/gdb.dlang/properties.exp
index 474c18b3177..3b92a81e2ca 100644
--- a/gdb/testsuite/gdb.dlang/properties.exp
+++ b/gdb/testsuite/gdb.dlang/properties.exp
@@ -80,10 +80,7 @@ proc test_d_typeof {} {
     gdb_test "ptype typeof(7.0f ^^ 3)" "type = float"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
+clean_restart
 
 if [set_lang_d] {
     test_d_sizeof
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 03/27] Eliminate spurious returns from the test suite
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
  2023-01-25 22:45 ` [PATCH 01/27] Use ordinary calling convention for clean_restart Tom Tromey
  2023-01-25 22:45 ` [PATCH 02/27] Use clean_restart in gdb.dlang Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 04/27] Remove some dead code in gdb.fortran/info-types.exp Tom Tromey
                   ` (24 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A number of tests end with "return".  However, this is unnecessary.
This patch removes all of these.
---
 gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp           | 1 -
 gdb/testsuite/gdb.base/attach.exp                    | 2 --
 gdb/testsuite/gdb.base/bfd-errors.exp                | 1 -
 gdb/testsuite/gdb.base/call-ar-st.exp                | 2 --
 gdb/testsuite/gdb.base/call-rt-st.exp                | 2 --
 gdb/testsuite/gdb.base/call-sc.exp                   | 2 --
 gdb/testsuite/gdb.base/call-signal-resume.exp        | 2 --
 gdb/testsuite/gdb.base/callexit.exp                  | 2 --
 gdb/testsuite/gdb.base/chng-syms.exp                 | 1 -
 gdb/testsuite/gdb.base/complex.exp                   | 2 --
 gdb/testsuite/gdb.base/cursal.exp                    | 2 --
 gdb/testsuite/gdb.base/define.exp                    | 1 -
 gdb/testsuite/gdb.base/detach.exp                    | 2 --
 gdb/testsuite/gdb.base/display.exp                   | 2 --
 gdb/testsuite/gdb.base/ena-dis-br.exp                | 1 -
 gdb/testsuite/gdb.base/ending-run.exp                | 2 +-
 gdb/testsuite/gdb.base/environ.exp                   | 1 -
 gdb/testsuite/gdb.base/eval-skip.exp                 | 8 --------
 gdb/testsuite/gdb.base/fileio.exp                    | 1 -
 gdb/testsuite/gdb.base/foll-exec-mode.exp            | 2 --
 gdb/testsuite/gdb.base/foll-exec.exp                 | 2 --
 gdb/testsuite/gdb.base/foll-vfork.exp                | 1 -
 gdb/testsuite/gdb.base/interrupt.exp                 | 1 -
 gdb/testsuite/gdb.base/jump.exp                      | 1 -
 gdb/testsuite/gdb.base/langs.exp                     | 1 -
 gdb/testsuite/gdb.base/long_long.exp                 | 1 -
 gdb/testsuite/gdb.base/maint.exp                     | 1 -
 gdb/testsuite/gdb.base/mips_pro.exp                  | 1 -
 gdb/testsuite/gdb.base/multi-forks.exp               | 2 --
 gdb/testsuite/gdb.base/range-stepping.exp            | 2 --
 gdb/testsuite/gdb.base/reread.exp                    | 2 --
 gdb/testsuite/gdb.base/sigall.exp                    | 2 --
 gdb/testsuite/gdb.base/signals.exp                   | 2 --
 gdb/testsuite/gdb.base/so-impl-ld.exp                | 7 -------
 gdb/testsuite/gdb.base/solib-symbol.exp              | 4 ----
 gdb/testsuite/gdb.base/step-break.exp                | 2 --
 gdb/testsuite/gdb.base/step-line.exp                 | 2 --
 gdb/testsuite/gdb.base/step-test.exp                 | 2 --
 gdb/testsuite/gdb.base/structs.exp                   | 1 -
 gdb/testsuite/gdb.base/twice.exp                     | 1 -
 gdb/testsuite/gdb.base/unwindonsignal.exp            | 2 --
 gdb/testsuite/gdb.base/whatis-exp.exp                | 1 -
 gdb/testsuite/gdb.cp/anon-ns.exp                     | 1 -
 gdb/testsuite/gdb.cp/breakpoint.exp                  | 1 -
 gdb/testsuite/gdb.cp/m-data.exp                      | 1 -
 gdb/testsuite/gdb.cp/m-static.exp                    | 1 -
 gdb/testsuite/gdb.cp/maint.exp                       | 1 -
 gdb/testsuite/gdb.cp/meth-typedefs.exp               | 1 -
 gdb/testsuite/gdb.cp/ovsrch.exp                      | 1 -
 gdb/testsuite/gdb.cp/pr-1023.exp                     | 1 -
 gdb/testsuite/gdb.cp/pr-1210.exp                     | 1 -
 gdb/testsuite/gdb.cp/pr-574.exp                      | 1 -
 gdb/testsuite/gdb.cp/pr10728.exp                     | 3 ---
 gdb/testsuite/gdb.cp/pr9067.exp                      | 2 --
 gdb/testsuite/gdb.cp/printmethod.exp                 | 1 -
 gdb/testsuite/gdb.cp/punctuator.exp                  | 1 -
 gdb/testsuite/gdb.cp/rtti.exp                        | 1 -
 gdb/testsuite/gdb.cp/static-method.exp               | 1 -
 gdb/testsuite/gdb.cp/try_catch.exp                   | 1 -
 gdb/testsuite/gdb.cp/userdef.exp                     | 1 -
 gdb/testsuite/gdb.cp/virtfunc2.exp                   | 2 --
 gdb/testsuite/gdb.mi/gdb2549.exp                     | 1 -
 gdb/testsuite/gdb.mi/gdb680.exp                      | 1 -
 gdb/testsuite/gdb.mi/gdb701.exp                      | 1 -
 gdb/testsuite/gdb.mi/gdb792.exp                      | 1 -
 gdb/testsuite/gdb.mi/mi-async.exp                    | 2 --
 gdb/testsuite/gdb.mi/mi-basics.exp                   | 1 -
 gdb/testsuite/gdb.mi/mi-cli.exp                      | 1 -
 gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp        | 2 --
 gdb/testsuite/gdb.mi/mi-console.exp                  | 1 -
 gdb/testsuite/gdb.mi/mi-disassemble.exp              | 1 -
 gdb/testsuite/gdb.mi/mi-eval.exp                     | 1 -
 gdb/testsuite/gdb.mi/mi-exit-code.exp                | 1 -
 gdb/testsuite/gdb.mi/mi-file.exp                     | 1 -
 gdb/testsuite/gdb.mi/mi-hack-cli.exp                 | 1 -
 gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp | 1 -
 gdb/testsuite/gdb.mi/mi-memory-changed.exp           | 1 -
 gdb/testsuite/gdb.mi/mi-read-memory.exp              | 1 -
 gdb/testsuite/gdb.mi/mi-record-changed.exp           | 2 --
 gdb/testsuite/gdb.mi/mi-regs.exp                     | 1 -
 gdb/testsuite/gdb.mi/mi-return.exp                   | 1 -
 gdb/testsuite/gdb.mi/mi-reverse.exp                  | 1 -
 gdb/testsuite/gdb.mi/mi-simplerun.exp                | 1 -
 gdb/testsuite/gdb.mi/mi-stack.exp                    | 1 -
 gdb/testsuite/gdb.mi/mi-stepi.exp                    | 1 -
 gdb/testsuite/gdb.mi/mi-syn-frame.exp                | 2 --
 gdb/testsuite/gdb.mi/mi-until.exp                    | 1 -
 gdb/testsuite/gdb.mi/mi-var-block.exp                | 1 -
 gdb/testsuite/gdb.mi/mi-var-child.exp                | 1 -
 gdb/testsuite/gdb.mi/mi-var-cmd.exp                  | 1 -
 gdb/testsuite/gdb.mi/mi-var-cp.exp                   | 1 -
 gdb/testsuite/gdb.mi/mi-var-display.exp              | 1 -
 gdb/testsuite/gdb.mi/mi-var-invalidate.exp           | 1 -
 gdb/testsuite/gdb.mi/mi-var-rtti.exp                 | 1 -
 gdb/testsuite/gdb.mi/mi-vla-c99.exp                  | 1 -
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp              | 1 -
 gdb/testsuite/gdb.mi/mi2-var-child.exp               | 1 -
 gdb/testsuite/gdb.multi/bkpt-multi-exec.exp          | 2 --
 gdb/testsuite/gdb.python/py-prompt.exp               | 1 -
 gdb/testsuite/gdb.stabs/weird.exp                    | 2 --
 gdb/testsuite/gdb.threads/attach-stopped.exp         | 2 --
 gdb/testsuite/gdb.threads/hand-call-in-threads.exp   | 2 --
 gdb/testsuite/gdb.threads/interrupted-hand-call.exp  | 2 --
 gdb/testsuite/gdb.threads/print-threads.exp          | 2 --
 gdb/testsuite/gdb.threads/thread-specific.exp        | 2 --
 gdb/testsuite/gdb.threads/thread-unwindonsignal.exp  | 2 --
 gdb/testsuite/gdb.threads/threxit-hop-specific.exp   | 2 --
 gdb/testsuite/gdb.threads/tls-nodebug.exp            | 2 --
 gdb/testsuite/gdb.threads/tls.exp                    | 2 --
 gdb/testsuite/gdb.trace/actions-changed.exp          | 2 --
 gdb/testsuite/gdb.trace/mi-traceframe-changed.exp    | 2 --
 gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp    | 2 --
 gdb/testsuite/gdb.trace/mi-tsv-changed.exp           | 2 --
 113 files changed, 1 insertion(+), 173 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
index d699f5fa30b..82c7b2a300a 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
@@ -135,4 +135,3 @@ mi_send_resuming_command "exec-continue" "continuing to inferior exit"
 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index 03214885082..95b330b72d9 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -650,5 +650,3 @@ do_command_attach_tests
 
 
 test_command_line_attach_run
-
-return 0
diff --git a/gdb/testsuite/gdb.base/bfd-errors.exp b/gdb/testsuite/gdb.base/bfd-errors.exp
index 08de1141336..7edb9d8d879 100644
--- a/gdb/testsuite/gdb.base/bfd-errors.exp
+++ b/gdb/testsuite/gdb.base/bfd-errors.exp
@@ -180,4 +180,3 @@ gdb_assert { $more_than_one == 0 } "consolidated bfd errors"
 gdb_assert { [array size bfd_error_count] >= 2 } "print all unique bfd errors"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp
index 37b817ae279..7e2aee6a4aa 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.exp
+++ b/gdb/testsuite/gdb.base/call-ar-st.exp
@@ -627,5 +627,3 @@ if ![gdb_skip_stdio_test "print print_one_large_struct(...)"] {
 }
 
 set timeout $oldtimeout
-return
-
diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp
index 16ecb9288b7..a84c1671e3a 100644
--- a/gdb/testsuite/gdb.base/call-rt-st.exp
+++ b/gdb/testsuite/gdb.base/call-rt-st.exp
@@ -175,5 +175,3 @@ if ![gdb_skip_stdio_test "print print_int_char_combo(*int_char_combo)"] {
 	".*Contents of int_char_combo_t:\[ \r\n\]+13\[ \t\]+!\[ \r\n\]+" \
 	".\[0-9\]+ = \\{int1 = 13, ch1 = 33 '!'\\}"
 }
-
-return
diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp
index dc78308d42e..cda6f618472 100644
--- a/gdb/testsuite/gdb.base/call-sc.exp
+++ b/gdb/testsuite/gdb.base/call-sc.exp
@@ -438,5 +438,3 @@ if {$allow_float_test} {
 
 # Approx size: 4, 8, ...
 test te
-
-return 0
diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp
index 4941188aac4..2388b9459d4 100644
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
@@ -138,5 +138,3 @@ gdb_test "continue" "Breakpoint \[0-9\]*, handle_signal.*" \
 
 gdb_test "continue" "$inferior_exited_re normally." \
     "continue to program exit"
-
-return 0
diff --git a/gdb/testsuite/gdb.base/callexit.exp b/gdb/testsuite/gdb.base/callexit.exp
index a8d14ef59da..4ed68936ae4 100644
--- a/gdb/testsuite/gdb.base/callexit.exp
+++ b/gdb/testsuite/gdb.base/callexit.exp
@@ -48,5 +48,3 @@ gdb_test_no_output "set may-call-functions on"
 gdb_test "call callexit()" \
 	"The program being debugged exited.*" \
 	"inferior function call terminated program"
-
-return 0
diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp
index d085d9c1366..eee51023537 100644
--- a/gdb/testsuite/gdb.base/chng-syms.exp
+++ b/gdb/testsuite/gdb.base/chng-syms.exp
@@ -83,4 +83,3 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 set timeout $oldtimeout
 verbose "Timeout is now $timeout seconds" 2
-return 0
diff --git a/gdb/testsuite/gdb.base/complex.exp b/gdb/testsuite/gdb.base/complex.exp
index 73538df866f..6507beb24b8 100644
--- a/gdb/testsuite/gdb.base/complex.exp
+++ b/gdb/testsuite/gdb.base/complex.exp
@@ -33,5 +33,3 @@ if {[runto f4]} {
     gdb_test "p *y" "\\\$\[0-9\]* = \{c = 42 '\\*', f = 1 \\+ 0i\}" \
 	    "print complex value in C"
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.base/cursal.exp b/gdb/testsuite/gdb.base/cursal.exp
index a4e3e3edeff..59cb1a28adc 100644
--- a/gdb/testsuite/gdb.base/cursal.exp
+++ b/gdb/testsuite/gdb.base/cursal.exp
@@ -65,5 +65,3 @@ if {! [runto_main]} {
 gdb_test "list" \
     "func1 \\(\\);" \
     "list size 3"
-
-return 0
diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp
index d57f2aaeb21..9ed5101e6ed 100644
--- a/gdb/testsuite/gdb.base/define.exp
+++ b/gdb/testsuite/gdb.base/define.exp
@@ -343,4 +343,3 @@ gdb_test_no_output "do-define" "invoke do-define"
 gdb_test "do-printit" "here" "invoke do-printit"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/detach.exp b/gdb/testsuite/gdb.base/detach.exp
index c602052b1de..d4427c13087 100644
--- a/gdb/testsuite/gdb.base/detach.exp
+++ b/gdb/testsuite/gdb.base/detach.exp
@@ -57,5 +57,3 @@ exec sleep 1
 
 set pass "two"
 do_detach_tests
-
-return 0
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index cacd6f530d4..a349fc8a97d 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -223,5 +223,3 @@ gdb_exit
 # Restore the preserved old timeout value.
 set timeout $oldtimeout
 verbose "Timeout is now $timeout seconds" 2
-
-return 0
diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index d0c46b08117..b6a8a3a4a7f 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -461,4 +461,3 @@ test_ena_dis_br "disable"
 test_ena_dis_br "enable"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp
index 4eda7579679..b2cfc03e3bf 100644
--- a/gdb/testsuite/gdb.base/ending-run.exp
+++ b/gdb/testsuite/gdb.base/ending-run.exp
@@ -296,7 +296,7 @@ if {!$use_gdb_stub
 set timeout $old_timeout
 
 #remote_exec build "rm -f ${binfile}"
-return 0
+
 
 
 
diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp
index 2944f826480..ad0291d9bbb 100644
--- a/gdb/testsuite/gdb.base/environ.exp
+++ b/gdb/testsuite/gdb.base/environ.exp
@@ -107,4 +107,3 @@ gdb_test "show paths" \
     "show paths works properly"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp
index 44433063d36..7936c42ae93 100644
--- a/gdb/testsuite/gdb.base/eval-skip.exp
+++ b/gdb/testsuite/gdb.base/eval-skip.exp
@@ -137,11 +137,3 @@ gdb_test "print (0 && (x=y))" ".$decimal = $false" \
 
 
 gdb_exit
-return 0
-
-
-
-
-
-
-
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index d19a8c4dde6..fd2eab5c6fc 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -273,4 +273,3 @@ if {[file exists $dir2] && ![file writable $dir2]} {
 }
 
 set timeout $oldtimeout
-return 0
diff --git a/gdb/testsuite/gdb.base/foll-exec-mode.exp b/gdb/testsuite/gdb.base/foll-exec-mode.exp
index 73b1827b1fa..0846441eac7 100644
--- a/gdb/testsuite/gdb.base/foll-exec-mode.exp
+++ b/gdb/testsuite/gdb.base/foll-exec-mode.exp
@@ -208,5 +208,3 @@ foreach cmd {"next" "continue"} {
 	}
     }
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index f4957c34a66..83ccb54e60e 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -385,5 +385,3 @@ gdb_exit
 clean_restart $binfile
 
 do_exec_tests
-
-return 0
diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp
index 5093ee3aab8..313afa06324 100644
--- a/gdb/testsuite/gdb.base/foll-vfork.exp
+++ b/gdb/testsuite/gdb.base/foll-vfork.exp
@@ -502,4 +502,3 @@ with_test_prefix "exit" {
 }
 
 set timeout $oldtimeout
-return 0
diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index 3952b6444c5..815994287d4 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -225,4 +225,3 @@ if {![file exists $binfile]} {
 	gdb_assert { $saw_end_of_file && $saw_inferior_exit } $msg
     }
 }
-return 0
diff --git a/gdb/testsuite/gdb.base/jump.exp b/gdb/testsuite/gdb.base/jump.exp
index a456698c380..032c4a6279d 100644
--- a/gdb/testsuite/gdb.base/jump.exp
+++ b/gdb/testsuite/gdb.base/jump.exp
@@ -114,4 +114,3 @@ gdb_test "jump $out_line" \
     "y"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp
index a882aadae7e..19830dc422d 100644
--- a/gdb/testsuite/gdb.base/langs.exp
+++ b/gdb/testsuite/gdb.base/langs.exp
@@ -124,4 +124,3 @@ if {[runto csub]} {
 }
 
 set timeout $oldtimeout
-return 0
diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp
index 3f6f751bf11..357f7cc8063 100644
--- a/gdb/testsuite/gdb.base/long_long.exp
+++ b/gdb/testsuite/gdb.base/long_long.exp
@@ -282,4 +282,3 @@ send_gdb "\n"
 gdb_test "" "0x00.*0x00" "repeat x command"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index d73ff569ad6..98e23b40ef6 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -515,4 +515,3 @@ gdb_test_no_output "maint print msymbols"
 gdb_test_no_output "maint print psymbols"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.base/mips_pro.exp b/gdb/testsuite/gdb.base/mips_pro.exp
index 12627bd0aea..59f6ddfc6e7 100644
--- a/gdb/testsuite/gdb.base/mips_pro.exp
+++ b/gdb/testsuite/gdb.base/mips_pro.exp
@@ -39,4 +39,3 @@ if {[runto middle]} {
     # or main -> middle.
     gdb_test "backtrace" "#0.*middle.*#\[12\].*main.*"
 }
-return 0
diff --git a/gdb/testsuite/gdb.base/multi-forks.exp b/gdb/testsuite/gdb.base/multi-forks.exp
index c1ee2a98108..542d36efec7 100644
--- a/gdb/testsuite/gdb.base/multi-forks.exp
+++ b/gdb/testsuite/gdb.base/multi-forks.exp
@@ -197,5 +197,3 @@ for {set i 6} { $i <= 16} {incr i} {
     gdb_test_no_output "kill inferior $i" "kill $i"
     gdb_test "info inferior $i" "<null>.*" "did kill $i"
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.base/range-stepping.exp b/gdb/testsuite/gdb.base/range-stepping.exp
index fd2eeda010b..ff4107610ac 100644
--- a/gdb/testsuite/gdb.base/range-stepping.exp
+++ b/gdb/testsuite/gdb.base/range-stepping.exp
@@ -221,5 +221,3 @@ with_test_prefix "software watchpoint" {
     gdb_test "watch \$pc" ".*" "set watchpoint"
     gdb_test "step" "soft-watch.*" "step still in same line"
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp
index a619d2897b8..65dab15ad92 100644
--- a/gdb/testsuite/gdb.base/reread.exp
+++ b/gdb/testsuite/gdb.base/reread.exp
@@ -132,5 +132,3 @@ foreach_with_prefix opts { "" "pie" } {
 
     }
 # End of tests.
-
-return 0
diff --git a/gdb/testsuite/gdb.base/sigall.exp b/gdb/testsuite/gdb.base/sigall.exp
index e5553f208ba..7f78d24e1ec 100644
--- a/gdb/testsuite/gdb.base/sigall.exp
+++ b/gdb/testsuite/gdb.base/sigall.exp
@@ -184,5 +184,3 @@ gdb_test "continue" \
     "get signal TERM"
 gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
 gdb_continue_to_end "continue to sigall exit"
-
-return 0
diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp
index 60b5891c624..6c41739348f 100644
--- a/gdb/testsuite/gdb.base/signals.exp
+++ b/gdb/testsuite/gdb.base/signals.exp
@@ -270,5 +270,3 @@ The program being debugged stopped while in a function called from GDB.*" \
 	"#0  handler .*#1  .signal handler called.*\#2 .*main.*" \
 	"backtrace for SIGUSR1"
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp
index e3052cbc6ae..fb4ef85221e 100644
--- a/gdb/testsuite/gdb.base/so-impl-ld.exp
+++ b/gdb/testsuite/gdb.base/so-impl-ld.exp
@@ -62,10 +62,3 @@ gdb_test "next" "${decimal}\[ \t\]*return ans;.* STEP .*" "step in solib call"
 gdb_step_until ".*main .. at.*return 0;.*" "step out of solib call"
 
 gdb_exit
-return 0
-
-
-
-
-
-
diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp
index dfc32c66e96..302981a64ad 100644
--- a/gdb/testsuite/gdb.base/solib-symbol.exp
+++ b/gdb/testsuite/gdb.base/solib-symbol.exp
@@ -65,7 +65,3 @@ gdb_test "br foo2" \
 	 "foo2 in mdlib"
 
 gdb_exit
-
-return 0
-
-
diff --git a/gdb/testsuite/gdb.base/step-break.exp b/gdb/testsuite/gdb.base/step-break.exp
index 9920e7ac5f5..ea1f8f6cd57 100644
--- a/gdb/testsuite/gdb.base/step-break.exp
+++ b/gdb/testsuite/gdb.base/step-break.exp
@@ -40,5 +40,3 @@ gdb_test "next 2" ".*place2.*" "next 2 (3)"
 gdb_test "next 2" ".*place3.*" "next 2 (4)"
 gdb_test "next 2" ".*place2.*" "next 2 (5)"
 gdb_test "next 2" ".*place3.*" "next 2 (6)"
-
-return 0
diff --git a/gdb/testsuite/gdb.base/step-line.exp b/gdb/testsuite/gdb.base/step-line.exp
index 6cd9115744d..89b5bd1e1eb 100644
--- a/gdb/testsuite/gdb.base/step-line.exp
+++ b/gdb/testsuite/gdb.base/step-line.exp
@@ -79,5 +79,3 @@ gdb_test "next" \
 gdb_test "next" \
          ".*RETURN \\(j\\);.*" \
 	 "next over dummy 10"
-
-return 0
diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp
index 6d2a5603396..faf172043fd 100644
--- a/gdb/testsuite/gdb.base/step-test.exp
+++ b/gdb/testsuite/gdb.base/step-test.exp
@@ -202,5 +202,3 @@ gdb_test_multiple "step" "$test" {
 }
 
 gdb_continue_to_end
-
-return 0
diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp
index 31b58cf8bdf..0a1920501c4 100644
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -603,4 +603,3 @@ if { $allow_float_test } {
     # Approx size: (4+4)+8=16, 32, ...
     test { tf td } {2} {2}
 }
-return 0
diff --git a/gdb/testsuite/gdb.base/twice.exp b/gdb/testsuite/gdb.base/twice.exp
index d5849256f53..4ddf4d3b8a3 100644
--- a/gdb/testsuite/gdb.base/twice.exp
+++ b/gdb/testsuite/gdb.base/twice.exp
@@ -48,4 +48,3 @@ if {[runto_main]} {
     gdb_test "step" "nothing \\(\\) at.*"
 }
 remote_exec build "rm -f twice.c" 
-return 0
diff --git a/gdb/testsuite/gdb.base/unwindonsignal.exp b/gdb/testsuite/gdb.base/unwindonsignal.exp
index 8470634e502..d10d1fe244d 100644
--- a/gdb/testsuite/gdb.base/unwindonsignal.exp
+++ b/gdb/testsuite/gdb.base/unwindonsignal.exp
@@ -71,5 +71,3 @@ gdb_test_multiple "maint print dummy-frames" \
 	pass "unwindonsignal, dummy frame removed"
     }
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.base/whatis-exp.exp b/gdb/testsuite/gdb.base/whatis-exp.exp
index f8ddd3046f4..7a40d0de32b 100644
--- a/gdb/testsuite/gdb.base/whatis-exp.exp
+++ b/gdb/testsuite/gdb.base/whatis-exp.exp
@@ -69,4 +69,3 @@ gdb_test "whatis x++" "type = int" "whatis value of  x++"
 gdb_test "whatis x--" "type = int" "whatis value of  x--"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/anon-ns.exp b/gdb/testsuite/gdb.cp/anon-ns.exp
index 35bef8d8267..68a49617e44 100644
--- a/gdb/testsuite/gdb.cp/anon-ns.exp
+++ b/gdb/testsuite/gdb.cp/anon-ns.exp
@@ -68,4 +68,3 @@ gdb_test "ptype '(anonymous namespace)'" \
     "type = namespace \\\(anonymous namespace\\\)"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/breakpoint.exp b/gdb/testsuite/gdb.cp/breakpoint.exp
index 7a244c7bdf8..ec03277801d 100644
--- a/gdb/testsuite/gdb.cp/breakpoint.exp
+++ b/gdb/testsuite/gdb.cp/breakpoint.exp
@@ -53,4 +53,3 @@ gdb_test "print i_" "\\\$2 = 3" "check the member variable from within C1::bar"
 
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/m-data.exp b/gdb/testsuite/gdb.cp/m-data.exp
index c5cb7af8366..274b315905c 100644
--- a/gdb/testsuite/gdb.cp/m-data.exp
+++ b/gdb/testsuite/gdb.cp/m-data.exp
@@ -96,4 +96,3 @@ gdb_test "print shadow" "\\$\[0-9]\* = 1" "shadowing member"
 gdb_test "print ::shadow" "\\$\[0-9]\* = 0" "shadowed global variable"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index c57aee10160..56c4cdad95e 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -194,4 +194,3 @@ gdb_test "step" "gnu_obj_1::method.*"
 gdb_test "print svar" " = true"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/maint.exp b/gdb/testsuite/gdb.cp/maint.exp
index d5319f43f61..59dccfbb3bd 100644
--- a/gdb/testsuite/gdb.cp/maint.exp
+++ b/gdb/testsuite/gdb.cp/maint.exp
@@ -118,4 +118,3 @@ test_first_component
 test_namespace
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/meth-typedefs.exp b/gdb/testsuite/gdb.cp/meth-typedefs.exp
index b484545d93e..27e76f53be6 100644
--- a/gdb/testsuite/gdb.cp/meth-typedefs.exp
+++ b/gdb/testsuite/gdb.cp/meth-typedefs.exp
@@ -187,4 +187,3 @@ foreach f [list "$func" "'$func'"] {
 }
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/ovsrch.exp b/gdb/testsuite/gdb.cp/ovsrch.exp
index 122ff26b760..31a8abf7793 100644
--- a/gdb/testsuite/gdb.cp/ovsrch.exp
+++ b/gdb/testsuite/gdb.cp/ovsrch.exp
@@ -91,4 +91,3 @@ gdb_continue_to_breakpoint "stop_here_too"
 test_class A::B::inner
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/pr-1023.exp b/gdb/testsuite/gdb.cp/pr-1023.exp
index 6eeab8efff7..dfc406000d7 100644
--- a/gdb/testsuite/gdb.cp/pr-1023.exp
+++ b/gdb/testsuite/gdb.cp/pr-1023.exp
@@ -50,4 +50,3 @@ gdb_test \
   "Breakpoint $decimal at $hex: file .*$srcfile, line 10.*"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/pr-1210.exp b/gdb/testsuite/gdb.cp/pr-1210.exp
index 30b9bd1eee6..f639e4eba92 100644
--- a/gdb/testsuite/gdb.cp/pr-1210.exp
+++ b/gdb/testsuite/gdb.cp/pr-1210.exp
@@ -54,4 +54,3 @@ gdb_test_multiple "print obj->myB" "print obj->myB" {
 }
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/pr-574.exp b/gdb/testsuite/gdb.cp/pr-574.exp
index 4854ba20a1b..762d32168a6 100644
--- a/gdb/testsuite/gdb.cp/pr-574.exp
+++ b/gdb/testsuite/gdb.cp/pr-574.exp
@@ -55,4 +55,3 @@ gdb_continue_to_breakpoint "end of constructors"
 gdb_test "print *theB" "\\$\[0-9\]* = {<A> = {\[^}\]*}, static b = <optimized out>}" "PR gdb/574"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/pr10728.exp b/gdb/testsuite/gdb.cp/pr10728.exp
index 6432ca32896..b860fb7c3ae 100644
--- a/gdb/testsuite/gdb.cp/pr10728.exp
+++ b/gdb/testsuite/gdb.cp/pr10728.exp
@@ -54,6 +54,3 @@ gdb_continue_to_breakpoint "marker 1"
 gdb_test "print x->y2 - x->y1" "warning: Type size unknown, assuming 1\. Try casting to a known type, or void \*\.\[^=\]*= 1"
 
 gdb_exit
-return 0
-
-
diff --git a/gdb/testsuite/gdb.cp/pr9067.exp b/gdb/testsuite/gdb.cp/pr9067.exp
index 388cf00a478..bd430f595a7 100644
--- a/gdb/testsuite/gdb.cp/pr9067.exp
+++ b/gdb/testsuite/gdb.cp/pr9067.exp
@@ -33,5 +33,3 @@ gdb_test "print b"  ".*same as static member.*"
 
 
 gdb_exit
-return 0
-
diff --git a/gdb/testsuite/gdb.cp/printmethod.exp b/gdb/testsuite/gdb.cp/printmethod.exp
index 4ab8b60ffe3..7a0150b5841 100644
--- a/gdb/testsuite/gdb.cp/printmethod.exp
+++ b/gdb/testsuite/gdb.cp/printmethod.exp
@@ -50,4 +50,3 @@ gdb_test "print theA->nonvirt" \
     "print nonvirtual method."
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/punctuator.exp b/gdb/testsuite/gdb.cp/punctuator.exp
index d1d7ab1be19..d853e7cecaf 100644
--- a/gdb/testsuite/gdb.cp/punctuator.exp
+++ b/gdb/testsuite/gdb.cp/punctuator.exp
@@ -45,4 +45,3 @@ gdb_test_no_output "set \$v = 0x5a5a" "set \$v 3"
 gdb_test "print (\$u xor_eq 0xaaaa) == (\$v ^= 0xaaaa)" "= true"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/rtti.exp b/gdb/testsuite/gdb.cp/rtti.exp
index a6944b4f919..8ad7683ee40 100644
--- a/gdb/testsuite/gdb.cp/rtti.exp
+++ b/gdb/testsuite/gdb.cp/rtti.exp
@@ -112,4 +112,3 @@ gdb_continue_to_breakpoint "end of constructors in func3"
 gdb_test "print *obj3" "\\$\[0-9\]* = {<n2::C2> = .*}"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/static-method.exp b/gdb/testsuite/gdb.cp/static-method.exp
index 775867579dc..b9e83b37e2e 100644
--- a/gdb/testsuite/gdb.cp/static-method.exp
+++ b/gdb/testsuite/gdb.cp/static-method.exp
@@ -110,4 +110,3 @@ foreach test $methods {
 }
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/try_catch.exp b/gdb/testsuite/gdb.cp/try_catch.exp
index 58ab88220e4..9c74fad98a0 100644
--- a/gdb/testsuite/gdb.cp/try_catch.exp
+++ b/gdb/testsuite/gdb.cp/try_catch.exp
@@ -63,4 +63,3 @@ gdb_continue_to_breakpoint "marker test-complete"
 gdb_test "p test" "= true"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/userdef.exp b/gdb/testsuite/gdb.cp/userdef.exp
index 9b5a6f11f96..f04a441c54d 100644
--- a/gdb/testsuite/gdb.cp/userdef.exp
+++ b/gdb/testsuite/gdb.cp/userdef.exp
@@ -133,4 +133,3 @@ gdb_test "print operator== (mem1, mem2)" " = false"
 gdb_test "print operator== (mem1, mem1)" " = true"
 
 gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.cp/virtfunc2.exp b/gdb/testsuite/gdb.cp/virtfunc2.exp
index a7b96ae40bf..b02f3d645c3 100644
--- a/gdb/testsuite/gdb.cp/virtfunc2.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc2.exp
@@ -47,5 +47,3 @@ gdb_test "print o2.do_print3()"  "\\$\[0-9\]+ = 111111"
 gdb_test "print o" " = {<interface> = {.*_vptr.interface = $hex <vtable for Obj.*>}, <No data fields>}"
 
 gdb_exit
-return 0
-
diff --git a/gdb/testsuite/gdb.mi/gdb2549.exp b/gdb/testsuite/gdb.mi/gdb2549.exp
index 4d91bc35406..b9611c531cb 100644
--- a/gdb/testsuite/gdb.mi/gdb2549.exp
+++ b/gdb/testsuite/gdb.mi/gdb2549.exp
@@ -103,4 +103,3 @@ mi_runto_main
 register_tests
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/gdb680.exp b/gdb/testsuite/gdb.mi/gdb680.exp
index cf968b94e46..fb9d865f6f4 100644
--- a/gdb/testsuite/gdb.mi/gdb680.exp
+++ b/gdb/testsuite/gdb.mi/gdb680.exp
@@ -49,4 +49,3 @@ for {set i 0} {$i < 4} {incr i} {
 do_test $i
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/gdb701.exp b/gdb/testsuite/gdb.mi/gdb701.exp
index d5ed24e2106..5a90bf505c5 100644
--- a/gdb/testsuite/gdb.mi/gdb701.exp
+++ b/gdb/testsuite/gdb.mi/gdb701.exp
@@ -54,4 +54,3 @@ foreach i [list x y z] {
 }
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/gdb792.exp b/gdb/testsuite/gdb.mi/gdb792.exp
index 2001f11b6fa..5805fb1c1db 100644
--- a/gdb/testsuite/gdb.mi/gdb792.exp
+++ b/gdb/testsuite/gdb.mi/gdb792.exp
@@ -78,4 +78,3 @@ mi_list_varobj_children "var2" {
 } "list children of class C"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.exp
index 5ca7c5dccc3..f970fc772ca 100644
--- a/gdb/testsuite/gdb.mi/mi-async.exp
+++ b/gdb/testsuite/gdb.mi/mi-async.exp
@@ -82,5 +82,3 @@ linux_async_tests
 mi_gdb_exit
 
 set GDBFLAGS $saved_gdbflags
-
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-basics.exp b/gdb/testsuite/gdb.mi/mi-basics.exp
index 3a40e58f5a8..086ce74eae5 100644
--- a/gdb/testsuite/gdb.mi/mi-basics.exp
+++ b/gdb/testsuite/gdb.mi/mi-basics.exp
@@ -270,4 +270,3 @@ if { [test_mi_interpreter_selection]
 }
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
index 408fb0ff535..04b3096d2ed 100644
--- a/gdb/testsuite/gdb.mi/mi-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-cli.exp
@@ -255,4 +255,3 @@ mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
   "-interpreter-exec console \"\""
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
index 552d7cd6cb1..7de92b7786f 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
@@ -117,5 +117,3 @@ proc test_command_param_changed { } {
 }
 
 test_command_param_changed
-
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index 5fc8e1d2c2f..738960739f7 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -96,4 +96,3 @@ mi_expect_stop "end-stepping-range" "main" "" ".*mi-console.c" $line "" \
     "finished step over hello"
     
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-disassemble.exp b/gdb/testsuite/gdb.mi/mi-disassemble.exp
index 0b4f4bcc219..2cd7df73acf 100644
--- a/gdb/testsuite/gdb.mi/mi-disassemble.exp
+++ b/gdb/testsuite/gdb.mi/mi-disassemble.exp
@@ -357,4 +357,3 @@ test_disassembly_mixed_lines_limit
 test_disassembly_opcode_format
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-eval.exp b/gdb/testsuite/gdb.mi/mi-eval.exp
index a446539bffe..1611b15c8f2 100644
--- a/gdb/testsuite/gdb.mi/mi-eval.exp
+++ b/gdb/testsuite/gdb.mi/mi-eval.exp
@@ -58,4 +58,3 @@ mi_gdb_test "511-data-evaluate-expression \"A + 3\"" "511\\^done,value=\"4\"" "e
 
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-exit-code.exp b/gdb/testsuite/gdb.mi/mi-exit-code.exp
index 366132c98e0..d98839e67d7 100644
--- a/gdb/testsuite/gdb.mi/mi-exit-code.exp
+++ b/gdb/testsuite/gdb.mi/mi-exit-code.exp
@@ -85,4 +85,3 @@ proc test_list_thread_groups { } {
 test_list_thread_groups
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-file.exp b/gdb/testsuite/gdb.mi/mi-file.exp
index 3d43868d9f4..811744e556f 100644
--- a/gdb/testsuite/gdb.mi/mi-file.exp
+++ b/gdb/testsuite/gdb.mi/mi-file.exp
@@ -76,4 +76,3 @@ test_file_list_exec_source_file
 test_file_list_exec_source_files
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-hack-cli.exp b/gdb/testsuite/gdb.mi/mi-hack-cli.exp
index 5d575f50e6d..3013d87462a 100644
--- a/gdb/testsuite/gdb.mi/mi-hack-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-hack-cli.exp
@@ -33,4 +33,3 @@ mi_gdb_test "47show architecture" \
 	"47show architecture"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp b/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
index a0976c071a7..d3523b07d00 100644
--- a/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
+++ b/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
@@ -63,4 +63,3 @@ mi_gdb_test "-data-evaluate-expression \"$path\"" \
     "-data-evaluate-expression $path"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-memory-changed.exp b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
index b992c3e4bbe..846415d6267 100644
--- a/gdb/testsuite/gdb.mi/mi-memory-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
@@ -79,4 +79,3 @@ regsub ^0x0* $main_addr "" main_addr
 mi_gdb_test "set var *(unsigned int *) 0x${main_addr} = ${main_insn}" \
     ".*=memory-changed,thread-group=\"i${decimal}\".addr=\"0x0*${main_addr}\",len=\"0x4\",type=\"code\".*\\^done"
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-read-memory.exp b/gdb/testsuite/gdb.mi/mi-read-memory.exp
index 77dec2c1888..0871f2f47ea 100644
--- a/gdb/testsuite/gdb.mi/mi-read-memory.exp
+++ b/gdb/testsuite/gdb.mi/mi-read-memory.exp
@@ -65,4 +65,3 @@ mi_gdb_test "6-data-read-memory shorts+64 o 2 1 1" \
 
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-record-changed.exp b/gdb/testsuite/gdb.mi/mi-record-changed.exp
index c5fb6355a6c..427023a107d 100644
--- a/gdb/testsuite/gdb.mi/mi-record-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-record-changed.exp
@@ -37,5 +37,3 @@ mi_gdb_test "record stop" \
 mi_gdb_test "target record" \
     ".*=record-started,thread-group=\"i${decimal}\",method=\"full\".*\\^done" \
     "target record"
-
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-regs.exp b/gdb/testsuite/gdb.mi/mi-regs.exp
index bda27d086d9..afc52c7a4c1 100644
--- a/gdb/testsuite/gdb.mi/mi-regs.exp
+++ b/gdb/testsuite/gdb.mi/mi-regs.exp
@@ -113,4 +113,3 @@ mi_runto_main
 sparc_register_tests
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-return.exp b/gdb/testsuite/gdb.mi/mi-return.exp
index cffb11c8e9a..6254711bdec 100644
--- a/gdb/testsuite/gdb.mi/mi-return.exp
+++ b/gdb/testsuite/gdb.mi/mi-return.exp
@@ -62,4 +62,3 @@ mi_gdb_test "205-break-delete" \
 test_return_simple
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-reverse.exp b/gdb/testsuite/gdb.mi/mi-reverse.exp
index 020b6feb448..baa53a495d7 100644
--- a/gdb/testsuite/gdb.mi/mi-reverse.exp
+++ b/gdb/testsuite/gdb.mi/mi-reverse.exp
@@ -165,4 +165,3 @@ proc test_controlled_execution_reverse {} {
 test_controlled_execution_reverse
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-simplerun.exp b/gdb/testsuite/gdb.mi/mi-simplerun.exp
index 829136b7cd0..99b729d5df3 100644
--- a/gdb/testsuite/gdb.mi/mi-simplerun.exp
+++ b/gdb/testsuite/gdb.mi/mi-simplerun.exp
@@ -187,4 +187,3 @@ test_controlling_breakpoints
 test_program_termination
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp
index f0424fc0c88..3359a877a6a 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi-stack.exp
@@ -208,4 +208,3 @@ test_stack_info_depth
 
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-stepi.exp b/gdb/testsuite/gdb.mi/mi-stepi.exp
index 17a73233a76..9fe8ada58f4 100644
--- a/gdb/testsuite/gdb.mi/mi-stepi.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepi.exp
@@ -68,4 +68,3 @@ mi_runto_main
 test_stepi_nexti
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
index 409fac623a7..5b3e60f4f34 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.exp
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -103,5 +103,3 @@ mi_gdb_test "410-data-evaluate-expression bar()" \
 mi_gdb_test "411-stack-list-frames" "411\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\",arch=\"$any\"}.*\\\]" "backtrace from inferior function at exception"
 
 mi_gdb_exit
-
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-until.exp b/gdb/testsuite/gdb.mi/mi-until.exp
index d6e757df829..be87d2c5474 100644
--- a/gdb/testsuite/gdb.mi/mi-until.exp
+++ b/gdb/testsuite/gdb.mi/mi-until.exp
@@ -81,4 +81,3 @@ test_running_to_foo
 test_until
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-block.exp b/gdb/testsuite/gdb.mi/mi-var-block.exp
index 2a8590d6574..3638dfd7ed5 100644
--- a/gdb/testsuite/gdb.mi/mi-var-block.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-block.exp
@@ -175,4 +175,3 @@ mi_gdb_test "-var-delete cb" \
 	"delete var cb"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-child.exp b/gdb/testsuite/gdb.mi/mi-var-child.exp
index 811398d811e..e64bde94959 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child.exp
@@ -1211,4 +1211,3 @@ if { [mi_run_inline_test child_deletion] < 0 } {
 
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index 432177ed603..9bd1f7cd1a8 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -688,4 +688,3 @@ mi_gdb_test "-var-update L" \
     "in-and-out-of-scope: in scope now, not changed"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.exp b/gdb/testsuite/gdb.mi/mi-var-cp.exp
index fa28e58f801..3ce48db6c2b 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.exp
@@ -123,4 +123,3 @@ proc verify_everything {variable_name} {
 mi_walk_varobj_tree c++ $tree verify_everything
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index 7c23aa91404..b889d197051 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -661,4 +661,3 @@ if { [info exists fp] } {
 
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
index 3ee35306d96..dfaff33b9a2 100644
--- a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
@@ -122,4 +122,3 @@ mi_gdb_test "-var-info-type global_simple" \
 	"no type for invalid variable global_simple"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-var-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-rtti.exp
index c724078a5cb..fb8e4923f82 100644
--- a/gdb/testsuite/gdb.mi/mi-var-rtti.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-rtti.exp
@@ -126,4 +126,3 @@ foreach_with_prefix inline_test $inline_tests {
 }
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-vla-c99.exp b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
index 48595fee4db..ddfe6076213 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-c99.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
@@ -80,4 +80,3 @@ mi_list_array_varobj_children "vla" "5" "int" \
     "get children of vla"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index 9020f89e117..a240fb36d61 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -209,4 +209,3 @@ mi_gdb_test "600-data-evaluate-expression pvla2" \
   "600\\^done,value=\"<not associated>\"" "evaluate vla pointer set to null"
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp
index 9b7fd10b4ef..47cfeb860e3 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-child.exp
@@ -1321,4 +1321,3 @@ set tree "
 mi_walk_varobj_tree c $tree verify_everything
 
 mi_gdb_exit
-return 0
diff --git a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
index 9ab1ef18559..3fe77b2f7de 100644
--- a/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
+++ b/gdb/testsuite/gdb.multi/bkpt-multi-exec.exp
@@ -76,5 +76,3 @@ gdb_test "inferior 1"
 # Now run to the breakpoint.  This should cross the exec, and stop at
 # the breakpoint before the crash.
 gdb_test "run" "${srcfile2}:${bp_location}.*set breakpoint here.*"
-
-return 0
diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp
index b5628933e0f..35e8144d3f9 100644
--- a/gdb/testsuite/gdb.python/py-prompt.exp
+++ b/gdb/testsuite/gdb.python/py-prompt.exp
@@ -116,4 +116,3 @@ with_test_prefix "sync_execution = 1, is_running = 0" {
 
 set GDBFLAGS $saved_gdbflags
 kill_wait_spawned_process $test_spawn_id
-return 0
diff --git a/gdb/testsuite/gdb.stabs/weird.exp b/gdb/testsuite/gdb.stabs/weird.exp
index 70355b40734..f89595b0789 100644
--- a/gdb/testsuite/gdb.stabs/weird.exp
+++ b/gdb/testsuite/gdb.stabs/weird.exp
@@ -311,5 +311,3 @@ gdb_expect 60 {
 }
 
 do_tests
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
index 25d63b37090..a3080c054af 100644
--- a/gdb/testsuite/gdb.threads/attach-stopped.exp
+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
@@ -96,5 +96,3 @@ if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" execut
 }
 
 corefunc threaded
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
index 1309ef82bc6..336199112b0 100644
--- a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
+++ b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
@@ -159,5 +159,3 @@ gdb_test "show scheduler-locking" ".* locking scheduler .* is \"off\"." "show sc
 #gdb_test "thread 1" ".*" "set thread to 1, prepare to resume"
 #
 #gdb_continue_to_end "hand-call-in-threads"
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/interrupted-hand-call.exp b/gdb/testsuite/gdb.threads/interrupted-hand-call.exp
index 478e29722b3..ed1ea9fe64d 100644
--- a/gdb/testsuite/gdb.threads/interrupted-hand-call.exp
+++ b/gdb/testsuite/gdb.threads/interrupted-hand-call.exp
@@ -76,5 +76,3 @@ gdb_test_multiple "maint print dummy-frames" "dummy frame popped" {
 # Continue one last time, the program should exit normally.
 
 gdb_continue_to_end "" continue 1
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/print-threads.exp b/gdb/testsuite/gdb.threads/print-threads.exp
index 49a0535bfc5..c0913025e87 100644
--- a/gdb/testsuite/gdb.threads/print-threads.exp
+++ b/gdb/testsuite/gdb.threads/print-threads.exp
@@ -108,5 +108,3 @@ gdb_breakpoint "kill"
 set timeout [expr $oldtimeout + 120]
 test_all_threads "slow with kill breakpoint" 1
 set timeout $oldtimeout
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/thread-specific.exp b/gdb/testsuite/gdb.threads/thread-specific.exp
index 3c3055e5dbc..9ba98ec6290 100644
--- a/gdb/testsuite/gdb.threads/thread-specific.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific.exp
@@ -128,5 +128,3 @@ if { $this_thread != -1 } {
 } else {
     untested "thread var at break"
 }
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
index 0b08723fffa..b3e3288ba69 100644
--- a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
+++ b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
@@ -100,5 +100,3 @@ gdb_test_multiple "maint print dummy-frames" "dummy frame popped" {
 # Continue one last time, the program should exit normally.
 
 gdb_continue_to_end "" continue 1
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/threxit-hop-specific.exp b/gdb/testsuite/gdb.threads/threxit-hop-specific.exp
index 0b7bd257234..24055db0b8c 100644
--- a/gdb/testsuite/gdb.threads/threxit-hop-specific.exp
+++ b/gdb/testsuite/gdb.threads/threxit-hop-specific.exp
@@ -47,5 +47,3 @@ gdb_breakpoint "$bpexitline"
 gdb_test "continue" \
     ".*set exit breakpoint here.*" \
     "get past the thread specific breakpoint"
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/tls-nodebug.exp b/gdb/testsuite/gdb.threads/tls-nodebug.exp
index 3dcf5f4a1d1..41a2f2719d8 100644
--- a/gdb/testsuite/gdb.threads/tls-nodebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-nodebug.exp
@@ -40,5 +40,3 @@ gdb_test "p (int) thread_local" "= 42" \
 # Done!
 #
 gdb_exit
-
-return 0
diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp
index 99e9951f1f6..89f6fb89bac 100644
--- a/gdb/testsuite/gdb.threads/tls.exp
+++ b/gdb/testsuite/gdb.threads/tls.exp
@@ -321,5 +321,3 @@ gdb_test "info address a_thread_local" "Symbol \"a_thread_local\" is a thread-lo
 # Done!
 #
 gdb_exit
-
-return 0
diff --git a/gdb/testsuite/gdb.trace/actions-changed.exp b/gdb/testsuite/gdb.trace/actions-changed.exp
index 0c1542f82c8..54d9918888a 100644
--- a/gdb/testsuite/gdb.trace/actions-changed.exp
+++ b/gdb/testsuite/gdb.trace/actions-changed.exp
@@ -171,5 +171,3 @@ if ![gdb_target_supports_trace] {
 }
 
 test_actions_changed
-
-return 0
diff --git a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
index 9d736a4ae01..e6ca7faa9d2 100644
--- a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
@@ -152,5 +152,3 @@ proc test_tfind_remote { } {
 }
 
 test_tfind_remote
-
-return 0
diff --git a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
index cdd28cb6f96..6dc5e38d1b2 100644
--- a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
@@ -258,5 +258,3 @@ gdb_exit
 test_reconnect
 
 test_pending_resolved
-
-return 0
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index 57bedd686f6..ea7fcf31a30 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -245,5 +245,3 @@ if ![gdb_target_supports_trace] {
 gdb_exit
 
 test_upload_tsv
-
-return 0
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 04/27] Remove some dead code in gdb.fortran/info-types.exp
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (2 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 03/27] Eliminate spurious returns from the test suite Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 05/27] Minor "require" fixups Tom Tromey
                   ` (23 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

An early "return" in this test case prevents a test from running.
This seems to have been intentional and has been in place since:

commit d57cbee932f86df06251498daa93154046dc77c0
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Tue Dec 3 13:18:43 2019 +0000

    gdb/testsuite/fortran: Fix info-modules/info-types for gfortran 8+

This patch removes the dead code.
---
 gdb/testsuite/gdb.fortran/info-types.exp | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 98fb812dd8b..8cd9a2ae6cb 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -61,20 +61,3 @@ if { [test_compiler_info {gfortran-*} f90] } {
     setup_xfail *-*-* gcc/105454
     GDBInfoSymbols::check_entry "${srcfile}" "41" "Type s1;"
 }
-
-return 0
-
-gdb_test "info types" \
-    [multi_line \
-	 "All defined types:" \
-	 "" \
-	 "File .*:" \
-	 "\[\t \]+${character1}" \
-	 "\[\t \]+${integer4}" \
-	 "(\[\t \]+${integer8}" \
-	 ")?\[\t \]+${logical4}" \
-	 "(35:\[\t \]+Type __vtype_mod1_M1t1;" \
-	 ")?$decimal:\[\t \]+Type m1t1;" \
-	 "\[\t \]+${real4}" \
-	 "41:\[\t \]+Type s1;(" \
-	 ".*)?"]
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 05/27] Minor "require" fixups
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (3 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 04/27] Remove some dead code in gdb.fortran/info-types.exp Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 06/27] Remove unnecessary call to standard_testfile Tom Tromey
                   ` (22 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I found a couple of spots that could use "require", and one spot where
hoisting the "require" closer to the top of the file made it more
clear.
---
 gdb/testsuite/gdb.btrace/enable.exp                   | 5 +----
 gdb/testsuite/gdb.mi/list-thread-groups-available.exp | 3 +--
 gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp        | 5 ++---
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.btrace/enable.exp b/gdb/testsuite/gdb.btrace/enable.exp
index 6a30d7d9187..bedff46ddb6 100644
--- a/gdb/testsuite/gdb.btrace/enable.exp
+++ b/gdb/testsuite/gdb.btrace/enable.exp
@@ -76,10 +76,7 @@ gdb_exit
 # skip the rerun test when using gdbserver
 # otherwise rerun twice, target should be automatically disabled
 load_lib gdbserver-support.exp
-if {![allow_gdbserver_tests]} {
-    unsupported "target does not support gdbserver"
-    return 0
-}
+require allow_gdbserver_tests
 clean_restart $testfile
 if ![runto_main] {
     return -1
diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp
index 27224b5f96f..3ab2cab850c 100644
--- a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp
+++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp
@@ -22,6 +22,7 @@ standard_testfile
 
 # Support for XML is needed to run this test.
 require allow_xml_test
+require can_spawn_for_attach
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
     untested "failed to compile"
@@ -32,8 +33,6 @@ if [mi_gdb_start] {
     return
 }
 
-require can_spawn_for_attach
-
 set string_re {(?:[^\\"]|\\.)*}
 
 set id_re "id=\"$decimal\""
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index 4657509e84c..109f4f18235 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -28,9 +28,8 @@ if [info exists COMPILE] {
     # make check RUNTESTFLAGS="gdb.mi/mi2-amd64-entry-value.exp COMPILE=1"
     set srcfile ${testfile}.c
     lappend opts debug optimize=-O2
-} elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } {
-    verbose "Skipping mi2-amd64-entry-value."
-    return
+} else {
+    require {istarget x86_64-*-*} is_lp64_target
 }
 
 set executable ${testfile}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 06/27] Remove unnecessary call to standard_testfile
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (4 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 05/27] Minor "require" fixups Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 07/27] Start gdb after building executable in mi-basics.exp Tom Tromey
                   ` (21 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This test does not build a program and does not need to call
standard_testfile.
---
 gdb/testsuite/gdb.mi/mi-cmd-error.exp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-cmd-error.exp b/gdb/testsuite/gdb.mi/mi-cmd-error.exp
index 3f2aed201ae..5a3b84a58a6 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-error.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-error.exp
@@ -30,8 +30,6 @@ if [mi_gdb_start] {
     return
 }
 
-standard_testfile
-
 # A synchronous execution execution command that errors out.
 
 proc failing_sync_execution_command {} {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 07/27] Start gdb after building executable in mi-basics.exp
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (5 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 06/27] Remove unnecessary call to standard_testfile Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 08/27] Use mi_clean_restart more Tom Tromey
                   ` (20 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

A lot of the MI tests start gdb and only then build the executable.
This just seemed weird to me, so I've fixed this up.  In this patch,
no other cleanups are done, the startup is just moved to a more
logical (to me) spot.
---
 gdb/testsuite/gdb.mi/mi-basics.exp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-basics.exp b/gdb/testsuite/gdb.mi/mi-basics.exp
index 086ce74eae5..30d0da6ed02 100644
--- a/gdb/testsuite/gdb.mi/mi-basics.exp
+++ b/gdb/testsuite/gdb.mi/mi-basics.exp
@@ -28,11 +28,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start separate-inferior-tty] {
-    return
-}
-
 standard_testfile basics.c
 # This file was audited to ensure that the explicit references to
 # objdir in it are safe for parallel testing.  Please be sure to
@@ -49,6 +44,11 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 # In this file we want to test if the operations needed by the following
 # procedures work, so it makes no sense using them here.
 
+gdb_exit
+if [mi_gdb_start separate-inferior-tty] {
+    return
+}
+
 # mi_delete_breakpoints
 # mi_gdb_reinitialize_dir $srcdir/$subdir
 # mi_gdb_load ${binfile}
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 08/27] Use mi_clean_restart more
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (6 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 07/27] Start gdb after building executable in mi-basics.exp Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 09/27] Use clean_restart in gdb.pascal Tom Tromey
                   ` (19 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a number of MI tests to use mi_clean_restart rather than
separate calls.  This reduces the number of lines, which is nice, and
also provides a nicer model to copy for future tests.
---
 gdb/testsuite/gdb.ada/mi_ex_cond.exp          |  7 +------
 gdb/testsuite/gdb.ada/mi_task_arg.exp         |  7 +------
 gdb/testsuite/gdb.ada/mi_task_info.exp        |  7 +------
 .../gdb.dwarf2/dw2-opt-structptr.exp          | 11 ++---------
 .../gdb.mi/dw2-ref-missing-frame.exp          | 12 ++----------
 gdb/testsuite/gdb.mi/gdb680.exp               |  3 +--
 .../gdb.mi/list-thread-groups-no-inferior.exp |  3 +--
 gdb/testsuite/gdb.mi/mi-async-run.exp         |  4 +---
 gdb/testsuite/gdb.mi/mi-async.exp             | 11 +++--------
 gdb/testsuite/gdb.mi/mi-break-qualified.exp   |  8 +-------
 .../gdb.mi/mi-breakpoint-changed.exp          |  5 +----
 .../gdb.mi/mi-catch-cpp-exceptions.exp        |  6 +-----
 gdb/testsuite/gdb.mi/mi-cmd-error.exp         |  3 +--
 .../gdb.mi/mi-condbreak-call-thr-state.exp    | 12 +++---------
 gdb/testsuite/gdb.mi/mi-console.exp           | 11 ++++-------
 gdb/testsuite/gdb.mi/mi-dprintf-pending.exp   |  9 ++++-----
 gdb/testsuite/gdb.mi/mi-editing.exp           |  3 +--
 gdb/testsuite/gdb.mi/mi-eval.exp              | 12 +++---------
 gdb/testsuite/gdb.mi/mi-file-transfer.exp     |  6 +-----
 gdb/testsuite/gdb.mi/mi-file.exp              | 11 +++--------
 gdb/testsuite/gdb.mi/mi-fullname-deleted.exp  | 10 +++-------
 gdb/testsuite/gdb.mi/mi-hack-cli.exp          |  3 +--
 gdb/testsuite/gdb.mi/mi-i-cmd.exp             |  3 +--
 gdb/testsuite/gdb.mi/mi-info-os.exp           | 11 ++++-------
 .../gdb.mi/mi-inheritance-syntax-error.exp    | 10 ++++------
 gdb/testsuite/gdb.mi/mi-language.exp          |  3 +--
 gdb/testsuite/gdb.mi/mi-memory-changed.exp    |  4 +---
 gdb/testsuite/gdb.mi/mi-pending.exp           |  7 +++----
 gdb/testsuite/gdb.mi/mi-pthreads.exp          | 10 +++-------
 gdb/testsuite/gdb.mi/mi-reg-undefined.exp     | 12 +++---------
 gdb/testsuite/gdb.mi/mi-return.exp            | 13 +++----------
 gdb/testsuite/gdb.mi/mi-simplerun.exp         | 12 +++---------
 gdb/testsuite/gdb.mi/mi-solib.exp             | 11 +++--------
 gdb/testsuite/gdb.mi/mi-stack.exp             | 12 +++---------
 gdb/testsuite/gdb.mi/mi-start.exp             | 12 +++---------
 gdb/testsuite/gdb.mi/mi-threads-interrupt.exp |  6 +-----
 gdb/testsuite/gdb.mi/mi-undefined-cmd.exp     |  4 +---
 gdb/testsuite/gdb.mi/mi-until.exp             | 12 +++---------
 gdb/testsuite/gdb.mi/mi-var-block.exp         | 11 +++--------
 gdb/testsuite/gdb.mi/mi-var-child-f.exp       | 10 +++-------
 gdb/testsuite/gdb.mi/mi-var-child.exp         | 11 +++--------
 gdb/testsuite/gdb.mi/mi-var-cmd.exp           | 12 +++---------
 gdb/testsuite/gdb.mi/mi-var-cp.exp            |  9 +++------
 gdb/testsuite/gdb.mi/mi-var-display.exp       | 11 +++--------
 gdb/testsuite/gdb.mi/mi-var-invalidate.exp    | 11 +++--------
 ...i-var-list-children-invalid-grandchild.exp | 11 +++--------
 gdb/testsuite/gdb.mi/mi-var-rtti.exp          |  9 +++------
 gdb/testsuite/gdb.mi/mi-vla-c99.exp           | 11 +++--------
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp       | 11 +++--------
 gdb/testsuite/gdb.mi/mi-watch.exp             |  2 --
 .../gdb.mi/mi2-amd64-entry-value.exp          | 14 ++++----------
 gdb/testsuite/gdb.mi/mi2-cli-display.exp      | 10 +++-------
 gdb/testsuite/gdb.mi/mi2-prompt.exp           |  3 +--
 gdb/testsuite/gdb.mi/mi2-var-child.exp        | 11 +++--------
 .../gdb.python/py-framefilter-mi.exp          | 11 +++--------
 gdb/testsuite/gdb.python/py-mi-events.exp     | 12 +++++-------
 gdb/testsuite/gdb.python/py-mi-objfile.exp    | 11 ++++-------
 gdb/testsuite/gdb.python/py-mi.exp            | 16 ++++------------
 .../gdb.trace/mi-tracepoint-changed.exp       | 19 +++----------------
 gdb/testsuite/gdb.trace/mi-tsv-changed.exp    | 18 ++++--------------
 60 files changed, 147 insertions(+), 403 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/mi_ex_cond.exp b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
index 6fba4da9e80..f41b633a822 100644
--- a/gdb/testsuite/gdb.ada/mi_ex_cond.exp
+++ b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
@@ -57,15 +57,10 @@ gdb_test_multiple "catch exception" $msg {
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 # And finally, the meat of the testcase... Insert an Ada exception
 # catchpoint that uses both conditions and exception name.
 
diff --git a/gdb/testsuite/gdb.ada/mi_task_arg.exp b/gdb/testsuite/gdb.ada/mi_task_arg.exp
index 771e9345c40..1d84e432ad8 100644
--- a/gdb/testsuite/gdb.ada/mi_task_arg.exp
+++ b/gdb/testsuite/gdb.ada/mi_task_arg.exp
@@ -26,15 +26,10 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 # This test won't work properly if system debuginfo is installed.
 mi_gdb_test "-gdb-set debug-file-directory \"\"" ".*"
 
diff --git a/gdb/testsuite/gdb.ada/mi_task_info.exp b/gdb/testsuite/gdb.ada/mi_task_info.exp
index 7701a3ef6d6..6e23f018e4c 100644
--- a/gdb/testsuite/gdb.ada/mi_task_info.exp
+++ b/gdb/testsuite/gdb.ada/mi_task_info.exp
@@ -26,15 +26,10 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 ####################################
 # 1. Try catching all exceptions.  #
 ####################################
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
index ae6c58f2434..0d54947d36c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
@@ -168,20 +168,13 @@ proc do_mi_test {} {
     set MIFLAGS "-i=mi"
 
     global mi_gdb_prompt
-    global srcdir
-    global subdir
     global binfile
     
     with_test_prefix "mi" {
-	gdb_exit
-	if {[mi_gdb_start]} {
-	    return -1
+	if {[mi_clean_restart $binfile]} {
+	    return
 	}
 	
-	mi_delete_breakpoints
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load $binfile
-	
 	# This causes GDB to dereference a pointer-to-structure when doing
 	# -var-create.
 	mi_gdb_test "-gdb-set print object on" ".*" "set print object on"
diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
index 336290ee1e1..692e0f1eeaa 100644
--- a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
+++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
@@ -32,14 +32,10 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $objsfile object {}] != ""
     return -1
 }
 
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 if [mi_runto func_nofb_marker] {
     # First try referencing DW_AT_frame_base which is not defined.
     mi_gdb_test "300-stack-list-locals --thread 1 --frame 1 --all-values" \
@@ -48,13 +44,9 @@ if [mi_runto func_nofb_marker] {
 }
 
 # GDB could have crashed.
-mi_gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
 
 # And now try referencing DW_AT_frame_base defined using a self-reference
 # (DW_OP_fbreg).
diff --git a/gdb/testsuite/gdb.mi/gdb680.exp b/gdb/testsuite/gdb.mi/gdb680.exp
index fb9d865f6f4..a5d321d9368 100644
--- a/gdb/testsuite/gdb.mi/gdb680.exp
+++ b/gdb/testsuite/gdb.mi/gdb680.exp
@@ -20,8 +20,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-no-inferior.exp b/gdb/testsuite/gdb.mi/list-thread-groups-no-inferior.exp
index 2e05f1d8f92..feb2915f8c5 100644
--- a/gdb/testsuite/gdb.mi/list-thread-groups-no-inferior.exp
+++ b/gdb/testsuite/gdb.mi/list-thread-groups-no-inferior.exp
@@ -21,8 +21,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-async-run.exp b/gdb/testsuite/gdb.mi/mi-async-run.exp
index 0267b546ef7..cd668b161f8 100644
--- a/gdb/testsuite/gdb.mi/mi-async-run.exp
+++ b/gdb/testsuite/gdb.mi/mi-async-run.exp
@@ -35,12 +35,10 @@ proc test_async_run {} {
 
 	set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
 
-	gdb_exit
-	if [mi_gdb_start] {
+	if {[mi_clean_restart $binfile]} {
 	    return
 	}
 
-	mi_gdb_load ${binfile}
 	mi_run_cmd
 	mi_gdb_test "123-exec-interrupt --all" "123\\^done" "send interrupt command"
 	mi_expect_interrupt "expect interrupt"
diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.exp
index f970fc772ca..4bc82d5f55d 100644
--- a/gdb/testsuite/gdb.mi/mi-async.exp
+++ b/gdb/testsuite/gdb.mi/mi-async.exp
@@ -35,11 +35,6 @@ set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
 
 load_lib mi-support.exp
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -47,9 +42,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 # mi_gdb_test cannot be used for asynchronous commands because there are
 # two prompts involved and this can lead to a race condition.
diff --git a/gdb/testsuite/gdb.mi/mi-break-qualified.exp b/gdb/testsuite/gdb.mi/mi-break-qualified.exp
index 64bb9e4104e..3f6acc566b1 100644
--- a/gdb/testsuite/gdb.mi/mi-break-qualified.exp
+++ b/gdb/testsuite/gdb.mi/mi-break-qualified.exp
@@ -93,14 +93,8 @@ proc test_break_qualified {} {
 	    "delete temp breakpoints"
 }
 
-mi_gdb_exit
-
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
 test_break_qualified
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
index 5cc2fe840fb..c0d9add9646 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
@@ -165,12 +165,9 @@ proc test_pending_resolved { } {
 	global lib_sl1 lib_sl2
 	global mi_gdb_prompt
 
-	gdb_exit
-	if [mi_gdb_start] {
+	if {[mi_clean_restart $binfile]} {
 	    return
 	}
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load ${binfile}
 	mi_load_shlibs $lib_sl1 $lib_sl2
 
 	# Create a pending breakpoint on pendfunc1
diff --git a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
index ac2d8e18828..595ae929e9a 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
@@ -46,14 +46,10 @@ proc restart_for_test {} {
     global srcdir subdir binfile srcfile
     global main_lineno
 
-    if {[mi_gdb_start]} {
+    if {[mi_clean_restart $binfile]} {
 	return
     }
 
-    mi_delete_breakpoints
-    mi_gdb_reinitialize_dir $srcdir/$subdir
-    mi_gdb_load ${binfile}
-
     mi_runto_main
 
     mi_create_breakpoint \
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-error.exp b/gdb/testsuite/gdb.mi/mi-cmd-error.exp
index 5a3b84a58a6..a43d82495c6 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-error.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-error.exp
@@ -25,8 +25,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp b/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
index de0914dd0ed..8184cd82ece 100644
--- a/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
+++ b/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
@@ -40,11 +40,6 @@ proc test { variant } {
     global mi_gdb_prompt async
 
     with_test_prefix "$variant" {
-	gdb_exit
-	if [mi_gdb_start] {
-	    return
-	}
-
 	set options {debug}
 	if {$variant == "mt" } {
 	    lappend options "pthreads"
@@ -64,10 +59,9 @@ proc test { variant } {
 	    return -1
 	}
 
-	mi_delete_breakpoints
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load ${binfile}
+	if {[mi_clean_restart $binfile]} {
+	    return
+	}
 
 	mi_runto test
 
diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index 738960739f7..c39e05cc3d6 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -46,11 +46,6 @@ proc semihosted_string { string } {
   return [join $semihosted_list ""]
 }
 
-gdb_exit
-if [mi_gdb_start separate-inferior-tty] {
-    return
-}
-
 standard_testfile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -58,8 +53,10 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
+
 mi_runto_main
 
 # The output we get from the target depends on how it is hosted.  If
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp b/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
index 66a30426a8b..358d929f1bb 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
@@ -39,11 +39,10 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""}
     return -1
 }
 
-# Start with a fresh gdb.
-gdb_exit
-mi_gdb_start
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
+
 mi_load_shlibs $lib_sl1
 
 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
diff --git a/gdb/testsuite/gdb.mi/mi-editing.exp b/gdb/testsuite/gdb.mi/mi-editing.exp
index 35ed2af8ad4..2fb65ff9a9d 100644
--- a/gdb/testsuite/gdb.mi/mi-editing.exp
+++ b/gdb/testsuite/gdb.mi/mi-editing.exp
@@ -23,8 +23,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-eval.exp b/gdb/testsuite/gdb.mi/mi-eval.exp
index 1611b15c8f2..74ff887ef9c 100644
--- a/gdb/testsuite/gdb.mi/mi-eval.exp
+++ b/gdb/testsuite/gdb.mi/mi-eval.exp
@@ -25,11 +25,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -37,10 +32,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 set line_callee4_head [gdb_get_line_number "callee4 ("]
 set line_callee4_body [expr $line_callee4_head + 2]
diff --git a/gdb/testsuite/gdb.mi/mi-file-transfer.exp b/gdb/testsuite/gdb.mi/mi-file-transfer.exp
index 726504c46d8..5aacab90bce 100644
--- a/gdb/testsuite/gdb.mi/mi-file-transfer.exp
+++ b/gdb/testsuite/gdb.mi/mi-file-transfer.exp
@@ -29,13 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_file_cmd ${binfile}
 
 proc mi_gdbserver_run { } {
     mi_gdb_test "kill" ".*" ""
diff --git a/gdb/testsuite/gdb.mi/mi-file.exp b/gdb/testsuite/gdb.mi/mi-file.exp
index 811744e556f..b14b15a9165 100644
--- a/gdb/testsuite/gdb.mi/mi-file.exp
+++ b/gdb/testsuite/gdb.mi/mi-file.exp
@@ -18,11 +18,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -30,9 +25,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_file_cmd ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 proc test_file_list_exec_source_file {} {
     global srcfile
diff --git a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
index b41cc7fa510..f898e556449 100644
--- a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
+++ b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
@@ -16,11 +16,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile
 set srcfileabs [standard_output_file $srcfile]
 
@@ -63,8 +58,9 @@ if { [gdb_compile "$srcfileabs" "${binfile}" executable {debug}] != "" } {
 
 file delete -- $srcfileabs
 
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_gdb_test "-interpreter-exec console \"set substitute-path ${initdir} ${initdir}subst\"" {\^done} "set substitute-path"
 
diff --git a/gdb/testsuite/gdb.mi/mi-hack-cli.exp b/gdb/testsuite/gdb.mi/mi-hack-cli.exp
index 3013d87462a..f39923ba60b 100644
--- a/gdb/testsuite/gdb.mi/mi-hack-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-hack-cli.exp
@@ -19,8 +19,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-i-cmd.exp b/gdb/testsuite/gdb.mi/mi-i-cmd.exp
index 80ef266dd3a..e64f9006f3c 100644
--- a/gdb/testsuite/gdb.mi/mi-i-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-i-cmd.exp
@@ -16,8 +16,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-info-os.exp b/gdb/testsuite/gdb.mi/mi-info-os.exp
index 2f243a7aac0..d71ad4c8192 100644
--- a/gdb/testsuite/gdb.mi/mi-info-os.exp
+++ b/gdb/testsuite/gdb.mi/mi-info-os.exp
@@ -25,20 +25,17 @@ if {![istarget *-*-linux*]} {
 # Support for XML-output is needed to run this test.
 require allow_xml_test
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile basics.c
 
 if [build_executable "Failed to build $testfile" $testfile $srcfile \
 	debug] {
     return -1;
 }
-if {[mi_gdb_load $binfile] < 0} {
-    return -1
+
+if {[mi_clean_restart $binfile]} {
+    return
 }
+
 # When testing a cross configuration, we need to be sure to first
 # connect to the target.  If we didn't do that, GDB would try running
 # the command against the default run target.  The usual way to do
diff --git a/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp b/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
index d3523b07d00..90bb18257af 100644
--- a/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
+++ b/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
@@ -18,11 +18,6 @@ require allow_cplus_tests
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile .cc
 
 if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""} {
@@ -30,10 +25,13 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""
   return -1
 }
 
+if {[mi_clean_restart $binfile]} {
+    return
+}
+
 # Test that children of derived classes are given the proper
 # path by -var-info-path-expression
 
-mi_gdb_load ${binfile}
 mi_runto C::testLocation
 
 mi_create_varobj "var1" "this" "create var for THIS"
diff --git a/gdb/testsuite/gdb.mi/mi-language.exp b/gdb/testsuite/gdb.mi/mi-language.exp
index 4e8dea3995c..41a6c22d6f8 100644
--- a/gdb/testsuite/gdb.mi/mi-language.exp
+++ b/gdb/testsuite/gdb.mi/mi-language.exp
@@ -16,8 +16,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi-memory-changed.exp b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
index 846415d6267..c56256802f6 100644
--- a/gdb/testsuite/gdb.mi/mi-memory-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
@@ -22,11 +22,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
 
 load_lib mi-support.exp
 
-if [mi_gdb_start] {
+if {[mi_clean_restart $binfile]} {
     return
 }
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
 
 mi_gdb_test "-break-insert -t ${srcfile}:[gdb_get_line_number "C = A + B"]" \
     "\\^done,bkpt=\{number=\"1\".*" \
diff --git a/gdb/testsuite/gdb.mi/mi-pending.exp b/gdb/testsuite/gdb.mi/mi-pending.exp
index 271908c9855..153efdf45ce 100644
--- a/gdb/testsuite/gdb.mi/mi-pending.exp
+++ b/gdb/testsuite/gdb.mi/mi-pending.exp
@@ -45,10 +45,9 @@ if { [gdb_compile_pthreads $srcdir/$subdir/$srcfile $binfile executable $exec_op
 }
 
 # Start with a fresh gdb.
-gdb_exit
-mi_gdb_start
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 mi_load_shlibs $lib_sl1
 mi_load_shlibs $lib_sl2
 
diff --git a/gdb/testsuite/gdb.mi/mi-pthreads.exp b/gdb/testsuite/gdb.mi/mi-pthreads.exp
index fc410af99be..f8e701e7854 100644
--- a/gdb/testsuite/gdb.mi/mi-pthreads.exp
+++ b/gdb/testsuite/gdb.mi/mi-pthreads.exp
@@ -22,11 +22,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if {[mi_gdb_start]} {
-    return
-}
-
 # This procedure tests the various thread commands in MI.
 proc check_mi_thread_command_set {} {
 
@@ -68,8 +63,9 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
     return -1
 }
 
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 check_mi_thread_command_set
 
diff --git a/gdb/testsuite/gdb.mi/mi-reg-undefined.exp b/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
index 94db94289e2..1b8386cb2f5 100644
--- a/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
+++ b/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
@@ -24,11 +24,6 @@ if {![istarget "x86_64-*-*"] || ![is_lp64_target]} {
     return 0
 }
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile .S
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nopie}] != "" } {
@@ -36,10 +31,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 if ![mi_runto stop_frame] {
     perror "Failed to stop in stop_frame"
diff --git a/gdb/testsuite/gdb.mi/mi-return.exp b/gdb/testsuite/gdb.mi/mi-return.exp
index 6254711bdec..12185fb81f5 100644
--- a/gdb/testsuite/gdb.mi/mi-return.exp
+++ b/gdb/testsuite/gdb.mi/mi-return.exp
@@ -24,11 +24,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -36,11 +31,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 proc test_return_simple {} {
     global mi_gdb_prompt
diff --git a/gdb/testsuite/gdb.mi/mi-simplerun.exp b/gdb/testsuite/gdb.mi/mi-simplerun.exp
index 99b729d5df3..fec4f014cd3 100644
--- a/gdb/testsuite/gdb.mi/mi-simplerun.exp
+++ b/gdb/testsuite/gdb.mi/mi-simplerun.exp
@@ -27,11 +27,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -39,10 +34,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 proc test_breakpoints_creation_and_listing {} {
     global srcfile
diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp
index 03637651d92..665759d4d53 100644
--- a/gdb/testsuite/gdb.mi/mi-solib.exp
+++ b/gdb/testsuite/gdb.mi/mi-solib.exp
@@ -18,11 +18,6 @@ set MIFLAGS "-i=mi2"
 
 require allow_shlib_tests
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile solib-main.c solib-lib.c
 
 set libname "solib-lib"
@@ -39,9 +34,9 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
   return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_load_shlibs $binfile_lib
 
diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp
index 3359a877a6a..633e090c13a 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi-stack.exp
@@ -25,11 +25,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -37,10 +32,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 proc test_stack_frame_listing {} {
     global mi_gdb_prompt
diff --git a/gdb/testsuite/gdb.mi/mi-start.exp b/gdb/testsuite/gdb.mi/mi-start.exp
index b7e81a30486..89ce2dd25ea 100644
--- a/gdb/testsuite/gdb.mi/mi-start.exp
+++ b/gdb/testsuite/gdb.mi/mi-start.exp
@@ -21,11 +21,6 @@ set MIFLAGS "-i=mi"
 # then there is no point in running this testcase...
 require !use_gdb_stub
 
-gdb_exit
-if [mi_gdb_start] {
-    continue
-}
-
 standard_testfile mi-start.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -33,10 +28,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 # First, verify that the debugger correctly advertises support
 # for the --start option of the -exec-run command.
diff --git a/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp b/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
index 2193f05f1e2..149940d6743 100644
--- a/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
+++ b/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
@@ -36,14 +36,10 @@ proc test_continue_interrupt { } {
   global binfile
   global async
 
-  gdb_exit
-  if {[mi_gdb_start]} {
+  if {[mi_clean_restart $binfile]} {
       return
   }
 
-  # Load the binary in gdb...
-  mi_gdb_load $binfile
-
   # ... and run it.
   #
   # Note this test relies on mi_runto deleting the breakpoint.
diff --git a/gdb/testsuite/gdb.mi/mi-undefined-cmd.exp b/gdb/testsuite/gdb.mi/mi-undefined-cmd.exp
index 998853cefb8..9b57c8237f8 100644
--- a/gdb/testsuite/gdb.mi/mi-undefined-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-undefined-cmd.exp
@@ -16,12 +16,10 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
-
 # First, verify that the debugger correctly advertises support
 # for the "undefined-command" error code...
 mi_gdb_test "-list-features" \
diff --git a/gdb/testsuite/gdb.mi/mi-until.exp b/gdb/testsuite/gdb.mi/mi-until.exp
index be87d2c5474..902fd8ae591 100644
--- a/gdb/testsuite/gdb.mi/mi-until.exp
+++ b/gdb/testsuite/gdb.mi/mi-until.exp
@@ -24,11 +24,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile until.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -36,10 +31,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 proc test_running_to_foo {} {
     set line [gdb_get_line_number "in-loop"]
diff --git a/gdb/testsuite/gdb.mi/mi-var-block.exp b/gdb/testsuite/gdb.mi/mi-var-block.exp
index 3638dfd7ed5..e2e788a888c 100644
--- a/gdb/testsuite/gdb.mi/mi-var-block.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-block.exp
@@ -22,11 +22,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile var-cmd.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -34,9 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_runto do_block_tests
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index 7723dbc574f..1b4e164e3ea 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -21,11 +21,6 @@ load_lib "fortran.exp"
 
 require allow_fortran_tests
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile array.f90
 
 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
@@ -33,8 +28,9 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
     return -1
 }
 
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 # Avoid shared lib symbols.
 mi_gdb_test "-gdb-set auto-solib-add off" "\\^done"
diff --git a/gdb/testsuite/gdb.mi/mi-var-child.exp b/gdb/testsuite/gdb.mi/mi-var-child.exp
index e64bde94959..3cfa0ce88ac 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child.exp
@@ -22,11 +22,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -34,9 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_runto do_children_tests
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index 9bd1f7cd1a8..08465803734 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -22,11 +22,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile var-cmd.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -34,10 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 #####                   #####
 #                           #
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.exp b/gdb/testsuite/gdb.mi/mi-var-cp.exp
index 3ce48db6c2b..edb4332e253 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.exp
@@ -18,11 +18,6 @@ require allow_cplus_tests
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile .cc
 
 if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""} {
@@ -30,7 +25,9 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""
   return -1
 }
 
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_prepare_inline_tests $srcfile
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index b889d197051..548c4fe2ca3 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -22,11 +22,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile var-cmd.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -34,9 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 set line_dct_end [gdb_get_line_number "{int a = 0;}"]
 
diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
index dfaff33b9a2..20d9171ac18 100644
--- a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
@@ -23,11 +23,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile var-cmd.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -49,9 +44,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {d
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 # Desc:  Create global variable.
 mi_create_varobj global_simple global_simple "create global variable"
diff --git a/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp b/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
index ea02467c5e0..f9da4e46c85 100644
--- a/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
@@ -19,11 +19,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -31,9 +26,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 set line_invalid_pointer_value [gdb_get_line_number "p_outer set to invalid value"]
 set line_valid_pointer_value [gdb_get_line_number "p_outer set to valid value"]
diff --git a/gdb/testsuite/gdb.mi/mi-var-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-rtti.exp
index fb8e4923f82..a41d58e0b52 100644
--- a/gdb/testsuite/gdb.mi/mi-var-rtti.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-rtti.exp
@@ -18,11 +18,6 @@ require allow_cplus_tests
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile .cc
 set opts {debug c++}
 
@@ -30,7 +25,9 @@ if [build_executable $testfile.exp $testfile $srcfile $opts] {
     return -1
 }
 
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_prepare_inline_tests $srcfile
 
diff --git a/gdb/testsuite/gdb.mi/mi-vla-c99.exp b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
index ddfe6076213..3c28549e621 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-c99.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
@@ -21,11 +21,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile vla.c
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \
@@ -34,9 +29,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 set bp_lineno [gdb_get_line_number "vla-filled"]
 
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index a240fb36d61..e4db423babd 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -22,11 +22,6 @@ load_lib mi-support.exp
 load_lib fortran.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile vla.f90
 
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
@@ -39,9 +34,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
 # the type names can be printed differently.
 set real [fortran_real4]
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
 mi_create_breakpoint "-t vla.f90:$bp_lineno" \
diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp
index a6e6f89bc11..5303a41e86e 100644
--- a/gdb/testsuite/gdb.mi/mi-watch.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch.exp
@@ -31,8 +31,6 @@ set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests]
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-
 standard_testfile basics.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index 109f4f18235..9154f5c620f 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -16,11 +16,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile .s
 set opts {}
 
@@ -32,14 +27,13 @@ if [info exists COMPILE] {
     require {istarget x86_64-*-*} is_lp64_target
 }
 
-set executable ${testfile}
-
-if [build_executable ${testfile}.exp ${executable} ${srcfile} $opts] {
+if [build_executable ${testfile}.exp ${binfile} ${srcfile} $opts] {
     return -1
 }
 
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 foreach name {different breakhere_different breakhere_validity breakhere_invalid} {
     mi_create_breakpoint $name "break $name"
diff --git a/gdb/testsuite/gdb.mi/mi2-cli-display.exp b/gdb/testsuite/gdb.mi/mi2-cli-display.exp
index 817c3832c66..6a2b86d7e12 100644
--- a/gdb/testsuite/gdb.mi/mi2-cli-display.exp
+++ b/gdb/testsuite/gdb.mi/mi2-cli-display.exp
@@ -18,10 +18,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
-if {[mi_gdb_start]} {
-    return
-}
-
 standard_testfile
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -29,9 +25,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_runto do_tests
 
diff --git a/gdb/testsuite/gdb.mi/mi2-prompt.exp b/gdb/testsuite/gdb.mi/mi2-prompt.exp
index 22fda0e0970..f528c76b3d8 100644
--- a/gdb/testsuite/gdb.mi/mi2-prompt.exp
+++ b/gdb/testsuite/gdb.mi/mi2-prompt.exp
@@ -16,8 +16,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp
index 47cfeb860e3..5c40f83d1fa 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-child.exp
@@ -22,11 +22,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile var-cmd.c
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -34,9 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 mi_runto do_children_tests
 
diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.exp b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
index 723945dde83..509f21b3962 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-mi.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
@@ -20,11 +20,6 @@ load_lib gdb-python.exp
 
 set MIFLAGS "-i=mi2"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile py-framefilter-mi.c
 set pyfile py-framefilter.py
 
@@ -33,9 +28,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 if {[lsearch -exact [mi_get_features] python] < 0} {
     unsupported "python support is disabled"
diff --git a/gdb/testsuite/gdb.python/py-mi-events.exp b/gdb/testsuite/gdb.python/py-mi-events.exp
index cc417d48bfe..8d546a9e757 100644
--- a/gdb/testsuite/gdb.python/py-mi-events.exp
+++ b/gdb/testsuite/gdb.python/py-mi-events.exp
@@ -20,12 +20,8 @@ set MIFLAGS "-i=mi2"
 
 require allow_python_tests
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile
+
 set pyfile ${testfile}-gdb.py
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -35,8 +31,10 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 
 set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}]
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
+if {[mi_clean_restart]} {
+    return
+}
+
 mi_gdb_test "set auto-load safe-path ${remote_python_file}" \
     {.*\^done} \
     "set safe-path"
diff --git a/gdb/testsuite/gdb.python/py-mi-objfile.exp b/gdb/testsuite/gdb.python/py-mi-objfile.exp
index bc02da252bc..d098bba547d 100644
--- a/gdb/testsuite/gdb.python/py-mi-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-mi-objfile.exp
@@ -20,11 +20,6 @@ set MIFLAGS "-i=mi2"
 
 require allow_python_tests
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile
 set pyfile ${testfile}-gdb.py
 
@@ -38,8 +33,10 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
 # gdb will find it.
 set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}]
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
+if {[mi_clean_restart $binfile]} {
+    return
+}
+
 mi_gdb_test "set auto-load safe-path ${remote_python_file}" \
     {.*\^done} \
     "set safe-path"
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
index 705a9c41741..a7b7a5ffcd3 100644
--- a/gdb/testsuite/gdb.python/py-mi.exp
+++ b/gdb/testsuite/gdb.python/py-mi.exp
@@ -19,11 +19,6 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile py-prettyprint.c
 set pyfile py-prettyprint.py
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DMI}] != "" } {
@@ -31,9 +26,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+if {[mi_clean_restart $binfile]} {
+    return
+}
 
 if {[lsearch -exact [mi_get_features] python] < 0} {
     unsupported "python support is disabled"
@@ -347,12 +342,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" \
     return -1
 }
 
-if [mi_gdb_start] {
+if {[mi_clean_restart ${binfile}-cxx]} {
     return
 }
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}-cxx
 
 if {[lsearch -exact [mi_get_features] python] < 0} {
     unsupported "python support is disabled"
diff --git a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
index 6dc5e38d1b2..fab1463d268 100644
--- a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
@@ -89,19 +89,12 @@ proc test_reconnect { } {
 	    }
 	}
 
-	gdb_exit
+	global binfile
 
-	if [mi_gdb_start] {
+	if {[mi_clean_restart $binfile]} {
 	    return
 	}
 
-	global srcdir
-	global subdir
-	global binfile
-
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load ${binfile}
-
 	global gdbserver_protocol
 	global gdbserver_gdbport
 
@@ -162,19 +155,13 @@ proc test_pending_resolved { } {
     with_test_prefix "pending resolved" {
 	global decimal hex
 	global executable
-	global srcdir
-	global subdir
 	global binfile
 	global lib_sl1 lib_sl2
 	global mi_gdb_prompt
 
-	gdb_exit
-	if [mi_gdb_start] {
+	if {[mi_clean_restart $binfile]} {
 	    return
 	}
-
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load ${binfile}
 	mi_load_shlibs $lib_sl1 $lib_sl2
 
 	# Create a pending tracepoint on pendfunc2
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index ea7fcf31a30..792bd4f7d42 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -76,13 +76,11 @@ proc test_create_delete_modify_tsv { } {
 	    return -1
 	}
 	gdb_exit
-	if [mi_gdb_start] {
+
+	if {[mi_clean_restart $binfile]} {
 	    return
 	}
 
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load ${binfile}
-
 	mi_gdb_test "tvariable \$tvar3 = 3" \
 	    ".*=tsv-created,name=\"tvar3\",initial=\"3\".*\\^done" \
 	    "tvariable \$tvar3 modified"
@@ -177,19 +175,11 @@ proc test_upload_tsv { } {
 	    }
 	}
 
-	gdb_exit
-
-	if [mi_gdb_start] {
+	global binfile
+	if {[mi_clean_restart $binfile]} {
 	    return
 	}
 
-	global srcdir
-	global subdir
-	global binfile
-
-	mi_gdb_reinitialize_dir $srcdir/$subdir
-	mi_gdb_load ${binfile}
-
 	global gdbserver_protocol
 	global gdbserver_gdbport
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 09/27] Use clean_restart in gdb.pascal
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (7 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 08/27] Use mi_clean_restart more Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 10/27] Use clean_restart in gdb.linespec Tom Tromey
                   ` (18 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.pascal to use clean_restart more consistently.
---
 gdb/testsuite/gdb.pascal/print.exp | 6 +-----
 gdb/testsuite/gdb.pascal/types.exp | 6 +-----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/gdb/testsuite/gdb.pascal/print.exp b/gdb/testsuite/gdb.pascal/print.exp
index d3f28e2fbd4..2d665c30661 100644
--- a/gdb/testsuite/gdb.pascal/print.exp
+++ b/gdb/testsuite/gdb.pascal/print.exp
@@ -57,11 +57,7 @@ proc test_float_rejected {} {
     test_print_reject "p 1.1ll"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 if [set_lang_pascal] {
     test_float_accepted
diff --git a/gdb/testsuite/gdb.pascal/types.exp b/gdb/testsuite/gdb.pascal/types.exp
index 1bf013cab0f..af2d31e36d5 100644
--- a/gdb/testsuite/gdb.pascal/types.exp
+++ b/gdb/testsuite/gdb.pascal/types.exp
@@ -68,11 +68,7 @@ proc test_float_literal_types_accepted {} {
     gdb_test "pt 10E20" "type = double"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 if {[set_lang_pascal]} {
     test_integer_literal_types_accepted
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 10/27] Use clean_restart in gdb.linespec
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (8 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 09/27] Use clean_restart in gdb.pascal Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 11/27] Use clean_restart in gdb.opencl Tom Tromey
                   ` (17 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.linespec to use clean_restart more consistently.
---
 gdb/testsuite/gdb.linespec/explicit.exp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 637470e6763..b08d65953d2 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -594,9 +594,7 @@ namespace eval $testfile {
     }
 
     # Test interaction of condition command and explicit linespec conditons.
-    gdb_exit
-    gdb_start
-    gdb_load [standard_output_file $exefile]
+    clean_restart [standard_output_file $exefile]
 
     set tst "condition_command overrides explicit linespec condition"
     if {![runto_main]} {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 11/27] Use clean_restart in gdb.opencl
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (9 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 10/27] Use clean_restart in gdb.linespec Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-25 22:45 ` [PATCH 12/27] Use clean_restart in gdb.trace Tom Tromey
                   ` (16 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.opencl to use clean_restart more consistently.
---
 gdb/testsuite/gdb.opencl/callfuncs.exp | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.opencl/callfuncs.exp b/gdb/testsuite/gdb.opencl/callfuncs.exp
index 1fa3f8abcb0..4a7b2fb9f82 100644
--- a/gdb/testsuite/gdb.opencl/callfuncs.exp
+++ b/gdb/testsuite/gdb.opencl/callfuncs.exp
@@ -30,12 +30,7 @@ if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
     return -1
 }
 
-gdb_exit
-gdb_start
-
-# Load the OpenCL app
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${objdir}/${subdir}/${testfile}
+clean_restart [standard_testfile $testfile]
 
 # Set breakpoint at the OpenCL kernel
 gdb_test "tbreak testkernel" \
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 12/27] Use clean_restart in gdb.trace
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (10 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 11/27] Use clean_restart in gdb.opencl Tom Tromey
@ 2023-01-25 22:45 ` Tom Tromey
  2023-01-26 17:34   ` Pedro Alves
  2023-01-25 22:46 ` [PATCH 13/27] Use clean_restart in gdb.objc Tom Tromey
                   ` (15 subsequent siblings)
  27 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:45 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.trace to use clean_restart more consistently.
---
 gdb/testsuite/gdb.trace/actions.exp        | 20 +++--------------
 gdb/testsuite/gdb.trace/ax.exp             |  6 +-----
 gdb/testsuite/gdb.trace/change-loc.exp     |  4 +---
 gdb/testsuite/gdb.trace/deltrace.exp       | 10 +--------
 gdb/testsuite/gdb.trace/entry-values.exp   | 11 +---------
 gdb/testsuite/gdb.trace/infotrace.exp      |  9 +-------
 gdb/testsuite/gdb.trace/packetlen.exp      |  8 ++-----
 gdb/testsuite/gdb.trace/passc-dyn.exp      |  7 ++----
 gdb/testsuite/gdb.trace/passcount.exp      |  9 +-------
 gdb/testsuite/gdb.trace/pending.exp        |  4 +---
 gdb/testsuite/gdb.trace/read-memory.exp    |  5 +----
 gdb/testsuite/gdb.trace/report.exp         |  7 +-----
 gdb/testsuite/gdb.trace/save-trace.exp     |  9 +-------
 gdb/testsuite/gdb.trace/tfile.exp          |  5 +----
 gdb/testsuite/gdb.trace/tfind.exp          |  8 ++-----
 gdb/testsuite/gdb.trace/tracecmd.exp       |  9 +-------
 gdb/testsuite/gdb.trace/tsv.exp            |  6 ++----
 gdb/testsuite/gdb.trace/unavailable.exp    | 25 +++++-----------------
 gdb/testsuite/gdb.trace/while-dyn.exp      |  8 ++-----
 gdb/testsuite/gdb.trace/while-stepping.exp | 20 +++--------------
 20 files changed, 33 insertions(+), 157 deletions(-)

diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp
index cf7efbbd4fd..270dd3f5aa4 100644
--- a/gdb/testsuite/gdb.trace/actions.exp
+++ b/gdb/testsuite/gdb.trace/actions.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -28,12 +24,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 # define relative source line numbers:
 # all subsequent line numbers are relative to this first one (baseline)
@@ -325,10 +317,7 @@ gdb_test "tsave -ctf ${tracefile}.ctf" \
     "save ctf trace file"
 
 # Restart GDB and read the trace data in tfile target.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd $binfile
+clean_restart $binfile
 gdb_test "target tfile ${tracefile}.tf" ".*" \
     "change to tfile target"
 check_tracepoint "tfile"
@@ -345,10 +334,7 @@ gdb_test_multiple "target ctf" "" {
 }
 
 if { $gdb_can_read_ctf_data } {
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_file_cmd $binfile
+    clean_restart $binfile
     gdb_test "target ctf ${tracefile}.ctf" ".*" \
 	"change to ctf target"
     check_tracepoint "ctf"
diff --git a/gdb/testsuite/gdb.trace/ax.exp b/gdb/testsuite/gdb.trace/ax.exp
index 9dee743c8dd..9cc61d09182 100644
--- a/gdb/testsuite/gdb.trace/ax.exp
+++ b/gdb/testsuite/gdb.trace/ax.exp
@@ -20,9 +20,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
 standard_testfile actions.c
 
 require gdb_trace_common_supports_arch
@@ -33,9 +30,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     return -1
 }
 
-gdb_load $binfile
+clean_restart $binfile
 runto_main
-gdb_reinitialize_dir $srcdir/$subdir
 
 gdb_test "maint agent 12" ".*const8 12.*pop.*end.*"
 
diff --git a/gdb/testsuite/gdb.trace/change-loc.exp b/gdb/testsuite/gdb.trace/change-loc.exp
index 4c4f54d89be..b77e283c0b4 100644
--- a/gdb/testsuite/gdb.trace/change-loc.exp
+++ b/gdb/testsuite/gdb.trace/change-loc.exp
@@ -175,9 +175,7 @@ proc tracepoint_change_loc_2 { trace_type } {
 	global binfile
 	global gdb_prompt
 
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
+	clean_restart
 
 	gdb_test_multiple "${trace_type} set_tracepoint" "set pending tracepoint" {
 	    -re ".*Make \(|fast \)tracepoint pending.*y or \\\[n\\\]. $" {
diff --git a/gdb/testsuite/gdb.trace/deltrace.exp b/gdb/testsuite/gdb.trace/deltrace.exp
index cfcb81e8c91..c3107853808 100644
--- a/gdb/testsuite/gdb.trace/deltrace.exp
+++ b/gdb/testsuite/gdb.trace/deltrace.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 
 require gdb_trace_common_supports_arch
@@ -30,12 +26,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 # define relative source line numbers:
 # all subsequent line numbers are relative to this first one (baseline)
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index d7e5a89f281..9fbad50e3bd 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -29,14 +29,7 @@ if  {[gdb_compile [list ${binfile}1.o] \
     return -1
 }
 
-# Start GDB and load executable file, compute the offset of the
-# instruction in bar returned from foo.  It is needed in the Dwarf
-# Assembler.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}1
+clean_restart ${binfile}1
 
 set returned_from_foo ""
 
@@ -83,8 +76,6 @@ if { [string equal $returned_from_foo ""] } {
     return -1
 }
 
-gdb_exit
-
 # Make some DWARF for the test.
 set asm_file [standard_output_file $srcfile2]
 Dwarf::assemble $asm_file {
diff --git a/gdb/testsuite/gdb.trace/infotrace.exp b/gdb/testsuite/gdb.trace/infotrace.exp
index 1252b30c0f5..41779206679 100644
--- a/gdb/testsuite/gdb.trace/infotrace.exp
+++ b/gdb/testsuite/gdb.trace/infotrace.exp
@@ -18,9 +18,6 @@
 load_lib "trace-support.exp"
 
 
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 
 require gdb_trace_common_supports_arch
@@ -30,12 +27,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 #
 # test "info tracepoints" command
diff --git a/gdb/testsuite/gdb.trace/packetlen.exp b/gdb/testsuite/gdb.trace/packetlen.exp
index 31686bcb3bb..df4badc35bd 100644
--- a/gdb/testsuite/gdb.trace/packetlen.exp
+++ b/gdb/testsuite/gdb.trace/packetlen.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -28,11 +24,11 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_load $binfile
+
+clean_restart $binfile
 gdb_test "tstop"       ".*" ""
 gdb_test "tfind none"  ".*" ""
 runto_main
-gdb_reinitialize_dir $srcdir/$subdir
 
 if {![gdb_target_supports_trace]} {
     unsupported "current target does not support trace"
diff --git a/gdb/testsuite/gdb.trace/passc-dyn.exp b/gdb/testsuite/gdb.trace/passc-dyn.exp
index c005c79053b..26a2cac4dd9 100644
--- a/gdb/testsuite/gdb.trace/passc-dyn.exp
+++ b/gdb/testsuite/gdb.trace/passc-dyn.exp
@@ -17,9 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -27,9 +24,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_load $binfile
+
+clean_restart $binfile
 runto_main
-gdb_reinitialize_dir $srcdir/$subdir
 
 if {![gdb_target_supports_trace]} {
     unsupported "current target does not support trace"
diff --git a/gdb/testsuite/gdb.trace/passcount.exp b/gdb/testsuite/gdb.trace/passcount.exp
index 3f711496083..d26d99946ed 100644
--- a/gdb/testsuite/gdb.trace/passcount.exp
+++ b/gdb/testsuite/gdb.trace/passcount.exp
@@ -17,9 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -27,12 +24,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 # define relative source line numbers:
 # all subsequent line numbers are relative to this first one (baseline)
diff --git a/gdb/testsuite/gdb.trace/pending.exp b/gdb/testsuite/gdb.trace/pending.exp
index 76d28652820..da355bcdaee 100644
--- a/gdb/testsuite/gdb.trace/pending.exp
+++ b/gdb/testsuite/gdb.trace/pending.exp
@@ -66,9 +66,7 @@ proc pending_tracepoint_resolved { trace_type } {
 	global lib_sl1
 
 	# Start with a fresh gdb.
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
+	clean_restart
 
 	gdb_test_multiple "$trace_type set_point1" "set pending tracepoint" {
 	    -re ".*Make \(fast |\)tracepoint pending.*y or \\\[n\\\]. $" {
diff --git a/gdb/testsuite/gdb.trace/read-memory.exp b/gdb/testsuite/gdb.trace/read-memory.exp
index 9d82939ca74..f24f72884ae 100644
--- a/gdb/testsuite/gdb.trace/read-memory.exp
+++ b/gdb/testsuite/gdb.trace/read-memory.exp
@@ -127,10 +127,7 @@ proc teset_from_exec { target } {
     global tracefile
 
     # Restart GDB and read the trace data in ${target} target.
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_file_cmd $binfile
+    clean_restart $binfile
 
     gdb_test "target ${target} ${tracefile}.${target}" ".*" \
 	"change to ${target} target"
diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
index 33bccaa1a6a..14db2511d40 100644
--- a/gdb/testsuite/gdb.trace/report.exp
+++ b/gdb/testsuite/gdb.trace/report.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -28,9 +24,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_load $binfile
+clean_restart $binfile
 runto_main
-gdb_reinitialize_dir $srcdir/$subdir
 
 if {![gdb_target_supports_trace]} {
     unsupported "current target does not support trace"
diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp
index 71a094a25dc..ab0dce26d13 100644
--- a/gdb/testsuite/gdb.trace/save-trace.exp
+++ b/gdb/testsuite/gdb.trace/save-trace.exp
@@ -18,9 +18,6 @@
 load_lib "trace-support.exp"
 
 
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -28,12 +25,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 # define relative source line numbers:
 # all subsequent line numbers are relative to this first one (baseline)
diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp
index 68e951b1c83..c62f7e3e9e4 100644
--- a/gdb/testsuite/gdb.trace/tfile.exp
+++ b/gdb/testsuite/gdb.trace/tfile.exp
@@ -121,10 +121,7 @@ gdb_test "info registers" "The program has no registers now\." \
 
 # Now start afresh, using only a trace file.
 
-gdb_exit
-gdb_start
-
-gdb_load $binfile
+clean_restart $binfile
 
 gdb_test "target tfile $tfile_error" "Created tracepoint.*" \
     "target tfile [file tail $tfile_error]"
diff --git a/gdb/testsuite/gdb.trace/tfind.exp b/gdb/testsuite/gdb.trace/tfind.exp
index 4579e85ed86..2dbc42bb631 100644
--- a/gdb/testsuite/gdb.trace/tfind.exp
+++ b/gdb/testsuite/gdb.trace/tfind.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 
 require gdb_trace_common_supports_arch
@@ -30,7 +26,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" \
     untested "failed to compile"
     return -1
 }
-gdb_load $binfile
+
+clean_restart $binfile
 
 # 6.2 test help tstart
 gdb_test "help tstart" \
@@ -60,7 +57,6 @@ gdb_test "help tfind trace" "Select a trace frame by tracepoint number.*" \
 	"8.38: help tfind tracepoint"
 
 runto_main
-gdb_reinitialize_dir $srcdir/$subdir
 
 if {![gdb_target_supports_trace]} {
     unsupported "current target does not support trace"
diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp
index 7ce6f59e2c9..0cf1ce0e0c0 100644
--- a/gdb/testsuite/gdb.trace/tracecmd.exp
+++ b/gdb/testsuite/gdb.trace/tracecmd.exp
@@ -17,9 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -27,12 +24,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 # define relative source line numbers:
 # all subsequent line numbers are relative to this first one (baseline)
diff --git a/gdb/testsuite/gdb.trace/tsv.exp b/gdb/testsuite/gdb.trace/tsv.exp
index ea7ad55143a..2319444fab1 100644
--- a/gdb/testsuite/gdb.trace/tsv.exp
+++ b/gdb/testsuite/gdb.trace/tsv.exp
@@ -15,9 +15,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
@@ -25,7 +22,8 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_load $binfile
+
+clean_restart $binfile
 
 # PR gdb/21352: Command tsave does not support -r argument
 gdb_test "tsave -r" "Argument required \\\(file in which to save trace data\\\)\." \
diff --git a/gdb/testsuite/gdb.trace/unavailable.exp b/gdb/testsuite/gdb.trace/unavailable.exp
index 65fc56c3383..ef091cbb0f4 100644
--- a/gdb/testsuite/gdb.trace/unavailable.exp
+++ b/gdb/testsuite/gdb.trace/unavailable.exp
@@ -202,10 +202,7 @@ proc gdb_collect_args_test {} {
 
 	foreach target_name ${trace_file_targets} {
 	    # Restart GDB and read the trace data in ${TARGET_NAME} target.
-	    gdb_exit
-	    gdb_start
-	    gdb_reinitialize_dir $srcdir/$subdir
-	    gdb_file_cmd $binfile
+	    clean_restart $binfile
 	    gdb_test "target ${target_name} ${tracefile}.args.${target_name}" ".*" \
 		"change to ${target_name} target"
 
@@ -286,10 +283,7 @@ proc gdb_collect_locals_test { func msg } {
 
 	foreach target_name ${trace_file_targets} {
 	    # Restart GDB and read the trace data in ${TARGET_NAME} target.
-	    gdb_exit
-	    gdb_start
-	    gdb_reinitialize_dir $srcdir/$subdir
-	    gdb_file_cmd $binfile
+	    clean_restart $binfile
 	    gdb_test "target ${target_name} ${tracefile}.locals.${target_name}" ".*" \
 		"change to ${target_name} target"
 
@@ -369,10 +363,7 @@ proc gdb_unavailable_registers_test { } {
 
 	foreach target_name ${trace_file_targets} {
 	    # Restart GDB and read the trace data in ${TARGET_NAME} target.
-	    gdb_exit
-	    gdb_start
-	    gdb_reinitialize_dir $srcdir/$subdir
-	    gdb_file_cmd $binfile
+	    clean_restart $binfile
 	    gdb_test "target ${target_name} ${tracefile}.registers.${target_name}" ".*" \
 		"change to ${target_name} target"
 
@@ -433,10 +424,7 @@ proc gdb_unavailable_floats { } {
 
 	foreach target_name ${trace_file_targets} {
 	    # Restart GDB and read the trace data in ${TARGET_NAME} target.
-	    gdb_exit
-	    gdb_start
-	    gdb_reinitialize_dir $srcdir/$subdir
-	    gdb_file_cmd $binfile
+	    clean_restart $binfile
 	    gdb_test "target ${target_name} ${tracefile}.floats.${target_name}" ".*" \
 		"change to ${target_name} target"
 
@@ -701,10 +689,7 @@ proc gdb_collect_globals_test { } {
 
 	foreach target_name ${trace_file_targets} {
 	    # Restart GDB and read the trace data in ${TARGET_NAME} target.
-	    gdb_exit
-	    gdb_start
-	    gdb_reinitialize_dir $srcdir/$subdir
-	    gdb_file_cmd $binfile
+	    clean_restart $binfile
 	    gdb_test "target ${target_name} ${tracefile}.globals.${target_name}" ".*" \
 		"change to ${target_name} target"
 
diff --git a/gdb/testsuite/gdb.trace/while-dyn.exp b/gdb/testsuite/gdb.trace/while-dyn.exp
index 960a95926b7..797020e7674 100644
--- a/gdb/testsuite/gdb.trace/while-dyn.exp
+++ b/gdb/testsuite/gdb.trace/while-dyn.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 set executable $testfile
 require gdb_trace_common_supports_arch
@@ -29,9 +25,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_load $binfile
+
+clean_restart $binfile
 runto_main
-gdb_reinitialize_dir $srcdir/$subdir
 
 if {![gdb_target_supports_trace]} {
     unsupported "current target does not support trace"
diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp
index 64c0c9ed84f..ba4ad4434d5 100644
--- a/gdb/testsuite/gdb.trace/while-stepping.exp
+++ b/gdb/testsuite/gdb.trace/while-stepping.exp
@@ -17,10 +17,6 @@
 
 load_lib "trace-support.exp"
 
-
-gdb_exit
-gdb_start
-
 standard_testfile actions.c
 require gdb_trace_common_supports_arch
 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \
@@ -28,12 +24,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \
     untested "failed to compile"
     return -1
 }
-gdb_reinitialize_dir $srcdir/$subdir
-
-# If testing on a remote host, download the source file.
-# remote_download host $srcdir/$subdir/$srcfile
 
-gdb_file_cmd $binfile
+clean_restart $binfile
 
 #
 # test while-stepping command
@@ -151,10 +143,7 @@ gdb_test "tsave -ctf ${tracefile}.ctf" \
     "save ctf trace file"
 
 # Restart GDB and read the trace data in tfile target.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd $binfile
+clean_restart $binfile
 gdb_test "target tfile ${tracefile}.tf" ".*" \
     "change to tfile target"
 check_tracepoint "tfile"
@@ -171,10 +160,7 @@ gdb_test_multiple "target ctf" "" {
 }
 
 if { $gdb_can_read_ctf_data } {
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_file_cmd $binfile
+    clean_restart $binfile
     gdb_test "target ctf ${tracefile}.ctf" ".*" \
 	"change to ctf target"
     check_tracepoint "ctf"
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 13/27] Use clean_restart in gdb.objc
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (11 preceding siblings ...)
  2023-01-25 22:45 ` [PATCH 12/27] Use clean_restart in gdb.trace Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 14/27] Use clean_restart in gdb.threads Tom Tromey
                   ` (14 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.objc to use clean_restart more consistently.
---
 gdb/testsuite/gdb.objc/basicclass.exp | 11 +----------
 gdb/testsuite/gdb.objc/nondebug.exp   | 13 +------------
 gdb/testsuite/gdb.objc/objcdecode.exp | 13 +------------
 gdb/testsuite/gdb.objc/print.exp      |  6 +-----
 4 files changed, 4 insertions(+), 39 deletions(-)

diff --git a/gdb/testsuite/gdb.objc/basicclass.exp b/gdb/testsuite/gdb.objc/basicclass.exp
index c09d852f006..05432a18a39 100644
--- a/gdb/testsuite/gdb.objc/basicclass.exp
+++ b/gdb/testsuite/gdb.objc/basicclass.exp
@@ -70,18 +70,9 @@ proc deduce_language_of_main {} {
 }
 
 proc do_objc_tests {} {
-    global subdir
-    global srcdir
     global binfile
-    global gdb_prompt
-
-
-    # Start with a fresh gdb.
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
+    clean_restart $binfile
 
     deduce_language_of_main
 }
diff --git a/gdb/testsuite/gdb.objc/nondebug.exp b/gdb/testsuite/gdb.objc/nondebug.exp
index d08c3d4b244..c1ab4f62d02 100644
--- a/gdb/testsuite/gdb.objc/nondebug.exp
+++ b/gdb/testsuite/gdb.objc/nondebug.exp
@@ -28,19 +28,8 @@ if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [
 }
 
 proc do_objc_tests {} {
-    global subdir
-    global srcdir
     global binfile
-    global gdb_prompt
-
-
-    # Start with a fresh gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
+    clean_restart $binfile
 }
 
 do_objc_tests
diff --git a/gdb/testsuite/gdb.objc/objcdecode.exp b/gdb/testsuite/gdb.objc/objcdecode.exp
index 6a713ad3450..abed6709aef 100644
--- a/gdb/testsuite/gdb.objc/objcdecode.exp
+++ b/gdb/testsuite/gdb.objc/objcdecode.exp
@@ -28,19 +28,8 @@ if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [
 }
 
 proc do_objc_tests {} {
-    global subdir
-    global srcdir
     global binfile
-    global gdb_prompt
-
-
-    # Start with a fresh gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load $binfile
-
+    clean_restart $binfile
 }
 
 do_objc_tests
diff --git a/gdb/testsuite/gdb.objc/print.exp b/gdb/testsuite/gdb.objc/print.exp
index 8dc83780b50..c311853c1e8 100644
--- a/gdb/testsuite/gdb.objc/print.exp
+++ b/gdb/testsuite/gdb.objc/print.exp
@@ -57,11 +57,7 @@ proc test_float_rejected {} {
     test_print_reject "p 1.1ll"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 if [set_lang_objc] {
     test_float_accepted
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 14/27] Use clean_restart in gdb.threads
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (12 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 13/27] Use clean_restart in gdb.objc Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 15/27] Use clean_restart in gdb.guile Tom Tromey
                   ` (13 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.threads to use clean_restart more consistently.
---
 gdb/testsuite/gdb.threads/attach-stopped.exp      | 9 +--------
 gdb/testsuite/gdb.threads/fork-thread-pending.exp | 6 +-----
 gdb/testsuite/gdb.threads/schedlock.exp           | 6 +-----
 gdb/testsuite/gdb.threads/watchthreads.exp        | 6 +-----
 4 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
index a3080c054af..acdfcb5d8c5 100644
--- a/gdb/testsuite/gdb.threads/attach-stopped.exp
+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
@@ -32,11 +32,8 @@ remote_exec build "rm -f ${binfile}"
 #log_user 1
 
 proc corefunc { threadtype } {
-    global srcfile
     global binfile
     global escapedbinfile
-    global srcdir
-    global subdir
     global gdb_prompt
 
     set test_spawn_id [spawn_wait_for_attach $binfile]
@@ -45,11 +42,7 @@ proc corefunc { threadtype } {
     # Stop the program 
     remote_exec build "kill -s STOP ${testpid}"
 
-    # Start with clean gdb
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
+    clean_restart $binfile
 
     # Verify that we can attach to the stopped process.
        
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.exp b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
index db72fb2679b..3ab2d31402c 100644
--- a/gdb/testsuite/gdb.threads/fork-thread-pending.exp
+++ b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
@@ -79,11 +79,7 @@ gdb_test_multiple "info threads" "$test" {
 
 # Start over, but this time, don't switch away from the fork event thread.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-gdb_load ${binfile}
+clean_restart $binfile
 if {![runto_main]} {
    return 0
 }
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index fa095508fb9..08435015f14 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -146,11 +146,7 @@ proc step_ten_loops { cmd } {
     }
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # We'll need this when we send_gdb a ^C to GDB.  Need to do it before we
 # run the program and gdb starts saving and restoring tty states.
diff --git a/gdb/testsuite/gdb.threads/watchthreads.exp b/gdb/testsuite/gdb.threads/watchthreads.exp
index 1aa7957c867..e80c60b8167 100644
--- a/gdb/testsuite/gdb.threads/watchthreads.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads.exp
@@ -31,11 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
+clean_restart $binfile
 gdb_test_no_output "set can-use-hw-watchpoints 1" ""
 
 #
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 15/27] Use clean_restart in gdb.guile
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (13 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 14/27] Use clean_restart in gdb.threads Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 16/27] Use clean_restart in gdb.arch Tom Tromey
                   ` (12 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.guile to use clean_restart more consistently.
---
 gdb/testsuite/gdb.guile/guile.exp              |  5 +----
 gdb/testsuite/gdb.guile/scm-gsmob.exp          |  6 +-----
 gdb/testsuite/gdb.guile/scm-objfile-script.exp |  6 +-----
 gdb/testsuite/gdb.guile/scm-parameter.exp      |  5 +----
 gdb/testsuite/gdb.guile/scm-pretty-print.exp   | 15 ++-------------
 gdb/testsuite/gdb.guile/scm-progspace.exp      |  6 +-----
 gdb/testsuite/gdb.guile/scm-section-script.exp | 10 ++--------
 gdb/testsuite/gdb.guile/scm-symbol.exp         |  6 +-----
 gdb/testsuite/gdb.guile/scm-type.exp           |  5 +----
 9 files changed, 11 insertions(+), 53 deletions(-)

diff --git a/gdb/testsuite/gdb.guile/guile.exp b/gdb/testsuite/gdb.guile/guile.exp
index 7c7dd3a3826..4db2f7cd309 100644
--- a/gdb/testsuite/gdb.guile/guile.exp
+++ b/gdb/testsuite/gdb.guile/guile.exp
@@ -18,10 +18,7 @@
 
 load_lib gdb-guile.exp
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Do this instead of the skip_guile_check.
 # We want to do some tests when Guile is not present.
diff --git a/gdb/testsuite/gdb.guile/scm-gsmob.exp b/gdb/testsuite/gdb.guile/scm-gsmob.exp
index a7c95c01c11..726c97cbb92 100644
--- a/gdb/testsuite/gdb.guile/scm-gsmob.exp
+++ b/gdb/testsuite/gdb.guile/scm-gsmob.exp
@@ -20,11 +20,7 @@ load_lib gdb-guile.exp
 
 require allow_guile_tests
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_install_guile_utils
 gdb_install_guile_module
diff --git a/gdb/testsuite/gdb.guile/scm-objfile-script.exp b/gdb/testsuite/gdb.guile/scm-objfile-script.exp
index 5b480d1ea55..6a935d7926c 100644
--- a/gdb/testsuite/gdb.guile/scm-objfile-script.exp
+++ b/gdb/testsuite/gdb.guile/scm-objfile-script.exp
@@ -26,10 +26,6 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     return
 }
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-
 # Make the -gdb.scm script available to gdb, it is automagically loaded by gdb.
 # Care is taken to put it in the same directory as the binary so that
 # gdb will find it.
@@ -37,7 +33,7 @@ set remote_guile_file [remote_download host \
 			   ${srcdir}/${subdir}/${testfile}-gdb.in \
 			   [standard_output_file ${testfile}-gdb.scm]]
 
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 gdb_test_no_output "set auto-load safe-path ${remote_guile_file}" \
     "set auto-load safe-path"
 gdb_load ${binfile}
diff --git a/gdb/testsuite/gdb.guile/scm-parameter.exp b/gdb/testsuite/gdb.guile/scm-parameter.exp
index 9ee50d152cd..2e9d9ed9a5d 100644
--- a/gdb/testsuite/gdb.guile/scm-parameter.exp
+++ b/gdb/testsuite/gdb.guile/scm-parameter.exp
@@ -20,10 +20,7 @@ load_lib gdb-guile.exp
 
 require allow_guile_tests
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_install_guile_utils
 gdb_install_guile_module
diff --git a/gdb/testsuite/gdb.guile/scm-pretty-print.exp b/gdb/testsuite/gdb.guile/scm-pretty-print.exp
index 3c20edf5061..41c840b6898 100644
--- a/gdb/testsuite/gdb.guile/scm-pretty-print.exp
+++ b/gdb/testsuite/gdb.guile/scm-pretty-print.exp
@@ -22,10 +22,6 @@ require allow_guile_tests
 
 standard_testfile
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-
 proc run_lang_tests {exefile lang} {
     with_test_prefix "lang=$lang" {
 	global srcdir subdir srcfile testfile hex
@@ -37,10 +33,7 @@ proc run_lang_tests {exefile lang} {
 	set nl "\[\r\n\]+"
 
 	# Start with a fresh gdb.
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
-	gdb_load ${exefile}
+	clean_restart $exefile
 
 	if ![gdb_guile_runto_main] {
 	    return
@@ -121,11 +114,7 @@ run_lang_tests "${binfile}-cxx" "c++"
 
 # Run various other tests.
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 if ![gdb_guile_runto_main] {
     return
diff --git a/gdb/testsuite/gdb.guile/scm-progspace.exp b/gdb/testsuite/gdb.guile/scm-progspace.exp
index c12a81e8ed1..0007f3742d7 100644
--- a/gdb/testsuite/gdb.guile/scm-progspace.exp
+++ b/gdb/testsuite/gdb.guile/scm-progspace.exp
@@ -26,11 +26,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_install_guile_utils
 gdb_install_guile_module
diff --git a/gdb/testsuite/gdb.guile/scm-section-script.exp b/gdb/testsuite/gdb.guile/scm-section-script.exp
index 9e52939aae3..ae0e484c3b7 100644
--- a/gdb/testsuite/gdb.guile/scm-section-script.exp
+++ b/gdb/testsuite/gdb.guile/scm-section-script.exp
@@ -46,11 +46,7 @@ if {[build_executable $testfile.exp $testfile $srcfile \
     return
 }
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Try first with a restrictive safe-path.
 
@@ -71,9 +67,7 @@ gdb_test_multiple "info auto-load guile-scripts" "$test_name" {
 
 # Try again with a working safe-path.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_no_output "set auto-load safe-path ${remote_guile_file}:${binfile}" \
     "set auto-load safe-path"
diff --git a/gdb/testsuite/gdb.guile/scm-symbol.exp b/gdb/testsuite/gdb.guile/scm-symbol.exp
index fa2cf778284..5680a7f176a 100644
--- a/gdb/testsuite/gdb.guile/scm-symbol.exp
+++ b/gdb/testsuite/gdb.guile/scm-symbol.exp
@@ -141,11 +141,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" executable "
     return -1
 }
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}-cxx
+clean_restart ${binfile}-cxx
 
 if ![gdb_guile_runto_main] {
     return
diff --git a/gdb/testsuite/gdb.guile/scm-type.exp b/gdb/testsuite/gdb.guile/scm-type.exp
index 45139cba0d5..a5eec3aee37 100644
--- a/gdb/testsuite/gdb.guile/scm-type.exp
+++ b/gdb/testsuite/gdb.guile/scm-type.exp
@@ -38,10 +38,7 @@ proc build_inferior {exefile lang} {
 proc restart_gdb {exefile} {
     global srcdir subdir
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${exefile}
+    clean_restart $exefile
 
     if { ![allow_guile_tests] } {
 	return 0
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 16/27] Use clean_restart in gdb.arch
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (14 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 15/27] Use clean_restart in gdb.guile Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 17/27] Use clean_restart in gdb.reverse Tom Tromey
                   ` (11 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.arch to use clean_restart more consistently.
---
 gdb/testsuite/gdb.arch/alpha-step.exp             | 5 +----
 gdb/testsuite/gdb.arch/altivec-abi.exp            | 5 +----
 gdb/testsuite/gdb.arch/e500-prologue.exp          | 5 +----
 gdb/testsuite/gdb.arch/e500-regs.exp              | 5 +----
 gdb/testsuite/gdb.arch/gdb1291.exp                | 5 +----
 gdb/testsuite/gdb.arch/gdb1431.exp                | 5 +----
 gdb/testsuite/gdb.arch/gdb1558.exp                | 5 +----
 gdb/testsuite/gdb.arch/i386-bp_permanent.exp      | 5 +----
 gdb/testsuite/gdb.arch/i386-gnu-cfi.exp           | 5 +----
 gdb/testsuite/gdb.arch/i386-prologue.exp          | 5 +----
 gdb/testsuite/gdb.arch/i386-signal.exp            | 5 +----
 gdb/testsuite/gdb.arch/i386-size-overlap.exp      | 5 +----
 gdb/testsuite/gdb.arch/i386-size.exp              | 5 +----
 gdb/testsuite/gdb.arch/i386-unwind.exp            | 5 +----
 gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp | 5 +----
 gdb/testsuite/gdb.arch/mips-octeon-bbit.exp       | 5 +----
 gdb/testsuite/gdb.arch/pa-nullify.exp             | 5 +----
 gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp   | 5 +----
 gdb/testsuite/gdb.arch/powerpc-d128-regs.exp      | 7 +------
 gdb/testsuite/gdb.arch/powerpc-prologue.exp       | 5 +----
 gdb/testsuite/gdb.arch/ppc-dfp.exp                | 7 +------
 gdb/testsuite/gdb.arch/ppc-fp.exp                 | 7 +------
 gdb/testsuite/gdb.arch/pr25124.exp                | 7 +------
 gdb/testsuite/gdb.arch/s390-multiarch.exp         | 5 +----
 gdb/testsuite/gdb.arch/thumb-prologue.exp         | 5 +----
 gdb/testsuite/gdb.arch/thumb2-it.exp              | 5 +----
 gdb/testsuite/gdb.arch/vsx-regs.exp               | 5 +----
 27 files changed, 27 insertions(+), 116 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/alpha-step.exp b/gdb/testsuite/gdb.arch/alpha-step.exp
index 07b4c3912d9..f17210ba5d6 100644
--- a/gdb/testsuite/gdb.arch/alpha-step.exp
+++ b/gdb/testsuite/gdb.arch/alpha-step.exp
@@ -25,10 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 proc test_stepi {function } {
     # Restart the program from scratch. If GDB got confused during one
diff --git a/gdb/testsuite/gdb.arch/altivec-abi.exp b/gdb/testsuite/gdb.arch/altivec-abi.exp
index b04858950e8..8417c8828e7 100644
--- a/gdb/testsuite/gdb.arch/altivec-abi.exp
+++ b/gdb/testsuite/gdb.arch/altivec-abi.exp
@@ -47,10 +47,7 @@ proc altivec_abi_tests { extra_flags force_abi } {
 	}
     }
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
+    clean_restart $binfile
 
     # Run to `main' where we begin our tests.
     if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.arch/e500-prologue.exp b/gdb/testsuite/gdb.arch/e500-prologue.exp
index 7c32d9dd5b0..82898d98aa9 100644
--- a/gdb/testsuite/gdb.arch/e500-prologue.exp
+++ b/gdb/testsuite/gdb.arch/e500-prologue.exp
@@ -27,10 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # Insert a breakpoint in FUNCTION and verifies that the breakpoint was
 # inserted at the expected location.  EXPECTED_LOCATION should be an
diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp b/gdb/testsuite/gdb.arch/e500-regs.exp
index 615b745d251..ac196ff4722 100644
--- a/gdb/testsuite/gdb.arch/e500-regs.exp
+++ b/gdb/testsuite/gdb.arch/e500-regs.exp
@@ -136,10 +136,7 @@ gdb_expect_list "info vector" ".*$gdb_prompt $" {
 # We must restart everything, because we have set important registers to
 # some unusual values.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 if {![runto_main]} {
     return 0
 }
diff --git a/gdb/testsuite/gdb.arch/gdb1291.exp b/gdb/testsuite/gdb.arch/gdb1291.exp
index a81a13ff151..56119ab1e29 100644
--- a/gdb/testsuite/gdb.arch/gdb1291.exp
+++ b/gdb/testsuite/gdb.arch/gdb1291.exp
@@ -33,10 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] !
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/gdb1431.exp b/gdb/testsuite/gdb.arch/gdb1431.exp
index eee14fb3025..ab59aa87522 100644
--- a/gdb/testsuite/gdb.arch/gdb1431.exp
+++ b/gdb/testsuite/gdb.arch/gdb1431.exp
@@ -35,10 +35,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] !
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/gdb1558.exp b/gdb/testsuite/gdb.arch/gdb1558.exp
index 9090f03d6d9..76ae9c9a0a3 100644
--- a/gdb/testsuite/gdb.arch/gdb1558.exp
+++ b/gdb/testsuite/gdb.arch/gdb1558.exp
@@ -32,10 +32,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"add
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 gdb_test "b -q main" "Breakpoint 1.*" "set breakpoint at main"
 gdb_test "b -q sub1" "Breakpoint 2.*" "set breakpoint at sub1"
diff --git a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
index d75ea648148..c56f31366c5 100644
--- a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
+++ b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
@@ -33,10 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
 }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
index 56a4eee32a6..d34bc81a299 100644
--- a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
+++ b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
@@ -40,10 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfilec} ${srcdir}/${subdir}/${srcfile
 
 # Get things started.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # We should stop in abort(3).
 
diff --git a/gdb/testsuite/gdb.arch/i386-prologue.exp b/gdb/testsuite/gdb.arch/i386-prologue.exp
index 8e24b879fd1..d5fa4421dbe 100644
--- a/gdb/testsuite/gdb.arch/i386-prologue.exp
+++ b/gdb/testsuite/gdb.arch/i386-prologue.exp
@@ -53,10 +53,7 @@ proc skip_breakpoint { msg } {
 }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/i386-signal.exp b/gdb/testsuite/gdb.arch/i386-signal.exp
index 17c6467076c..f6a88719a40 100644
--- a/gdb/testsuite/gdb.arch/i386-signal.exp
+++ b/gdb/testsuite/gdb.arch/i386-signal.exp
@@ -25,10 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 runto func
 gdb_test "backtrace 10" \
diff --git a/gdb/testsuite/gdb.arch/i386-size-overlap.exp b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
index a5517b836f3..8da15f25c18 100644
--- a/gdb/testsuite/gdb.arch/i386-size-overlap.exp
+++ b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
@@ -30,10 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # We use gdb_run_cmd so this stands a chance to work for remote
 # targets too.
diff --git a/gdb/testsuite/gdb.arch/i386-size.exp b/gdb/testsuite/gdb.arch/i386-size.exp
index 0b616f68893..89679f217ae 100644
--- a/gdb/testsuite/gdb.arch/i386-size.exp
+++ b/gdb/testsuite/gdb.arch/i386-size.exp
@@ -35,10 +35,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # We use gdb_run_cmd so this stands a chance to work for remote
 # targets too.
diff --git a/gdb/testsuite/gdb.arch/i386-unwind.exp b/gdb/testsuite/gdb.arch/i386-unwind.exp
index 04ef77132eb..bdcf3da9b94 100644
--- a/gdb/testsuite/gdb.arch/i386-unwind.exp
+++ b/gdb/testsuite/gdb.arch/i386-unwind.exp
@@ -33,10 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # Testcase for backtrace/1435.
 
diff --git a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
index e9f98d0eb9e..f5f8282dc68 100644
--- a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
+++ b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
@@ -23,10 +23,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # We need to start the inferior to place the breakpoints in the memory at all.
 if ![runto_main] {
diff --git a/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp b/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
index 2b00fe14ce0..40cd02946c2 100644
--- a/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
+++ b/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
@@ -86,10 +86,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
 
 pass "compilation"
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 # Native needs run.
 runto_main
 
diff --git a/gdb/testsuite/gdb.arch/pa-nullify.exp b/gdb/testsuite/gdb.arch/pa-nullify.exp
index 285047cc95f..577bfbde6f9 100644
--- a/gdb/testsuite/gdb.arch/pa-nullify.exp
+++ b/gdb/testsuite/gdb.arch/pa-nullify.exp
@@ -40,10 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # In the first test, we do a "step" on a function whose last instruction 
 # contains a branch-with-nullify.  The instruction in the delay slot belongs
diff --git a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
index 8179c03f2f1..17bd0787a6c 100644
--- a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
@@ -28,10 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 # Insert a breakpoint in FUNCTION and verifies that the breakpoint was
 # inserted at the expected location.  EXPECTED_LOCATION should be an
diff --git a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
index 72ce2316b16..a4faa2d13dc 100644
--- a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
@@ -29,12 +29,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {qui
      return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 if {![runto_main]} {
    return
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
index edc7116754a..f5b2ab6e102 100644
--- a/gdb/testsuite/gdb.arch/powerpc-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
@@ -31,10 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
 }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/ppc-dfp.exp b/gdb/testsuite/gdb.arch/ppc-dfp.exp
index eca44a683e4..25269ba4a2b 100644
--- a/gdb/testsuite/gdb.arch/ppc-dfp.exp
+++ b/gdb/testsuite/gdb.arch/ppc-dfp.exp
@@ -31,12 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 gdb_breakpoint [gdb_get_line_number "Set DFP rounding mode."]
 
diff --git a/gdb/testsuite/gdb.arch/ppc-fp.exp b/gdb/testsuite/gdb.arch/ppc-fp.exp
index db7ea1202d5..73073940947 100644
--- a/gdb/testsuite/gdb.arch/ppc-fp.exp
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -31,12 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 gdb_breakpoint [gdb_get_line_number "Invalid operation."]
 gdb_breakpoint [gdb_get_line_number "Division by zero."]
diff --git a/gdb/testsuite/gdb.arch/pr25124.exp b/gdb/testsuite/gdb.arch/pr25124.exp
index 45033771d79..4b6dbfd86a2 100644
--- a/gdb/testsuite/gdb.arch/pr25124.exp
+++ b/gdb/testsuite/gdb.arch/pr25124.exp
@@ -25,12 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-# Load the symbol file the first time.
-gdb_load ${binfile}
+clean_restart $binfile
 
 # Check if the disassemble ouput is correct.
 gdb_test "x /i main+8" \
diff --git a/gdb/testsuite/gdb.arch/s390-multiarch.exp b/gdb/testsuite/gdb.arch/s390-multiarch.exp
index 4256d30b0b9..68f339cc283 100644
--- a/gdb/testsuite/gdb.arch/s390-multiarch.exp
+++ b/gdb/testsuite/gdb.arch/s390-multiarch.exp
@@ -28,8 +28,6 @@ require isnative {istarget s390x-*-*}
 standard_testfile
 set binprefix $binfile
 
-gdb_exit
-
 proc compile_and_dump {variant ccopts binfile} {
     global srcdir subdir srcfile
     set compile_flags {debug}
@@ -136,8 +134,7 @@ if { $core31 != "" } {
     remote_exec host "$binfile ${core31}.2 ${core31}.3 774"
 }
 
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 if { $core64 != "" } {
     test_all_core64 $core64 "no exec"
diff --git a/gdb/testsuite/gdb.arch/thumb-prologue.exp b/gdb/testsuite/gdb.arch/thumb-prologue.exp
index 1d74a30905a..a33a59b1e6f 100644
--- a/gdb/testsuite/gdb.arch/thumb-prologue.exp
+++ b/gdb/testsuite/gdb.arch/thumb-prologue.exp
@@ -27,10 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"add
 }
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 #
 # Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/thumb2-it.exp b/gdb/testsuite/gdb.arch/thumb2-it.exp
index 024718677de..5ea2963dbf7 100644
--- a/gdb/testsuite/gdb.arch/thumb2-it.exp
+++ b/gdb/testsuite/gdb.arch/thumb2-it.exp
@@ -24,10 +24,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 if {![runto_main]} {
     return -1
diff --git a/gdb/testsuite/gdb.arch/vsx-regs.exp b/gdb/testsuite/gdb.arch/vsx-regs.exp
index 2b72a012ef9..ccb4ee3df9d 100644
--- a/gdb/testsuite/gdb.arch/vsx-regs.exp
+++ b/gdb/testsuite/gdb.arch/vsx-regs.exp
@@ -184,10 +184,7 @@ if {!$core_supported} {
   return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
 if { $core_loaded == -1 } {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 17/27] Use clean_restart in gdb.reverse
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (15 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 16/27] Use clean_restart in gdb.arch Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 18/27] Use clean_restart in gdb.dwarf2 Tom Tromey
                   ` (10 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.reverse to use clean_restart more consistently.
---
 gdb/testsuite/gdb.reverse/sigall-precsave.exp | 6 +-----
 gdb/testsuite/gdb.reverse/sigall-reverse.exp  | 6 +-----
 gdb/testsuite/gdb.reverse/solib-precsave.exp  | 8 +-------
 gdb/testsuite/gdb.reverse/solib-reverse.exp   | 8 +-------
 4 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
index df0e8228fb4..e2a786a7b9b 100644
--- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
@@ -20,10 +20,6 @@ if [target_info exists gdb,nosignals] {
 
 require supports_reverse
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
 standard_testfile sigall-reverse.c
 set precsave [standard_output_file sigall.precsave]
 
@@ -145,7 +141,7 @@ proc test_one_sig_reverse {prevsig} {
     }
 }
 
-gdb_load $binfile
+clean_restart $binfile
 
 runto gen_ABRT
 
diff --git a/gdb/testsuite/gdb.reverse/sigall-reverse.exp b/gdb/testsuite/gdb.reverse/sigall-reverse.exp
index 7499d784b9b..7891dca92a9 100644
--- a/gdb/testsuite/gdb.reverse/sigall-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-reverse.exp
@@ -20,10 +20,6 @@ if [target_info exists gdb,nosignals] {
 
 require supports_reverse
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
 standard_testfile
 
 if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
@@ -151,7 +147,7 @@ proc test_one_sig_reverse {prevsig} {
     }
 }
 
-gdb_load $binfile
+clean_restart $binfile
 
 runto gen_ABRT
 
diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp
index 88261b6f6b0..3ca73828063 100644
--- a/gdb/testsuite/gdb.reverse/solib-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp
@@ -53,11 +53,6 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \
     return -1
 }
      
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-
 # Note: The test previously did "set debug-file-directory" to (try to)
 # ensure the debug info for the dynamic loader and libc weren't found.
 # This doesn't work if the debug info is in the .debug subdirectory.
@@ -65,8 +60,7 @@ gdb_start
 # and is no longer attempted.  Instead, the test does not make assumptions
 # about whether the debug info is present or not.
 
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib $library1
 gdb_load_shlib $library2
 
diff --git a/gdb/testsuite/gdb.reverse/solib-reverse.exp b/gdb/testsuite/gdb.reverse/solib-reverse.exp
index 0afe21926c5..c061086a8d7 100644
--- a/gdb/testsuite/gdb.reverse/solib-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/solib-reverse.exp
@@ -45,11 +45,6 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opt
     return -1
 }
      
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-
 # Note: The test previously did "set debug-file-directory" to (try to)
 # ensure the debug info for the dynamic loader and libc weren't found.
 # This doesn't work if the debug info is in the .debug subdirectory.
@@ -57,8 +52,7 @@ gdb_start
 # and is no longer attempted.  Instead, the test does not make assumptions
 # about whether the debug info is present or not.
 
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib $library1
 gdb_load_shlib $library2
 
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 18/27] Use clean_restart in gdb.dwarf2
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (16 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 17/27] Use clean_restart in gdb.reverse Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 19/27] Use clean_restart in gdb.ada Tom Tromey
                   ` (9 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.dwarf2 to use clean_restart more consistently.
---
 gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp         | 4 +---
 gdb/testsuite/gdb.dwarf2/dw2-error.exp             | 4 +---
 gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp    | 4 +---
 gdb/testsuite/gdb.dwarf2/dwp-symlink.exp           | 4 +---
 gdb/testsuite/gdb.dwarf2/dwzbuildid.exp            | 4 +---
 gdb/testsuite/gdb.dwarf2/dwznolink.exp             | 5 +----
 gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp | 4 +---
 7 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
index b24500b8301..88d3d79cad8 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
@@ -28,9 +28,7 @@ if {[gdb_compile [file join $srcdir $subdir $srcfile] $binfile \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir [file join $srcdir $subdir]
+clean_restart
 
 # Be sure to set cp-abi before $binfile gets loaded
 gdb_test "set cp-abi gnu-v3"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-error.exp b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
index 0980f43078f..83a5b875323 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-error.exp
@@ -31,9 +31,7 @@ if {[build_executable $testfile.exp $testfile $srcfile {nodebug quiet}]} {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_no_output "set breakpoint pending off"
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp b/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
index a3b9dd075e1..52dfae3d7d7 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
@@ -23,9 +23,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != ""
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # From gdb_file_cmd:
 if [is_remote host] {
diff --git a/gdb/testsuite/gdb.dwarf2/dwp-symlink.exp b/gdb/testsuite/gdb.dwarf2/dwp-symlink.exp
index e9bedd53cc3..d893fd3252c 100644
--- a/gdb/testsuite/gdb.dwarf2/dwp-symlink.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwp-symlink.exp
@@ -75,9 +75,7 @@ gdb_test "ptype main" {type = int \(int, char \*\*\)} "binary symlink, dwp at sy
 # a relative path for the program.
 
 # This is clean_restart, but specifying a relative path to the binary.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 gdb_test "cd [file dirname [standard_output_file ${thelink}]]" \
     "Working directory .*"
 gdb_load "./${thelink}"
diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
index 1b9ba8da092..ba9db41ba61 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.exp
@@ -146,9 +146,7 @@ if {[gdb_compile [list ${binfile}1.o ${binfile}6.o] ${binfile}-fallback \
 
 foreach testname {ok mismatch fallback} {
     with_test_prefix $testname {
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
+	clean_restart
 
 	gdb_test_no_output "set debug-file-directory $debugdir" \
 	    "set debug-file-directory"
diff --git a/gdb/testsuite/gdb.dwarf2/dwznolink.exp b/gdb/testsuite/gdb.dwarf2/dwznolink.exp
index d0bfa6b57f7..19ed2c3c8cb 100644
--- a/gdb/testsuite/gdb.dwarf2/dwznolink.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwznolink.exp
@@ -47,10 +47,7 @@ if {[build_executable $testfile.exp $testfile \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
+clean_restart
 gdb_test "file -readnow $binfile" \
     "could not read '.gnu_debugaltlink' section" \
     "file $testfile"
diff --git a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
index 9afad943d1c..0003dfa6bc6 100644
--- a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
+++ b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
@@ -26,9 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} object {debug}] !=
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Be sure to set cp-abi before ${binfile} gets loaded
 gdb_test "set cp-abi gnu-v3"
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 19/27] Use clean_restart in gdb.ada
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (17 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 18/27] Use clean_restart in gdb.dwarf2 Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 20/27] Use clean_restart in gdb.fortran Tom Tromey
                   ` (8 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.ada to use clean_restart more consistently.
---
 gdb/testsuite/gdb.ada/assign_1.exp          | 4 +---
 gdb/testsuite/gdb.ada/boolean_expr.exp      | 4 +---
 gdb/testsuite/gdb.ada/ptype_arith_binop.exp | 4 +---
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.ada/assign_1.exp b/gdb/testsuite/gdb.ada/assign_1.exp
index 88ba9a54f40..d5d81281e46 100644
--- a/gdb/testsuite/gdb.ada/assign_1.exp
+++ b/gdb/testsuite/gdb.ada/assign_1.exp
@@ -17,9 +17,7 @@ load_lib "ada.exp"
 
 require allow_ada_tests
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Force the language to Ada, as this will not happen automatically
 # in this case (no test program).
diff --git a/gdb/testsuite/gdb.ada/boolean_expr.exp b/gdb/testsuite/gdb.ada/boolean_expr.exp
index c3b854fd331..fda5da1ed79 100644
--- a/gdb/testsuite/gdb.ada/boolean_expr.exp
+++ b/gdb/testsuite/gdb.ada/boolean_expr.exp
@@ -17,9 +17,7 @@ load_lib "ada.exp"
 
 require allow_ada_tests
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 set any_nb "\[0-9\]+"
 set any_addr "0x\[0-9a-zA-Z\]+"
diff --git a/gdb/testsuite/gdb.ada/ptype_arith_binop.exp b/gdb/testsuite/gdb.ada/ptype_arith_binop.exp
index 19b85bfd4e1..bdfd5f0ce51 100644
--- a/gdb/testsuite/gdb.ada/ptype_arith_binop.exp
+++ b/gdb/testsuite/gdb.ada/ptype_arith_binop.exp
@@ -15,9 +15,7 @@
 
 require allow_ada_tests
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_no_output "set lang ada" \
          "set lang ada"
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 20/27] Use clean_restart in gdb.fortran
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (18 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 19/27] Use clean_restart in gdb.ada Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 21/27] Use clean_restart in gdb.stabs Tom Tromey
                   ` (7 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.fortran to use clean_restart more consistently.
---
 gdb/testsuite/gdb.fortran/exprs.exp | 6 +-----
 gdb/testsuite/gdb.fortran/types.exp | 7 +------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.fortran/exprs.exp b/gdb/testsuite/gdb.fortran/exprs.exp
index 30f0aa691db..7633ab0fefa 100644
--- a/gdb/testsuite/gdb.fortran/exprs.exp
+++ b/gdb/testsuite/gdb.fortran/exprs.exp
@@ -241,11 +241,7 @@ proc test_arithmetic_expressions {} {
 
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test "set print sevenbit-strings" ""
 
diff --git a/gdb/testsuite/gdb.fortran/types.exp b/gdb/testsuite/gdb.fortran/types.exp
index aaa6962c37c..3c26c79ec9e 100644
--- a/gdb/testsuite/gdb.fortran/types.exp
+++ b/gdb/testsuite/gdb.fortran/types.exp
@@ -98,12 +98,7 @@ proc test_primitive_types_known {} {
     }
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
+clean_restart
 gdb_test "set print sevenbit-strings" ""
 
 if {[set_lang_fortran]} {
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 21/27] Use clean_restart in gdb.stabs
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (19 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 20/27] Use clean_restart in gdb.fortran Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 22/27] Use clean_restart in gdb.go Tom Tromey
                   ` (6 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.stabs to use clean_restart more consistently.
---
 gdb/testsuite/gdb.stabs/weird.exp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.stabs/weird.exp b/gdb/testsuite/gdb.stabs/weird.exp
index f89595b0789..2375e4c96e4 100644
--- a/gdb/testsuite/gdb.stabs/weird.exp
+++ b/gdb/testsuite/gdb.stabs/weird.exp
@@ -273,10 +273,7 @@ if  { [gdb_compile "${srcfile}" "${binfile}" object ""] != "" } {
 
 remote_file build delete ${srcfile}
 
-# Start with a fresh gdb
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 set binfile [gdb_remote_download host ${binfile} \
 		 [standard_output_file object.o]]
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 22/27] Use clean_restart in gdb.go
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (20 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 21/27] Use clean_restart in gdb.stabs Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 23/27] Use clean_restart in gdb.perf Tom Tromey
                   ` (5 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.go to use clean_restart more consistently.
---
 gdb/testsuite/gdb.go/print.exp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.go/print.exp b/gdb/testsuite/gdb.go/print.exp
index 893fa30e7be..8fcbf12e5e6 100644
--- a/gdb/testsuite/gdb.go/print.exp
+++ b/gdb/testsuite/gdb.go/print.exp
@@ -56,11 +56,7 @@ proc test_float_rejected {} {
     test_print_reject "p 1.1ll"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 if [set_lang_go] {
     test_float_accepted
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 23/27] Use clean_restart in gdb.perf
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (21 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 22/27] Use clean_restart in gdb.go Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 24/27] Use clean_restart in gdb.disasm Tom Tromey
                   ` (4 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.perf to use clean_restart more consistently.
---
 gdb/testsuite/gdb.perf/disassemble.exp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.perf/disassemble.exp b/gdb/testsuite/gdb.perf/disassemble.exp
index 067754747ec..94a32fb0364 100644
--- a/gdb/testsuite/gdb.perf/disassemble.exp
+++ b/gdb/testsuite/gdb.perf/disassemble.exp
@@ -29,12 +29,9 @@ PerfTest::assemble {
     # Don't have compilation step.
     return 0
 } {
-    global srcdir subdir
     global binfile
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
+    clean_restart
 
     # When GDB is debugging GDB, the prompt is changed to "(top-gdb) ".
     # In order to avoid the confusion of pattern matching, set the
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 24/27] Use clean_restart in gdb.disasm
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (22 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 23/27] Use clean_restart in gdb.perf Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 25/27] Use clean_restart in gdb.cp Tom Tromey
                   ` (3 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.disasm to use clean_restart more consistently.
---
 gdb/testsuite/gdb.disasm/am33.exp    | 7 +------
 gdb/testsuite/gdb.disasm/h8300s.exp  | 4 +---
 gdb/testsuite/gdb.disasm/hppa.exp    | 7 +------
 gdb/testsuite/gdb.disasm/mn10300.exp | 7 +------
 gdb/testsuite/gdb.disasm/sh3.exp     | 5 +----
 gdb/testsuite/gdb.go/basic-types.exp | 6 +-----
 6 files changed, 6 insertions(+), 30 deletions(-)

diff --git a/gdb/testsuite/gdb.disasm/am33.exp b/gdb/testsuite/gdb.disasm/am33.exp
index a278f395dd6..51936857ad0 100644
--- a/gdb/testsuite/gdb.disasm/am33.exp
+++ b/gdb/testsuite/gdb.disasm/am33.exp
@@ -795,12 +795,7 @@ proc dsp_autoincrement_tests { } {
     }
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 call_tests
 movm_tests
diff --git a/gdb/testsuite/gdb.disasm/h8300s.exp b/gdb/testsuite/gdb.disasm/h8300s.exp
index cd68a630959..17da0ad0b95 100644
--- a/gdb/testsuite/gdb.disasm/h8300s.exp
+++ b/gdb/testsuite/gdb.disasm/h8300s.exp
@@ -640,9 +640,7 @@ proc all_block_data_transfer_tests { } {
     }
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 all_set_machine_h8300s
 gdb_load $binfile
 
diff --git a/gdb/testsuite/gdb.disasm/hppa.exp b/gdb/testsuite/gdb.disasm/hppa.exp
index 19fc08b6115..fadbb0a31e1 100644
--- a/gdb/testsuite/gdb.disasm/hppa.exp
+++ b/gdb/testsuite/gdb.disasm/hppa.exp
@@ -1365,12 +1365,7 @@ proc fmemLRbug_tests { } {
     }
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 all_integer_memory_tests
 all_immediate_tests
diff --git a/gdb/testsuite/gdb.disasm/mn10300.exp b/gdb/testsuite/gdb.disasm/mn10300.exp
index 425dc0615c8..5cf57ef12a8 100644
--- a/gdb/testsuite/gdb.disasm/mn10300.exp
+++ b/gdb/testsuite/gdb.disasm/mn10300.exp
@@ -529,12 +529,7 @@ proc sub_tests { } {
     }
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 add_tests
 bcc_tests
diff --git a/gdb/testsuite/gdb.disasm/sh3.exp b/gdb/testsuite/gdb.disasm/sh3.exp
index 84479ce83e7..4be9bf57419 100644
--- a/gdb/testsuite/gdb.disasm/sh3.exp
+++ b/gdb/testsuite/gdb.disasm/sh3.exp
@@ -100,10 +100,7 @@ proc all_fp_misc_tests { } {
     }
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 all_fp_move_and_load_tests
 all_fp_arithmetic_tests
diff --git a/gdb/testsuite/gdb.go/basic-types.exp b/gdb/testsuite/gdb.go/basic-types.exp
index ce56ba4a681..ae95906a99a 100644
--- a/gdb/testsuite/gdb.go/basic-types.exp
+++ b/gdb/testsuite/gdb.go/basic-types.exp
@@ -100,11 +100,7 @@ proc test_complex_literal_types_accepted {} {
     gdb_test "pt complex128(i1.0)" "type = complex128"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 if [set_lang_go] {
     test_integer_literal_types_accepted
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 25/27] Use clean_restart in gdb.cp
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (23 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 24/27] Use clean_restart in gdb.disasm Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 26/27] Use clean_restart in gdb.python Tom Tromey
                   ` (2 subsequent siblings)
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.cp to use clean_restart more consistently.
---
 gdb/testsuite/gdb.cp/cp-relocate.exp | 9 ++-------
 gdb/testsuite/gdb.cp/ref-params.exp  | 2 --
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/cp-relocate.exp b/gdb/testsuite/gdb.cp/cp-relocate.exp
index 5e70f9d30d3..6c953c0543d 100644
--- a/gdb/testsuite/gdb.cp/cp-relocate.exp
+++ b/gdb/testsuite/gdb.cp/cp-relocate.exp
@@ -46,10 +46,7 @@ proc get_func_address { func } {
 
 # Load the file as an executable; GDB should assign non-overlapping
 # section offsets.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
 
 # Find the interesting functions.  We go to a little effort to find
 # the right function names here, to work around PR c++/40.
@@ -118,9 +115,7 @@ if { $func1_sec == $func2_sec } {
 }
 
 # Now start a clean GDB, for add-symbol-file tests.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test "add-symbol-file ${binfile} 0 -s ${func1_sec} 0x10000 -s ${func2_sec} 0x20000" \
 	"Reading symbols from .*${testfile}\\.o\\.\\.\\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)" \
diff --git a/gdb/testsuite/gdb.cp/ref-params.exp b/gdb/testsuite/gdb.cp/ref-params.exp
index 52bbb4d097a..c06fc202893 100644
--- a/gdb/testsuite/gdb.cp/ref-params.exp
+++ b/gdb/testsuite/gdb.cp/ref-params.exp
@@ -28,8 +28,6 @@ if {[build_executable $testfile.exp $testfile $srcfile {debug c++}] == -1} {
     return -1
 }
 
-gdb_exit
-
 proc gdb_start_again { text } {
     global binfile
     global srcfile
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 26/27] Use clean_restart in gdb.python
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (24 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 25/27] Use clean_restart in gdb.cp Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-25 22:46 ` [PATCH 27/27] Use clean_restart in gdb.base Tom Tromey
  2023-01-26 17:37 ` [PATCH 00/27] Many small testsuite cleanups Pedro Alves
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.python to use clean_restart more consistently.
---
 gdb/testsuite/gdb.python/py-format-string.exp  |  5 +----
 gdb/testsuite/gdb.python/py-function.exp       |  6 +-----
 gdb/testsuite/gdb.python/py-lookup-type.exp    |  4 +---
 gdb/testsuite/gdb.python/py-prettyprint.exp    | 11 ++---------
 gdb/testsuite/gdb.python/py-progspace.exp      |  6 +-----
 gdb/testsuite/gdb.python/py-section-script.exp | 10 ++--------
 gdb/testsuite/gdb.python/py-template.exp       |  6 +-----
 gdb/testsuite/gdb.python/py-type.exp           |  7 +------
 gdb/testsuite/gdb.python/python.exp            |  5 +----
 9 files changed, 11 insertions(+), 49 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index f343ce31a46..1d50f59dee3 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -47,10 +47,7 @@ proc build_inferior {exefile lang} {
 proc prepare_gdb {exefile} {
   global srcdir subdir srcfile testfile hex
 
-  gdb_exit
-  gdb_start
-  gdb_reinitialize_dir $srcdir/$subdir
-  gdb_load ${exefile}
+  clean_restart $exefile
 
   if {![runto_main]} {
       return
diff --git a/gdb/testsuite/gdb.python/py-function.exp b/gdb/testsuite/gdb.python/py-function.exp
index 25b83a797aa..3a6e30259fd 100644
--- a/gdb/testsuite/gdb.python/py-function.exp
+++ b/gdb/testsuite/gdb.python/py-function.exp
@@ -20,11 +20,7 @@ load_lib gdb-python.exp
 
 require allow_python_tests
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_multiline "input convenience function" \
   "python" "" \
diff --git a/gdb/testsuite/gdb.python/py-lookup-type.exp b/gdb/testsuite/gdb.python/py-lookup-type.exp
index c914ea1068b..63f603cc009 100644
--- a/gdb/testsuite/gdb.python/py-lookup-type.exp
+++ b/gdb/testsuite/gdb.python/py-lookup-type.exp
@@ -25,9 +25,7 @@ require allow_python_tests
 # created by each language since GDB.  So, we must start GDB without
 # loading any symbol in.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 proc test_lookup_type { lang type_name } {
     gdb_test_no_output "set language ${lang}"
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index 674a4edd0d2..b7661ff14ed 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -36,10 +36,7 @@ proc run_lang_tests {exefile lang} {
     set nl "\[\r\n\]+"
 
     # Start with a fresh gdb.
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${exefile}
+    clean_restart $exefile
 
     if {![runto_main]} {
 	return
@@ -190,11 +187,7 @@ with_test_prefix c++ {
 
 # Run various other tests.
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 if {![runto_main]} {
     return
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index c7be9489601..638b27927c6 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -26,11 +26,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test "python print (gdb.current_progspace().filename)" "None" \
   "current progspace filename (None)"
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index 24d207416af..fec7b007317 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -46,11 +46,7 @@ if {[build_executable $testfile.exp $testfile $srcfile \
     return -1
 }
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Try first with a restrictive safe-path.
 
@@ -71,9 +67,7 @@ gdb_test_multiple "info auto-load python-scripts" "$test_name" {
 
 # Try again with a working safe-path.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Get the name of the binfile on the host; on a remote host this means
 # stripping off any directory prefix.
diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp
index a89a813578d..9bc392dcb8d 100644
--- a/gdb/testsuite/gdb.python/py-template.exp
+++ b/gdb/testsuite/gdb.python/py-template.exp
@@ -25,11 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 proc test_template_arg {exefile type} {
     global testfile srcdir subdir srcfile
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index e7837d7405f..c245d41a1ac 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -34,12 +34,7 @@ proc build_inferior {exefile lang} {
 
 # Restart GDB.
 proc restart_gdb {exefile} { 
-  global srcdir subdir srcfile testfile hex
-
-  gdb_exit
-  gdb_start
-  gdb_reinitialize_dir $srcdir/$subdir
-  gdb_load ${exefile}
+  clean_restart $exefile
 
   if {![runto_main]} {
       return
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index b8a4718ef6c..8fe119fead1 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -25,10 +25,7 @@ if {[build_executable $testfile.exp $testfile \
     return -1
 }
 
-# Start with a fresh gdb.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 set remote_source2_py [gdb_remote_download host \
 			   ${srcdir}/${subdir}/source2.py]
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 27/27] Use clean_restart in gdb.base
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (25 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 26/27] Use clean_restart in gdb.python Tom Tromey
@ 2023-01-25 22:46 ` Tom Tromey
  2023-01-26 17:37 ` [PATCH 00/27] Many small testsuite cleanups Pedro Alves
  27 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-25 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Change gdb.base to use clean_restart more consistently.
---
 gdb/testsuite/gdb.base/address_space_qualifier.exp |  4 +---
 gdb/testsuite/gdb.base/alias.exp                   |  4 +---
 gdb/testsuite/gdb.base/annota1.exp                 |  5 +----
 gdb/testsuite/gdb.base/bitops.exp                  |  5 +----
 gdb/testsuite/gdb.base/break-interp.exp            |  8 ++------
 gdb/testsuite/gdb.base/checkpoint.exp              |  5 +----
 gdb/testsuite/gdb.base/comprdebug.exp              |  4 +---
 gdb/testsuite/gdb.base/cursal.exp                  |  5 +----
 gdb/testsuite/gdb.base/detach.exp                  |  6 +-----
 gdb/testsuite/gdb.base/dfp-exprs.exp               |  6 +-----
 gdb/testsuite/gdb.base/display.exp                 |  5 +----
 gdb/testsuite/gdb.base/dprintf-pending.exp         |  8 ++------
 gdb/testsuite/gdb.base/dump.exp                    | 10 ++--------
 gdb/testsuite/gdb.base/fileio.exp                  |  7 +------
 gdb/testsuite/gdb.base/fixsection.exp              |  7 +------
 gdb/testsuite/gdb.base/foll-exec.exp               |  3 ---
 gdb/testsuite/gdb.base/fullname.exp                | 12 +++---------
 gdb/testsuite/gdb.base/gcore.exp                   |  5 +----
 gdb/testsuite/gdb.base/hashline2.exp               |  5 +----
 gdb/testsuite/gdb.base/hashline3.exp               |  5 +----
 gdb/testsuite/gdb.base/langs.exp                   |  5 +----
 gdb/testsuite/gdb.base/list.exp                    |  7 +------
 gdb/testsuite/gdb.base/pending.exp                 | 12 ++----------
 gdb/testsuite/gdb.base/permissions.exp             |  4 +---
 gdb/testsuite/gdb.base/print-symbol-loading.exp    |  4 +---
 gdb/testsuite/gdb.base/printcmds.exp               |  6 +-----
 gdb/testsuite/gdb.base/readline.exp                |  4 +---
 gdb/testsuite/gdb.base/relocate.exp                | 13 +++----------
 gdb/testsuite/gdb.base/sep.exp                     |  5 +----
 gdb/testsuite/gdb.base/sepdebug.exp                |  8 ++------
 gdb/testsuite/gdb.base/solib-disc.exp              |  5 +----
 gdb/testsuite/gdb.base/solib-symbol.exp            |  5 +----
 gdb/testsuite/gdb.base/solib-weak.exp              |  5 +----
 gdb/testsuite/gdb.base/subst.exp                   |  4 +---
 gdb/testsuite/gdb.base/unload.exp                  |  7 +------
 gdb/testsuite/gdb.base/watchpoint-solib.exp        |  7 +------
 36 files changed, 44 insertions(+), 176 deletions(-)

diff --git a/gdb/testsuite/gdb.base/address_space_qualifier.exp b/gdb/testsuite/gdb.base/address_space_qualifier.exp
index ec8d3a33342..a8b8856a244 100644
--- a/gdb/testsuite/gdb.base/address_space_qualifier.exp
+++ b/gdb/testsuite/gdb.base/address_space_qualifier.exp
@@ -16,9 +16,7 @@
 # Regression test for expression evaluation of address space qualifiers
 # in C and C++.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_no_output "set language c"
 
diff --git a/gdb/testsuite/gdb.base/alias.exp b/gdb/testsuite/gdb.base/alias.exp
index 7a1a95528c6..d3ddafabf70 100644
--- a/gdb/testsuite/gdb.base/alias.exp
+++ b/gdb/testsuite/gdb.base/alias.exp
@@ -14,9 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Helper to test the -a option to alias.
 # Aliases that are abbreviations of commands (e.g. r -> run)
diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
index 96698642675..90c03d0d385 100644
--- a/gdb/testsuite/gdb.base/annota1.exp
+++ b/gdb/testsuite/gdb.base/annota1.exp
@@ -495,10 +495,7 @@ proc thread_test {} {
 
     if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
 
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
-	gdb_load ${binfile}
+	clean_restart $binfile
 	if {![runto_main]} {
 	    return
 	}
diff --git a/gdb/testsuite/gdb.base/bitops.exp b/gdb/testsuite/gdb.base/bitops.exp
index c619b163769..fc575b9e49b 100644
--- a/gdb/testsuite/gdb.base/bitops.exp
+++ b/gdb/testsuite/gdb.base/bitops.exp
@@ -28,10 +28,7 @@
 #
 
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
+clean_restart
 
 gdb_test "print !1" ".\[0-9\]* = 0" "print value of !1"
 
diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index 6061c739d05..17a686e5716 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -393,11 +393,9 @@ proc test_ld {file ifmain trynosym displacement} {
 
     # First test normal `file'-command loaded $FILE with symbols.
 
-    gdb_exit
-    gdb_start
+    clean_restart
     # Clear it to never find any separate debug infos in $debug_root.
     gdb_test_no_output "set debug-file-directory"
-    gdb_reinitialize_dir $srcdir/$subdir
     gdb_load $file
 
     # Print the "PIE (Position Independent Executable) displacement" message.
@@ -479,11 +477,9 @@ proc test_ld {file ifmain trynosym displacement} {
 	# without symbols.  SYMBOL_OBJFILE is not available and only
 	# EXEC_BFD must be used.
 
-	gdb_exit
-	gdb_start
+	clean_restart
 	# Clear it to never find any separate debug infos in $debug_root.
 	gdb_test_no_output "set debug-file-directory"
-	gdb_reinitialize_dir $srcdir/$subdir
 
 	# Print the "PIE (Position Independent Executable)
 	# displacement" message.
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index afe2203c285..189a240979f 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -290,10 +290,7 @@ gdb_test "restart 10" "Not found.*" "no more checkpoint 10"
 # Now let's try setting a large number of checkpoints (>600)
 #
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 runto_main
 gdb_breakpoint $break1_loc
diff --git a/gdb/testsuite/gdb.base/comprdebug.exp b/gdb/testsuite/gdb.base/comprdebug.exp
index 72b330cf5a6..3e0113ca415 100644
--- a/gdb/testsuite/gdb.base/comprdebug.exp
+++ b/gdb/testsuite/gdb.base/comprdebug.exp
@@ -34,9 +34,7 @@ if {$result == 1} {
     return
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 set testname "file [file tail $ofile]"
 if {[gdb_file_cmd $ofile] == 0} {
     pass $testname
diff --git a/gdb/testsuite/gdb.base/cursal.exp b/gdb/testsuite/gdb.base/cursal.exp
index 59cb1a28adc..9db963b3941 100644
--- a/gdb/testsuite/gdb.base/cursal.exp
+++ b/gdb/testsuite/gdb.base/cursal.exp
@@ -21,10 +21,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
 gdb_test_no_output "set listsize 1"
 
 # initial sal should be first statement in main
diff --git a/gdb/testsuite/gdb.base/detach.exp b/gdb/testsuite/gdb.base/detach.exp
index d4427c13087..56ea9322a6d 100644
--- a/gdb/testsuite/gdb.base/detach.exp
+++ b/gdb/testsuite/gdb.base/detach.exp
@@ -42,11 +42,7 @@ proc do_detach_tests {} {
   gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach, $pass"
 }
 
-# Start with a fresh gdb
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 global pass
 set pass "one"
diff --git a/gdb/testsuite/gdb.base/dfp-exprs.exp b/gdb/testsuite/gdb.base/dfp-exprs.exp
index 9794d3e59c9..512d2ec4596 100644
--- a/gdb/testsuite/gdb.base/dfp-exprs.exp
+++ b/gdb/testsuite/gdb.base/dfp-exprs.exp
@@ -191,11 +191,7 @@ proc test_dfp_conversions {} {
     gdb_test "p (_Decimal32) 4" " = 4"
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 test_dfp_literals_accepted
 test_dfp_arithmetic_expressions
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index a349fc8a97d..79ef4d894e8 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -52,10 +52,7 @@ if !$use_gdb_stub {
     gdb_test "kill" ".*" "kill again"
     gdb_test "detach" ".*" "detach again"
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load ${binfile}
+    clean_restart $binfile
 }
 
 # Ok, on to real life
diff --git a/gdb/testsuite/gdb.base/dprintf-pending.exp b/gdb/testsuite/gdb.base/dprintf-pending.exp
index 79abd69cd62..f80ca3b60c4 100644
--- a/gdb/testsuite/gdb.base/dprintf-pending.exp
+++ b/gdb/testsuite/gdb.base/dprintf-pending.exp
@@ -31,18 +31,14 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
 }
 
 with_test_prefix "without format" {
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
+    clean_restart
 
     gdb_test "dprintf pendfunc" "Format string required" "missing ,FMT"
     gdb_test "dprintf pendfunc," "Format string required" "missing FMT"
 }
 
 with_test_prefix "without symbols" {
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
+    clean_restart
 
     gdb_test \
 	"dprintf pendfunc1, \"x=%d\\n\", x" \
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index 2a722808c46..57a93f5d123 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -52,11 +52,7 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${op
      return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart $binfile
 
 gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
 	 "inaccessible memory is reported"
@@ -479,9 +475,7 @@ foreach_with_prefix format $formats {
 
 # Now start a fresh gdb session, and reload the saved value files.
 
-gdb_exit
-gdb_start
-gdb_file_cmd ${binfile}
+clean_restart $binfile
 
 # Now fix the endianness at the correct state.
 
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index fd2eab5c6fc..09ca29eebee 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -45,12 +45,7 @@ system "rm -rf [standard_output_file *.fileio.test]"
 set oldtimeout $timeout
 set timeout [expr "$timeout + 60"]
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_test_no_output "set print sevenbit-strings"
 gdb_test_no_output "set print address off"
 gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/fixsection.exp b/gdb/testsuite/gdb.base/fixsection.exp
index b998a151fce..8b6f86a868b 100644
--- a/gdb/testsuite/gdb.base/fixsection.exp
+++ b/gdb/testsuite/gdb.base/fixsection.exp
@@ -32,12 +32,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib ${lib_sl}
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index 83ccb54e60e..0092fcceacc 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -379,9 +379,6 @@ proc do_exec_tests {} {
    }
 }
 
-# Start with a fresh gdb
-
-gdb_exit
 clean_restart $binfile
 
 do_exec_tests
diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp
index 51ccb012688..3e25f8de58b 100644
--- a/gdb/testsuite/gdb.base/fullname.exp
+++ b/gdb/testsuite/gdb.base/fullname.exp
@@ -45,9 +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.
 
-gdb_exit
-gdb_start
-gdb_load ${binfile}
+clean_restart $binfile
 
 set msg "set breakpoint by full path before loading symbols - built absolute"
 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -72,9 +70,7 @@ if  { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_load ${binfile}
+clean_restart $binfile
 
 set msg "set breakpoint by full path before loading symbols - built relative"
 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -103,9 +99,7 @@ with_cwd [standard_output_file {}] {
     }
 }
 
-gdb_exit
-gdb_start
-gdb_load ${binfile}
+clean_restart $binfile
 
 set msg "set breakpoint by full path before loading symbols - built other"
 if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index bd5dcd250ea..1e88d5334ba 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -57,10 +57,7 @@ if {!$core_supported} {
 }
 
 # Now restart gdb and load the corefile.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
 if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp
index 6b270d839f3..7916f0cbe1f 100644
--- a/gdb/testsuite/gdb.base/hashline2.exp
+++ b/gdb/testsuite/gdb.base/hashline2.exp
@@ -34,10 +34,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}]
 
diff --git a/gdb/testsuite/gdb.base/hashline3.exp b/gdb/testsuite/gdb.base/hashline3.exp
index e0b1656223e..abc5f629978 100644
--- a/gdb/testsuite/gdb.base/hashline3.exp
+++ b/gdb/testsuite/gdb.base/hashline3.exp
@@ -35,10 +35,7 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
 
diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp
index 19830dc422d..44da0a9c175 100644
--- a/gdb/testsuite/gdb.base/langs.exp
+++ b/gdb/testsuite/gdb.base/langs.exp
@@ -93,10 +93,7 @@ if {[runto csub]} {
     gdb_continue_to_end "first session"
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+clean_restart $binfile
 
 # Try exercising the "minimal" language a bit...
 
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 4fbf5352c7b..8abc6061944 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -400,12 +400,7 @@ proc test_list_invalid_args {} {
 	"second use of \"list +INVALID\""
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
 
 gdb_test_no_output "set width 0"
 
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index c3e6bb4d58a..be54fb1ce08 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -35,11 +35,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
      -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
@@ -68,11 +64,7 @@ gdb_test "" \
 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
 "run to resolved breakpoint 1 (without symbols)"
 
-# Restart with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 with_test_prefix "second load" {
     gdb_load ${binfile}
diff --git a/gdb/testsuite/gdb.base/permissions.exp b/gdb/testsuite/gdb.base/permissions.exp
index 7bbe8f0ff16..a78b40a6dce 100644
--- a/gdb/testsuite/gdb.base/permissions.exp
+++ b/gdb/testsuite/gdb.base/permissions.exp
@@ -26,9 +26,7 @@ if {[build_executable $testfile.exp $testfile \
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 with_test_prefix "observer mode off" {
 
diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp
index c8d1ee763bf..bdea0982dea 100644
--- a/gdb/testsuite/gdb.base/print-symbol-loading.exp
+++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp
@@ -49,9 +49,7 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
 proc test_load_core { print_symbol_loading } {
     global binfile binfile_lib gcorefile srcdir subdir
     with_test_prefix "core ${print_symbol_loading}" {
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
+	clean_restart
 	gdb_test_no_output "set print symbol-loading $print_symbol_loading"
 	if { ${print_symbol_loading} != "off" } {
 	    gdb_test "file $binfile" "Reading symbols from.*" "file"
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index c1adc787e33..21a2cad458c 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -1087,11 +1087,7 @@ proc test_printf_convenience_var {prefix} {
 }
 
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test "print \$pc" "No registers\\."
 
diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp
index d46db245a38..73c10f8000f 100644
--- a/gdb/testsuite/gdb.base/readline.exp
+++ b/gdb/testsuite/gdb.base/readline.exp
@@ -199,9 +199,7 @@ save_vars { env(TERM) } {
 	set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history"
 	set env(GDBHISTSIZE) "10"
 
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
+	clean_restart
 
 	operate_and_get_next "Simple operate-and-get-next, two" \
 	    "p 7" ".* = 7" \
diff --git a/gdb/testsuite/gdb.base/relocate.exp b/gdb/testsuite/gdb.base/relocate.exp
index add323b53f8..16b869f79a0 100644
--- a/gdb/testsuite/gdb.base/relocate.exp
+++ b/gdb/testsuite/gdb.base/relocate.exp
@@ -25,9 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}]
      return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 #Check that invalid options are rejected.
 foreach x {"-raednow" "readnow" "foo" "-readnow s"} {
@@ -194,9 +192,7 @@ if { "${function_foo_addr}" == "${function_bar_addr}" } {
 # Now use a variable as an offset to add-symbol-file, and check that
 # the functions' addresses change.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 gdb_test_no_output "set \$offset = 0x10000"
 
@@ -317,10 +313,7 @@ with_test_prefix "global vars, 3rd" {
 # Now try loading the object as an exec-file; we should be able to print
 # the values of variables after we do this.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_file_cmd ${binfile}
+clean_restart $binfile
 
 # Check the values of the variables.
 gdb_test "print static_foo" "\\\$$decimal = 1"
diff --git a/gdb/testsuite/gdb.base/sep.exp b/gdb/testsuite/gdb.base/sep.exp
index 500c2c1ce12..29901af34a5 100644
--- a/gdb/testsuite/gdb.base/sep.exp
+++ b/gdb/testsuite/gdb.base/sep.exp
@@ -45,10 +45,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.
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 
 set test "breakpoint inside included file"
 gdb_test_multiple "break sep-proc.c:$location" "$test" {
diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp
index 7daf3388f77..6a0c1035552 100644
--- a/gdb/testsuite/gdb.base/sepdebug.exp
+++ b/gdb/testsuite/gdb.base/sepdebug.exp
@@ -561,9 +561,7 @@ proc test_different_dir {type test_different_dir xfail} {
 	global srcdir subdir binfile srcfile timeout gdb_prompt
 	global bp_location6 decimal hex
 
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
+	clean_restart
 	gdb_test_no_output "set debug-file-directory ${test_different_dir}" \
 	    "set separate debug location"
 	gdb_load ${binfile}
@@ -656,9 +654,7 @@ if {[build_executable sepdebug.exp sepdebug2 sepdebug2.c debug] != -1
 
     remote_exec build "cp ${debugfile} [standard_output_file sepdebug2.debug]"
 
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
+    clean_restart
 
     set escapedobjdirsubdir [string_to_regexp [standard_output_file {}]]
 
diff --git a/gdb/testsuite/gdb.base/solib-disc.exp b/gdb/testsuite/gdb.base/solib-disc.exp
index 46b11dc768b..c397f6b3d72 100644
--- a/gdb/testsuite/gdb.base/solib-disc.exp
+++ b/gdb/testsuite/gdb.base/solib-disc.exp
@@ -44,10 +44,7 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
     return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib $libobj
 
 if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp
index 302981a64ad..f1d3c3a5c5a 100644
--- a/gdb/testsuite/gdb.base/solib-symbol.exp
+++ b/gdb/testsuite/gdb.base/solib-symbol.exp
@@ -34,10 +34,7 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
   return -1
 }
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib $binfile_lib
 
 # Set a breakpoint in the binary.
diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp
index 9a140c1d9ac..dc99be71648 100644
--- a/gdb/testsuite/gdb.base/solib-weak.exp
+++ b/gdb/testsuite/gdb.base/solib-weak.exp
@@ -84,10 +84,7 @@ proc do_test { lib1opts lib2opts lib1first } {
     }
 
     with_test_prefix $testopts {
-	gdb_exit
-	gdb_start
-	gdb_reinitialize_dir $srcdir/$subdir
-	gdb_load ${binfile}
+	clean_restart $binfile
 	gdb_load_shlib $lib1
 	gdb_load_shlib $lib2
 
diff --git a/gdb/testsuite/gdb.base/subst.exp b/gdb/testsuite/gdb.base/subst.exp
index ad5ebb3e864..6f3d57e8df4 100644
--- a/gdb/testsuite/gdb.base/subst.exp
+++ b/gdb/testsuite/gdb.base/subst.exp
@@ -13,9 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
 # Do a bunch of testing of the set/unset/show substitute-path
 # commands that do not require the presence of an executable.
diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp
index 3e340e9fada..76b061cacc2 100644
--- a/gdb/testsuite/gdb.base/unload.exp
+++ b/gdb/testsuite/gdb.base/unload.exp
@@ -50,12 +50,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib $lib_sl
 gdb_load_shlib $lib_sl2
 
diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp
index 142680c58cb..b648a017438 100644
--- a/gdb/testsuite/gdb.base/watchpoint-solib.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp
@@ -49,12 +49,7 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
     return -1
 }
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart $binfile
 gdb_load_shlib $lib_sl
 
 runto_main
-- 
2.39.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 12/27] Use clean_restart in gdb.trace
  2023-01-25 22:45 ` [PATCH 12/27] Use clean_restart in gdb.trace Tom Tromey
@ 2023-01-26 17:34   ` Pedro Alves
  2023-01-26 18:34     ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Pedro Alves @ 2023-01-26 17:34 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2023-01-25 10:45 p.m., Tom Tromey wrote:
> --- a/gdb/testsuite/gdb.trace/unavailable.exp
> +++ b/gdb/testsuite/gdb.trace/unavailable.exp
> @@ -202,10 +202,7 @@ proc gdb_collect_args_test {} {
>  
>  	foreach target_name ${trace_file_targets} {
>  	    # Restart GDB and read the trace data in ${TARGET_NAME} target.
> -	    gdb_exit
> -	    gdb_start
> -	    gdb_reinitialize_dir $srcdir/$subdir
> -	    gdb_file_cmd $binfile
> +	    clean_restart $binfile

Note this one is not 100% equivalent, because this was using gdb_file_cmd instead of gdb_load for
a reason --  I think because afterwards we're explicitly connecting to a target, while gdb_load may connect
to the target.  I recall patches from Daniel switching from gdb_load to gdb_file_cmd in tests that
don't really need execution for that reason years ago.  ISTR a number of them, but I'm not finding all
that much.  I did find this one, though:

  https://sourceware.org/pipermail/gdb-patches/2010-March/072735.html

So IIRC, what Daniel described back then is I think the reason several tests in
for example gdb.base/ use gdb_file_cmd.

So I grepped for gdb_file_cmd in gdb.base/ and randomly picked gdb.base/list.exp, used
git blame and that led me to this patch:

  https://sourceware.org/pipermail/gdb-patches/2012-June/093697.html

which again is exactly about avoiding gdb_load.

So maybe for the cases we are using gdb_file_cmd today, we should use:

	    clean_restart
	    gdb_file_cmd $binfile

instead of:

	    clean_restart $binfile

?

Pedro Alves

>  	    gdb_test "target ${target_name} ${tracefile}.args.${target_name}" ".*" \
>  		"change to ${target_name} target"


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 00/27] Many small testsuite cleanups
  2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
                   ` (26 preceding siblings ...)
  2023-01-25 22:46 ` [PATCH 27/27] Use clean_restart in gdb.base Tom Tromey
@ 2023-01-26 17:37 ` Pedro Alves
  27 siblings, 0 replies; 32+ messages in thread
From: Pedro Alves @ 2023-01-26 17:37 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 2023-01-25 10:45 p.m., Tom Tromey wrote:
> I noticed a few things in the test suite that looked off, so I wrote
> some patches to clean it up.  Each patch should be reasonably
> self-explanatory.
> 

I read the whole thing, and the only thing that jumped out at me was
the gdb_file_cmd vs gdb_load issue I pointed out in another email.

Everything else looked OK.

Thanks for doing this.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 12/27] Use clean_restart in gdb.trace
  2023-01-26 17:34   ` Pedro Alves
@ 2023-01-26 18:34     ` Tom Tromey
  2023-01-27  0:36       ` Tom Tromey
  0 siblings, 1 reply; 32+ messages in thread
From: Tom Tromey @ 2023-01-26 18:34 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:

>> -	    gdb_exit
>> -	    gdb_start
>> -	    gdb_reinitialize_dir $srcdir/$subdir
>> -	    gdb_file_cmd $binfile
>> +	    clean_restart $binfile

Pedro> Note this one is not 100% equivalent, because this was using
Pedro> gdb_file_cmd instead of gdb_load for a reason

Ugh, I saw that clean_restart calls gdb_load, but gdb_load is really
simple -- it just calls gdb_file_cmd!

But... now I see the board files redefine gdb_load.


It would be nice to get rid of the redefinitions and monkey-patching
that is done in the test suite.  IMO this leads to a lot of hidden
gotchas.

Maybe one idea would be to have a list (or namespace or something) of
override-able procs, and require each board to provide them all... and
then have a default "native" board.  This way at least the default
implementations wouldn't be living in gdb.exp to confuse me.

I'll dig through and fix up these bits.

Tom

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 12/27] Use clean_restart in gdb.trace
  2023-01-26 18:34     ` Tom Tromey
@ 2023-01-27  0:36       ` Tom Tromey
  0 siblings, 0 replies; 32+ messages in thread
From: Tom Tromey @ 2023-01-27  0:36 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Pedro Alves, gdb-patches

Tom> I'll dig through and fix up these bits.

I went through all the patches and restored the use of gdb_file_cmd in
all the spots where I'd changed it.  I've re-tested and now I'm going to
check it in.

Tom

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2023-01-27  0:36 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 22:45 [PATCH 00/27] Many small testsuite cleanups Tom Tromey
2023-01-25 22:45 ` [PATCH 01/27] Use ordinary calling convention for clean_restart Tom Tromey
2023-01-25 22:45 ` [PATCH 02/27] Use clean_restart in gdb.dlang Tom Tromey
2023-01-25 22:45 ` [PATCH 03/27] Eliminate spurious returns from the test suite Tom Tromey
2023-01-25 22:45 ` [PATCH 04/27] Remove some dead code in gdb.fortran/info-types.exp Tom Tromey
2023-01-25 22:45 ` [PATCH 05/27] Minor "require" fixups Tom Tromey
2023-01-25 22:45 ` [PATCH 06/27] Remove unnecessary call to standard_testfile Tom Tromey
2023-01-25 22:45 ` [PATCH 07/27] Start gdb after building executable in mi-basics.exp Tom Tromey
2023-01-25 22:45 ` [PATCH 08/27] Use mi_clean_restart more Tom Tromey
2023-01-25 22:45 ` [PATCH 09/27] Use clean_restart in gdb.pascal Tom Tromey
2023-01-25 22:45 ` [PATCH 10/27] Use clean_restart in gdb.linespec Tom Tromey
2023-01-25 22:45 ` [PATCH 11/27] Use clean_restart in gdb.opencl Tom Tromey
2023-01-25 22:45 ` [PATCH 12/27] Use clean_restart in gdb.trace Tom Tromey
2023-01-26 17:34   ` Pedro Alves
2023-01-26 18:34     ` Tom Tromey
2023-01-27  0:36       ` Tom Tromey
2023-01-25 22:46 ` [PATCH 13/27] Use clean_restart in gdb.objc Tom Tromey
2023-01-25 22:46 ` [PATCH 14/27] Use clean_restart in gdb.threads Tom Tromey
2023-01-25 22:46 ` [PATCH 15/27] Use clean_restart in gdb.guile Tom Tromey
2023-01-25 22:46 ` [PATCH 16/27] Use clean_restart in gdb.arch Tom Tromey
2023-01-25 22:46 ` [PATCH 17/27] Use clean_restart in gdb.reverse Tom Tromey
2023-01-25 22:46 ` [PATCH 18/27] Use clean_restart in gdb.dwarf2 Tom Tromey
2023-01-25 22:46 ` [PATCH 19/27] Use clean_restart in gdb.ada Tom Tromey
2023-01-25 22:46 ` [PATCH 20/27] Use clean_restart in gdb.fortran Tom Tromey
2023-01-25 22:46 ` [PATCH 21/27] Use clean_restart in gdb.stabs Tom Tromey
2023-01-25 22:46 ` [PATCH 22/27] Use clean_restart in gdb.go Tom Tromey
2023-01-25 22:46 ` [PATCH 23/27] Use clean_restart in gdb.perf Tom Tromey
2023-01-25 22:46 ` [PATCH 24/27] Use clean_restart in gdb.disasm Tom Tromey
2023-01-25 22:46 ` [PATCH 25/27] Use clean_restart in gdb.cp Tom Tromey
2023-01-25 22:46 ` [PATCH 26/27] Use clean_restart in gdb.python Tom Tromey
2023-01-25 22:46 ` [PATCH 27/27] Use clean_restart in gdb.base Tom Tromey
2023-01-26 17:37 ` [PATCH 00/27] Many small testsuite cleanups Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).