Use mi_clean_restart more
authorTom Tromey <tom@tromey.com>
Wed, 25 Jan 2023 17:01:57 +0000 (10:01 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 27 Jan 2023 01:28:31 +0000 (18:28 -0700)
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.

60 files changed:
gdb/testsuite/gdb.ada/mi_ex_cond.exp
gdb/testsuite/gdb.ada/mi_task_arg.exp
gdb/testsuite/gdb.ada/mi_task_info.exp
gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
gdb/testsuite/gdb.mi/gdb680.exp
gdb/testsuite/gdb.mi/list-thread-groups-no-inferior.exp
gdb/testsuite/gdb.mi/mi-async-run.exp
gdb/testsuite/gdb.mi/mi-async.exp
gdb/testsuite/gdb.mi/mi-break-qualified.exp
gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
gdb/testsuite/gdb.mi/mi-cmd-error.exp
gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
gdb/testsuite/gdb.mi/mi-console.exp
gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
gdb/testsuite/gdb.mi/mi-editing.exp
gdb/testsuite/gdb.mi/mi-eval.exp
gdb/testsuite/gdb.mi/mi-file-transfer.exp
gdb/testsuite/gdb.mi/mi-file.exp
gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
gdb/testsuite/gdb.mi/mi-hack-cli.exp
gdb/testsuite/gdb.mi/mi-i-cmd.exp
gdb/testsuite/gdb.mi/mi-info-os.exp
gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
gdb/testsuite/gdb.mi/mi-language.exp
gdb/testsuite/gdb.mi/mi-memory-changed.exp
gdb/testsuite/gdb.mi/mi-pending.exp
gdb/testsuite/gdb.mi/mi-pthreads.exp
gdb/testsuite/gdb.mi/mi-reg-undefined.exp
gdb/testsuite/gdb.mi/mi-return.exp
gdb/testsuite/gdb.mi/mi-simplerun.exp
gdb/testsuite/gdb.mi/mi-solib.exp
gdb/testsuite/gdb.mi/mi-stack.exp
gdb/testsuite/gdb.mi/mi-start.exp
gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
gdb/testsuite/gdb.mi/mi-undefined-cmd.exp
gdb/testsuite/gdb.mi/mi-until.exp
gdb/testsuite/gdb.mi/mi-var-block.exp
gdb/testsuite/gdb.mi/mi-var-child-f.exp
gdb/testsuite/gdb.mi/mi-var-child.exp
gdb/testsuite/gdb.mi/mi-var-cmd.exp
gdb/testsuite/gdb.mi/mi-var-cp.exp
gdb/testsuite/gdb.mi/mi-var-display.exp
gdb/testsuite/gdb.mi/mi-var-invalidate.exp
gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
gdb/testsuite/gdb.mi/mi-var-rtti.exp
gdb/testsuite/gdb.mi/mi-vla-c99.exp
gdb/testsuite/gdb.mi/mi-vla-fortran.exp
gdb/testsuite/gdb.mi/mi-watch.exp
gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
gdb/testsuite/gdb.mi/mi2-cli-display.exp
gdb/testsuite/gdb.mi/mi2-prompt.exp
gdb/testsuite/gdb.mi/mi2-var-child.exp
gdb/testsuite/gdb.python/py-framefilter-mi.exp
gdb/testsuite/gdb.python/py-mi-events.exp
gdb/testsuite/gdb.python/py-mi-objfile.exp
gdb/testsuite/gdb.python/py-mi.exp
gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
gdb/testsuite/gdb.trace/mi-tsv-changed.exp

index 6fba4da9e8037a7200318040c013821e8c571f76..f41b633a8220f8dc628aae545dbc724aa856c67e 100644 (file)
@@ -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.
 
index 771e9345c40ca6346afcd972bfa11a4ff2787df5..1d84e432ad8276d6c11d13c897a65c6590109f7c 100644 (file)
@@ -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 \"\"" ".*"
 
index 7701a3ef6d646bb63218dde4d0f6462cd9526cfe..6e23f018e4c56380168fe71f5ada17e6fcfea538 100644 (file)
@@ -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.  #
 ####################################
index ae6c58f24341b586133f0a151ba11b8c8c0df06a..0d54947d36c859d53b0eb4a23dc54cebc247d1af 100644 (file)
@@ -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"
index 336290ee1e17fd5efd684cf43c9087f619525b28..692e0f1eeaa6ecd26a21720984c1324c7ca8b203 100644 (file)
@@ -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).
index fb9d865f6f4ad108b287a90fb4cac11982040c8b..a5d321d9368b8ce8a3f2497e780a8a44e5cbd78e 100644 (file)
@@ -20,8 +20,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index 2e05f1d8f92a3fe2ec84516635285e4de2c2e633..feb2915f8c5422e9dddecabf9b5036befda9e137 100644 (file)
@@ -21,8 +21,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index 0267b546ef7348201e7129eb6723db3bbcc5a2cd..cd668b161f85178e99ca5243d18d8f444b6f04a7 100644 (file)
@@ -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"
index f970fc772caeda744318b5c3896c253696516bc6..4bc82d5f55d9185016f1b798572318bee439e2e5 100644 (file)
@@ -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.
index 64bb9e4104e852c7028f518ea363163615206cb7..3f6acc566b18b6c5a86e4728d66b5703bdb6f5dc 100644 (file)
@@ -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
index 5cc2fe840fb2ce5ec6bd3aa7e9fddb72d6246fd0..c0d9add964607814a4221aa0f23e0b0ec8c28b97 100644 (file)
@@ -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
index ac2d8e188284d39669d71a53bf5926f766c51db8..595ae929e9ae4109c890752037b68ae4f33a60b6 100644 (file)
@@ -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 \
index 5a3b84a58a66702627854964e1d6ab04b1a7f568..a43d82495c625cb1043cc85c638e15274dfc644a 100644 (file)
@@ -25,8 +25,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index de0914dd0ede00ec365f20ee53a5cb5afa142ad7..8184cd82ece5cf9d09d702f81590c857009e6304 100644 (file)
@@ -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
 
