1 # Copyright 2002, 2003, 2004, 2005, 2007 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 # This file tests that GDB's console can be accessed via the MI.
18 # Specifically, we are testing the "interpreter-exec" command and that
19 # the commands that are executed via this command are properly executed.
20 # Console commands executed via MI should use MI output wrappers, MI event
23 load_lib mi-support.exp
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/${testfile}
34 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
39 mi_gdb_reinitialize_dir $srcdir/$subdir
41 mi_gdb_test "-interpreter-exec" \
42 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
43 "-interpreter-exec with no arguments"
45 mi_gdb_test "-interpreter-exec console" \
46 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
47 "-interpreter-exec with one argument"
49 mi_gdb_test "-interpreter-exec bogus command" \
50 {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
51 "-interpreter-exec with bogus interpreter"
53 set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.}
54 mi_gdb_test "-interpreter-exec console bogus" \
55 "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
56 "-interpreter-exec console bogus"
58 # NOTE: cagney/2003-02-03: Not yet.
59 # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
61 # "-interpreter-exec console \"file \$binfile\""
62 mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
63 {~"Reading symbols from .*basics...".*done} \
64 "-interpreter-exec console \"file \$binfile\""
68 set line_main_head [gdb_get_line_number "main ("]
69 set line_main_body [expr $line_main_head + 2]
70 set line_main_hello [gdb_get_line_number "Hello, World!"]
71 set line_main_return [expr $line_main_hello + 2]
73 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
75 "-interpreter-exec console \"set args foobar\""
77 mi_gdb_test "-interpreter-exec console \"show args\"" \
78 {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
79 "-interpreter-exec console \"show args\""
81 # NOTE: cagney/2003-02-03: Not yet.
82 # mi_gdb_test "-interpreter-exec console \"break callee4\"" \
83 # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
84 # "-interpreter-exec console \"break callee4\""
85 mi_gdb_test "-interpreter-exec console \"break callee4\"" \
86 {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
87 "-interpreter-exec console \"break callee4\""
89 mi_gdb_test "-interpreter-exec console \"info break\"" \
90 {\~"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} \
91 "-interpreter-exec console \"info break\""
93 mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
95 "-interpreter-exec console \"set listsize 1\""
97 # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
98 mi_gdb_test "-interpreter-exec console \"list\"" \
99 ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
100 "-interpreter-exec console \"list\""
102 # # NOTE: cagney/2003-02-03: Not yet.
103 # mi_gdb_test "-exec-continue" \
104 # {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="8"\}} \
105 # "-interpreter-exec console \"continue to callee4\""
106 send_gdb "999-exec-continue\n"
108 -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
109 pass "continue to callee4"
112 fail "continue to callee4 (timeout)"
116 # NOTE: cagney/2003-02-03: Not yet.
117 # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
118 # {.*=breakpoint-delete,number=\"2\".*\^done} \
119 # "-interpreter-exec console \"delete 2\""
120 mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
122 "-interpreter-exec console \"delete 2\""
124 # NOTE: cagney/2003-02-03: Not yet.
125 # mi_gdb_test "200-interpreter-exec console \"up\"" \
126 # {.*=selected-frame-level-changed,level="1".*\^done} \
127 # "-interpreter-exec console \"up\""
128 mi_gdb_test "200-interpreter-exec console \"up\"" \
129 {~"#.*".*200\^done} \
130 "-interpreter-exec console \"up\""
132 # NOTE: cagney/2003-02-03: Not yet.
133 # mi_gdb_test "300-interpreter-exec console \"down\"" \
134 # {.*=selected-frame-level-changed,level="0".*\^done} \
135 # "-interpreter-exec console \"down\""
136 mi_gdb_test "300-interpreter-exec console \"down\"" \
137 {~"#.*".*300\^done} \
138 "-interpreter-exec console \"down\""
140 # NOTE: cagney/2003-02-03: Not yet.
141 # mi_gdb_test "-interpreter-exec console \"frame 2\"" \
142 # {.*=selected-frame-level-changed,level="2".*\^done} \
143 # "-interpreter-exec console \"frame 2\""
144 mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
145 {~"#.*".*400\^done} \
146 "-interpreter-exec console \"frame 2\""
148 # NOTE: cagney/2003-02-03: Not yet.
149 # mi_gdb_test "-stack-select-frame 0" \
150 # {.*=selected-frame-level-changed,level="0".*\^done} \
151 # "-stack-select-frame 0"
152 mi_gdb_test "500-stack-select-frame 0" \
154 "-stack-select-frame 0"
156 # NOTE: cagney/2003-02-03: Not yet.
157 # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
158 # {.*=breakpoint-create,number="3".*\^done} \
159 # "-break-insert -t basics.c:\$line_main_hello"
160 mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
161 {600\^done,bkpt=.number="3",type="breakpoint".*\}} \
162 "-break-insert -t basics.c:\$line_main_hello"
164 # mi_gdb_test "-exec-continue" \
165 # {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \
166 # "-exec-continue to line \$line_main_hello"
167 send_gdb "700-exec-continue\n"
169 -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" {
170 pass "-exec-continue to line \$line_main_hello"
173 fail "-exec-continue to line \$line_main_hello"
177 # NOTE: cagney/2003-02-03: Not yet.
178 # mi_gdb_test "-exec-next" \
179 # {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \
180 # "-exec-next to line \$line_main_return"
181 send_gdb "800-exec-next\n"
183 -re "800\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped,reason=.end-stepping-range.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_return.*$mi_gdb_prompt$" {
184 pass "-exec-next to line \$line_main_return"
187 fail "-exec-next to line \$line_main_return"
191 mi_gdb_test "-interpreter-exec console \"list\"" \
192 "\~\"$line_main_return\[\\\\t ]*return 0;\\\\n\".*\\^done" \
193 "-interpreter-exec console \"list\" at basics.c:\$line_main_return"
195 mi_gdb_test "-interpreter-exec console \"help set args\"" \
196 {\~"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} \
197 "-interpreter-exec console \"help set args\""
199 # NOTE: cagney/2003-02-03: Not yet.
200 # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
201 # {.*=target-changed.*\^done} \
202 # "-interpreter-exec console \"set \$pc=0x0\""
203 mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
205 "-interpreter-exec console \"set \$pc=0x0\""
207 #mi_gdb_test "-interpreter-exec console \"\"" \
209 "-interpreter-exec console \"\""