]>
Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright 2002-2013 Free Software Foundation, Inc. |
2fcf52f0 AC |
2 | |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
2fcf52f0 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
2fcf52f0 AC |
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. | |
e22f8b7c | 12 | # |
2fcf52f0 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
2fcf52f0 | 15 | |
2fcf52f0 AC |
16 | # This file tests that GDB's console can be accessed via the MI. |
17 | # Specifically, we are testing the "interpreter-exec" command and that | |
18 | # the commands that are executed via this command are properly executed. | |
19 | # Console commands executed via MI should use MI output wrappers, MI event | |
20 | # handlers, etc. | |
21 | ||
22 | load_lib mi-support.exp | |
91567807 | 23 | set MIFLAGS "-i=mi" |
2fcf52f0 AC |
24 | |
25 | gdb_exit | |
26 | if [mi_gdb_start] { | |
27 | continue | |
28 | } | |
29 | ||
298a9cf0 TT |
30 | standard_testfile basics.c |
31 | ||
9357e021 | 32 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { |
91567807 | 33 | untested mi-cli.exp |
b60f0898 | 34 | return -1 |
2fcf52f0 AC |
35 | } |
36 | ||
2fcf52f0 | 37 | mi_gdb_test "-interpreter-exec" \ |
1b05df00 | 38 | {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \ |
2fcf52f0 AC |
39 | "-interpreter-exec with no arguments" |
40 | ||
41 | mi_gdb_test "-interpreter-exec console" \ | |
1b05df00 | 42 | {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \ |
2fcf52f0 AC |
43 | "-interpreter-exec with one argument" |
44 | ||
45 | mi_gdb_test "-interpreter-exec bogus command" \ | |
1b05df00 | 46 | {\^error,msg="-interpreter-exec: could not find interpreter \\\"bogus\\\""} \ |
2fcf52f0 AC |
47 | "-interpreter-exec with bogus interpreter" |
48 | ||
49 | set msg {Undefined command: \\\"bogus\\\"\. Try \\\"help\\\"\.} | |
50 | mi_gdb_test "-interpreter-exec console bogus" \ | |
51 | "&\\\"$msg\\\\n\\\".*\\^error,msg=\\\"$msg\\\".*" \ | |
52 | "-interpreter-exec console bogus" | |
53 | ||
54 | # NOTE: cagney/2003-02-03: Not yet. | |
55 | # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
56 | # {(=.*)+\^done} \ | |
57 | # "-interpreter-exec console \"file \$binfile\"" | |
58 | mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
91567807 | 59 | {~"Reading symbols from .*mi-cli...".*\^done} \ |
2fcf52f0 AC |
60 | "-interpreter-exec console \"file \$binfile\"" |
61 | ||
62 | mi_run_to_main | |
63 | ||
dd322c54 JK |
64 | set line_main_head [gdb_get_line_number "main ("] |
65 | set line_main_body [expr $line_main_head + 2] | |
66 | set line_main_hello [gdb_get_line_number "Hello, World!"] | |
67 | set line_main_return [expr $line_main_hello + 2] | |
68 | set line_callee4_head [gdb_get_line_number "callee4 ("] | |
69 | set line_callee4_body [expr $line_callee4_head + 2] | |
a065d7af | 70 | set line_callee4_next [expr $line_callee4_body + 1] |
45f07fef | 71 | |
2fcf52f0 | 72 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
5b9afe8a | 73 | ".*=cmd-param-changed,param=\"args\",value=\"foobar\".*\\^done" \ |
2fcf52f0 AC |
74 | "-interpreter-exec console \"set args foobar\"" |
75 | ||
76 | mi_gdb_test "-interpreter-exec console \"show args\"" \ | |
77 | {\~"Argument list to give program being debugged when it is started is \\\"foobar\\\"\.\\n".*\^done} \ | |
78 | "-interpreter-exec console \"show args\"" | |
79 | ||
2fcf52f0 | 80 | mi_gdb_test "-interpreter-exec console \"break callee4\"" \ |
a1e5fd69 YQ |
81 | {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done} \ |
82 | "-interpreter-exec console \"break callee4\"" | |
2fcf52f0 AC |
83 | |
84 | mi_gdb_test "-interpreter-exec console \"info break\"" \ | |
85 | {\~"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} \ | |
86 | "-interpreter-exec console \"info break\"" | |
87 | ||
88 | mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ | |
5b9afe8a | 89 | ".*=cmd-param-changed,param=\"listsize\",value=\"1\".*\\^done" \ |
2fcf52f0 AC |
90 | "-interpreter-exec console \"set listsize 1\"" |
91 | ||
45f07fef | 92 | # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } |
2fcf52f0 | 93 | mi_gdb_test "-interpreter-exec console \"list\"" \ |
45f07fef | 94 | ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ |
2fcf52f0 AC |
95 | "-interpreter-exec console \"list\"" |
96 | ||
dd322c54 | 97 | mi_execute_to "exec-continue" "breakpoint-hit" "callee4" "" ".*basics.c" $line_callee4_body \ |
18ac113b | 98 | { "" "disp=\"keep\"" } \ |
bb378428 | 99 | "continue to callee4" |
2fcf52f0 | 100 | |
2fcf52f0 | 101 | mi_gdb_test "100-interpreter-exec console \"delete 2\"" \ |
a1e5fd69 YQ |
102 | {.*=breakpoint-deleted,id=\"2\".*\^done} \ |
103 | "-interpreter-exec console \"delete 2\"" | |
2fcf52f0 AC |
104 | |
105 | # NOTE: cagney/2003-02-03: Not yet. | |
106 | # mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
107 | # {.*=selected-frame-level-changed,level="1".*\^done} \ | |
108 | # "-interpreter-exec console \"up\"" | |
109 | mi_gdb_test "200-interpreter-exec console \"up\"" \ | |
39fb8e9e | 110 | {~"#.*".*200\^done} \ |
2fcf52f0 AC |
111 | "-interpreter-exec console \"up\"" |
112 | ||
113 | # NOTE: cagney/2003-02-03: Not yet. | |
114 | # mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
115 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
116 | # "-interpreter-exec console \"down\"" | |
117 | mi_gdb_test "300-interpreter-exec console \"down\"" \ | |
39fb8e9e | 118 | {~"#.*".*300\^done} \ |
2fcf52f0 AC |
119 | "-interpreter-exec console \"down\"" |
120 | ||
121 | # NOTE: cagney/2003-02-03: Not yet. | |
122 | # mi_gdb_test "-interpreter-exec console \"frame 2\"" \ | |
123 | # {.*=selected-frame-level-changed,level="2".*\^done} \ | |
124 | # "-interpreter-exec console \"frame 2\"" | |
125 | mi_gdb_test "400-interpreter-exec console \"frame 2\"" \ | |
39fb8e9e | 126 | {~"#.*".*400\^done} \ |
2fcf52f0 AC |
127 | "-interpreter-exec console \"frame 2\"" |
128 | ||
129 | # NOTE: cagney/2003-02-03: Not yet. | |
130 | # mi_gdb_test "-stack-select-frame 0" \ | |
131 | # {.*=selected-frame-level-changed,level="0".*\^done} \ | |
132 | # "-stack-select-frame 0" | |
133 | mi_gdb_test "500-stack-select-frame 0" \ | |
134 | {500\^done} \ | |
135 | "-stack-select-frame 0" | |
136 | ||
a065d7af YQ |
137 | # When a CLI command is entered in MI session, the respose is different in |
138 | # sync and async modes. In sync mode normal_stop is called when current | |
139 | # interpreter is CLI. So: | |
140 | # - print_stop_reason prints stop reason in CLI uiout, and we don't show it | |
141 | # in MI | |
142 | # - The stop position is printed, and appears in MI 'console' channel. | |
143 | # | |
144 | # In async mode the stop event is processed when we're back to MI interpreter, | |
145 | # so the stop reason is printed into MI uiout an. | |
146 | if {$async} { | |
147 | set reason "end-stepping-range" | |
148 | } else { | |
149 | set reason "" | |
150 | } | |
151 | ||
152 | mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \ | |
153 | "" "check *stopped from CLI command" | |
154 | ||
45f07fef | 155 | mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ |
2fcf52f0 | 156 | {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ |
8ae551cf | 157 | "-break-insert -t basics.c:\$line_main_hello" |
2fcf52f0 | 158 | |
18ac113b AR |
159 | mi_execute_to "exec-continue" "breakpoint-hit" "main" "" ".*basics.c" \ |
160 | $line_main_hello { "" "disp=\"del\"" } \ | |
8ae551cf | 161 | "-exec-continue to line \$line_main_hello" |
2fcf52f0 | 162 | |
a065d7af YQ |
163 | # Test that the token is output even for CLI commands |
164 | # Also test that *stopped includes frame information. | |
165 | mi_gdb_test "34 next" \ | |
166 | ".*34\\\^running.*\\*running,thread-id=\"all\"" \ | |
167 | "34 next: run" | |
168 | ||
169 | if {!$async} { | |
170 | gdb_expect { | |
171 | -re "~\[^\r\n\]+\r\n" { | |
172 | } | |
173 | } | |
174 | } | |
175 | ||
176 | # Note that the output does not include stop reason. This is fine. | |
177 | # The purpose of *stopped notification for CLI command is to make | |
178 | # sure that frontend knows that inferior is stopped, and knows where. | |
179 | # Supplementary information is not necessary. | |
180 | mi_expect_stop "$reason" "main" "" ".*basics.c" $line_main_return "" \ | |
181 | "34 next: stop" | |
2fcf52f0 AC |
182 | |
183 | mi_gdb_test "-interpreter-exec console \"list\"" \ | |
60c46647 | 184 | "\~\"$line_main_return\[\\\\t ]*callme \\(1\\);\\\\n\".*\\^done" \ |
45f07fef | 185 | "-interpreter-exec console \"list\" at basics.c:\$line_main_return" |
2fcf52f0 AC |
186 | |
187 | mi_gdb_test "-interpreter-exec console \"help set args\"" \ | |
188 | {\~"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} \ | |
189 | "-interpreter-exec console \"help set args\"" | |
190 | ||
191 | # NOTE: cagney/2003-02-03: Not yet. | |
192 | # mi_gdb_test "-interpreter-exec console \"set \$pc=0x0\"" \ | |
193 | # {.*=target-changed.*\^done} \ | |
194 | # "-interpreter-exec console \"set \$pc=0x0\"" | |
195 | mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \ | |
196 | {888\^done} \ | |
197 | "-interpreter-exec console \"set \$pc=0x0\"" | |
198 | ||
199 | #mi_gdb_test "-interpreter-exec console \"\"" \ | |
200 | {} \ | |
201 | "-interpreter-exec console \"\"" | |
202 | ||
203 | mi_gdb_exit | |
204 | return 0 |