1 # Copyright 2002, 2003 Free Software Foundation, Inc.
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
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
26 load_lib mi-support.exp
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."
41 mi_gdb_reinitialize_dir $srcdir/$subdir
43 mi_gdb_test "-interpreter-exec" \
44 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
45 "-interpreter-exec with no arguments"
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"
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"
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"
60 # NOTE: cagney/2003-02-03: Not yet.
61 # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
63 # "-interpreter-exec console \"file \$binfile\""
64 mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
66 "-interpreter-exec console \"file \$binfile\""
70 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
72 "-interpreter-exec console \"set args foobar\""
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\""
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\""
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\""
90 mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
92 "-interpreter-exec console \"set listsize 1\""
94 mi_gdb_test "-interpreter-exec console \"list\"" \
95 {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done} \
96 "-interpreter-exec console \"list\""
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"
104 -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
105 pass "continue to callee4"
108 fail "continue to callee4 (timeout)"
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\"" \
118 "-interpreter-exec console \"delete 2\""
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\"" \
126 "-interpreter-exec console \"up\""
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\"" \
134 "-interpreter-exec console \"down\""
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\"" \
142 "-interpreter-exec console \"frame 2\""
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" \
150 "-stack-select-frame 0"
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"
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"
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"
169 fail "-exec-continue to line 35"
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"
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"
183 fail "-exec-next to line 37"
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"
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\""
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\"" \
201 "-interpreter-exec console \"set \$pc=0x0\""
203 #mi_gdb_test "-interpreter-exec console \"\"" \
205 "-interpreter-exec console \"\""