aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog31
-rw-r--r--gdb/testsuite/gdb.mi/mi-cli.exp44
-rw-r--r--gdb/testsuite/gdb.mi/mi-console.exp7
-rw-r--r--gdb/testsuite/gdb.mi/mi-pending.exp5
-rw-r--r--gdb/testsuite/gdb.mi/mi-simplerun.exp30
-rw-r--r--gdb/testsuite/gdb.mi/mi-stack.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepi.exp61
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-until.exp65
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-display.exp41
-rw-r--r--gdb/testsuite/gdb.mi/mi-watch.exp36
-rw-r--r--gdb/testsuite/gdb.mi/mi2-cli.exp44
-rw-r--r--gdb/testsuite/gdb.mi/mi2-console.exp14
-rw-r--r--gdb/testsuite/gdb.mi/mi2-simplerun.exp30
-rw-r--r--gdb/testsuite/gdb.mi/mi2-stack.exp9
-rw-r--r--gdb/testsuite/gdb.mi/mi2-stepi.exp61
-rw-r--r--gdb/testsuite/gdb.mi/mi2-until.exp65
-rw-r--r--gdb/testsuite/gdb.mi/mi2-var-display.exp41
-rw-r--r--gdb/testsuite/gdb.mi/mi2-watch.exp36
-rw-r--r--gdb/testsuite/lib/mi-support.exp142
20 files changed, 243 insertions, 530 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 570e0cb..eac9ba9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,34 @@
+2008-04-05 Vladimir Prus <vladimir@codesourcery.com>
+
+ * lib/mi-support.exp (mi_expect_stop): New.
+ (mi_run_cmd): Change the
+ token. Use mi_send_resuming_command, use
+ mi_expect_stop.
+ (mi_execute_to_helper): Rename to mi_execute_to.
+ (mi_send_resuming_command): Add more error patterns.
+ (mi_wait_for_stop): Renamed to...
+ (mi_get_stop_line): ...this.
+ (mi_run_inline_test): Adjust.
+
+ * gdb.mi/mi-cli.exp: Use mi_execute_to/mi_expect_stop.
+ * gdb.mi/mi-console.exp: Likewise.
+ * gdb.mi/mi-pending.exp: Likewise.
+ * gdb.mi/mi-simplerun.exp: Likewise.
+ * gdb.mi/mi-stack.exp: Likewise.
+ * gdb.mi/mi-stepi.exp: Likewise.
+ * gdb.mi/mi-syn-frame.exp: Add comment.
+ * gdb.mi/mi-until.exp: Likewise.
+ * gdb.mi/mi-var-display.exp: Likewise.
+ * gdb.mi/mi-watch.exp: Likewise.
+ * gdb.mi/mi2-cli.exp: Likewise.
+ * gdb.mi/mi2-console.exp: Likewise.
+ * gdb.mi/mi2-simplerun.exp: Likewise.
+ * gdb.mi/mi2-stack.exp: Likewise.
+ * gdb.mi/mi2-stepi.exp: Likewise.
+ * gdb.mi/mi2-until.exp: Likewise.
+ * gdb.mi/mi2-var-display.exp: Likewise.
+ * gdb.mi/mi2-watch.exp: Likewise.
+
2008-04-04 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* gdb.base/watch_thread_num.exp: Use gdb_compile_pthreads.
diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
index ef674b0..add3fa3 100644
--- a/gdb/testsuite/gdb.mi/mi-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-cli.exp
@@ -96,19 +96,8 @@ mi_gdb_test "-interpreter-exec console \"list\"" \
".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
"-interpreter-exec console \"list\""
-# # NOTE: cagney/2003-02-03: Not yet.
-# mi_gdb_test "-exec-continue" \
-# {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="8"\}} \
-# "-interpreter-exec console \"continue to callee4\""
-send_gdb "999-exec-continue\n"
-gdb_expect {
- -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
- pass "continue to callee4"
- }
- timeout {
- fail "continue to callee4 (timeout)"
- }
-}
+mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "27" "" \
+ "continue to callee4"
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
@@ -158,32 +147,11 @@ mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
{600\^done,bkpt=.number="3",type="breakpoint".*\}} \
"-break-insert -t basics.c:\$line_main_hello"
-# mi_gdb_test "-exec-continue" \
-# {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \
-# "-exec-continue to line \$line_main_hello"
-send_gdb "700-exec-continue\n"
-gdb_expect {
- -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" {
- pass "-exec-continue to line \$line_main_hello"
- }
- timeout {
- fail "-exec-continue to line \$line_main_hello"
- }
-}
+mi_execute_to "exec-continue" "" "main" "" ".*basics.c" $line_main_hello "" \
+ "-exec-continue to line $line_main_hello"
-# NOTE: cagney/2003-02-03: Not yet.
-# mi_gdb_test "-exec-next" \
-# {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \
-# "-exec-next to line \$line_main_return"
-send_gdb "800-exec-next\n"
-gdb_expect {
- -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_return.*$mi_gdb_prompt$" {
- pass "-exec-next to line \$line_main_return"
- }
- timeout {
- fail "-exec-next to line \$line_main_return"
- }
-}
+mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \
+ "-exec-next to line $line_main_return"
mi_gdb_test "-interpreter-exec console \"list\"" \
"\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index 32bde2d..7d093dc 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -51,12 +51,13 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
mi_run_to_main
# Next over the hello() call which will produce lots of output
-mi_gdb_test "47-exec-next" \
- "47\\^running" \
+mi_gdb_test "220-exec-next" \
+ "220\\^running" \
"Testing console output" \
"Hello \\\\\"!\[\r\n\]+"
-mi_gdb_test "" "47\\*stopped.*" "Finished step over hello"
+mi_expect_stop "end-stepping-range" "main" "" ".*mi-console.c" "14" "" \
+ "finished step over hello"
mi_gdb_exit
return 0
diff --git a/gdb/testsuite/gdb.mi/mi-pending.exp b/gdb/testsuite/gdb.mi/mi-pending.exp
index 51c7f16..01fd934 100644
--- a/gdb/testsuite/gdb.mi/mi-pending.exp
+++ b/gdb/testsuite/gdb.mi/mi-pending.exp
@@ -68,8 +68,5 @@ mi_gdb_test "-break-insert -f pendfunc1" \
"MI pending breakpoint on pendfunc1"
mi_run_cmd
-
-# Make sure we hit breakpoint.
-mi_gdb_test "" \
- ".*\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\".*func=\"pendfunc1\".*" \
+mi_expect_stop "breakpoint-hit" "pendfunc1" ".*" ".*" ".*" "" \
"Run till MI pending breakpoint on pendfunc1" \ No newline at end of file
diff --git a/gdb/testsuite/gdb.mi/mi-simplerun.exp b/gdb/testsuite/gdb.mi/mi-simplerun.exp
index 535ed49..c4e550f 100644
--- a/gdb/testsuite/gdb.mi/mi-simplerun.exp
+++ b/gdb/testsuite/gdb.mi/mi-simplerun.exp
@@ -113,17 +113,7 @@ proc test_running_the_program {} {
# two prompts involved and this can lead to a race condition.
# The following is equivalent to a send_gdb "000-exec-run\n"
mi_run_cmd
- gdb_expect {
- -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"$line_main_body\"\}\r\n$mi_gdb_prompt$" {
- pass "run to main"
- }
- -re ".*$mi_gdb_prompt$" {
- fail "run to main (2)"
- }
- timeout {
- fail "run to main (timeout)"
- }
- }
+ mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" "$line_main_body" "" "run to main"
}
proc test_controlled_execution {} {
@@ -191,23 +181,7 @@ proc test_program_termination {} {
# -exec-abort
# (normal termination of inferior)
- # FIXME: "stopped" doesn't seem appropriate.
- # mi_gdb_test cannot be used for asynchronous commands because there are
- # two prompts involved and this can lead to a race condition.
- send_gdb "999-exec-continue\n"
- gdb_expect {
- -re "999\\^running\r\n$mi_gdb_prompt" {
- gdb_expect {
- -re "999\\*stopped,reason=\"exited-normally\"\r\n$mi_gdb_prompt$" {
- pass "continue to end"
- }
- -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
- timeout {fail "continue to end (timeout 2)"}
- }
- }
- -re ".*$mi_gdb_prompt$" {fail "continue to end (1)"}
- timeout {fail "continue to end (timeout 1)"}
- }
+ mi_execute_to "exec-continue" "exited-normally" "" "" "" "" "" "continue to end"
}
test_breakpoints_creation_and_listing
diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp
index 14771fa..297d20f 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi-stack.exp
@@ -173,13 +173,8 @@ proc test_stack_locals_listing {} {
set line_callee4_return_0 [gdb_get_line_number "return 0;"]
# step until A, B, C, D have some reasonable values.
-send_gdb "-exec-next 4\n"
-gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
- pass "next's in callee4"
- }
- timeout { fail "next in callee4 (timeout)" }
-}
+mi_execute_to "exec-next 4" "end-stepping-range" "callee4" "" ".*${srcfile}" $line_callee4_return_0 ""\
+ "next's in callee4"
mi_gdb_test "232-stack-list-locals 1" \
"232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\},\{name=\"D\",value=\"\\{0, 1, 2\\}\"\}\\\]" \
diff --git a/gdb/testsuite/gdb.mi/mi-stepi.exp b/gdb/testsuite/gdb.mi/mi-stepi.exp
index 391cd75..7711a70 100644
--- a/gdb/testsuite/gdb.mi/mi-stepi.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepi.exp
@@ -47,47 +47,28 @@ proc test_stepi_nexti {} {
set line_main_body [expr $line_main_head + 2]
set line_main_hello [gdb_get_line_number "Hello, World!"]
- send_gdb "111-exec-step-instruction\n"
- gdb_expect {
- -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" {
- set line $expect_out(2,string)
- if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "step-instruction at main"
- } else {
- fail "step-instruction at main"
- }
- }
- timeout {
- fail "step-instruction at main (timeout)"
- }
- }
- send_gdb "222-exec-next-instruction\n"
- gdb_expect {
- -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" {
- set line $expect_out(2,string)
- if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "next-instruction at main"
- } else {
- fail "next-instruction at main"
- }
- }
- timeout {
- fail "next-instruction at main (timeout)"
- }
+ set line [mi_execute_to "exec-step-instruction" "end-stepping-range" "main" "" \
+ ".*basics.c" "\[0-9\]+" "" "step-instruction at main"]
+ if { $line >= $line_main_body && $line <= $line_main_hello } {
+ pass "step-instruction at main (line check)"
+ } else {
+ fail "step-instruction at main (line check)"
+ }
+
+ set line [mi_execute_to "exec-next-instruction" "end-stepping-range" "main" "" \
+ ".*basics.c" "\[0-9\]+" "" "next-instruction at main"]
+ if { $line >= $line_main_body && $line <= $line_main_hello } {
+ pass "next-instruction at main (line check)"
+ } else {
+ fail "next-instruction at main (line check)"
}
- send_gdb "333-exec-next-instruction\n"
- gdb_expect {
- -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" {
- set line $expect_out(2,string)
- if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "next-instruction at main"
- } else {
- fail "next-instruction at main"
- }
- }
- timeout {
- fail "next-instruction at main (timeout)"
- }
+
+ set line [mi_execute_to "exec-next-instruction" "end-stepping-range" "main" "" \
+ ".*basics.c" "\[0-9\]+" "" "next-instruction at main 2"]
+ if { $line >= $line_main_body && $line <= $line_main_hello } {
+ pass "next-instruction at main 2 (line check)"
+ } else {
+ fail "next-instruction at main 2 (line check)"
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
index f117c15..aa68cea 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.exp
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -60,6 +60,8 @@ mi_gdb_test "403-exec-continue" \
"403\\^running" \
"testing exec continue"
+# Presently, the *stopped notification for this case does not include
+# any information. This can be considered a bug.
mi_gdb_test "" "403\\*stopped" "finished exec continue"
mi_gdb_test "404-stack-list-frames 0 0" \
diff --git a/gdb/testsuite/gdb.mi/mi-until.exp b/gdb/testsuite/gdb.mi/mi-until.exp
index 3c2cb9c..1ea9acb 100644
--- a/gdb/testsuite/gdb.mi/mi-until.exp
+++ b/gdb/testsuite/gdb.mi/mi-until.exp
@@ -55,18 +55,7 @@ proc test_running_to_foo {} {
"break-insert operation"
mi_run_cmd
-
- gdb_expect {
- -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"10\"\}\r\n$mi_gdb_prompt$" {
- pass "run to main"
- }
- -re ".*$mi_gdb_prompt$" {
- fail "run to main (2)"
- }
- timeout {
- fail "run to main (timeout)"
- }
- }
+ mi_expect_stop "breakpoint-hit" "foo" "" ".*until.c" 10 "" "run to main"
mi_gdb_test "100-break-delete 1" "100\\^done" "break-delete 1"
@@ -76,51 +65,19 @@ proc test_until {} {
global mi_gdb_prompt
global hex fullname_syntax srcfile
- send_gdb "111-exec-until\n"
- gdb_expect {
- -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"12\"\}\r\n$mi_gdb_prompt$" {
- pass "until after while loop"
- }
- -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"9\"\}\r\n$mi_gdb_prompt$" {
- kfail gdb/2104 "until after while loop (went backwards)"
- }
- timeout {
- fail "until after while loop (timeout)"
- }
- }
-
- send_gdb "222-exec-until 15\n"
- gdb_expect {
- -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"15\"\}\r\n$mi_gdb_prompt$" {
- pass "until line number"
- }
- timeout {
- fail "until line number (timeout)"
- }
- }
-
- send_gdb "333-exec-until until.c:17\n"
- gdb_expect {
- -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"17\"\}\r\n$mi_gdb_prompt$" {
- pass "until line number:file"
- }
- timeout {
- fail "until line number:file (timeout)"
- }
- }
+ setup_kfail gdb/2104 "*-*-*"
+ mi_execute_to "exec-until" "end-stepping-range" "foo" "" ".*until.c" "12" "" \
+ "until after while loop"
- # This is supposed to NOT stop at line 25. It stops right after foo is over.
+ mi_execute_to "exec-until 15" "location-reached" "foo" "" ".*until.c" "15" ""\
+ "until line number"
- send_gdb "444-exec-until until.c:25\n"
- gdb_expect {
- -re "444\\^running\r\n${mi_gdb_prompt}444\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(23|24)\"\}\r\n$mi_gdb_prompt$" {
- pass "until after current function"
- }
- timeout {
- fail "until after current function (timeout)"
- }
- }
+ mi_execute_to "exec-until until.c:17" "location-reached" "foo" "" ".*until.c" "17" ""\
+ "until line number:file"
+ # This is supposed to NOT stop at line 25. It stops right after foo is over.
+ mi_execute_to "exec-until until.c:25" "location-reached" "main" "" ".*until.c" "(23|24)" ""\
+ "until after current function"
}
test_running_to_foo
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index 2251e42..b6742de 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -47,14 +47,7 @@ mi_gdb_test "200-break-insert $srcfile:$line_dct_end" \
"break-insert operation"
mi_run_cmd
-# The running part has been checked already by mi_run_cmd
-gdb_expect {
- -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dct_end\"\}\r\n$mi_gdb_prompt$" {
- pass "run to do_children_tests"
- }
- -re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"}
- timeout {fail "run to do_children_tests (timeout 2)"}
-}
+mi_expect_stop "breakpoint-hit" "do_children_tests" "" ".*var-cmd.c" $line_dct_end "" "run to main"
##### #####
# #
@@ -337,15 +330,8 @@ mi_gdb_test "200-break-insert $line_dst_incr_a_2" \
"200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"$line_dst_incr_a_2\",times=\"0\"\}" \
"break-insert operation"
-send_gdb "-exec-continue\n"
-gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_special_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dst_incr_a_2\"\}\r\n$mi_gdb_prompt$" {
- pass "continue to do_special_tests"
- }
- timeout {
- fail "continue to do_special_tests (timeout)"
- }
-}
+mi_execute_to "exec-continue" "breakpoint-hit" "do_special_tests" "" ".*var-cmd.c" $line_dst_incr_a_2 "" \
+ "continue to do_special_tests"
# Test: c_variable-7.10
# Desc: create union u
@@ -586,26 +572,7 @@ gdb_expect {
timeout { fail "print FP register (timeout)"}
}
-set line_incr_a_b_a [gdb_get_line_number "b = a;"]
-
-mi_gdb_test "200-break-insert incr_a" \
- "200\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"incr_a\",file=\".*var-cmd.c\",line=\"$line_incr_a_b_a\",times=\"0\"\}" \
- "break-insert operation"
-send_gdb "-exec-continue\n"
-gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"2\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_incr_a_b_a\"\}\r\n$mi_gdb_prompt$" {
- pass "continue to incr_a"
- }
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"([expr $line_incr_a_b_a - 2]|[expr $line_incr_a_b_a - 1]|$line_incr_a_b_a)\"\}\r\n$mi_gdb_prompt$" {
- fail "continue to incr_a (compiler debug info incorrect)"
- }
- -re "\\^running\r\n${mi_gdb_prompt}.*\r\n$mi_gdb_prompt$" {
- fail "continue to incr_a (unknown output)"
- }
- timeout {
- fail "continue to incr_a (timeout)"
- }
-}
+mi_continue_to "incr_a"
# Test: c_variable-7.81
# Desc: Create variables in different scopes
diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp
index 2c2899b..dd999bc 100644
--- a/gdb/testsuite/gdb.mi/mi-watch.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch.exp
@@ -132,38 +132,18 @@ proc test_watchpoint_triggering {type} {
# -exec-continue (Here wp triggers)
# -exec-continue (Here wp goes out of scope)
- send_gdb "222-exec-continue\n"
- gdb_expect {
- -re "222\\^running\r\n$mi_gdb_prompt" {
- gdb_expect {
- -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
- pass "watchpoint trigger"
- }
- -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"}
- timeout {fail "watchpoint trigger (timeout 2)"}
- }
- }
- -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"}
- timeout {fail "watchpoint trigger (timeout 1)"}
- }
+ mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \
+ ".*basics.c" $line_callee4_return_0 \
+ {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \
+ "watchpoint trigger"
if { $type == "sw" } {
setup_xfail *-*-*
}
- send_gdb "223-exec-continue\n"
- gdb_expect {
- -re "223\\^running\r\n$mi_gdb_prompt" {
- gdb_expect {
- -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee3_close_brace\"\}\r\n$mi_gdb_prompt$" {
- pass "wp out of scope"
- }
- -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"}
- timeout {fail "wp out of scope (timeout 2)"}
- }
- }
- -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"}
- timeout {fail "wp out of scope (timeout 1)"}
- }
+ mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \
+ ".*basics.c" $line_callee3_close_brace \
+ {"" "wpnum=\"2\""} \
+ "watchpoint trigger"
clear_xfail *-*-*
}
diff --git a/gdb/testsuite/gdb.mi/mi2-cli.exp b/gdb/testsuite/gdb.mi/mi2-cli.exp
index 7879bd7..5c993f8 100644
--- a/gdb/testsuite/gdb.mi/mi2-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi2-cli.exp
@@ -96,19 +96,8 @@ mi_gdb_test "-interpreter-exec console \"list\"" \
".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
"-interpreter-exec console \"list\""
-# # NOTE: cagney/2003-02-03: Not yet.
-# mi_gdb_test "-exec-continue" \
-# {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",line="8"\}} \
-# "-interpreter-exec console \"continue to callee4\""
-send_gdb "999-exec-continue\n"
-gdb_expect {
- -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
- pass "continue to callee4"
- }
- timeout {
- fail "continue to callee4 (timeout)"
- }
-}
+mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "27" "" \
+ "continue to callee4"
# NOTE: cagney/2003-02-03: Not yet.
# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
@@ -158,32 +147,11 @@ mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
{600\^done,bkpt=.number="3",type="breakpoint".*\}} \
"-break-insert -t basics.c:\$line_main_hello"
-# mi_gdb_test "-exec-continue" \
-# {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \
-# "-exec-continue to line \$line_main_hello"
-send_gdb "700-exec-continue\n"
-gdb_expect {
- -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" {
- pass "-exec-continue to line \$line_main_hello"
- }
- timeout {
- fail "-exec-continue to line \$line_main_hello"
- }
-}
+mi_execute_to "exec-continue" "" "main" "" ".*basics.c" $line_main_hello "" \
+ "-exec-continue to line $line_main_hello"
-# NOTE: cagney/2003-02-03: Not yet.
-# mi_gdb_test "-exec-next" \
-# {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \
-# "-exec-next to line \$line_main_return"
-send_gdb "800-exec-next\n"
-gdb_expect {
- -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_return.*$mi_gdb_prompt$" {
- pass "-exec-next to line \$line_main_return"
- }
- timeout {
- fail "-exec-next to line \$line_main_return"
- }
-}
+mi_execute_to "exec-next" "end-stepping-range" "main" "" ".*basics.c" $line_main_return "" \
+ "-exec-next to line $line_main_return"
mi_gdb_test "-interpreter-exec console \"list\"" \
"\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
diff --git a/gdb/testsuite/gdb.mi/mi2-console.exp b/gdb/testsuite/gdb.mi/mi2-console.exp
index 92d13c1..88b4fdd 100644
--- a/gdb/testsuite/gdb.mi/mi2-console.exp
+++ b/gdb/testsuite/gdb.mi/mi2-console.exp
@@ -51,9 +51,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
mi_run_to_main
# Next over the hello() call which will produce lots of output
-send_gdb "47-exec-next\n"
+send_gdb "220-exec-next\n"
gdb_expect {
- -re "47\\^running\r\n$mi_gdb_prompt" {
+ -re "220\\^running\r\n$mi_gdb_prompt" {
pass "Started step over hello"
}
timeout {
@@ -83,14 +83,8 @@ if { ![target_info exists gdb,noinferiorio] } {
}
}
-gdb_expect {
- -re "47\\*stopped.*$mi_gdb_prompt$" {
- pass "Finished step over hello"
- }
- timeout {
- fail "Finished step over hello (timeout)"
- }
-}
+mi_expect_stop "end-stepping-range" "main" "" ".*mi-console.c" "14" "" \
+ "finished step over hello"
mi_gdb_exit
return 0
diff --git a/gdb/testsuite/gdb.mi/mi2-simplerun.exp b/gdb/testsuite/gdb.mi/mi2-simplerun.exp
index a036926..66ad03a 100644
--- a/gdb/testsuite/gdb.mi/mi2-simplerun.exp
+++ b/gdb/testsuite/gdb.mi/mi2-simplerun.exp
@@ -113,17 +113,7 @@ proc test_running_the_program {} {
# two prompts involved and this can lead to a race condition.
# The following is equivalent to a send_gdb "000-exec-run\n"
mi_run_cmd
- gdb_expect {
- -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",line=\"$line_main_body\"\}\r\n$mi_gdb_prompt$" {
- pass "run to main"
- }
- -re ".*$mi_gdb_prompt$" {
- fail "run to main (2)"
- }
- timeout {
- fail "run to main (timeout)"
- }
- }
+ mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" "$line_main_body" "" "run to main"
}
proc test_controlled_execution {} {
@@ -191,23 +181,7 @@ proc test_program_termination {} {
# -exec-abort
# (normal termination of inferior)
- # FIXME: "stopped" doesn't seem appropriate.
- # mi_gdb_test cannot be used for asynchronous commands because there are
- # two prompts involved and this can lead to a race condition.
- send_gdb "999-exec-continue\n"
- gdb_expect {
- -re "999\\^running\r\n$mi_gdb_prompt" {
- gdb_expect {
- -re "999\\*stopped,reason=\"exited-normally\"\r\n$mi_gdb_prompt$" {
- pass "continue to end"
- }
- -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
- timeout {fail "continue to end (timeout 2)"}
- }
- }
- -re ".*$mi_gdb_prompt$" {fail "continue to end (1)"}
- timeout {fail "continue to end (timeout 1)"}
- }
+ mi_execute_to "exec-continue" "exited-normally" "" "" "" "" "" "continue to end"
}
test_breakpoints_creation_and_listing
diff --git a/gdb/testsuite/gdb.mi/mi2-stack.exp b/gdb/testsuite/gdb.mi/mi2-stack.exp
index 0b6f14c..88be36c 100644
--- a/gdb/testsuite/gdb.mi/mi2-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi2-stack.exp
@@ -173,13 +173,8 @@ proc test_stack_locals_listing {} {
set line_callee4_return_0 [gdb_get_line_number "return 0;"]
# step until A, B, C, D have some reasonable values.
-send_gdb "-exec-next 4\n"
-gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*${srcfile}\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
- pass "next's in callee4"
- }
- timeout { fail "next in callee4 (timeout)" }
-}
+mi_execute_to "exec-next 4" "end-stepping-range" "callee4" "" ".*${srcfile}" $line_callee4_return_0 ""\
+ "next's in callee4"
mi_gdb_test "232-stack-list-locals 1" \
"232\\^done,locals=\\\[\{name=\"A\",value=\"1\"\},\{name=\"B\",value=\"2\"\},\{name=\"C\",value=\"3\"\},\{name=\"D\",value=\"\\{0, 1, 2\\}\"\}\\\]" \
diff --git a/gdb/testsuite/gdb.mi/mi2-stepi.exp b/gdb/testsuite/gdb.mi/mi2-stepi.exp
index e7b709d..67d7aec 100644
--- a/gdb/testsuite/gdb.mi/mi2-stepi.exp
+++ b/gdb/testsuite/gdb.mi/mi2-stepi.exp
@@ -47,47 +47,28 @@ proc test_stepi_nexti {} {
set line_main_body [expr $line_main_head + 2]
set line_main_hello [gdb_get_line_number "Hello, World!"]
- send_gdb "111-exec-step-instruction\n"
- gdb_expect {
- -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" {
- set line $expect_out(2,string)
- if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "step-instruction at main"
- } else {
- fail "step-instruction at main"
- }
- }
- timeout {
- fail "step-instruction at main (timeout)"
- }
- }
- send_gdb "222-exec-next-instruction\n"
- gdb_expect {
- -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" {
- set line $expect_out(2,string)
- if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "next-instruction at main"
- } else {
- fail "next-instruction at main"
- }
- }
- timeout {
- fail "next-instruction at main (timeout)"
- }
+ set line [mi_execute_to "exec-step-instruction" "end-stepping-range" "main" "" \
+ ".*basics.c" "\[0-9\]+" "" "step-instruction at main"]
+ if { $line >= $line_main_body && $line <= $line_main_hello } {
+ pass "step-instruction at main (line check)"
+ } else {
+ fail "step-instruction at main (line check)"
+ }
+
+ set line [mi_execute_to "exec-next-instruction" "end-stepping-range" "main" "" \
+ ".*basics.c" "\[0-9\]+" "" "next-instruction at main"]
+ if { $line >= $line_main_body && $line <= $line_main_hello } {
+ pass "next-instruction at main (line check)"
+ } else {
+ fail "next-instruction at main (line check)"
}
- send_gdb "333-exec-next-instruction\n"
- gdb_expect {
- -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(\[0-9\]+)\"\}\r\n$mi_gdb_prompt$" {
- set line $expect_out(2,string)
- if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "next-instruction at main"
- } else {
- fail "next-instruction at main"
- }
- }
- timeout {
- fail "next-instruction at main (timeout)"
- }
+
+ set line [mi_execute_to "exec-next-instruction" "end-stepping-range" "main" "" \
+ ".*basics.c" "\[0-9\]+" "" "next-instruction at main 2"]
+ if { $line >= $line_main_body && $line <= $line_main_hello } {
+ pass "next-instruction at main 2 (line check)"
+ } else {
+ fail "next-instruction at main 2 (line check)"
}
}
diff --git a/gdb/testsuite/gdb.mi/mi2-until.exp b/gdb/testsuite/gdb.mi/mi2-until.exp
index 6e007a0..5bf9bd8 100644
--- a/gdb/testsuite/gdb.mi/mi2-until.exp
+++ b/gdb/testsuite/gdb.mi/mi2-until.exp
@@ -56,18 +56,7 @@ proc test_running_to_foo {} {
"break-insert operation"
mi_run_cmd
-
- gdb_expect {
- -re "000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",line=\"10\"\}\r\n$mi_gdb_prompt$" {
- pass "run to main"
- }
- -re ".*$mi_gdb_prompt$" {
- fail "run to main (2)"
- }
- timeout {
- fail "run to main (timeout)"
- }
- }
+ mi_expect_stop "breakpoint-hit" "foo" "" ".*until.c" 10 "" "run to main"
mi_gdb_test "100-break-delete 1" "100\\^done" "break-delete 1"
@@ -77,51 +66,19 @@ proc test_until {} {
global mi_gdb_prompt
global hex fullname_syntax srcfile
- send_gdb "111-exec-until\n"
- gdb_expect {
- -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"12\"\}\r\n$mi_gdb_prompt$" {
- pass "until after while loop"
- }
- -re "111\\^running\r\n${mi_gdb_prompt}111\\*stopped,reason=\"end-stepping-range\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"9\"\}\r\n$mi_gdb_prompt$" {
- kfail gdb/2104 "until after while loop (went backwards)"
- }
- timeout {
- fail "until after while loop (timeout)"
- }
- }
-
- send_gdb "222-exec-until 15\n"
- gdb_expect {
- -re "222\\^running\r\n${mi_gdb_prompt}222\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"15\"\}\r\n$mi_gdb_prompt$" {
- pass "until line number"
- }
- timeout {
- fail "until line number (timeout)"
- }
- }
-
- send_gdb "333-exec-until until.c:17\n"
- gdb_expect {
- -re "333\\^running\r\n${mi_gdb_prompt}333\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"foo\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"17\"\}\r\n$mi_gdb_prompt$" {
- pass "until line number:file"
- }
- timeout {
- fail "until line number:file (timeout)"
- }
- }
+ setup_kfail gdb/2104 "*-*-*"
+ mi_execute_to "exec-until" "end-stepping-range" "foo" "" ".*until.c" "12" "" \
+ "until after while loop"
- # This is supposed to NOT stop at line 25. It stops right after foo is over.
+ mi_execute_to "exec-until 15" "location-reached" "foo" "" ".*until.c" "15" ""\
+ "until line number"
- send_gdb "444-exec-until until.c:25\n"
- gdb_expect {
- -re "444\\^running\r\n${mi_gdb_prompt}444\\*stopped,reason=\"location-reached\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"main\",args=\\\[\\\],file=\".*until.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"(23|24)\"\}\r\n$mi_gdb_prompt$" {
- pass "until after current function"
- }
- timeout {
- fail "until after current function (timeout)"
- }
- }
+ mi_execute_to "exec-until until.c:17" "location-reached" "foo" "" ".*until.c" "17" ""\
+ "until line number:file"
+ # This is supposed to NOT stop at line 25. It stops right after foo is over.
+ mi_execute_to "exec-until until.c:25" "location-reached" "main" "" ".*until.c" "(23|24)" ""\
+ "until after current function"
}
test_running_to_foo
diff --git a/gdb/testsuite/gdb.mi/mi2-var-display.exp b/gdb/testsuite/gdb.mi/mi2-var-display.exp
index 0226186..21f1aa6 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-display.exp
@@ -47,14 +47,7 @@ mi_gdb_test "200-break-insert $srcfile:$line_dct_end" \
"break-insert operation"
mi_run_cmd
-# The running part has been checked already by mi_run_cmd
-gdb_expect {
- -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dct_end\"\}\r\n$mi_gdb_prompt$" {
- pass "run to do_children_tests"
- }
- -re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"}
- timeout {fail "run to do_children_tests (timeout 2)"}
-}
+mi_expect_stop "breakpoint-hit" "do_children_tests" "" ".*var-cmd.c" $line_dct_end "" "run to main"
##### #####
# #
@@ -337,15 +330,8 @@ mi_gdb_test "200-break-insert $line_dst_incr_a_2" \
"200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"$line_dst_incr_a_2\",times=\"0\"\}" \
"break-insert operation"
-send_gdb "-exec-continue\n"
-gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_special_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dst_incr_a_2\"\}\r\n$mi_gdb_prompt$" {
- pass "continue to do_special_tests"
- }
- timeout {
- fail "continue to do_special_tests (timeout)"
- }
-}
+mi_execute_to "exec-continue" "breakpoint-hit" "do_special_tests" "" ".*var-cmd.c" $line_dst_incr_a_2 "" \
+ "continue to do_special_tests"
# Test: c_variable-7.10
# Desc: create union u
@@ -586,26 +572,7 @@ gdb_expect {
timeout { fail "print FP register (timeout)"}
}
-set line_incr_a_b_a [gdb_get_line_number "b = a;"]
-
-mi_gdb_test "200-break-insert incr_a" \
- "200\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"incr_a\",file=\".*var-cmd.c\",line=\"$line_incr_a_b_a\",times=\"0\"\}" \
- "break-insert operation"
-send_gdb "-exec-continue\n"
-gdb_expect {
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"2\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_incr_a_b_a\"\}\r\n$mi_gdb_prompt$" {
- pass "continue to incr_a"
- }
- -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"([expr $line_incr_a_b_a - 2]|[expr $line_incr_a_b_a - 1]|$line_incr_a_b_a)\"\}\r\n$mi_gdb_prompt$" {
- fail "continue to incr_a (compiler debug info incorrect)"
- }
- -re "\\^running\r\n${mi_gdb_prompt}.*\r\n$mi_gdb_prompt$" {
- fail "continue to incr_a (unknown output)"
- }
- timeout {
- fail "continue to incr_a (timeout)"
- }
-}
+mi_continue_to "incr_a"
# Test: c_variable-7.81
# Desc: Create variables in different scopes
diff --git a/gdb/testsuite/gdb.mi/mi2-watch.exp b/gdb/testsuite/gdb.mi/mi2-watch.exp
index df9895e..6e3fce9 100644
--- a/gdb/testsuite/gdb.mi/mi2-watch.exp
+++ b/gdb/testsuite/gdb.mi/mi2-watch.exp
@@ -132,38 +132,18 @@ proc test_watchpoint_triggering {type} {
# -exec-continue (Here wp triggers)
# -exec-continue (Here wp goes out of scope)
- send_gdb "222-exec-continue\n"
- gdb_expect {
- -re "222\\^running\r\n$mi_gdb_prompt" {
- gdb_expect {
- -re "222\\*stopped,reason=\"watchpoint-trigger\",wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\},thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee4\",args=\\\[\\\],file=\".*basics.c\",line=\"$line_callee4_return_0\"\}\r\n$mi_gdb_prompt$" {
- pass "watchpoint trigger"
- }
- -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (2)"}
- timeout {fail "watchpoint trigger (timeout 2)"}
- }
- }
- -re ".*$mi_gdb_prompt$" {fail "watchpoint trigger (1)"}
- timeout {fail "watchpoint trigger (timeout 1)"}
- }
+ mi_execute_to "exec-continue" "watchpoint-trigger" "callee4" "" \
+ ".*basics.c" $line_callee4_return_0 \
+ {"" "wpt=\{number=\"2\",exp=\"C\"\},value=\{old=\".*\",new=\"3\"\}"} \
+ "watchpoint trigger"
if { $type == "sw" } {
setup_xfail *-*-*
}
- send_gdb "223-exec-continue\n"
- gdb_expect {
- -re "223\\^running\r\n$mi_gdb_prompt" {
- gdb_expect {
- -re "\[\r\n\]*223\\*stopped,reason=\"watchpoint-scope\",wpnum=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"callee3\",args=\\\[.*\\\],file=\".*basics.c\",line=\"$line_callee3_close_brace\"\}\r\n$mi_gdb_prompt$" {
- pass "wp out of scope"
- }
- -re ".*$mi_gdb_prompt$" {fail "wp out of scope (2)"}
- timeout {fail "wp out of scope (timeout 2)"}
- }
- }
- -re ".*$mi_gdb_prompt$" {fail "wp out of scope (1)"}
- timeout {fail "wp out of scope (timeout 1)"}
- }
+ mi_execute_to "exec-continue" "watchpoint-scope" "callee3" ".*" \
+ ".*basics.c" $line_callee3_close_brace \
+ {"" "wpnum=\"2\""} \
+ "watchpoint trigger"
clear_xfail *-*-*
}
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 2fb53e7..317ba49 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -798,9 +798,9 @@ proc mi_run_cmd {args} {
if [target_info exists use_gdb_stub] {
if [target_info exists gdb,do_reload_on_run] {
- send_gdb "000-exec-continue\n";
+ send_gdb "220-exec-continue\n";
gdb_expect 60 {
- -re "000\\^running\[\r\n\]+$mi_gdb_prompt$" {}
+ -re "220\\^running\[\r\n\]+$mi_gdb_prompt$" {}
default {}
}
return;
@@ -819,9 +819,9 @@ proc mi_run_cmd {args} {
return
}
- send_gdb "000-exec-run $args\n"
+ send_gdb "220-exec-run $args\n"
gdb_expect {
- -re "000\\^running\r\n${mi_gdb_prompt}" {
+ -re "220\\^running\r\n${mi_gdb_prompt}" {
}
timeout {
perror "Unable to start target"
@@ -886,30 +886,10 @@ proc mi_runto_helper {func run_or_continue} {
if {$run_or_continue == "run"} {
mi_run_cmd
} else {
- send_gdb "000-exec-continue\n"
- gdb_expect {
- -re "000\\^running\r\n${mi_gdb_prompt}" {
- }
- timeout {
- fail "$test"
- return -1
- }
- }
+ mi_send_resuming_command "exec-continue" "$test"
}
- gdb_expect {
- -re ".*000\\*stopped,thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=\(\\\[.*\\\]\|\{.*\}\),file=\".*\",fullname=\"${fullname_syntax}.*\",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
- }
- }
+ mi_expect_stop "" $func ".*" ".*" "\[0-9\]+" "" $test
}
proc mi_runto {func} {
@@ -931,32 +911,76 @@ proc mi_step { test } {
return [mi_step_to {.*} {.*} {.*} {.*} $test]
}
-# cmd should not include the number or newline (i.e. "exec-step 3", not
-# "220-exec-step 3\n"
-
-# Can not match -re ".*\r\n${mi_gdb_prompt}", because of false positives
-# after the first prompt is printed.
+# Wait for MI *stopped notification to appear.
+# The REASON, FUNC, ARGS, FILE and LINE are regular expressions
+# to match against whatever is output in *stopped. ARGS should
+# not include [] the list of argument is enclosed in, and other
+# regular expressions should not include quotes.
+# If EXTRA is a list of one element, it's the regular expression
+# for output expected right after *stopped, and before GDB prompt.
+# If EXTRA is a list of two elements, the first element is for
+# output right after *stopped, and the second element is output
+# right after reason field. The regex after reason should not include
+# the comma separating it from the following fields.
+#
+# When we fail to match output at all, -1 is returned. Otherwise,
+# the line at which we stop is returned. This is useful when exact
+# line is not possible to specify for some reason -- one can pass
+# the .* regexp for line, and then check the line programmatically.
+proc mi_expect_stop { reason func args file line extra test } {
-proc mi_execute_to_helper { cmd reason func args file line extra test } {
- global suppress_flag
- if { $suppress_flag } {
- return -1
- }
global mi_gdb_prompt
global hex
global decimal
global fullname_syntax
- send_gdb "220-$cmd\n"
+
+ set after_stopped ""
+ set after_reason ""
+ if { [llength $extra] == 2 } {
+ set after_stopped [lindex $extra 0]
+ set after_reason [lindex $extra 1]
+ set after_reason "${after_reason},"
+ } elseif { [llength $extra] == 1 } {
+ set after_stopped [lindex $extra 0]
+ }
+
+ if { $reason == "exited-normally" } {
+
+ gdb_expect {
+ -re "220\\*stopped,reason=\"exited-normally\"\r\n$mi_gdb_prompt$" {
+ pass "$test"
+ }
+ -re ".*$mi_gdb_prompt$" {fail "continue to end (2)"}
+ timeout {
+ fail "$test (unknown output after running)"
+ }
+ }
+ return
+ }
+
+ set args "\\\[$args\\\]"
+
+ set bn ""
+ if { $reason == "breakpoint-hit" } {
+ set bn {bkptno="[0-9]+",}
+ }
+
+ set r ""
+ if { $reason != "" } {
+ set r "reason=\"$reason\","
+ }
+
+ verbose -log "mi_expect_stop: expecting: .*220\\*stopped,${r}${bn}${after_reason}thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$after_stopped\r\n$mi_gdb_prompt$"
gdb_expect {
- -re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"$line\"\}$extra\r\n$mi_gdb_prompt$" {
+ -re ".*220\\*stopped,${r}${bn}${after_reason}thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\"$func\",args=$args,file=\".*$file\",fullname=\"${fullname_syntax}$file\",line=\"($line)\"\}$after_stopped\r\n$mi_gdb_prompt$" {
pass "$test"
- return 0
+ return $expect_out(2,string)
}
- -re "220\\^running\r\n${mi_gdb_prompt}.*220\\*stopped,reason=\"$reason\",thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
+ -re ".*220\\*stopped,${r}${bn}${after_reason}thread-id=\"$decimal\",frame=\{addr=\"$hex\",func=\".*\",args=\[\\\[\{\].*\[\\\]\}\],file=\".*\",fullname=\"${fullname_syntax}.*\",line=\"\[0-9\]*\"\}.*\r\n$mi_gdb_prompt$" {
fail "$test (stopped at wrong place)"
return -1
}
- -re "220\\^running\r\n${mi_gdb_prompt}.*\r\n${mi_gdb_prompt}$" {
+ -re ".*\r\n${mi_gdb_prompt}$" {
fail "$test (unknown output after running)"
return -1
}
@@ -964,12 +988,24 @@ proc mi_execute_to_helper { cmd reason func args file line extra test } {
fail "$test (timeout)"
return -1
}
- }
+ }
}
+# cmd should not include the number or newline (i.e. "exec-step 3", not
+# "220-exec-step 3\n"
+
+# Can not match -re ".*\r\n${mi_gdb_prompt}", because of false positives
+# after the first prompt is printed.
+
proc mi_execute_to { cmd reason func args file line extra test } {
- mi_execute_to_helper "$cmd" "$reason" "$func" "\\\[$args\\\]" \
- "$file" "$line" "$extra" "$test"
+ global suppress_flag
+ if { $suppress_flag } {
+ return -1
+ }
+
+ mi_send_resuming_command "$cmd" "$test"
+ set r [mi_expect_stop $reason $func $args $file $line $extra $test]
+ return $r
}
proc mi_next_to { func args file line test } {
@@ -1269,8 +1305,16 @@ proc mi_send_resuming_command {command test} {
gdb_expect {
-re "220\\^running\r\n${mi_gdb_prompt}" {
}
+ -re ".*${mi_gdb_prompt}" {
+ fail "$test (failed to resume)"
+ }
+ -re "220\\^error,msg=.*" {
+ fail "$test (MI error)"
+ return -1
+ }
timeout {
- fail $test
+ fail "$test"
+ return -1
}
}
}
@@ -1286,11 +1330,11 @@ proc mi_continue_to_line {location test} {
mi_tbreak $location
mi_send_resuming_command "exec-continue" "run to $location (exec-continue)"
- return [mi_wait_for_stop $test]
+ return [mi_get_stop_line $test]
}
# Wait until gdb prints the current line.
-proc mi_wait_for_stop {test} {
+proc mi_get_stop_line {test} {
global mi_gdb_prompt
@@ -1367,7 +1411,7 @@ proc mi_run_inline_test { testcase } {
# Start the program afresh.
mi_tbreak "$mi_autotest_source:$line"
mi_run_cmd
- set line_now [mi_wait_for_stop "$testcase: step to $line"]
+ set line_now [mi_get_stop_line "$testcase: step to $line"]
set first 0
} elseif {$line_now!=$line} {
set line_now [mi_continue_to_line "$mi_autotest_source:$line" "continue to $line"]
@@ -1383,7 +1427,7 @@ proc mi_run_inline_test { testcase } {
# Single-step past the line.
mi_send_resuming_command "exec-next" "$testcase: step over $line"
- set line_now [mi_wait_for_stop "$testcase: step over $line"]
+ set line_now [mi_get_stop_line "$testcase: step over $line"]
# We probably want to use 'uplevel' so that statements
# have direct access to global variables that the