From: Pedro Alves Date: Sun, 11 Oct 2020 20:58:31 +0000 (+0100) Subject: Eliminate mi_run_to_main, introduce mi_clean_restart X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b75d55d4d2;p=binutils-gdb.git Eliminate mi_run_to_main, introduce mi_clean_restart 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 --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a6b16a094f8..4261e4a7204 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-10-13 Pedro Alves + + * lib/mi-support.exp (mi_clean_restart): New. + (mi_run_to_main): Delete. + All callers adjust to use mi_clean_restart / mi_runto_main. + 2020-10-13 Pedro Alves * config/monitor.exp: Use "list -q". diff --git a/gdb/testsuite/gdb.ada/mi_catch_assert.exp b/gdb/testsuite/gdb.ada/mi_catch_assert.exp index 30543e56008..095815d1829 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 63c6984bc66..103ec85f862 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 06e466672ea..ef3dd249790 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 5c8b986e455..4b5d2c10d58 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 eeb8247a3bf..52c37c45348 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 f948237558d..a2c0d0453e4 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 fb4ca8d7ffb..703fabdacdc 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 71f26c02dee..86df5680dda 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 5e07f1ebcc0..56c8522e196 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 14e899221e3..196daff904e 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 4ef213b7a6e..09b89ce4e46 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 f950855d871..da09d7abedb 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 01c67200581..d7e619191ae 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 cc6441c8ec0..54ef3b71435 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 4eaed22191c..edd076ec3a5 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 3f0801986c4..85c48f2ea7c 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 89227036251..1fec75b0b93 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 . -# -# 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 1149bb34c8d..3c594c8de4f 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 5dbedd8302f..3f3acfd9967 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 60a098e6013..0f5d33599a9 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 14e820fa350..54383f66d65 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 b2538070316..21f3fe03db6 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 214cc8a479e..ad06c7c05da 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 2d653c0e801..1715c764d24 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 626d72d60e1..a1ab50d3d9c 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 e334d0bf0f3..02e70c01f80 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 a9b8362659b..1027488eeb4 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 d17d957ee22..87f8c72251c 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 ce0670fea29..6254787f212 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 f10b49cee0f..b8a133a19c0 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 acc9b92e398..658da39bce3 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 e7ee1b96e46..de5657d2823 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 c5cec8d6c29..420fe7a878d 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 49b2e8e2e01..347b01c10fe 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 58f974a54dd..0f8f59b5a41 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 45401432ee5..6da365ef68e 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 ff27fa33160..3e58754c9a4 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 7f98bee4096..bb4520e9337 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 35a6315470e..ebbdb4186a4 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 c020c6ac1b7..aa0e81c84ca 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 d311e1fe89b..3e99b5f0c6f 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 27101cae22c..6f4800aa912 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 a9b8dbce62a..7c1047eeea0 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 bef48d602d4..bed77c89d15 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 81ff8acfde0..13ab59c1357 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 091173ea829..f92450eb2d6 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 a1efdf78e2d..1f3e5593a06 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 4725da15e43..9a0a68d5c00 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 152a186e02c..f12b758c2f6 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 48e872ab669..4207f31647a 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 a64529a86e3..3ad3b5c6829 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 fc2872d705d..6b56f384239 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 ffd36874246..850261b83e1 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 9f2d7dc13c6..f76a4719e4e 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 9b82355d14e..2e611c7d964 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 969fe2755c6..4c7c103605c 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 77923a510c2..4abb92be107 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 f0be9a8b4f4..a4c7cf6f6b7 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 ea59288443e..3dea699a0b2 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