This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cleanup MI testsuite, again


This time, I've replaced all checks for *stopped output with
calls to helper functions. The problem with manual checks for *stopped
is the same as with manual checks of variable objects -- they all crash
and burn whenever any change to the output is made, and there's no way
to conveniently update the testsuite for the desired changes. Furthermore,
many of the *stopped checks are half-broken, in that any unexpected output
results in timeout, not an immediate error.

I've left 4 uses of *stopped in mi(|2)-syn-frame.exp, since there, we check
for *stopped without *any* information, so it's relatively safe. Other
than that, there are not direct checks for *stopped in tests, and in
mi-support.exp all checks for *stopped are located in a single function.

Checked in.

- Volodya

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.
Index: lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.53
diff -u -p -r1.53 mi-support.exp
--- lib/mi-support.exp	28 Mar 2008 16:32:11 -0000	1.53
+++ lib/mi-support.exp	5 Apr 2008 17:12:25 -0000
@@ -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_contin
   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 f
 	    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 t
     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
Index: gdb.mi/mi-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-cli.exp,v
retrieving revision 1.11
diff -u -p -r1.11 mi-cli.exp
--- gdb.mi/mi-cli.exp	22 Jan 2008 19:43:10 -0000	1.11
+++ gdb.mi/mi-cli.exp	5 Apr 2008 17:12:25 -0000
@@ -96,19 +96,8 @@ mi_gdb_test "-interpreter-exec console \
   ".*\~\"$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.
 	{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"
-    }
-}
-
-# 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-continue" "" "main" "" ".*basics.c" $line_main_hello "" \
+    "-exec-continue to line $line_main_hello"
+
+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" \
Index: gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.21
diff -u -p -r1.21 mi-console.exp
--- gdb.mi/mi-console.exp	1 Jan 2008 22:53:20 -0000	1.21
+++ gdb.mi/mi-console.exp	5 Apr 2008 17:12:25 -0000
@@ -51,12 +51,13 @@ if  { [gdb_compile "${srcdir}/${subdir}/
 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
Index: gdb.mi/mi-pending.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-pending.exp,v
retrieving revision 1.3
diff -u -p -r1.3 mi-pending.exp
--- gdb.mi/mi-pending.exp	26 Feb 2008 08:14:11 -0000	1.3
+++ gdb.mi/mi-pending.exp	5 Apr 2008 17:12:25 -0000
@@ -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
Index: gdb.mi/mi-simplerun.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-simplerun.exp,v
retrieving revision 1.18
diff -u -p -r1.18 mi-simplerun.exp
--- gdb.mi/mi-simplerun.exp	27 Feb 2008 20:29:31 -0000	1.18
+++ gdb.mi/mi-simplerun.exp	5 Apr 2008 17:12:25 -0000
@@ -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
Index: gdb.mi/mi-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stack.exp,v
retrieving revision 1.26
diff -u -p -r1.26 mi-stack.exp
--- gdb.mi/mi-stack.exp	4 Apr 2008 21:59:25 -0000	1.26
+++ gdb.mi/mi-stack.exp	5 Apr 2008 17:12:25 -0000
@@ -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\\}\"\}\\\]" \
Index: gdb.mi/mi-stepi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stepi.exp,v
retrieving revision 1.16
diff -u -p -r1.16 mi-stepi.exp
--- gdb.mi/mi-stepi.exp	1 Jan 2008 22:53:20 -0000	1.16
+++ gdb.mi/mi-stepi.exp	5 Apr 2008 17:12:25 -0000
@@ -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)"
     }
 }
 
Index: gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.14
diff -u -p -r1.14 mi-syn-frame.exp
--- gdb.mi/mi-syn-frame.exp	4 Apr 2008 21:59:25 -0000	1.14
+++ gdb.mi/mi-syn-frame.exp	5 Apr 2008 17:12:25 -0000
@@ -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" \
Index: gdb.mi/mi-until.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-until.exp,v
retrieving revision 1.15
diff -u -p -r1.15 mi-until.exp
--- gdb.mi/mi-until.exp	1 Jan 2008 22:53:20 -0000	1.15
+++ gdb.mi/mi-until.exp	5 Apr 2008 17:12:25 -0000
@@ -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
Index: gdb.mi/mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.25
diff -u -p -r1.25 mi-var-display.exp
--- gdb.mi/mi-var-display.exp	4 Apr 2008 21:59:25 -0000	1.25
+++ gdb.mi/mi-var-display.exp	5 Apr 2008 17:12:25 -0000
@@ -47,14 +47,7 @@ mi_gdb_test "200-break-insert $srcfile:$
 	"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_
 	"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
