2003-02-05 Keith Seitz <keiths@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-cli.exp
CommitLineData
cbf1e085
AC
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
26load_lib mi-support.exp
27set MIFLAGS "-i=mi"
28
29gdb_exit
30if [mi_gdb_start] {
31 continue
32}
33
34set testfile "basics"
35set srcfile ${testfile}.c
36set binfile ${objdir}/${subdir}/${testfile}
37if { [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
41mi_gdb_reinitialize_dir $srcdir/$subdir
42
43mi_gdb_test "-interpreter-exec" \
44 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
45 "-interpreter-exec with no arguments"
46
47mi_gdb_test "-interpreter-exec console" \
48 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
49 "-interpreter-exec with one argument"
50
51mi_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
55set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.}
56mi_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\""
64mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
65 {\^done} \
66 "-interpreter-exec console \"file \$binfile\""
67
68mi_run_to_main
69
70mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
71 {\^done} \
72 "-interpreter-exec console \"set args foobar\""
73
74mi_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\""
82mi_gdb_test "-interpreter-exec console \"break callee4\"" \
83 {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
84 "-interpreter-exec console \"break callee4\""
85
86mi_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
90mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
91 {\^done} \
92 "-interpreter-exec console \"set listsize 1\""
93
94mi_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\""
102send_gdb "999-exec-continue\n"
103gdb_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\""
116mi_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\""
124mi_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\""
132mi_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\""
140mi_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"
148mi_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"
156mi_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"
163send_gdb "700-exec-continue\n"
164gdb_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"
177send_gdb "800-exec-next\n"
178gdb_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
187mi_gdb_test "-interpreter-exec console \"list\"" \
188 {\~"37[ \t(\\t)]*return 0;\\n".*\^done} \
189 "-interpreter-exec console \"list\" at basics.c:37"
190
191mi_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\""
199mi_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
207mi_gdb_exit
208return 0
This page took 0.064461 seconds and 4 git commands to generate.