diff options
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r-- | gdb/testsuite/lib/mi-support.exp | 81 |
1 files changed, 51 insertions, 30 deletions
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 70d8a1eaf38..770ee3887e1 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -621,47 +621,68 @@ proc mi_run_to_main { } { return -1 } - global mi_gdb_prompt - global hex - global decimal global srcdir global subdir global binfile global srcfile - global MIFLAGS - set test "mi run-to-main" mi_delete_breakpoints mi_gdb_reinitialize_dir $srcdir/$subdir mi_gdb_load ${binfile} - set version 2 - scan $MIFLAGS "\-i=mi%d" version - if {$version < 2} { - # MI0 or MI1 - set bp_result "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"main\",file=\".*\",line=\"\[0-9\]*\",times=\"0\"\}" - } else { - # MI2+ - set bp_result "=breakpoint-create,number=\"\[0-9\]\"\r\n200\\^done" - } - mi_gdb_test "200-break-insert main" \ - $bp_result \ - "breakpoint at main" + mi_runto main +} - mi_run_cmd - gdb_expect { - -re ".*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"\[0-9\]+\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"main\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",line=\"\[0-9\]*\"\}\r\n$mi_gdb_prompt$" { - pass "$test" - return 0 - } - -re ".*$mi_gdb_prompt$" { - fail "$test (2)" - } - timeout { - fail "$test (timeout)" - return -1 - } +# Just like gdb's "runto" proc, it will run the target to a given +# function. +# FUNC is the linespec of the place to stop (it inserts a breakpoint here). +# It returns: +# -1 if test suppressed, failed, timedout +# 0 if test passed + +proc mi_runto {func} { + global suppress_flag + if { $suppress_flag } { + return -1 + } + + global mi_gdb_prompt expect_out + global hex decimal + global MIFLAGS + + set test "mi runto $func" + set version 2 + scan $MIFLAGS "\-i=mi%d" version + if {$version < 2} { + # MI0 or MI1 + set bp_result "200\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"$func\",file=\".*\",line=\"\[0-9\]*\",times=\"0\"\}" + } else { + # MI2+ + set bp_result "=breakpoint-create,number=\"\[0-9\]\"\r\n200\\^done" + } + mi_gdb_test "200-break-insert $func" \ + $bp_result \ + "breakpoint at $func" + + if {![regexp {number="[0-9]+"} $expect_out(buffer) str] + || ![scan $str {number="%d"} bkptno]} { + set bkptno {[0-9]+} + } + + mi_run_cmd + gdb_expect { + -re ".*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"$bkptno\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",line=\"\[0-9\]*\"\}\r\n$mi_gdb_prompt$" { + pass "$test" + return 0 } + -re ".*$mi_gdb_prompt$" { + fail "$test (2)" + } + timeout { + fail "$test (timeout)" + return -1 + } + } } |