Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 2002, 2003, 2004, 2005, 2007 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 | |
5 | # the Free Software Foundation; either version 2 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
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. | |
12 | # | |
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. | |
16 | ||
2fcf52f0 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=mi2" | |
25 | ||
26 | gdb_exit | |
27 | if [mi_gdb_start] { | |
28 | continue | |
29 | } | |
30 | ||
31 | set testfile "basics" | |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
35 | untested mi2-cli.exp |
36 | return -1 | |
2fcf52f0 AC |
37 | } |
38 | ||
39 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
40 | ||
41 | mi_gdb_test "-interpreter-exec" \ | |
42 | {\^error,msg="mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"} \ | |
43 | "-interpreter-exec with no arguments" | |
44 | ||
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" | |
48 | ||
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" | |
52 | ||
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" | |
57 | ||
58 | # NOTE: cagney/2003-02-03: Not yet. | |
59 | # mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
60 | # {(=.*)+\^done} \ | |
61 | # "-interpreter-exec console \"file \$binfile\"" | |
62 | mi_gdb_test "-interpreter-exec console \"file $binfile\"" \ | |
39fb8e9e | 63 | {~"Reading symbols from .*basics...".*\^done} \ |
2fcf52f0 AC |
64 | "-interpreter-exec console \"file \$binfile\"" |
65 | ||
66 | mi_run_to_main | |
67 | ||
45f07fef MC |
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] | |
72 | ||
2fcf52f0 AC |
73 | mi_gdb_test "-interpreter-exec console \"set args foobar\"" \ |
74 | {\^done} \ | |
75 | "-interpreter-exec console \"set args foobar\"" | |
76 | ||
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\"" | |
80 | ||
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\"" | |
88 | ||
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\"" | |
92 | ||
93 | mi_gdb_test "-interpreter-exec console \"set listsize 1\"" \ | |
94 | {\^done} \ | |
95 | "-interpreter-exec console \"set listsize 1\"" | |
96 | ||
45f07fef | 97 | # {.*\~"32[ \t(\\t)]*callee1.*\\n".*\^done } |
2fcf52f0 | 98 | mi_gdb_test "-interpreter-exec console \"list\"" \ |
45f07fef | 99 | ".*\~\"$line_main_body\[\\\\t \]*callee1.*;\\\\n\".*\\^done" \ |
2fcf52f0 AC |
100 | "-interpreter-exec console \"list\"" |
101 | ||
102 | # # NOTE: cagney/2003-02-03: Not yet. | |
103 | # mi_gdb_test "-exec-continue" \ | |
104 | # {.*\*stopped,reason="breakpoint-hit",.*func="callee4".*file=".*basics.c",line="8"\}} \ | |
105 | # "-interpreter-exec console \"continue to callee4\"" | |
106 | send_gdb "999-exec-continue\n" | |
107 | gdb_expect { | |
108 | -re "999\\^running\[\r\n\]+$mi_gdb_prompt.*999\\*stopped,reason=.breakpoint-hit.*$mi_gdb_prompt$" { | |
109 | pass "continue to callee4" | |
110 | } | |
111 | timeout { | |
112 | fail "continue to callee4 (timeout)" | |
113 | } | |
114 | } | |
115 | ||
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\"" \ | |
121 | {100\^done} \ | |
122 | "-interpreter-exec console \"delete 2\"" | |
123 | ||
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\"" \ | |
39fb8e9e | 129 | {~"#.*".*200\^done} \ |
2fcf52f0 AC |
130 | "-interpreter-exec console \"up\"" |
131 | ||
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\"" \ | |
39fb8e9e | 137 | {~"#.*".*300\^done} \ |
2fcf52f0 AC |
138 | "-interpreter-exec console \"down\"" |
139 | ||
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\"" \ | |
39fb8e9e | 145 | {~"#.*".*400\^done} \ |
2fcf52f0 AC |
146 | "-interpreter-exec console \"frame 2\"" |
147 | ||
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" \ | |
153 | {500\^done} \ | |
154 | "-stack-select-frame 0" | |
155 | ||
156 | # NOTE: cagney/2003-02-03: Not yet. | |
45f07fef | 157 | # mi_gdb_test "-break-insert -t basics.c:$line_main_hello" \ |
2fcf52f0 | 158 | # {.*=breakpoint-create,number="3".*\^done} \ |
45f07fef MC |
159 | # "-break-insert -t basics.c:\$line_main_hello" |
160 | mi_gdb_test "600-break-insert -t basics.c:$line_main_hello" \ | |
2fcf52f0 | 161 | {600\^done,bkpt=.number="3",type="breakpoint".*\}} \ |
45f07fef | 162 | "-break-insert -t basics.c:\$line_main_hello" |
2fcf52f0 AC |
163 | |
164 | # mi_gdb_test "-exec-continue" \ | |
76ff342d | 165 | # {.*\*stopped.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_hello"\}} \ |
45f07fef | 166 | # "-exec-continue to line \$line_main_hello" |
2fcf52f0 AC |
167 | send_gdb "700-exec-continue\n" |
168 | gdb_expect { | |
76ff342d | 169 | -re "700\\^running\[\r\n\]+$mi_gdb_prompt.*\\*stopped.*,file=\".*basics.c\",fullname=\"${fullname_syntax}${srcfile}\",line=.$line_main_hello.*$mi_gdb_prompt$" { |
45f07fef | 170 | pass "-exec-continue to line \$line_main_hello" |
2fcf52f0 AC |
171 | } |
172 | timeout { | |
45f07fef | 173 | fail "-exec-continue to line \$line_main_hello" |
2fcf52f0 AC |
174 | } |
175 | } | |
176 | ||
177 | # NOTE: cagney/2003-02-03: Not yet. | |
178 | # mi_gdb_test "-exec-next" \ | |
76ff342d | 179 | # {.*\*stopped,reason="end-stepping-range",.*,file=".*basics.c",fullname="${fullname_syntax}${srcfile}",line="$line_main_return"\}} \ |
45f07fef | 180 | # "-exec-next to line \$line_main_return" |
2fcf52f0 AC |
181 | send_gdb "800-exec-next\n" |
182 | gdb_expect { | |
76ff342d | 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$" { |
45f07fef | 184 | pass "-exec-next to line \$line_main_return" |
2fcf52f0 AC |
185 | } |
186 | timeout { | |
45f07fef | 187 | fail "-exec-next to line \$line_main_return" |
2fcf52f0 AC |
188 | } |
189 | } | |
190 | ||
191 | mi_gdb_test "-interpreter-exec console \"list\"" \ | |
45f07fef MC |
192 | "\~\"$line_main_return\[\\\\t ]*return 0;\\\\n\".*\\^done" \ |
193 | "-interpreter-exec console \"list\" at basics.c:\$line_main_return" | |
2fcf52f0 AC |
194 | |
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\"" | |
198 | ||
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\"" \ | |
204 | {888\^done} \ | |
205 | "-interpreter-exec console \"set \$pc=0x0\"" | |
206 | ||
207 | #mi_gdb_test "-interpreter-exec console \"\"" \ | |
208 | {} \ | |
209 | "-interpreter-exec console \"\"" | |
210 | ||
211 | mi_gdb_exit | |
212 | return 0 |