index 738960739f7a20ea0fc8b56e0d605b1788bd1915..c39e05cc3d66ec21a888660850416d3fd830e560 100644 (file)
@@ -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
index 66a30426a8b8e9811fcbb2734ff5434d2fd51ffd..358d929f1bbc7c7a27f2a9af522cd4777a22c132 100644 (file)
@@ -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"]
index 35ed2af8ad473d57e33b27e599cfde8bf3fe7441..2fb65ff9a9d33a09ccb05c6e82f9179f0dedb605 100644 (file)
@@ -23,8 +23,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_clean_restart]} {
     return
 }
 
index 1611b15c8f249430e4bac69bc6b409330702da0a..74ff887ef9c9df365bc27fcc4f744706d90d5567 100644 (file)
 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]
index 726504c46d8be32d4b7ca61ceb1940c86ed3d5bd..edb1ea60a267628305a53e350e526e06825a4c41 100644 (file)
@@ -29,12 +29,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_file_cmd ${binfile}
 
 proc mi_gdbserver_run { } {
index 811744e556fe234010cec6307870444a8e990bd9..0785c2b2580a359feb23aac150112a6dd3023dde 100644 (file)
 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,8 +25,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
+if {[mi_clean_restart]} {
+    return
+}
 mi_gdb_file_cmd ${binfile}
 
 proc test_file_list_exec_source_file {} {
index b41cc7fa510d058412b1c35591f03534379e740c..f898e556449e359338e838fb1fb143f10e5afae7 100644 (file)
 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"
 
index 3013d87462a43f84d1679bf252673b2982790a36..f39923ba60bce4aa603a5af5b5663e329a3beb82 100644 (file)
@@ -19,8 +19,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index 80ef266dd3afffcc91f7c0db8f52f4ccec3922e4..e64f9006f3cfafcb766d4566884ea3987eaf4144 100644 (file)
@@ -16,8 +16,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index 2f243a7aac01fd79e4ccb63be07cfa0bd25fc19c..d71ad4c819252368a300a0eb40795c9c7178d3a8 100644 (file)
@@ -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
index d3523b07d00130b9d06789d84e137cf0a83350ef..90bb18257afff38644eef343438970ce99919fa1 100644 (file)
@@ -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"
index 4e8dea3995cfaa7a4e9fefc4cee7bd389a9200ca..41a6c22d6f8660aea31c4044855002ee46290efa 100644 (file)
@@ -16,8 +16,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index 846415d6267154a4418a5db25f7f3747f79c87e7..c56256802f65872bfc39553e36ef657460723317 100644 (file)
@@ -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\".*" \
index 271908c9855d3452bab849a61289ffeeb9a18fa1..153efdf45ceebe95c6cb2b0b4792d86780b5e9cf 100644 (file)
@@ -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
 
index fc410af99bee8063ab54da67e53b0e3a093b8183..f8e701e78547a33ab256db7ec4ac9d2bde6baead 100644 (file)
 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
 
index caca9690e9bbf3a964aacf1b3c6bd866586582da..d69059514f38795e6bb053d3853e43cd1c0f9c4c 100644 (file)
@@ -22,11 +22,6 @@ require dwarf2_support
 # This test can only be run on x86_64 targets.
 require is_x86_64_m64_target
 
-gdb_exit
-if [mi_gdb_start] {
-    return
-}
-
 standard_testfile .S
 
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nopie}] != "" } {
@@ -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_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"
index 6254711bdec03dddeed47a844f0d694f0a333989..12185fb81f5dc1bfa9ac26043d2b4502e28a19f3 100644 (file)
 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
index 99b729d5df3d1043c21e797f2503b7d690a1c039..fec4f014cd323cdc9388febc1aa9164dc554ea83 100644 (file)
 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
index 03637651d927aaab07a29e2941be443367c53029..665759d4d530c0f2fec8d9c4781c1350a0e54257 100644 (file)
@@ -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
 
index 3359a877a6a59cab14315e43aeb3f778f3d5cc54..633e090c13a1cf7df2a21c1d0bdfa1196b5fff02 100644 (file)
 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
index b7e81a304863b28357a43599a15cba4494b87f88..89ce2dd25eac5a97c249e7dbd44878ec7ed29ab5 100644 (file)
@@ -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.
index 2193f05f1e2b9f10dda09c177d0b33b68186305a..149940d67432e721ac6ae364946796cb61c93ebf 100644 (file)
@@ -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.
index 998853cefb8a456d4820f961fb85037722b81de7..9b57c8237f8fcc28c43fe9c1bcb2b0e9ad6eb634 100644 (file)
 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" \
index be87d2c5474c252f572e9c223c3e237b0a897dd2..902fd8ae591426f5974fa935247462dd621f86dc 100644 (file)
 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"]
index 3638dfd7ed518ab13ad0f08149590f8818b8315f..e2e788a888c07669bfc88723b8ae409c64f289ae 100644 (file)
 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
 
index 7723dbc574f4e26a4cc37630e309b531c73f081a..1b4e164e3eaffa560559c892b57c708bd1d17e4d 100644 (file)
@@ -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"
index e64bde94959b7aab5a5a8331acdcc0cdab3f72f5..3cfa0ce88ac2321fdb1dad18087738d9677448a8 100644 (file)
 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
 
index 9bd1f7cd1a8efbc4aa9b176fca0c41e58831a7a5..084658037348eda569a2b5eb7e21b242e9fcce4d 100644 (file)
 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
+}
 
 #####                   #####
 #                           #
