Commit | Line | Data |
---|---|---|
4c38e0a4 | 1 | # Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
0fb0cc75 | 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 | ||
dd322c54 JK |
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 | set line_callee4_head [gdb_get_line_number "callee4 ("] | |
71 | set line_callee4_body [expr $line_callee4_head + 2] | |
72 | set line_callee4_next [expr $line_callee4_body + 1] | |
45f07fef | 73 | |
cbf1e085 AC |
74 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
75 | {\^done} \ | |
76 | "-interpreter-exec console \"set args foobar\"" | |
77 | ||
78 | mi_gdb_test "-interpreter-exec console \"show args\"" \ | |
79 | {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \ | |
80 | "-interpreter-exec console \"show args\"" | |
81 | ||
82 | # NOTE: cagney/2003-02-03: Not yet. | |
83 | # mi_gdb_test "-interpreter-exec console \"break callee4\"" \ | |
84 | # {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-create,number="2".*\^done} \ | |
85 | # "-interpreter-exec console \"break callee4\"" | |
86 | mi_gdb_test "-interpreter-exec console \"break callee4\"" \ | |
87 | {(&.*)*.*~"Breakpoint 2 at.*\\n".*\^done} \ | |
88 | "-interpreter-exec console \"break callee4\"" | |
89 | ||
90 | mi_gdb_test "-interpreter-exec console \"info break\"" \ | |
91 | {\~"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} \ | |
92 | "-interpreter-exec console \"info break\"" | |
93 | ||
94 | mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ | |
95 | {\^done} \ | |
96 | "-interpreter-exec console \"set listsize 1\"" | |
97 | ||
45f07fef | 98 | # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } |
cbf1e085 | 99 | mi_gdb_test "-interpreter-exec console \"list\"" \ |
45f07fef | 100 | ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ |
cbf1e085 AC |
101 | "-interpreter-exec console \"list\"" |
102 | ||
dd322c54 | 103 | mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \ |
18ac113b | 104 | { "" "disp=\"keep\"" } "continue to callee4" |
cbf1e085 AC |
105 | |
106 | # NOTE: cagney/2003-02-03: Not yet. | |
107 | # mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
108 | # {.*=breakpoint-delete,number=\"2\".*\^done} \ | |
109 | # "-interpreter-exec console \"delete 2\"" | |
110 | mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ | |
111 | {100\^done} \ | |
112 | "-interpreter-exec console \"delete 2\"" | |
113 | ||
114 | # NOTE: cagney/2003-02-03: Not yet. | |
115 | # mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
116 | # {.*=selected-frame-level-changed,level="1".*\^done} \ | |
117 | # "-interpreter-exec console \"up\"" | |
118 | mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
39fb8e9e | 119 | {~"#.*".*200\^done} \ |
cbf1e085 AC |
120 | "-interpreter-exec console \"up\"" |
121 | ||
122 | # NOTE: cagney/2003-02-03: Not yet. | |
123 | # mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
124 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
125 | # "-interpreter-exec console \"down\"" | |
126 | mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
39fb8e9e | 127 | {~"#.*".*300\^done} \ |
cbf1e085 AC |
128 | "-interpreter-exec console \"down\"" |
129 | ||
130 | # NOTE: cagney/2003-02-03: Not yet. | |
131 | # mi_gdb_test "-interpreter-exec console \"frame 2\"" \ | |
132 | # {.*=selected-frame-level-changed,level="2".*\^done} \ | |
133 | # "-interpreter-exec console \"frame 2\"" | |
134 | mi_gdb_test "400-interpreter-exec console \"frame 2\"" \ | |
39fb8e9e | 135 | {~"#.*".*400\^done} \ |
cbf1e085 AC |
136 | "-interpreter-exec console \"frame 2\"" |
137 | ||
138 | # NOTE: cagney/2003-02-03: Not yet. | |
139 | # mi_gdb_test "-stack-select-frame 0" \ | |
140 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
141 | # "-stack-select-frame 0" | |
142 | mi_gdb_test "500-stack-select-frame 0" \ | |
143 | {500\^done} \ | |
144 | "-stack-select-frame 0" | |
145 | ||
f7c60c5e VP |
146 | # When a CLI command is entered in MI session, the respose is different in |
147 | # sync and async modes. In sync mode normal_stop is called when current | |
148 | # interpreter is CLI. So: | |
149 | # - print_stop_reason prints stop reason in CLI uiout, and we don't show it | |
150 | # in MI | |
151 | # - The stop position is printed, and appears in MI 'console' channel. | |
152 | # | |
153 | # In async mode the stop event is processed when we're back to MI interpreter, | |
154 | # so the stop reason is printed into MI uiout an. | |
155 | if {$async} { | |
156 | set reason "end-stepping-range" | |
157 | } else { | |
158 | set reason "" | |
159 | } | |
160 | ||
dd322c54 | 161 | mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \ |
1d33d6ba VP |
162 | "" "check *stopped from CLI command" |
163 | ||
cbf1e085 | 164 | # NOTE: cagney/2003-02-03: Not yet. |
45f07fef | 165 | # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \ |
cbf1e085 | 166 | # {.*=breakpoint-create,number="3".*\^done} \ |
45f07fef MC |
167 | # "-break-insert -t basics.c:\$line_main_hello" |
168 | mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ | |
cbf1e085 | 169 | {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ |
45f07fef | 170 | "-break-insert -t basics.c:\$line_main_hello" |
cbf1e085 | 171 | |
18ac113b AR |
172 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \ |
173 | $line_main_hello { "" "disp=\"del\"" } \ | |
bb378428 | 174 | "-exec-continue to line $line_main_hello" |
cbf1e085 | 175 | |
1f31650a VP |
176 | # Test that the token is output even for CLI commands |
177 | # Also test that *stopped includes frame information. | |
178 | mi_gdb_test "34 next" \ | |
179 | ".*34\\\^running.*\\*running,thread-id=\"all\"" \ | |
180 | "34 next: run" | |
181 | ||
f7c60c5e VP |
182 | if {!$async} { |
183 | gdb_expect { | |
184 | -re "~\[^\r\n\]+\r\n" { | |
185 | } | |
1f31650a VP |
186 | } |
187 | } | |
188 | ||
189 | # Note that the output does not include stop reason. This is fine. | |
190 | # The purpose of *stopped notification for CLI command is to make | |
191 | # sure that frontend knows that inferior is stopped, and knows where. | |
192 | # Supplementary information is not necessary. | |
f7c60c5e | 193 | mi_expect_stop "$reason" "main" "" ".*basics.c" $line_main_return "" \ |
1f31650a | 194 | "34 next: stop" |
cbf1e085 AC |
195 | |
196 | mi_gdb_test "-interpreter-exec console \"list\"" \ | |
60c46647 | 197 | "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ |
45f07fef | 198 | "-interpreter-exec console \"list\" at basics.c:\$line_main_return" |
cbf1e085 AC |
199 | |
200 | mi_gdb_test "-interpreter-exec console \"help set args\"" \ | |
201 | {\~"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} \ | |
202 | "-interpreter-exec console \"help set args\"" | |
203 | ||
204 | # NOTE: cagney/2003-02-03: Not yet. | |
205 | # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \ | |
206 | # {.*=target-changed.*\^done} \ | |
207 | # "-interpreter-exec console \"set \$pc=0x0\"" | |
208 | mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \ | |
209 | {888\^done} \ | |
210 | "-interpreter-exec console \"set \$pc=0x0\"" | |
211 | ||
212 | #mi_gdb_test "-interpreter-exec console \"\"" \ | |
213 | {} \ | |
214 | "-interpreter-exec console \"\"" | |
215 | ||
216 | mi_gdb_exit | |
217 | return 0 |