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
This commit is contained in:
Pedro Alves 2020-10-11 21:58:31 +01:00
parent e777225bfd
commit b75d55d4d2
60 changed files with 190 additions and 400 deletions

View file

@ -1,3 +1,9 @@
2020-10-13 Pedro Alves <pedro@palves.net>
* 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 <pedro@palves.net>
* config/monitor.exp: Use "list -q".

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -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
}

View file

@ -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_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${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
}

View file

@ -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
}

View file

@ -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_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -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_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -28,15 +28,9 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != "" } {
return -1
}
if {[mi_gdb_start]} {
continue
}
mi_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -32,16 +32,9 @@ foreach_with_prefix scenario {none all minimal} {
return -1
}
gdb_exit
if [mi_gdb_start] {
continue
}
mi_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -34,16 +34,9 @@ foreach_with_prefix scenario {none all minimal} {
return -1
}
gdb_exit
if [mi_gdb_start] {
continue
}
mi_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -33,16 +33,9 @@ foreach_with_prefix scenario {none all minimal} {
return -1
}
gdb_exit
if [mi_gdb_start] {
continue
}
mi_clean_restart $binfile
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
if ![mi_run_to_main] then {
if {[mi_runto_main] < 0} {
fail "cannot run to main, testcase aborted"
return 0
}

View file

@ -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

View file

@ -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} {

View file

@ -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\""

View file

@ -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"

View file

@ -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" \

View file

@ -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}

View file

@ -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" \

View file

@ -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]]

View file

@ -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"

View file

@ -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]

View file

@ -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" } {

View file

@ -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\"" \

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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" \

View file

@ -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"

View file

@ -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"\

View file

@ -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.

View file

@ -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" \

View file

@ -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.

View file

@ -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"]

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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" \

View file

@ -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"

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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}\}"

View file

@ -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" \

View file

@ -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
}

View file

@ -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
}

View file

@ -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}" \

View file

@ -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

View file

@ -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"

View file

@ -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\".*\"\}" \

View file

@ -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\".*\"\}" \

View file

@ -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"

View file

@ -1023,29 +1023,42 @@ 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
#
# 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_run_to_main { } {
global suppress_flag
if { $suppress_flag } {
proc mi_clean_restart { args } {
global srcdir
global subdir
global errcnt
global warncnt
if { [llength $args] > 1 } {
error "bad number of args: [llength $args]"
}
gdb_exit
# This is a clean restart, so reset error and warning count.
set errcnt 0
set warncnt 0
if {[mi_gdb_start]} {
return -1
}
global srcdir
global subdir
global binfile
global srcfile
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
# is that mi_execute_to must have the inferior running already. This