+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".
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. #
# - 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
}
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
}
# - 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
}
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
}
# 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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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
}
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}] != "" } {
}
}
+mi_clean_restart $binfile
+
register_tests_no_exec
-mi_run_to_main
+
+mi_runto_main
+
register_tests
mi_gdb_exit
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
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} {
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] != ""} {
# 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\""
# 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++"] {
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"
"\\^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" \
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}
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" \
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]]
return -1
}
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
if {[get_compiler_info]} {
warning "Could not get compiler info"
untested "no compiler info"
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"
}
}
-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"
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}] != "" } {
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"
{~"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]
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" } {
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++}] != "" } {
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\"" \
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
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} {
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"
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}] != "" } {
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
test_disassembly_only
test_disassembly_with_opcodes
test_disassembly_mixed
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} {
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" \
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}] != "" } {
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 \
"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 \
}
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"
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}] != "" } {
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"\
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.
# 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" \
# 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" \
# 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.
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"]
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile basics.c
set opts {debug}
return -1
}
-if {[mi_run_to_main] < 0} {
+mi_clean_restart $binfile
+
+if {[mi_runto_main] < 0} {
return -1
}
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
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
}
# Run the program again.
-if { [mi_run_to_main] < 0 } {
+mi_delete_breakpoints
+
+if { [mi_runto_main] < 0 } {
continue
}
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
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
}
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
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
}
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
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
}
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
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
}
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
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
}
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}] != "" } {
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" \
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"
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}] != "" } {
}
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"
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}] != "" } {
return -1
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
if [supports_process_record] {
# Activate process record/replay
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}] != "" } {
}
}
-mi_run_to_main
+mi_clean_restart $binfile
+mi_runto_main
test_stepi_nexti
mi_gdb_exit
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile
set opts {debug}
return -1
}
-if {[mi_run_to_main] < 0} {
+mi_clean_restart $binfile
+
+if {[mi_runto_main] < 0} {
return -1
}
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}\}"
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" \
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if [mi_gdb_start] {
- continue
-}
-
standard_testfile .c
set opts {debug}
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
}
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
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
}
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}" \
}
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
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-gdb_exit
-if {[mi_gdb_start]} {
- continue
-}
-
#
# Start here
#
return -1
}
+mi_clean_restart $binfile
+
# Skip all tests if Python scripting is not enabled.
if { [mi_skip_python_tests] } { continue }
".*\\^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"
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\".*\"\}" \
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\".*\"\}" \
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" \
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"
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