*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi2-cli.exp
CommitLineData
0b302171 1# Copyright 2002-2005, 2007-2012 Free Software Foundation, Inc.
2fcf52f0
AC
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
2fcf52f0 6# (at your option) any later version.
e22f8b7c 7#
2fcf52f0
AC
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
e22f8b7c 12#
2fcf52f0 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
2fcf52f0 15
2fcf52f0
AC
16# This file tests that GDB's console can be accessed via the MI.
17# Specifically, we are testing the "interpreter-exec" command and that
18# the commands that are executed via this command are properly executed.
19# Console commands executed via MI should use MI output wrappers, MI event
20# handlers, etc.
21
22load_lib mi-support.exp
23set MIFLAGS "-i=mi2"
24
25gdb_exit
26if [mi_gdb_start] {
27 continue
28}
29
298a9cf0
TT
30standard_testfile basics.c
31
9357e021 32if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
33 untested mi2-cli.exp
34 return -1
2fcf52f0
AC
35}
36
2fcf52f0 37mi_gdb_test "-interpreter-exec" \
1b05df00 38 {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
2fcf52f0
AC
39 "-interpreter-exec with no arguments"
40
41mi_gdb_test "-interpreter-exec console" \
1b05df00 42 {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
2fcf52f0
AC
43 "-interpreter-exec with one argument"
44
45mi_gdb_test "-interpreter-exec bogus command" \
1b05df00 46 {\^error,msg="-interpreter-exec: could not find interpreter \\\"bogus\\\""} \
2fcf52f0
AC
47 "-interpreter-exec with bogus interpreter"
48
49set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.}
50mi_gdb_test "-interpreter-exec console bogus" \
51 "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
52 "-interpreter-exec console bogus"
53
54# NOTE: cagney/2003-02-03: Not yet.
55# mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
56# {(=.*)+\^done} \
57# "-interpreter-exec console \"file \$binfile\""
58mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
3788363d 59 {~"Reading symbols from .*mi2-cli...".*\^done} \
2fcf52f0
AC
60 "-interpreter-exec console \"file \$binfile\""
61
62mi_run_to_main
63
dd322c54
JK
64set line_main_head [gdb_get_line_number "main ("]
65set line_main_body [expr $line_main_head + 2]
66set line_main_hello [gdb_get_line_number "Hello, World!"]
67set line_main_return [expr $line_main_hello + 2]
68set line_callee4_head [gdb_get_line_number "callee4 ("]
69set line_callee4_body [expr $line_callee4_head + 2]
a065d7af 70set line_callee4_next [expr $line_callee4_body + 1]
45f07fef 71
2fcf52f0 72mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
5b9afe8a 73 ".*=cmd-param-changed,param=\"args\",value=\"foobar\".*\\^done" \
2fcf52f0
AC
74 "-interpreter-exec console \"set args foobar\""
75
76mi_gdb_test "-interpreter-exec console \"show args\"" \
77 {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
78 "-interpreter-exec console \"show args\""
79
80# NOTE: cagney/2003-02-03: Not yet.
81# mi_gdb_test "-interpreter-exec console \"break callee4\"" \
82# {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
83# "-interpreter-exec console \"break callee4\""
84mi_gdb_test "-interpreter-exec console \"break callee4\"" \
85 {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
86 "-interpreter-exec console \"break callee4\""
87
88mi_gdb_test "-interpreter-exec console \"info break\"" \
89 {\~"Num[ \t]*Type[ \t]*Disp[ \t]*Enb[ \t]*Address[ \t]*What\\n".*~"2[ \t]*breakpoint[ \t]*keep[ \t]*y[ \t]*0x[0-9A-Fa-f]+[ \t]*in callee4 at .*basics.c:[0-9]+\\n".*\^done} \
90 "-interpreter-exec console \"info break\""
91
92mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
5b9afe8a 93 ".*=cmd-param-changed,param=\"listsize\",value=\"1\".*\\^done" \
2fcf52f0
AC
94 "-interpreter-exec console \"set listsize 1\""
95
45f07fef 96# {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
2fcf52f0 97mi_gdb_test "-interpreter-exec console \"list\"" \
45f07fef 98 ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
2fcf52f0
AC
99 "-interpreter-exec console \"list\""
100
dd322c54 101mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \
18ac113b 102 { "" "disp=\"keep\"" } \
bb378428 103 "continue to callee4"
2fcf52f0
AC
104
105# NOTE: cagney/2003-02-03: Not yet.
106# mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
107# {.*=breakpoint-delete,number=\"2\".*\^done} \
108# "-interpreter-exec console \"delete 2\""
109mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
8d3788bd 110 {=breakpoint-deleted,id=\"2\"\r\n100\^done} \
2fcf52f0
AC
111 "-interpreter-exec console \"delete 2\""
112
113# NOTE: cagney/2003-02-03: Not yet.
114# mi_gdb_test "200-interpreter-exec console \"up\"" \
115# {.*=selected-frame-level-changed,level="1".*\^done} \
116# "-interpreter-exec console \"up\""
117mi_gdb_test "200-interpreter-exec console \"up\"" \
39fb8e9e 118 {~"#.*".*200\^done} \
2fcf52f0
AC
119 "-interpreter-exec console \"up\""
120
121# NOTE: cagney/2003-02-03: Not yet.
122# mi_gdb_test "300-interpreter-exec console \"down\"" \
123# {.*=selected-frame-level-changed,level="0".*\^done} \
124# "-interpreter-exec console \"down\""
125mi_gdb_test "300-interpreter-exec console \"down\"" \
39fb8e9e 126 {~"#.*".*300\^done} \
2fcf52f0
AC
127 "-interpreter-exec console \"down\""
128
129# NOTE: cagney/2003-02-03: Not yet.
130# mi_gdb_test "-interpreter-exec console \"frame 2\"" \
131# {.*=selected-frame-level-changed,level="2".*\^done} \
132# "-interpreter-exec console \"frame 2\""
133mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
39fb8e9e 134 {~"#.*".*400\^done} \
2fcf52f0
AC
135 "-interpreter-exec console \"frame 2\""
136
137# NOTE: cagney/2003-02-03: Not yet.
138# mi_gdb_test "-stack-select-frame 0" \
139# {.*=selected-frame-level-changed,level="0".*\^done} \
140# "-stack-select-frame 0"
141mi_gdb_test "500-stack-select-frame 0" \
142 {500\^done} \
143 "-stack-select-frame 0"
144
a065d7af
YQ
145# When a CLI command is entered in MI session, the respose is different in
146# sync and async modes. In sync mode normal_stop is called when current
147# interpreter is CLI. So:
148# - print_stop_reason prints stop reason in CLI uiout, and we don't show it
149# in MI
150# - The stop position is printed, and appears in MI 'console' channel.
151#
152# In async mode the stop event is processed when we're back to MI interpreter,
153# so the stop reason is printed into MI uiout an.
154if {$async} {
155 set reason "end-stepping-range"
156} else {
157 set reason ""
158}
159
160mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \
161 "" "check *stopped from CLI command"
162
2fcf52f0 163# NOTE: cagney/2003-02-03: Not yet.
45f07fef 164# mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
2fcf52f0 165# {.*=breakpoint-create,number="3".*\^done} \
45f07fef
MC
166# "-break-insert -t basics.c:\$line_main_hello"
167mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
2fcf52f0 168 {600\^done,bkpt=.number="3",type="breakpoint".*\}} \
a3569abd 169 "-break-insert -t basics.c:$line_main_hello"
2fcf52f0 170
18ac113b
AR
171mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \
172 $line_main_hello { "" "disp=\"del\"" } \
bb378428 173 "-exec-continue to line $line_main_hello"
2fcf52f0 174
a065d7af
YQ
175# Test that the token is output even for CLI commands
176# Also test that *stopped includes frame information.
177mi_gdb_test "34 next" \
178 ".*34\\\^running.*\\*running,thread-id=\"all\"" \
179 "34 next: run"
180
181if {!$async} {
182 gdb_expect {
183 -re "~\[^\r\n\]+\r\n" {
184 }
185 }
186}
187
188# Note that the output does not include stop reason. This is fine.
189# The purpose of *stopped notification for CLI command is to make
190# sure that frontend knows that inferior is stopped, and knows where.
191# Supplementary information is not necessary.
192mi_expect_stop "$reason" "main" "" ".*basics.c" $line_main_return "" \
193 "34 next: stop"
2fcf52f0
AC
194
195mi_gdb_test "-interpreter-exec console \"list\"" \
60c46647 196 "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \
45f07fef 197 "-interpreter-exec console \"list\" at basics.c:\$line_main_return"
2fcf52f0
AC
198
199mi_gdb_test "-interpreter-exec console \"help set args\"" \
200 {\~"Set argument list to give program being debugged when it is started\.\\nFollow this command with any number of args, to be passed to the program\.".*\^done} \
201 "-interpreter-exec console \"help set args\""
202
203# NOTE: cagney/2003-02-03: Not yet.
204# mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
205# {.*=target-changed.*\^done} \
206# "-interpreter-exec console \"set \$pc=0x0\""
207mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
208 {888\^done} \
209 "-interpreter-exec console \"set \$pc=0x0\""
210
211#mi_gdb_test "-interpreter-exec console \"\"" \
212 {} \
213 "-interpreter-exec console \"\""
214
215mi_gdb_exit
216return 0
This page took 1.566579 seconds and 4 git commands to generate.