]>
Commit | Line | Data |
---|---|---|
0fb0cc75 JB |
1 | # Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009 |
2 | # Free Software Foundation, Inc. | |
cbf1e085 AC |
3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 6 | # the Free Software Foundation; either version 3 of the License, or |
cbf1e085 | 7 | # (at your option) any later version. |
e22f8b7c | 8 | # |
cbf1e085 AC |
9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
e22f8b7c | 13 | # |
cbf1e085 | 14 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
cbf1e085 | 16 | |
cbf1e085 AC |
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 | |
21 | # handlers, etc. | |
22 | ||
23 | load_lib mi-support.exp | |
24 | set MIFLAGS "-i=mi" | |
25 | ||
26 | gdb_exit | |
27 | if [mi_gdb_start] { | |
28 | continue | |
29 | } | |
30 | ||
31 | set testfile "basics" | |
32 | set srcfile ${testfile}.c | |
3788363d | 33 | set binfile ${objdir}/${subdir}/mi-cli |
cbf1e085 | 34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { |
b60f0898 JB |
35 | untested mi-cli.exp |
36 | return -1 | |
cbf1e085 AC |
37 | } |
38 | ||
cbf1e085 AC |
39 | mi_gdb_test "-interpreter-exec" \ |
40 | {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ | |
41 | "-interpreter-exec with no arguments" | |
42 | ||
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" | |
46 | ||
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" | |
50 | ||
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" | |
55 | ||
56 | # NOTE: cagney/2003-02-03: Not yet. | |
57 | # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
58 | # {(=.*)+\^done} \ | |
59 | # "-interpreter-exec console \"file \$binfile\"" | |
60 | mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
3788363d | 61 | {~"Reading symbols from .*mi-cli...".*done} \ |
cbf1e085 AC |
62 | "-interpreter-exec console \"file \$binfile\"" |
63 | ||
64 | mi_run_to_main | |
65 | ||
45f07fef MC |
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] | |
70 | ||
cbf1e085 AC |
71 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
72 | {\^done} \ | |
73 | "-interpreter-exec console \"set args foobar\"" | |
74 | ||
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\"" | |
78 | ||
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\"" | |
86 | ||
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\"" | |
90 | ||
91 | mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ | |
92 | {\^done} \ | |
93 | "-interpreter-exec console \"set listsize 1\"" | |
94 | ||
45f07fef | 95 | # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } |
cbf1e085 | 96 | mi_gdb_test "-interpreter-exec console \"list\"" \ |
45f07fef | 97 | ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ |
cbf1e085 AC |
98 | "-interpreter-exec console \"list\"" |
99 | ||
6ae37fef | 100 | mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" "28" \ |
18ac113b | 101 | { "" "disp=\"keep\"" } "continue to callee4" |
cbf1e085 AC |
102 | |
103 | # NOTE: cagney/2003-02-03: Not yet. | |
104 | # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
105 | # {.*=breakpoint-delete,number=\"2\".*\^done} \ | |
106 | # "-interpreter-exec console \"delete 2\"" | |
107 | mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
108 | {100\^done} \ | |
109 | "-interpreter-exec console \"delete 2\"" | |
110 | ||
111 | # NOTE: cagney/2003-02-03: Not yet. | |
112 | # mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
113 | # {.*=selected-frame-level-changed,level="1".*\^done} \ | |
114 | # "-interpreter-exec console \"up\"" | |
115 | mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
39fb8e9e | 116 | {~"#.*".*200\^done} \ |
cbf1e085 AC |
117 | "-interpreter-exec console \"up\"" |
118 | ||
119 | # NOTE: cagney/2003-02-03: Not yet. | |
120 | # mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
121 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
122 | # "-interpreter-exec console \"down\"" | |
123 | mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
39fb8e9e | 124 | {~"#.*".*300\^done} \ |
cbf1e085 AC |
125 | "-interpreter-exec console \"down\"" |
126 | ||
127 | # NOTE: cagney/2003-02-03: Not yet. | |
128 | # mi_gdb_test "-interpreter-exec console \"frame 2\"" \ | |
129 | # {.*=selected-frame-level-changed,level="2".*\^done} \ | |
130 | # "-interpreter-exec console \"frame 2\"" | |
131 | mi_gdb_test "400-interpreter-exec console \"frame 2\"" \ | |
39fb8e9e | 132 | {~"#.*".*400\^done} \ |
cbf1e085 AC |
133 | "-interpreter-exec console \"frame 2\"" |
134 | ||
135 | # NOTE: cagney/2003-02-03: Not yet. | |
136 | # mi_gdb_test "-stack-select-frame 0" \ | |
137 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
138 | # "-stack-select-frame 0" | |
139 | mi_gdb_test "500-stack-select-frame 0" \ | |
140 | {500\^done} \ | |
141 | "-stack-select-frame 0" | |
142 | ||
f7c60c5e VP |
143 | # When a CLI command is entered in MI session, the respose is different in |
144 | # sync and async modes. In sync mode normal_stop is called when current | |
145 | # interpreter is CLI. So: | |
146 | # - print_stop_reason prints stop reason in CLI uiout, and we don't show it | |
147 | # in MI | |
148 | # - The stop position is printed, and appears in MI 'console' channel. | |
149 | # | |
150 | # In async mode the stop event is processed when we're back to MI interpreter, | |
151 | # so the stop reason is printed into MI uiout an. | |
152 | if {$async} { | |
153 | set reason "end-stepping-range" | |
154 | } else { | |
155 | set reason "" | |
156 | } | |
157 | ||
158 | mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" "29" \ | |
1d33d6ba VP |
159 | "" "check *stopped from CLI command" |
160 | ||
cbf1e085 | 161 | # NOTE: cagney/2003-02-03: Not yet. |
45f07fef | 162 | # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \ |
cbf1e085 | 163 | # {.*=breakpoint-create,number="3".*\^done} \ |
45f07fef MC |
164 | # "-break-insert -t basics.c:\$line_main_hello" |
165 | mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ | |
cbf1e085 | 166 | {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ |
45f07fef | 167 | "-break-insert -t basics.c:\$line_main_hello" |
cbf1e085 | 168 | |
18ac113b AR |
169 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \ |
170 | $line_main_hello { "" "disp=\"del\"" } \ | |
bb378428 | 171 | "-exec-continue to line $line_main_hello" |
cbf1e085 | 172 | |
1f31650a VP |
173 | # Test that the token is output even for CLI commands |
174 | # Also test that *stopped includes frame information. | |
175 | mi_gdb_test "34 next" \ | |
176 | ".*34\\\^running.*\\*running,thread-id=\"all\"" \ | |
177 | "34 next: run" | |
178 | ||
f7c60c5e VP |
179 | if {!$async} { |
180 | gdb_expect { | |
181 | -re "~\[^\r\n\]+\r\n" { | |
182 | } | |
1f31650a VP |
183 | } |
184 | } | |
185 | ||
186 | # Note that the output does not include stop reason. This is fine. | |
187 | # The purpose of *stopped notification for CLI command is to make | |
188 | # sure that frontend knows that inferior is stopped, and knows where. | |
189 | # Supplementary information is not necessary. | |
f7c60c5e | 190 | mi_expect_stop "$reason" "main" "" ".*basics.c" $line_main_return "" \ |
1f31650a | 191 | "34 next: stop" |
cbf1e085 AC |
192 | |
193 | mi_gdb_test "-interpreter-exec console \"list\"" \ | |
60c46647 | 194 | "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ |
45f07fef | 195 | "-interpreter-exec console \"list\" at basics.c:\$line_main_return" |
cbf1e085 AC |
196 | |
197 | mi_gdb_test "-interpreter-exec console \"help set args\"" \ | |
198 | {\~"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} \ | |
199 | "-interpreter-exec console \"help set args\"" | |
200 | ||
201 | # NOTE: cagney/2003-02-03: Not yet. | |
202 | # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \ | |
203 | # {.*=target-changed.*\^done} \ | |
204 | # "-interpreter-exec console \"set \$pc=0x0\"" | |
205 | mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \ | |
206 | {888\^done} \ | |
207 | "-interpreter-exec console \"set \$pc=0x0\"" | |
208 | ||
209 | #mi_gdb_test "-interpreter-exec console \"\"" \ | |
210 | {} \ | |
211 | "-interpreter-exec console \"\"" | |
212 | ||
213 | mi_gdb_exit | |
214 | return 0 |