PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in...
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-cli.exp
index cb8d3afc9f66009c6fbaefd7e7a547229e75f95a..81f8898923ee1987d50c3887857cadc29ecb2c34 100644 (file)
@@ -69,6 +69,7 @@ set line_main_callme_2 [expr $line_main_return + 1]
 set line_callee4_head [gdb_get_line_number "callee4 ("]
 set line_callee4_body [expr $line_callee4_head + 2]
 set line_callee4_next [expr $line_callee4_body + 1]
+set line_callee4_next_step [expr $line_callee4_next + 3]
 
 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
   ".*=cmd-param-changed,param=\"args\",value=\"foobar\".*\\^done" \
@@ -153,13 +154,44 @@ if {$async} {
 mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \
     "" "check *stopped from CLI command"
 
+mi_send_resuming_command "exec-step" "-exec-step to line \$line_callee4_next_step"
+
+# Test that the new current source line is _not_ output, given we
+# executed MI's -exec-next, not CLI's 'next' command.
+
+set output [mi_gdb_expect_cli_output "\\*stopped" "collect CLI output for -exec-step"]
+
+set test "-exec-step does not produce CLI step output"
+if {[regexp "A + B" "$output"]} {
+    fail $test
+} else {
+    pass $test
+}
+
+mi_expect_stop "end-stepping-range" "callee4" "" ".*basics.c" $line_callee4_next_step \
+    "" "check *stopped from CLI command 2"
+
 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_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \
-    $line_main_hello { "" "disp=\"del\"" } \
-    "-exec-continue to line \$line_main_hello"
+# Test that breakpoint events are always mirrored to the CLI output
+# stream (both sync and async modes).
+mi_send_resuming_command "exec-continue" "-exec-continue to line \$line_main_hello"
+
+set output [mi_gdb_expect_cli_output "\\*stopped" "collect CLI output for breakpoint hit"]
+set test "breakpoint hit produces CLI output"
+set pattern "\\\\nTemporary breakpoint 3, main \\(\\) at \[^\n\]+basics.c:$line_main_hello\\\\n\[^\n\]+Hello"
+
+if {[regexp $pattern $output]} {
+    pass $test
+} else {
+    fail $test
+}
+
+# Test the MI output.
+mi_expect_stop "breakpoint-hit" "main" "" ".*basics.c" \
+    $line_main_hello { "" "disp=\"del\"" } "temporary breakpoint output hit in MI"
 
 # Test that the token is output even for CLI commands
 # Also test that *stopped includes frame information.
@@ -167,10 +199,16 @@ mi_gdb_test "34 next" \
     ".*34\\\^running.*\\*running,thread-id=\"all\"" \
     "34 next: run"
 
-if {!$async} {
-    gdb_expect {
-        -re "~\[^\r\n\]+\r\n" {
-        }
+# Test that the new current source line is output to the console
+# stream, given we executed the console 'next' command, not
+# -exec-next.
+set test "34 next: CLI output"
+gdb_expect {
+    -re "~\"$line_main_return\[^\r\n\]+\r\n" {
+       pass $test
+    }
+    timeout {
+       fail "$test (timeout)"
     }
 }
 
This page took 0.026536 seconds and 4 git commands to generate.