2003-02-05 Keith Seitz <keiths@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-cli.exp
1 # Copyright 2002, 2003 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file tests that GDB's console can be accessed via the MI.
21 # Specifically, we are testing the "interpreter-exec" command and that
22 # the commands that are executed via this command are properly executed.
23 # Console commands executed via MI should use MI output wrappers, MI event
24 # handlers, etc.
25
26 load_lib mi-support.exp
27 set MIFLAGS "-i=mi"
28
29 gdb_exit
30 if [mi_gdb_start] {
31 continue
32 }
33
34 set testfile "basics"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
38 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
39 }
40
41 mi_gdb_reinitialize_dir $srcdir/$subdir
42
43 mi_gdb_test "-interpreter-exec" \
44 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
45 "-interpreter-exec with no arguments"
46
47 mi_gdb_test "-interpreter-exec console" \
48 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
49 "-interpreter-exec with one argument"
50
51 mi_gdb_test "-interpreter-exec bogus command" \
52 {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
53 "-interpreter-exec with bogus interpreter"
54
55 set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.}
56 mi_gdb_test "-interpreter-exec console bogus" \
57 "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
58 "-interpreter-exec console bogus"
59
60 # NOTE: cagney/2003-02-03: Not yet.
61 # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
62 # {(=.*)+\^done} \
63 # "-interpreter-exec console \"file \$binfile\""
64 mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
65 {\^done} \
66 "-interpreter-exec console \"file \$binfile\""
67
68 mi_run_to_main
69
70 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
71 {\^done} \
72 "-interpreter-exec console \"set args foobar\""
73
74 mi_gdb_test "-interpreter-exec console \"show args\"" \
75 {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
76 "-interpreter-exec console \"show args\""
77
78 # NOTE: cagney/2003-02-03: Not yet.
79 # mi_gdb_test "-interpreter-exec console \"break callee4\"" \
80 # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
81 # "-interpreter-exec console \"break callee4\""
82 mi_gdb_test "-interpreter-exec console \"break callee4\"" \
83 {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
84 "-interpreter-exec console \"break callee4\""
85
86 mi_gdb_test "-interpreter-exec console \"info break\"" \
87 {\~"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} \
88 "-interpreter-exec console \"info break\""
89
90 mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
91 {\^done} \
92 "-interpreter-exec console \"set listsize 1\""
93
94 mi_gdb_test "-interpreter-exec console \"list\"" \
95 {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done} \
96 "-interpreter-exec console \"list\""
97
98 # # NOTE: cagney/2003-02-03: Not yet.
99 # mi_gdb_test "-exec-continue" \
100 # {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",line="8"\}} \
101 # "-interpreter-exec console \"continue to callee4\""
102 send_gdb "999-exec-continue\n"
103 gdb_expect {
104 -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
105 pass "continue to callee4"
106 }
107 timeout {
108 fail "continue to callee4 (timeout)"
109 }
110 }
111
112 # NOTE: cagney/2003-02-03: Not yet.
113 # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
114 # {.*=breakpoint-delete,number=\"2\".*\^done} \
115 # "-interpreter-exec console \"delete 2\""
116 mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
117 {100\^done} \
118 "-interpreter-exec console \"delete 2\""
119
120 # NOTE: cagney/2003-02-03: Not yet.
121 # mi_gdb_test "200-interpreter-exec console \"up\"" \
122 # {.*=selected-frame-level-changed,level="1".*\^done} \
123 # "-interpreter-exec console \"up\""
124 mi_gdb_test "200-interpreter-exec console \"up\"" \
125 {200\^done} \
126 "-interpreter-exec console \"up\""
127
128 # NOTE: cagney/2003-02-03: Not yet.
129 # mi_gdb_test "300-interpreter-exec console \"down\"" \
130 # {.*=selected-frame-level-changed,level="0".*\^done} \
131 # "-interpreter-exec console \"down\""
132 mi_gdb_test "300-interpreter-exec console \"down\"" \
133 {300\^done} \
134 "-interpreter-exec console \"down\""
135
136 # NOTE: cagney/2003-02-03: Not yet.
137 # mi_gdb_test "-interpreter-exec console \"frame 2\"" \
138 # {.*=selected-frame-level-changed,level="2".*\^done} \
139 # "-interpreter-exec console \"frame 2\""
140 mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
141 {400\^done} \
142 "-interpreter-exec console \"frame 2\""
143
144 # NOTE: cagney/2003-02-03: Not yet.
145 # mi_gdb_test "-stack-select-frame 0" \
146 # {.*=selected-frame-level-changed,level="0".*\^done} \
147 # "-stack-select-frame 0"
148 mi_gdb_test "500-stack-select-frame 0" \
149 {500\^done} \
150 "-stack-select-frame 0"
151
152 # NOTE: cagney/2003-02-03: Not yet.
153 # mi_gdb_test "-break-insert -t basics.c:35" \
154 # {.*=breakpoint-create,number="3".*\^done} \
155 # "-break-insert -t basics.c:35"
156 mi_gdb_test "600-break-insert -t basics.c:35" \
157 {600\^done,bkpt=.number="3",type="breakpoint".*\}} \
158 "-break-insert -t basics.c:35"
159
160 # mi_gdb_test "-exec-continue" \
161 # {.*\*stopped.*,file=".*basics.c",line="35"\}} \
162 # "-exec-continue to line 35"
163 send_gdb "700-exec-continue\n"
164 gdb_expect {
165 -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=.*basics.c.,line=.35.*$mi_gdb_prompt$" {
166 pass "-exec-continue to line 35"
167 }
168 timeout {
169 fail "-exec-continue to line 35"
170 }
171 }
172
173 # NOTE: cagney/2003-02-03: Not yet.
174 # mi_gdb_test "-exec-next" \
175 # {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",line="37"\}} \
176 # "-exec-next to line 37"
177 send_gdb "800-exec-next\n"
178 gdb_expect {
179 -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=.*basics.c.,line=.37.*$mi_gdb_prompt$" {
180 pass "-exec-next to line 37"
181 }
182 timeout {
183 fail "-exec-next to line 37"
184 }
185 }
186
187 mi_gdb_test "-interpreter-exec console \"list\"" \
188 {\~"37[ \t(\\t)]*return 0;\\n".*\^done} \
189 "-interpreter-exec console \"list\" at basics.c:37"
190
191 mi_gdb_test "-interpreter-exec console \"help set args\"" \
192 {\~"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} \
193 "-interpreter-exec console \"help set args\""
194
195 # NOTE: cagney/2003-02-03: Not yet.
196 # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
197 # {.*=target-changed.*\^done} \
198 # "-interpreter-exec console \"set \$pc=0x0\""
199 mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
200 {888\^done} \
201 "-interpreter-exec console \"set \$pc=0x0\""
202
203 #mi_gdb_test "-interpreter-exec console \"\"" \
204 {} \
205 "-interpreter-exec console \"\""
206
207 mi_gdb_exit
208 return 0
This page took 0.034368 seconds and 5 git commands to generate.