aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2020-10-11 21:58:31 +0100
committerPedro Alves <pedro@palves.net>2020-10-12 01:45:51 +0100
commitbdfbda93f2fa10e94dec6f06a08459d825213a8d (patch)
tree6430384bd8b3549c748336da21aca93f3373d6c7
parentdf47e3e9fe15a647db52361a10f726421ddd034e (diff)
downloadgdb-users/palves/runto_main.zip
gdb-users/palves/runto_main.tar.gz
gdb-users/palves/runto_main.tar.bz2
Eliminate mi_run_to_main, introduce mi_clean_restartusers/palves/runto_main
Since we now have mi_runto_main which is like runto_main, eliminate mi_run_to_main, in favor of a new MI clean_restart counterpart -- mi_clean_restart -- and mi_runto_main. This makes MI testcases look a bit more like CLI testcases. gdb/testsuite/ChangeLog: * lib/mi-support.exp (mi_clean_restart): New. (mi_run_to_main): Delete. All callers adjust to use mi_clean_restart / mi_runto_main. Change-Id: I34920bab4fea1f23fb752928c2969c1f6ad714b6
-rw-r--r--gdb/testsuite/gdb.ada/mi_catch_assert.exp11
-rw-r--r--gdb/testsuite/gdb.ada/mi_catch_ex.exp13
-rw-r--r--gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp9
-rw-r--r--gdb/testsuite/gdb.ada/mi_dyn_arr.exp11
-rw-r--r--gdb/testsuite/gdb.ada/mi_exc_info.exp7
-rw-r--r--gdb/testsuite/gdb.ada/mi_interface.exp13
-rw-r--r--gdb/testsuite/gdb.ada/mi_prot.exp7
-rw-r--r--gdb/testsuite/gdb.ada/mi_ref_changeable.exp11
-rw-r--r--gdb/testsuite/gdb.ada/mi_string_access.exp11
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_access.exp10
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_array.exp11
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_union.exp11
-rw-r--r--gdb/testsuite/gdb.ada/mi_variant.exp11
-rw-r--r--gdb/testsuite/gdb.mi/gdb2549.exp11
-rw-r--r--gdb/testsuite/gdb.mi/gdb669.exp8
-rw-r--r--gdb/testsuite/gdb.mi/gdb701.exp8
-rw-r--r--gdb/testsuite/gdb.mi/gdb792.exp15
-rw-r--r--gdb/testsuite/gdb.mi/mi-break.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-catch-load.exp18
-rw-r--r--gdb/testsuite/gdb.mi/mi-cli.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-complete.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-console.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-detach.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-disassemble.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf.exp10
-rw-r--r--gdb/testsuite/gdb.mi/mi-exit-code.exp14
-rw-r--r--gdb/testsuite/gdb.mi/mi-fill-memory.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-fortran-modules.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-frame-regs.exp14
-rw-r--r--gdb/testsuite/gdb.mi/mi-info-os.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-logging.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-nonstop-exit.exp14
-rw-r--r--gdb/testsuite/gdb.mi/mi-nonstop.exp18
-rw-r--r--gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp10
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsintrall.exp10
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsmoribund.exp10
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsthrexec.exp10
-rw-r--r--gdb/testsuite/gdb.mi/mi-read-memory.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-record-changed.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-regs.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-reverse.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepi.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepn.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-sym-info.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.exp6
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-create-rtti.exp11
-rw-r--r--gdb/testsuite/gdb.mi/mi-watch-nonstop.exp10
-rw-r--r--gdb/testsuite/gdb.mi/pr11022.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-mi-events.exp3
-rw-r--r--gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp11
-rw-r--r--gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp6
-rw-r--r--gdb/testsuite/gdb.trace/mi-trace-unavailable.exp6
-rw-r--r--gdb/testsuite/gdb.trace/mi-traceframe-changed.exp12
-rw-r--r--gdb/testsuite/lib/mi-support.exp43
59 files changed, 184 insertions, 400 deletions
diff --git a/gdb/testsuite/gdb.ada/mi_catch_assert.exp b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
index 30543e5..095815d 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_assert.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
@@ -58,14 +58,7 @@ gdb_test_multiple "catch exception" $msg {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
###################################################
# 2. Try catching conditionnal failed assertion. #
@@ -77,7 +70,7 @@ mi_gdb_load ${binfile}
# - continue, we should see the second failed assertion
# - continue, the program exits.
-if ![mi_run_to_main] then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex.exp b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
index 63c6984..103ec85 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
@@ -58,21 +58,14 @@ gdb_test_multiple "catch exception" $msg {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
####################################
# 1. Try catching all exceptions. #
####################################
with_test_prefix "scenario 1" {
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
@@ -130,7 +123,7 @@ continue_to_exception \
# - continue, the program exits.
with_test_prefix "scenario 2" {
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
index 06e4666..ef3dd24 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
@@ -57,17 +57,14 @@ gdb_test_multiple "catch handlers" $msg {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
+mi_clean_restart $binfile
#############################################
# 1. Try catching all exceptions handlers. #
#############################################
with_test_prefix "scenario 1" {
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
@@ -119,7 +116,7 @@ continue_to_exception_handler \
# but exit instead.
with_test_prefix "scenario 2" {
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_dyn_arr.exp b/gdb/testsuite/gdb.ada/mi_dyn_arr.exp
index 5c8b986..4b5d2c1 100644
--- a/gdb/testsuite/gdb.ada/mi_dyn_arr.exp
+++ b/gdb/testsuite/gdb.ada/mi_dyn_arr.exp
@@ -26,16 +26,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
-if ![mi_run_to_main] then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_exc_info.exp b/gdb/testsuite/gdb.ada/mi_exc_info.exp
index eeb8247..52c37c4 100644
--- a/gdb/testsuite/gdb.ada/mi_exc_info.exp
+++ b/gdb/testsuite/gdb.ada/mi_exc_info.exp
@@ -26,12 +26,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
+mi_clean_restart $binfile
-if ![mi_run_to_main] then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_interface.exp b/gdb/testsuite/gdb.ada/mi_interface.exp
index f948237..a2c0d045 100644
--- a/gdb/testsuite/gdb.ada/mi_interface.exp
+++ b/gdb/testsuite/gdb.ada/mi_interface.exp
@@ -26,17 +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] {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
-if ![mi_run_to_main] then {
- fail "cannot run to main, testcase aborted"
+if {[mi_runto_main] < 0} {
+ fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_prot.exp b/gdb/testsuite/gdb.ada/mi_prot.exp
index fb4ca8d..703fabd 100644
--- a/gdb/testsuite/gdb.ada/mi_prot.exp
+++ b/gdb/testsuite/gdb.ada/mi_prot.exp
@@ -30,12 +30,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
+mi_clean_restart $binfile
-if {![mi_run_to_main]} then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_ref_changeable.exp b/gdb/testsuite/gdb.ada/mi_ref_changeable.exp
index 71f26c0..86df568 100644
--- a/gdb/testsuite/gdb.ada/mi_ref_changeable.exp
+++ b/gdb/testsuite/gdb.ada/mi_ref_changeable.exp
@@ -26,16 +26,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
-if ![mi_run_to_main] then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_string_access.exp b/gdb/testsuite/gdb.ada/mi_string_access.exp
index 5e07f1e..56c8522 100644
--- a/gdb/testsuite/gdb.ada/mi_string_access.exp
+++ b/gdb/testsuite/gdb.ada/mi_string_access.exp
@@ -26,16 +26,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
-if ![mi_run_to_main] then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_var_access.exp b/gdb/testsuite/gdb.ada/mi_var_access.exp
index 14e8992..196daff 100644
--- a/gdb/testsuite/gdb.ada/mi_var_access.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_access.exp
@@ -28,15 +28,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != "" } {
return -1
}
-if {[mi_gdb_start]} {
- continue
-}
-
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
-if ![mi_run_to_main] then {
+if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_var_array.exp b/gdb/testsuite/gdb.ada/mi_var_array.exp
index 4ef213b..09b89ce 100644
--- a/gdb/testsuite/gdb.ada/mi_var_array.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_array.exp
@@ -32,16 +32,9 @@ foreach_with_prefix scenario {none all minimal} {
return -1
}
- gdb_exit
- if [mi_gdb_start] {
- continue
- }
-
- mi_delete_breakpoints
- mi_gdb_reinitialize_dir $srcdir/$subdir
- mi_gdb_load ${binfile}
+ mi_clean_restart $binfile
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_var_union.exp b/gdb/testsuite/gdb.ada/mi_var_union.exp
index f950855..da09d7a 100644
--- a/gdb/testsuite/gdb.ada/mi_var_union.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_union.exp
@@ -34,16 +34,9 @@ foreach_with_prefix scenario {none all minimal} {
return -1
}
- gdb_exit
- if [mi_gdb_start] {
- continue
- }
-
- mi_delete_breakpoints
- mi_gdb_reinitialize_dir $srcdir/$subdir
- mi_gdb_load ${binfile}
+ mi_clean_restart $binfile
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.ada/mi_variant.exp b/gdb/testsuite/gdb.ada/mi_variant.exp
index 01c6720..d7e6191 100644
--- a/gdb/testsuite/gdb.ada/mi_variant.exp
+++ b/gdb/testsuite/gdb.ada/mi_variant.exp
@@ -33,16 +33,9 @@ foreach_with_prefix scenario {none all minimal} {
return -1
}
- gdb_exit
- if [mi_gdb_start] {
- continue
- }
-
- mi_delete_breakpoints
- mi_gdb_reinitialize_dir $srcdir/$subdir
- mi_gdb_load ${binfile}
+ mi_clean_restart $binfile
- if ![mi_run_to_main] then {
+ if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}
diff --git a/gdb/testsuite/gdb.mi/gdb2549.exp b/gdb/testsuite/gdb.mi/gdb2549.exp
index cc6441c..54ef3b7 100644
--- a/gdb/testsuite/gdb.mi/gdb2549.exp
+++ b/gdb/testsuite/gdb.mi/gdb2549.exp
@@ -25,11 +25,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -103,8 +98,12 @@ proc register_tests { } {
}
}
+mi_clean_restart $binfile
+
register_tests_no_exec
-mi_run_to_main
+
+mi_runto_main
+
register_tests
mi_gdb_exit
diff --git a/gdb/testsuite/gdb.mi/gdb669.exp b/gdb/testsuite/gdb.mi/gdb669.exp
index 4eaed22..edd076e 100644
--- a/gdb/testsuite/gdb.mi/gdb669.exp
+++ b/gdb/testsuite/gdb.mi/gdb669.exp
@@ -20,11 +20,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
@@ -35,7 +30,8 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
check_mi_and_console_threads "at main"
for {set i 0} {$i < 4} {incr i} {
diff --git a/gdb/testsuite/gdb.mi/gdb701.exp b/gdb/testsuite/gdb.mi/gdb701.exp
index 3f08019..85c48f2 100644
--- a/gdb/testsuite/gdb.mi/gdb701.exp
+++ b/gdb/testsuite/gdb.mi/gdb701.exp
@@ -20,11 +20,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile
if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} {
@@ -40,7 +35,8 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} {
# If it doesn't, Bad Things Happen(TM).
# Run to main
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
# Step over "foo = 0"
mi_next "step over \"foo = 0\""
diff --git a/gdb/testsuite/gdb.mi/gdb792.exp b/gdb/testsuite/gdb.mi/gdb792.exp
index 8922703..1fec75b 100644
--- a/gdb/testsuite/gdb.mi/gdb792.exp
+++ b/gdb/testsuite/gdb.mi/gdb792.exp
@@ -13,20 +13,14 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-#
-# test gdb/792
-#
+# Test that children of classes are properly reported. Regression
+# test for gdb/792.
if { [skip_cplus_tests] } { continue }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile .cc
if [get_compiler_info "c++"] {
@@ -38,10 +32,9 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""
return -1
}
-# Test that children of classes are properly reported
+mi_clean_restart $binfile
-# Run to main
-mi_run_to_main
+mi_runto_main
mi_create_varobj "var1" "a" "create var for class A"
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index 1149bb3..3c594c8 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -272,7 +272,7 @@ proc test_breakpoint_commands {} {
"\\^done,[mi_make_breakpoint_table [list $bp_no_script]]" \
"breakpoint commands: check that commands are cleared"
- mi_run_to_main
+ mi_runto_main
mi_create_breakpoint "basics.c:callee2" \
"breakpoint commands: insert breakpoint at basics.c:callee2, again" \
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
index 5dbedd8..3f3acfd 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
@@ -46,15 +46,13 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""
proc test_insert_delete_modify { } {
global mi_gdb_prompt
global lib_sl1 lib_sl2
+ global binfile
- gdb_exit
- if [mi_gdb_start] {
- continue
- }
+ mi_clean_restart $binfile
mi_load_shlibs $lib_sl1 $lib_sl2
- mi_run_to_main
+ mi_runto_main
mi_gdb_test "break marker" \
{(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done}
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
index 60a098e..0f5d335 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
@@ -53,15 +53,12 @@ proc make_breakpoints_pattern { expect_fixed_output bp_num loc1_en loc2_en } {
proc do_test { mi_version use_fix_flag expect_fixed_output } {
with_test_prefix "mi_version=${mi_version}" {
with_test_prefix "use_fix_flag=${use_fix_flag}" {
- global MIFLAGS decimal
+ global MIFLAGS decimal binfile
set MIFLAGS "-i=mi${mi_version}"
- gdb_exit
- if {[mi_gdb_start]} {
- return
- }
+ mi_clean_restart $binfile
- mi_run_to_main
+ mi_runto_main
if $use_fix_flag {
mi_gdb_test "-fix-multi-location-breakpoint-output" "\\^done" \
diff --git a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
index 14e820f..54383f6 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
@@ -27,13 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if [mi_gdb_start] {
- continue
-}
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
-if {![mi_run_to_main]} {
+mi_clean_restart $binfile
+if {[mi_runto_main] < 0} {
return -1
}
set libstdcxx_probe_tests_supported [expr ![mi_skip_libstdcxx_probe_tests]]
diff --git a/gdb/testsuite/gdb.mi/mi-catch-load.exp b/gdb/testsuite/gdb.mi/mi-catch-load.exp
index b253807..21f3fe0 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-load.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-load.exp
@@ -18,11 +18,6 @@ if {[skip_shlib_tests]} {
return -1
}
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
if {[get_compiler_info]} {
warning "Could not get compiler info"
untested "no compiler info"
@@ -44,7 +39,9 @@ if { [gdb_compile_shlib "${srcdir}/${subdir}/${srcfile2}" ${binfile2} {debug}] !
untested "failed to compile shared library"
return -1
}
-mi_run_to_main
+
+mi_clean_restart $binfile
+mi_runto_main
# test -catch-load
mi_gdb_test "111-gdb-set auto-solib-add on" "111\\^done" "catch-load: auto-solib-add on"
@@ -66,13 +63,8 @@ gdb_expect {
}
}
-mi_gdb_exit
-
-
-if [mi_gdb_start] {
- continue
-}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
# test -catch-unload
mi_gdb_test "111-gdb-set auto-solib-add on" "111\\^done" "catch-unload: auto-solib-add on"
diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
index 214cc8a..ad06c7c 100644
--- a/gdb/testsuite/gdb.mi/mi-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-cli.exp
@@ -22,11 +22,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -34,6 +29,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
+mi_clean_restart $binfile
+
mi_gdb_test "-interpreter-exec" \
{\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
"-interpreter-exec with no arguments"
@@ -59,7 +56,7 @@ mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
{~"Reading symbols from .*mi-cli...\\n".*} \
"-interpreter-exec console \"file \$binfile\""
-mi_run_to_main
+mi_runto_main
set line_main_head [gdb_get_line_number "main ("]
set line_main_body [expr $line_main_head + 2]
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
index 2d653c0..1715c76 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
@@ -28,12 +28,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
proc test_command_param_changed { } {
global scheduler_locking_supported
+ global binfile
with_test_prefix "cmd param" {
- if [mi_gdb_start] {
- return
- }
- mi_run_to_main
+ mi_clean_restart $binfile
+ mi_runto_main
if { $scheduler_locking_supported } {
foreach opt { "on" "off" "step" } {
diff --git a/gdb/testsuite/gdb.mi/mi-complete.exp b/gdb/testsuite/gdb.mi/mi-complete.exp
index 626d72d..a1ab50d 100644
--- a/gdb/testsuite/gdb.mi/mi-complete.exp
+++ b/gdb/testsuite/gdb.mi/mi-complete.exp
@@ -19,11 +19,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile .cc
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
@@ -31,7 +26,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-mi_run_to_main
+mi_clean_restart $binfile
+
+mi_runto_main
mi_gdb_test "1-complete br" \
"1\\^done,completion=\"break\",matches=\\\[.*\"break\",.*\"break-range\".*\\\],max_completions_reached=\"0\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index e334d0b..02e70c0 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -58,7 +58,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_run_to_main
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+mi_runto_main
# The output we get from the target depends on how it is hosted. If
# we are semihosted (e.g., the sim or a remote target that supports
diff --git a/gdb/testsuite/gdb.mi/mi-detach.exp b/gdb/testsuite/gdb.mi/mi-detach.exp
index a9b8362..1027488 100644
--- a/gdb/testsuite/gdb.mi/mi-detach.exp
+++ b/gdb/testsuite/gdb.mi/mi-detach.exp
@@ -18,11 +18,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
@@ -30,6 +25,7 @@ if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
return -1
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
mi_gdb_test "-target-detach" "=thread-exited,id=\"1\".*=thread-group-exited,id=\"i1\".*" "detach"
diff --git a/gdb/testsuite/gdb.mi/mi-disassemble.exp b/gdb/testsuite/gdb.mi/mi-disassemble.exp
index d17d957..87f8c72 100644
--- a/gdb/testsuite/gdb.mi/mi-disassemble.exp
+++ b/gdb/testsuite/gdb.mi/mi-disassemble.exp
@@ -23,11 +23,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -244,7 +239,8 @@ proc test_disassembly_bogus_args {} {
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
test_disassembly_only
test_disassembly_with_opcodes
test_disassembly_mixed
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp
index ce0670f..6254787 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp
@@ -17,11 +17,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile
if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
@@ -29,12 +24,11 @@ if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
return -1
}
-mi_delete_breakpoints
-
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set dp_location1 [gdb_get_line_number "set dprintf 1 here"]
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
set i 0
mi_gdb_test "[incr i]-dprintf-insert" \
diff --git a/gdb/testsuite/gdb.mi/mi-exit-code.exp b/gdb/testsuite/gdb.mi/mi-exit-code.exp
index f10b49c..b8a133a 100644
--- a/gdb/testsuite/gdb.mi/mi-exit-code.exp
+++ b/gdb/testsuite/gdb.mi/mi-exit-code.exp
@@ -16,11 +16,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -31,6 +26,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
proc test_list_thread_groups { } {
global hex
global decimal
+ global binfile
+
+ mi_clean_restart
# Before any run, exit-code should not be present.
mi_gdb_test \
@@ -38,8 +36,10 @@ proc test_list_thread_groups { } {
"122\\^done,groups=\\\[\{id=\"i1\",type=\"process\"\}\]" \
"-list-thread-groups before run shows no exit-code"
+ mi_clean_restart $binfile
+
with_test_prefix "first run" {
- mi_run_to_main
+ mi_runto_main
# During the run, exit-code should not be present.
mi_gdb_test \
@@ -59,7 +59,7 @@ proc test_list_thread_groups { } {
}
with_test_prefix "second run" {
- mi_run_to_main
+ mi_runto_main
# Write the exit code we want in the global var
mi_gdb_test "set var exit_code = 8" ".*\\^done" "write exit code"
diff --git a/gdb/testsuite/gdb.mi/mi-fill-memory.exp b/gdb/testsuite/gdb.mi/mi-fill-memory.exp
index acc9b92..658da39 100644
--- a/gdb/testsuite/gdb.mi/mi-fill-memory.exp
+++ b/gdb/testsuite/gdb.mi/mi-fill-memory.exp
@@ -20,11 +20,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile "mi-read-memory"
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}.c" "${binfile}" executable {debug}] != "" } {
@@ -32,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}.c" "${binfile}" executable {d
return -1
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
mi_next_to "main" "" "mi-read-memory.c" "20" "next at main"
mi_gdb_test "1-data-write-memory-bytes"\
diff --git a/gdb/testsuite/gdb.mi/mi-fortran-modules.exp b/gdb/testsuite/gdb.mi/mi-fortran-modules.exp
index e7ee1b9..de5657d 100644
--- a/gdb/testsuite/gdb.mi/mi-fortran-modules.exp
+++ b/gdb/testsuite/gdb.mi/mi-fortran-modules.exp
@@ -26,12 +26,9 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
+mi_clean_restart $binfile
-mi_run_to_main
+mi_runto_main
# Patterns to skip optional system modules that appear with later versions of GFortran.
diff --git a/gdb/testsuite/gdb.mi/mi-frame-regs.exp b/gdb/testsuite/gdb.mi/mi-frame-regs.exp
index c5cec8d..420fe7a 100644
--- a/gdb/testsuite/gdb.mi/mi-frame-regs.exp
+++ b/gdb/testsuite/gdb.mi/mi-frame-regs.exp
@@ -58,17 +58,16 @@ proc breakpoint_address {bpnum} {
# breakpoints in different functions.
proc_with_prefix do_floating_varobj_test {} {
- global srcfile
+ global srcfile binfile
global hex
global expect_out
- gdb_exit
- if {[mi_gdb_start]} then {
+ if {[mi_clean_restart $binfile]} {
fail "couldn't start gdb"
return
}
- mi_run_to_main
+ mi_runto_main
# Create a floating varobj for $pc.
mi_gdb_test "-var-create --thread 1 --frame 0 - @ \$pc" \
@@ -111,16 +110,15 @@ proc_with_prefix do_floating_varobj_test {} {
# counter changes (without substantially changing the stack).
proc_with_prefix do_fixed_varobj_test {} {
- global srcfile
+ global srcfile binfile
global hex
- gdb_exit
- if {[mi_gdb_start]} then {
+ if {[mi_clean_restart $binfile] != 0} {
fail "couldn't start gdb"
return
}
- mi_run_to_main
+ mi_runto_main
# Run to the function 'callee3' so we have several frames.
mi_create_breakpoint "basics.c:callee3" \
diff --git a/gdb/testsuite/gdb.mi/mi-info-os.exp b/gdb/testsuite/gdb.mi/mi-info-os.exp
index 49b2e8e..347b01c 100644
--- a/gdb/testsuite/gdb.mi/mi-info-os.exp
+++ b/gdb/testsuite/gdb.mi/mi-info-os.exp
@@ -45,7 +45,7 @@ if {[mi_gdb_load $binfile] < 0} {
# 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
-# that and cover all targets is to run to main, with mi_run_to_main.
+# that and cover all targets is to run to main, with mi_runto_main.
# However, with native configurations, -info-os should work before
# running any program, so we want to avoid "run". Using
# mi_gdb_target_load directly instead achieves this.
diff --git a/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp b/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp
index 58f974a..0f8f59b 100644
--- a/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp
+++ b/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp
@@ -31,17 +31,14 @@ if {[prepare_for_testing "failed to prepare" $exefile $srcfile {debug c++}]} {
return -1
}
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
+mi_clean_restart $binfile
# Turn off the pending breakpoint queries.
mi_gdb_test "-interpreter-exec console \"set breakpoint pending off\"" \
{=cmd-param-changed,param=\"breakpoint pending\",.*\^done} \
"-interpreter-exec console \"set breakpoint pending off\""
-mi_run_to_main
+mi_runto_main
# Run to a location in the file.
set bp_location [gdb_get_line_number "set breakpoint here"]
diff --git a/gdb/testsuite/gdb.mi/mi-logging.exp b/gdb/testsuite/gdb.mi/mi-logging.exp
index 4540143..6da365e 100644
--- a/gdb/testsuite/gdb.mi/mi-logging.exp
+++ b/gdb/testsuite/gdb.mi/mi-logging.exp
@@ -16,11 +16,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
set opts {debug}
@@ -29,7 +24,9 @@ if [build_executable $testfile.exp $testfile $srcfile $opts] {
return -1
}
-if {[mi_run_to_main] < 0} {
+mi_clean_restart $binfile
+
+if {[mi_runto_main] < 0} {
return -1
}
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp b/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp
index ff27fa3..3e58754 100644
--- a/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp
+++ b/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp
@@ -21,11 +21,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
@@ -36,14 +31,13 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+mi_clean_restart $binfile
mi_gdb_test "-gdb-set non-stop 1" ".*"
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
@@ -53,7 +47,9 @@ mi_expect_stop "exited-normally" "" "" "" "" "" "finished exec continue"
# Run the program again.
-if { [mi_run_to_main] < 0 } {
+mi_delete_breakpoints
+
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp
index 7f98bee..bb4520e 100644
--- a/gdb/testsuite/gdb.mi/mi-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-nonstop.exp
@@ -22,15 +22,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-
-save_vars { GDBFLAGS } {
- append GDBFLAGS " -ex \"set non-stop on\""
- if {[mi_gdb_start]} {
- continue
- }
-}
-
proc mi_nonstop_resume { command test } {
if { [mi_send_resuming_command $command $test] != 0 } {
# If a resume fails, assume non-stop is broken or unsupported
@@ -50,13 +41,16 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+
+save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set non-stop on\""
+ mi_clean_restart $binfile
+}
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp b/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
index 35a6315..ebbdb41 100644
--- a/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
+++ b/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
@@ -24,11 +24,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
proc mi_nonstop_resume { command test } {
if { [mi_send_resuming_command $command $test] != 0 } {
# If a resume fails, assume non-stop is broken or unsupported
@@ -49,14 +44,13 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" \
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+mi_clean_restart $binfile
mi_gdb_test "-gdb-set non-stop 1" ".*"
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/mi-nsintrall.exp b/gdb/testsuite/gdb.mi/mi-nsintrall.exp
index c020c6a..aa0e81c 100644
--- a/gdb/testsuite/gdb.mi/mi-nsintrall.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsintrall.exp
@@ -21,11 +21,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
@@ -36,14 +31,13 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+mi_clean_restart $binfile
mi_gdb_test "-gdb-set non-stop 1" ".*"
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
index d311e1f..3e99b5f 100644
--- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
@@ -21,11 +21,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
@@ -36,14 +31,13 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+mi_clean_restart $binfile
mi_gdb_test "-gdb-set non-stop 1" ".*"
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
index 27101ca..6f4800a 100644
--- a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
@@ -26,11 +26,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
@@ -41,14 +36,13 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+mi_clean_restart $binfile
mi_gdb_test "-gdb-set non-stop 1" ".*"
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/mi-read-memory.exp b/gdb/testsuite/gdb.mi/mi-read-memory.exp
index a9b8dbc..7c1047e 100644
--- a/gdb/testsuite/gdb.mi/mi-read-memory.exp
+++ b/gdb/testsuite/gdb.mi/mi-read-memory.exp
@@ -18,11 +18,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile
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_clean_restart $binfile
+mi_runto_main
-mi_run_to_main
mi_next_to "main" "" "mi-read-memory.c" "20" "next at main"
mi_gdb_test "1-data-read-memory" \
diff --git a/gdb/testsuite/gdb.mi/mi-record-changed.exp b/gdb/testsuite/gdb.mi/mi-record-changed.exp
index bef48d6..bed77c8 100644
--- a/gdb/testsuite/gdb.mi/mi-record-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-record-changed.exp
@@ -26,10 +26,9 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
load_lib mi-support.exp
-if [mi_gdb_start] {
- return
-}
-mi_run_to_main
+mi_clean_restart $binfile
+
+mi_runto_main
mi_gdb_test "record" ".*=record-started,thread-group=\"i${decimal}\",method=\"full\".*\\^done" \
"record"
diff --git a/gdb/testsuite/gdb.mi/mi-regs.exp b/gdb/testsuite/gdb.mi/mi-regs.exp
index 81ff8ac..13ab59c 100644
--- a/gdb/testsuite/gdb.mi/mi-regs.exp
+++ b/gdb/testsuite/gdb.mi/mi-regs.exp
@@ -25,11 +25,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -110,8 +105,10 @@ proc sparc_register_tests { } {
}
if [istarget "sparc-*-*"] then {
+ mi_clean_restart
sparc_register_tests_no_exec
- mi_run_to_main
+ mi_clean_restart $binfile
+ mi_runto_main
sparc_register_tests
} else {
verbose "mi-regs.exp tests ignored for this target"
diff --git a/gdb/testsuite/gdb.mi/mi-reverse.exp b/gdb/testsuite/gdb.mi/mi-reverse.exp
index 091173e..f92450e 100644
--- a/gdb/testsuite/gdb.mi/mi-reverse.exp
+++ b/gdb/testsuite/gdb.mi/mi-reverse.exp
@@ -34,11 +34,6 @@ if ![supports_reverse] {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -46,7 +41,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
if [supports_process_record] {
# Activate process record/replay
diff --git a/gdb/testsuite/gdb.mi/mi-stepi.exp b/gdb/testsuite/gdb.mi/mi-stepi.exp
index a1efdf7..1f3e559 100644
--- a/gdb/testsuite/gdb.mi/mi-stepi.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepi.exp
@@ -23,11 +23,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -68,7 +63,8 @@ proc test_stepi_nexti {} {
}
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
test_stepi_nexti
mi_gdb_exit
diff --git a/gdb/testsuite/gdb.mi/mi-stepn.exp b/gdb/testsuite/gdb.mi/mi-stepn.exp
index 4725da1..9a0a68d 100644
--- a/gdb/testsuite/gdb.mi/mi-stepn.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepn.exp
@@ -19,11 +19,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile
set opts {debug}
@@ -31,7 +26,9 @@ if [build_executable ${testfile}.exp ${testfile} ${srcfile} $opts] {
return -1
}
-if {[mi_run_to_main] < 0} {
+mi_clean_restart $binfile
+
+if {[mi_runto_main] < 0} {
return -1
}
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info.exp b/gdb/testsuite/gdb.mi/mi-sym-info.exp
index 859dabd..207f892 100644
--- a/gdb/testsuite/gdb.mi/mi-sym-info.exp
+++ b/gdb/testsuite/gdb.mi/mi-sym-info.exp
@@ -33,12 +33,9 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
+mi_clean_restart $binfile
-mi_run_to_main
+mi_runto_main
set qstr "\"\[^\"\]+\""
set fun_re "\{line=\"$decimal\",name=${qstr},type=${qstr},description=${qstr}\}"
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
index 48e872a..4207f31 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.exp
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -32,9 +32,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_gdb_exit
-mi_gdb_start
-mi_run_to_main
+mi_clean_restart $binfile
+
+mi_runto_main
mi_create_breakpoint "foo" \
"insert breakpoint foo" \
diff --git a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
index a64529a..3ad3b5c 100644
--- a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
@@ -16,11 +16,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile .c
set opts {debug}
@@ -28,11 +23,9 @@ if [build_executable $testfile.exp $testfile $srcfile $opts] {
return -1
}
-mi_delete_breakpoints
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load ${binfile}
+mi_clean_restart $binfile
-if ![mi_run_to_main] {
+if {[mi_runto_main] < 0} {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp b/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
index fc2872d..6b56f38 100644
--- a/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
@@ -25,11 +25,6 @@ if { ![support_displaced_stepping] } {
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
proc mi_nonstop_resume { command test } {
if { [mi_send_resuming_command $command $test] != 0 } {
# If a resume fails, assume non-stop is broken or unsupported
@@ -48,14 +43,13 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" }
return -1
}
-mi_gdb_reinitialize_dir $srcdir/$subdir
-mi_gdb_load $binfile
+mi_clean_restart $binfile
mi_gdb_test "-gdb-set non-stop 1" ".*"
mi_gdb_test "-gdb-set mi-async 1" ".*"
mi_detect_async
-if { [mi_run_to_main] < 0 } {
+if { [mi_runto_main] < 0 } {
continue
}
diff --git a/gdb/testsuite/gdb.mi/pr11022.exp b/gdb/testsuite/gdb.mi/pr11022.exp
index ffd3687..850261b 100644
--- a/gdb/testsuite/gdb.mi/pr11022.exp
+++ b/gdb/testsuite/gdb.mi/pr11022.exp
@@ -29,12 +29,10 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
proc test_memory_changed_observer { mi_command } {
with_test_prefix "${mi_command}" {
- global srcfile
+ global srcfile binfile
- if [mi_gdb_start] {
- return
- }
- mi_run_to_main
+ mi_clean_restart $binfile
+ mi_runto_main
set line_number [gdb_get_line_number "break here"]
mi_gdb_test "-break-insert ${srcfile}:${line_number}" \
diff --git a/gdb/testsuite/gdb.python/py-mi-events.exp b/gdb/testsuite/gdb.python/py-mi-events.exp
index 9f2d7dc..f76a471 100644
--- a/gdb/testsuite/gdb.python/py-mi-events.exp
+++ b/gdb/testsuite/gdb.python/py-mi-events.exp
@@ -49,7 +49,8 @@ if [is_remote host] {
}
mi_gdb_test "-file-exec-and-symbols ${filename}" ".*\\^done" "file-exec-and-symbols operation"
-mi_run_to_main
+mi_gdb_load ${binfile}
+mi_runto_main
# register the python event handlers with test-events command
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
index 9b82355..2e611c7 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
@@ -18,11 +18,6 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
@@ -32,6 +27,8 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" }
return -1
}
+mi_clean_restart $binfile
+
# Skip all tests if Python scripting is not enabled.
if { [mi_skip_python_tests] } { continue }
@@ -48,9 +45,7 @@ mi_gdb_test "set python print-stack full" \
".*\\^done" \
"set python print-stack full"
-
-mi_run_to_main
-
+mi_runto_main
mi_continue_to_line [gdb_get_line_number "next line" ${srcfile}] \
"step to breakpoint"
diff --git a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
index 969fe27..4c7c103 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
@@ -41,10 +41,8 @@ gdb_exit
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-if [mi_gdb_start] {
- return
-}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
mi_gdb_test "-break-insert end" \
"\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \
diff --git a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
index 77923a5..4abb92b 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
@@ -36,10 +36,8 @@ gdb_exit
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-if [mi_gdb_start] {
- return
-}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
mi_gdb_test "-break-insert marker" \
"\\^done,bkpt=\{number=\"${decimal}\",type=\"breakpoint\".*\"\}" \
diff --git a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
index f0be9a8..a4c7cf6 100644
--- a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
@@ -49,10 +49,7 @@ proc test_tfind_tfile { } {
global decimal
global tfile_basic
- if [mi_gdb_start] {
- return
- }
- mi_gdb_load ${binfile}
+ mi_clean_restart $binfile
mi_gdb_test "-target-select tfile ${tfile_basic}" \
".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \
@@ -124,11 +121,10 @@ gdb_exit
proc test_tfind_remote { } {
with_test_prefix "remote" {
global decimal
+ global binfile
- if [mi_gdb_start] {
- return
- }
- mi_run_to_main
+ mi_clean_restart $binfile
+ mi_runto_main
mi_gdb_test "-break-insert end" "\\^done.*" "break end"
mi_gdb_test "-break-insert -a func2" "\\^done.*" "break func2"
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 693c7d2..0de3aa8 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1023,28 +1023,41 @@ proc mi_run_with_cli {args} {
return [eval mi_run_cmd_full 0 $args]
}
-#
-# Just like run-to-main but works with the MI interface
-#
-
-proc mi_run_to_main { } {
- global suppress_flag
- if { $suppress_flag } {
- return -1
- }
+# Starts fresh GDB binary and loads an optional executable into GDB.
+# 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 } {
global srcdir
global subdir
- global binfile
- global srcfile
+ 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.
+ set errcnt 0
+ set warncnt 0
+
+ if {[mi_gdb_start]} {
+ return -1
+ }
- mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
- mi_gdb_load ${binfile}
- mi_runto_main
-}
+ if { [llength $args] >= 1 } {
+ set executable [lindex $args 0]
+ set binfile [standard_output_file ${executable}]
+ return [mi_gdb_load ${binfile}]
+ }
+ return 0
+}
# Just like gdb's "runto" proc, it will run the target to a given
# function. The big difference here between mi_runto and mi_execute_to