index 3ce48db6c2b7143465c2853dfb5b33b1a251e756..edb4332e253f1e0bb98609b42c2dc143c3822c87 100644 (file)
@@ -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
 
index b889d197051aab387aba65be3ae83529edcc9af7..548c4fe2ca394522024b255b3697441b971ca553 100644 (file)
 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;}"]
 
index dfaff33b9a2308b32813b681e2d734a06b9e8451..20d9171ac18e4465f8767ad6e3db9656dcd1493e 100644 (file)
 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"
index ea02467c5e0a711958cfaf4f45df65844cc37fb4..f9da4e46c85bd6f79a3ceb641f56371a5e2a1cbd 100644 (file)
 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"]
index fb8e4923f8291b5c9f697a9a746eb51b16e49d0c..a41d58e0b5224aa1b90a44d613f0362d294492eb 100644 (file)
@@ -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
 
index ddfe607621391fbbfe28b0cf99ef9bd6d49f06f6..3c28549e621c2521631135081eabb88f98fb08c5 100644 (file)
 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"]
 
index a240fb36d618c03d61708d8996db0ef1110c94c5..e4db423babd880004d929ed7b24353fc69400615 100644 (file)
@@ -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" \
index a6e6f89bc1113ac0bfbe1f571f80e127e21df26f..5303a41e86e1a059b69b79816f4e5f61e8fce682 100644 (file)
@@ -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}] != "" } {
index 76acabc0adefb57ad4bbb3dddba3db7582c8b38c..80c8ddf56b44407674a46db111bde277390dd4e2 100644 (file)
 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 is_x86_64_m64_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"
index 817c3832c668b4446cbf13ffad552bac4341bb69..6a2b86d7e12e986902ca00fa1d5bb020eafb0a3e 100644 (file)
 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
 
index 22fda0e09709107bf094d7c62d0a6aef45e6c95f..f528c76b3d841021bcaa2cf35603e3364dc6ea89 100644 (file)
@@ -16,8 +16,7 @@
 load_lib mi-support.exp
 set MIFLAGS "-i=mi2"
 
-gdb_exit
-if [mi_gdb_start] {
+if {[mi_clean_restart]} {
     return
 }
 
index 47cfeb860e372ff43f45e15a3d41e5be23b673e8..5c40f83d1fabef308aeeb6a2047838b530fc6267 100644 (file)
 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
 
index 723945dde83c295ddb45636891ec7c48f3e71f17..509f21b3962b3862edb10a07bb417da5b77d1456 100644 (file)
@@ -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"
index cc417d48bfeec3e51a62c237020b16dbb4a96e11..8d546a9e757c9028c415f50b2ee27eb966926a3d 100644 (file)
@@ -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"
index bc02da252bccf1e5646983d5c47d7494f6402110..d098bba547d2fe868c23042ad520bfe899b265a4 100644 (file)
@@ -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"
index 705a9c417418cd3189ed616b7a25f6861e22ffed..a7b7a5ffcd33434a80d9c8e899b28d0902d47a5e 100644 (file)
 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"
index 6dc5e38d1b2127792fd9edd9a4a3b613cda5dd00..fab1463d268035b73d359e4405b464de65eff4c3 100644 (file)
@@ -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
index ea7fcf31a309c49a4fc1da532039e85e824b5a66..792bd4f7d42a5ce7f42a9af8772a30ff75f1a0be 100644 (file)
@@ -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