Index: gdb.mi/mi-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-watch.exp,v
retrieving revision 1.20
diff -u -p -r1.20 mi-watch.exp
--- gdb.mi/mi-watch.exp	1 Jan 2008 22:53:20 -0000	1.20
+++ gdb.mi/mi-watch.exp	5 Apr 2008 17:12:25 -0000
@@ -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 *-*-*
 }
 
Index: gdb.mi/mi2-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-cli.exp,v
retrieving revision 1.10
diff -u -p -r1.10 mi2-cli.exp
--- gdb.mi/mi2-cli.exp	22 Jan 2008 19:43:10 -0000	1.10
+++ gdb.mi/mi2-cli.exp	5 Apr 2008 17:12:25 -0000
@@ -96,19 +96,8 @@ mi_gdb_test "-interpreter-exec console \
   ".*\~\"$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.
 	{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"
-    }
-}
-
-# 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-continue" "" "main" "" ".*basics.c" $line_main_hello "" \
+    "-exec-continue to line $line_main_hello"
+
+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" \
Index: gdb.mi/mi2-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-console.exp,v
retrieving revision 1.9
diff -u -p -r1.9 mi2-console.exp
--- gdb.mi/mi2-console.exp	1 Jan 2008 22:53:20 -0000	1.9
+++ gdb.mi/mi2-console.exp	5 Apr 2008 17:12:25 -0000
@@ -51,9 +51,9 @@ if  { [gdb_compile "${srcdir}/${subdir}/
 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,noinferior
     }
 }
 
-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
Index: gdb.mi/mi2-simplerun.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-simplerun.exp,v
retrieving revision 1.9
diff -u -p -r1.9 mi2-simplerun.exp
--- gdb.mi/mi2-simplerun.exp	27 Feb 2008 20:29:31 -0000	1.9
+++ gdb.mi/mi2-simplerun.exp	5 Apr 2008 17:12:25 -0000
@@ -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
Index: gdb.mi/mi2-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-stack.exp,v
retrieving revision 1.12
diff -u -p -r1.12 mi2-stack.exp
--- gdb.mi/mi2-stack.exp	4 Apr 2008 21:59:25 -0000	1.12
+++ gdb.mi/mi2-stack.exp	5 Apr 2008 17:12:25 -0000
@@ -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\\}\"\}\\\]" \
Index: gdb.mi/mi2-stepi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-stepi.exp,v
retrieving revision 1.9
diff -u -p -r1.9 mi2-stepi.exp
--- gdb.mi/mi2-stepi.exp	1 Jan 2008 22:53:20 -0000	1.9
+++ gdb.mi/mi2-stepi.exp	5 Apr 2008 17:12:25 -0000
@@ -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)"
     }
 }
 
Index: gdb.mi/mi2-until.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-until.exp,v
retrieving revision 1.9
diff -u -p -r1.9 mi2-until.exp
--- gdb.mi/mi2-until.exp	1 Jan 2008 22:53:20 -0000	1.9
+++ gdb.mi/mi2-until.exp	5 Apr 2008 17:12:25 -0000
@@ -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
Index: gdb.mi/mi2-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-var-display.exp,v
retrieving revision 1.18
diff -u -p -r1.18 mi2-var-display.exp
--- gdb.mi/mi2-var-display.exp	4 Apr 2008 21:59:25 -0000	1.18
+++ gdb.mi/mi2-var-display.exp	5 Apr 2008 17:12:25 -0000
@@ -47,14 +47,7 @@ mi_gdb_test "200-break-insert $srcfile:$
 	"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_
 	"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
Index: gdb.mi/mi2-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi2-watch.exp,v
retrieving revision 1.11
diff -u -p -r1.11 mi2-watch.exp
--- gdb.mi/mi2-watch.exp	1 Jan 2008 22:53:20 -0000	1.11
+++ gdb.mi/mi2-watch.exp	5 Apr 2008 17:12:25 -0000
@@ -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 *-*-*
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]