* gdb.mi/dw2-ref-missing-frame.exp: Use standard_testfile,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-cli.exp
index b77a4d42921faa35590e9f3e6b913fe754f440ea..b7abbc72390bab21497833cdc70a712d7f97bf13 100644 (file)
@@ -1,5 +1,4 @@
-# Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009
-# Free Software Foundation, Inc.
+# Copyright 2002-2005, 2007-2012 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -28,24 +27,23 @@ if [mi_gdb_start] {
     continue
 }
 
-set testfile "basics"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
+standard_testfile basics.c
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
      untested mi-cli.exp
      return -1
 }
 
 mi_gdb_test "-interpreter-exec" \
-  {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
+  {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
   "-interpreter-exec with no arguments"
 
 mi_gdb_test "-interpreter-exec console" \
-  {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
+  {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
   "-interpreter-exec with one argument"
 
 mi_gdb_test "-interpreter-exec bogus command" \
-  {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
+  {\^error,msg="-interpreter-exec: could not find interpreter \\\"bogus\\\""} \
   "-interpreter-exec with bogus interpreter"
 
 set msg {Undefined command: \\\"bogus\\\"\.  Try \\\"help\\\"\.}
@@ -58,15 +56,18 @@ mi_gdb_test "-interpreter-exec console bogus" \
 #   {(=.*)+\^done} \
 #   "-interpreter-exec console \"file \$binfile\""
 mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
-  {~"Reading symbols from .*basics...".*done} \
+  {~"Reading symbols from .*mi-cli...".*done} \
   "-interpreter-exec console \"file \$binfile\""
 
 mi_run_to_main
 
-set line_main_head   [gdb_get_line_number "main ("]
-set line_main_body   [expr $line_main_head + 2]
-set line_main_hello  [gdb_get_line_number "Hello, World!"]
-set line_main_return [expr $line_main_hello + 2]
+set line_main_head    [gdb_get_line_number "main ("]
+set line_main_body    [expr $line_main_head + 2]
+set line_main_hello   [gdb_get_line_number "Hello, World!"]
+set line_main_return  [expr $line_main_hello + 2]
+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]
 
 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
   {\^done} \
@@ -97,7 +98,7 @@ mi_gdb_test "-interpreter-exec console \"list\"" \
   ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
   "-interpreter-exec console \"list\""
 
-mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \
+mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \
     { "" "disp=\"keep\"" } "continue to callee4"
 
 # NOTE: cagney/2003-02-03: Not yet.
@@ -105,7 +106,7 @@ mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \
 #   {.*=breakpoint-delete,number=\"2\".*\^done} \
 #   "-interpreter-exec console \"delete 2\""
 mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
-  {100\^done} \
+  {=breakpoint-deleted,id=\"2\"\r\n100\^done} \
   "-interpreter-exec console \"delete 2\""
 
 # NOTE: cagney/2003-02-03: Not yet.
@@ -140,6 +141,24 @@ mi_gdb_test "500-stack-select-frame 0" \
   {500\^done} \
   "-stack-select-frame 0"
 
+# When a CLI command is entered in MI session, the respose is different in
+# sync and async modes. In sync mode normal_stop is called when current
+# interpreter is CLI. So:
+#   - print_stop_reason prints stop reason in CLI uiout, and we don't show it
+#     in MI
+#   - The stop position is printed, and appears in MI 'console' channel.
+#
+# In async mode the stop event is processed when we're back to MI interpreter,
+# so the stop reason is printed into MI uiout an.
+if {$async} {
+    set reason "end-stepping-range"
+} else {
+    set reason ""
+}
+
+mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \
+    "" "check *stopped from CLI command"
+
 # NOTE: cagney/2003-02-03: Not yet.
 # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
 #   {.*=breakpoint-create,number="3".*\^done} \
@@ -152,8 +171,25 @@ mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \
     $line_main_hello { "" "disp=\"del\"" } \
     "-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"
+# Test that the token is output even for CLI commands
+# Also test that *stopped includes frame information.
+mi_gdb_test "34 next" \
+    ".*34\\\^running.*\\*running,thread-id=\"all\"" \
+    "34 next: run"
+
+if {!$async} {
+    gdb_expect {
+        -re "~\[^\r\n\]+\r\n" {
+        }
+    }
+}
+
+# Note that the output does not include stop reason. This is fine.
+# The purpose of *stopped notification for CLI command is to make
+# sure that frontend knows that inferior is stopped, and knows where.
+# Supplementary information is not necessary.
+mi_expect_stop "$reason" "main" "" ".*basics.c" $line_main_return "" \
+    "34 next: stop"
 
 mi_gdb_test "-interpreter-exec console \"list\"" \
   "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
This page took 0.026368 seconds and 4 git commands to generate.