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_test "-interpreter-exec" \
40 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
41 "-interpreter-exec with no arguments"
43 mi_gdb_test "-interpreter-exec console" \
44 {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \
45 "-interpreter-exec with one argument"
47 mi_gdb_test "-interpreter-exec bogus command" \
48 {\^error,msg="mi_cmd_interpreter_exec: could not find interpreter \\\"bogus\\\""} \
49 "-interpreter-exec with bogus interpreter"
51 set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.}
52 mi_gdb_test "-interpreter-exec console bogus" \
53 "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \
54 "-interpreter-exec console bogus"
56 # NOTE: cagney/2003-02-03: Not yet.
57 # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
59 # "-interpreter-exec console \"file \$binfile\""
60 mi_gdb_test "-interpreter-exec console \"file $binfile\"" \
61 {~"Reading symbols from .*basics...".*\^done} \
62 "-interpreter-exec console \"file \$binfile\""
66 set line_main_head [gdb_get_line_number "main ("]
67 set line_main_body [expr $line_main_head + 2]
68 set line_main_hello [gdb_get_line_number "Hello, World!"]
69 set line_main_return [expr $line_main_hello + 2]
71 mi_gdb_test "-interpreter-exec console \"set args foobar\"" \
73 "-interpreter-exec console \"set args foobar\""
75 mi_gdb_test "-interpreter-exec console \"show args\"" \
76 {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \
77 "-interpreter-exec console \"show args\""
79 # NOTE: cagney/2003-02-03: Not yet.
80 # mi_gdb_test "-interpreter-exec console \"break callee4\"" \
81 # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \
82 # "-interpreter-exec console \"break callee4\""
83 mi_gdb_test "-interpreter-exec console \"break callee4\"" \
84 {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \
85 "-interpreter-exec console \"break callee4\""
87 mi_gdb_test "-interpreter-exec console \"info break\"" \
88 {\~"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} \
89 "-interpreter-exec console \"info break\""
91 mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \
93 "-interpreter-exec console \"set listsize 1\""
95 # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done }
96 mi_gdb_test "-interpreter-exec console \"list\"" \
97 ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \
98 "-interpreter-exec console \"list\""
100 # # NOTE: cagney/2003-02-03: Not yet.
101 # mi_gdb_test "-exec-continue" \
102 # {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",line="8"\}} \
103 # "-interpreter-exec console \"continue to callee4\""
104 send_gdb "999-exec-continue\n"
106 -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" {
107 pass "continue to callee4"
110 fail "continue to callee4 (timeout)"
114 # NOTE: cagney/2003-02-03: Not yet.
115 # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
116 # {.*=breakpoint-delete,number=\"2\".*\^done} \
117 # "-interpreter-exec console \"delete 2\""
118 mi_gdb_test "100-interpreter-exec console \"delete 2\"" \
120 "-interpreter-exec console \"delete 2\""
122 # NOTE: cagney/2003-02-03: Not yet.
123 # mi_gdb_test "200-interpreter-exec console \"up\"" \
124 # {.*=selected-frame-level-changed,level="1".*\^done} \
125 # "-interpreter-exec console \"up\""
126 mi_gdb_test "200-interpreter-exec console \"up\"" \
127 {~"#.*".*200\^done} \
128 "-interpreter-exec console \"up\""
130 # NOTE: cagney/2003-02-03: Not yet.
131 # mi_gdb_test "300-interpreter-exec console \"down\"" \
132 # {.*=selected-frame-level-changed,level="0".*\^done} \
133 # "-interpreter-exec console \"down\""
134 mi_gdb_test "300-interpreter-exec console \"down\"" \
135 {~"#.*".*300\^done} \
136 "-interpreter-exec console \"down\""
138 # NOTE: cagney/2003-02-03: Not yet.
139 # mi_gdb_test "-interpreter-exec console \"frame 2\"" \
140 # {.*=selected-frame-level-changed,level="2".*\^done} \
141 # "-interpreter-exec console \"frame 2\""
142 mi_gdb_test "400-interpreter-exec console \"frame 2\"" \
143 {~"#.*".*400\^done} \
144 "-interpreter-exec console \"frame 2\""
146 # NOTE: cagney/2003-02-03: Not yet.
147 # mi_gdb_test "-stack-select-frame 0" \
148 # {.*=selected-frame-level-changed,level="0".*\^done} \
149 # "-stack-select-frame 0"
150 mi_gdb_test "500-stack-select-frame 0" \
152 "-stack-select-frame 0"
154 # NOTE: cagney/2003-02-03: Not yet.
155 # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \
156 # {.*=breakpoint-create,number="3".*\^done} \
157 # "-break-insert -t basics.c:\$line_main_hello"
158 mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \
159 {600\^done,bkpt=.number="3",type="breakpoint".*\}} \
160 "-break-insert -t basics.c:\$line_main_hello"
162 # mi_gdb_test "-exec-continue" \
163 # {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \
164 # "-exec-continue to line \$line_main_hello"
165 send_gdb "700-exec-continue\n"
167 -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" {
168 pass "-exec-continue to line \$line_main_hello"
171 fail "-exec-continue to line \$line_main_hello"
175 # NOTE: cagney/2003-02-03: Not yet.
176 # mi_gdb_test "-exec-next" \
177 # {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \
178 # "-exec-next to line \$line_main_return"
179 send_gdb "800-exec-next\n"
181 -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$" {
182 pass "-exec-next to line \$line_main_return"
185 fail "-exec-next to line \$line_main_return"
189 mi_gdb_test "-interpreter-exec console \"list\"" \
190 "\~\"$line_main_return\[\\\\t ]*return 0;\\\\n\".*\\^done" \
191 "-interpreter-exec console \"list\" at basics.c:\$line_main_return"
193 mi_gdb_test "-interpreter-exec console \"help set args\"" \
194 {\~"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} \
195 "-interpreter-exec console \"help set args\""
197 # NOTE: cagney/2003-02-03: Not yet.
198 # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \
199 # {.*=target-changed.*\^done} \
200 # "-interpreter-exec console \"set \$pc=0x0\""
201 mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
203 "-interpreter-exec console \"set \$pc=0x0\""
205 #mi_gdb_test "-interpreter-exec console \"\"" \
207 "-interpreter-exec console \"\""