Commit | Line | Data |
---|---|---|
b6ba6518 KB |
1 | # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1997, 1998, 1999, 2000, |
2 | # 2001 Free Software Foundation, Inc. | |
c906108c SS |
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 | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
beb998c6 | 8 | # |
c906108c SS |
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. | |
beb998c6 | 13 | # |
c906108c SS |
14 | # You should have received a copy of the GNU General Public License |
15 | # along with this program; if not, write to the Free Software | |
beb998c6 | 16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
c906108c SS |
17 | |
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # bug-gdb@prep.ai.mit.edu | |
20 | ||
21 | if $tracelevel then { | |
22 | strace $tracelevel | |
23 | } | |
24 | ||
25 | # | |
26 | # test special commands (if, while, etc) | |
27 | # | |
28 | set prms_id 0 | |
29 | set bug_id 0 | |
30 | ||
31 | set testfile "run" | |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/commands | |
34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
35 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
36 | } | |
37 | ||
38 | gdb_exit | |
39 | gdb_start | |
40 | delete_breakpoints | |
41 | gdb_reinitialize_dir $srcdir/$subdir | |
42 | gdb_load ${binfile} | |
43 | ||
44 | proc gdbvar_simple_if_test {} { | |
45 | global gdb_prompt | |
46 | ||
47 | gdb_test "set \$foo = 0" "" "set foo in gdbvar_simple_if_test" | |
48 | # All this test should do is print 0xdeadbeef once. | |
42f5c13f MS |
49 | gdb_test "if \$foo == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \ |
50 | "\\\$\[0-9\]* = 0xdeadbeef" "gdbvar_simple_if_test #1" | |
c906108c | 51 | # All this test should do is print 0xfeedface once. |
42f5c13f MS |
52 | gdb_test "if \$foo == 0\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \ |
53 | "\\\$\[0-9\]* = 0xfeedface" "gdbvar_simple_if_test #2" | |
c906108c SS |
54 | } |
55 | ||
56 | proc gdbvar_simple_while_test {} { | |
57 | global gdb_prompt | |
58 | ||
59 | gdb_test "set \$foo = 5" "" "set foo in gdbvar_simple_while_test" | |
60 | # This test should print 0xfeedface five times. | |
42f5c13f MS |
61 | gdb_test "while \$foo > 0\np/x 0xfeedface\nset \$foo -= 1\nend" \ |
62 | "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \ | |
63 | "gdbvar_simple_while_test #1" | |
c906108c SS |
64 | } |
65 | ||
66 | proc gdbvar_complex_if_while_test {} { | |
67 | global gdb_prompt | |
68 | ||
69 | gdb_test "set \$foo = 4" "" "set foo in gdbvar complex_if_while_test" | |
70 | # This test should alternate between 0xdeadbeef and 0xfeedface two times. | |
42f5c13f MS |
71 | gdb_test "while \$foo > 0\nset \$foo -= 1\nif \(\$foo % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \ |
72 | "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \ | |
73 | "gdbvar_complex_if_while_test #1" | |
c906108c SS |
74 | } |
75 | ||
76 | proc progvar_simple_if_test {} { | |
77 | global gdb_prompt | |
78 | ||
beb998c6 | 79 | if [target_info exists noargs] { |
c906108c SS |
80 | verbose "Skipping progvar_simple_if_test because of noargs." |
81 | return | |
82 | } | |
83 | ||
84 | if { ![runto factorial] } then { gdb_suppress_tests; } | |
42f5c13f MS |
85 | # Don't depend upon argument passing, since most simulators don't |
86 | # currently support it. Bash value variable to be what we want. | |
c906108c SS |
87 | gdb_test "p value=5" "" "set value to 5 in progvar_simple_if_test #1" |
88 | # All this test should do is print 0xdeadbeef once. | |
42f5c13f MS |
89 | gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \ |
90 | "\\\$\[0-9\]* = 0xdeadbeef" \ | |
91 | "progvar_simple_if_test #1" | |
c906108c | 92 | # All this test should do is print 0xfeedface once. |
42f5c13f MS |
93 | gdb_test "if value == 5\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \ |
94 | "\\\$\[0-9\]* = 0xfeedface" \ | |
95 | "progvar_simple_if_test #2" | |
c906108c SS |
96 | gdb_stop_suppressing_tests; |
97 | } | |
98 | ||
99 | proc progvar_simple_while_test {} { | |
100 | global gdb_prompt | |
101 | ||
beb998c6 | 102 | if [target_info exists noargs] { |
c906108c SS |
103 | verbose "Skipping progvar_simple_while_test because of noargs." |
104 | return | |
105 | } | |
106 | ||
085dd6e6 | 107 | gdb_test "set args 5" "" "set args in progvar_simple_while_test" |
c906108c | 108 | if { ![runto factorial] } then { gdb_suppress_tests } |
42f5c13f MS |
109 | # Don't depend upon argument passing, since most simulators don't |
110 | # currently support it. Bash value variable to be what we want. | |
c906108c SS |
111 | gdb_test "p value=5" "" "set value to 5 in progvar_simple_if_test #2" |
112 | # This test should print 0xfeedface five times. | |
42f5c13f MS |
113 | gdb_test "while value > 0\np/x 0xfeedface\nset value -= 1\nend" \ |
114 | "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \ | |
115 | "progvar_simple_while_test #1" | |
c906108c SS |
116 | gdb_stop_suppressing_tests; |
117 | } | |
118 | ||
119 | proc progvar_complex_if_while_test {} { | |
120 | global gdb_prompt | |
121 | ||
beb998c6 | 122 | if [target_info exists noargs] { |
c906108c SS |
123 | verbose "Skipping progvar_simple_if_while_test because of noargs." |
124 | return | |
125 | } | |
126 | ||
085dd6e6 | 127 | gdb_test "set args 4" "" "set args in progvar_complex_if_while_test" |
c906108c | 128 | if { ![runto factorial] } then { gdb_suppress_tests } |
42f5c13f MS |
129 | # Don't depend upon argument passing, since most simulators don't |
130 | # currently support it. Bash value variable to be what we want. | |
c906108c SS |
131 | gdb_test "p value=4" "" "set value to 4 in progvar_simple_if_test" |
132 | # This test should alternate between 0xdeadbeef and 0xfeedface two times. | |
42f5c13f MS |
133 | gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \ |
134 | "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \ | |
135 | "progvar_complex_if_while_test #1" | |
c906108c SS |
136 | gdb_stop_suppressing_tests; |
137 | } | |
138 | ||
139 | proc if_while_breakpoint_command_test {} { | |
beb998c6 | 140 | if [target_info exists noargs] { |
c906108c SS |
141 | verbose "Skipping if_while_breakpoint_command_test because of noargs." |
142 | return | |
143 | } | |
144 | ||
085dd6e6 | 145 | gdb_test "set args 5" "" "set args in if_while_breakpoint_command_test" |
c906108c | 146 | if { ![runto factorial] } then { gdb_suppress_tests } |
42f5c13f MS |
147 | # Don't depend upon argument passing, since most simulators don't |
148 | # currently support it. Bash value variable to be what we want. | |
c906108c SS |
149 | gdb_test "p value=5" "" "set value to 5 in progvar_simple_if_test" |
150 | delete_breakpoints | |
151 | gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #1" | |
152 | ||
153 | send_gdb "commands\n" | |
154 | gdb_expect { | |
155 | -re "End with" { | |
156 | pass "commands in if_while_breakpoint_command_test" | |
157 | } | |
158 | default { | |
159 | fail "(timeout or eof) commands in if_while_breakpoint_command_test" | |
160 | } | |
161 | } | |
162 | # This test should alternate between 0xdeadbeef and 0xfeedface two times. | |
42f5c13f MS |
163 | gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \ |
164 | "" \ | |
165 | "commands part 2 in if_while_breakpoint_command_test" | |
166 | gdb_test "continue" \ | |
167 | "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \ | |
168 | "if_while_breakpoint_command_test #1" | |
169 | gdb_test "info break" \ | |
170 | "while.*set.*if.*p/x.*else.*p/x.*end.*" \ | |
171 | "info break in if_while_breakpoint_command_test" | |
c906108c SS |
172 | gdb_stop_suppressing_tests; |
173 | } | |
174 | ||
175 | # Test that we can run the inferior from breakpoint commands. | |
02aa71d5 MC |
176 | # |
177 | # The expected behavior is that all commands after the first "step" | |
178 | # shall be ignored. See the gdb manual, "Break Commands", | |
179 | # subsection "Breakpoint command lists". | |
180 | ||
c906108c | 181 | proc infrun_breakpoint_command_test {} { |
beb998c6 | 182 | if [target_info exists noargs] { |
c906108c SS |
183 | verbose "Skipping infrun_breakpoint_command_test because of noargs." |
184 | return | |
185 | } | |
186 | ||
7dbd117d | 187 | gdb_test "set args 6" "" "set args in infrun_breakpoint_command_test" |
c906108c | 188 | if { ![runto factorial] } then { gdb_suppress_tests } |
42f5c13f MS |
189 | # Don't depend upon argument passing, since most simulators don't |
190 | # currently support it. Bash value variable to be what we want. | |
c906108c SS |
191 | gdb_test "p value=6" "" "set value to 6 in progvar_simple_if_test #1" |
192 | delete_breakpoints | |
193 | gdb_test "break factorial if value == 5" "Breakpoint.*at.*" | |
194 | ||
beb998c6 | 195 | # infrun_breakpoint_command_test - This test was broken into two parts |
c906108c SS |
196 | # to get around a synchronization problem in expect. |
197 | # part1: issue the gdb command "commands" | |
198 | # part2: send the list of commands | |
199 | send_gdb "commands\n" | |
200 | gdb_expect { | |
201 | -re "End with" { | |
202 | pass "commands in infrun_breakpoint_command_test #1" | |
203 | } | |
204 | default { | |
205 | fail "(timeout or eof) commands in infrun_breakpoint_command_test" | |
206 | } | |
207 | } | |
02aa71d5 | 208 | gdb_test "step\nstep\nstep\nstep\nend" "" \ |
c906108c | 209 | "commands in infrun_breakpoint_command_test #2" |
085dd6e6 | 210 | |
085dd6e6 | 211 | gdb_test "continue" \ |
42f5c13f MS |
212 | "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*" \ |
213 | "continue in infrun_breakpoint_command_test" | |
085dd6e6 | 214 | |
c906108c SS |
215 | gdb_stop_suppressing_tests; |
216 | } | |
217 | ||
218 | proc breakpoint_command_test {} { | |
beb998c6 | 219 | if [target_info exists noargs] { |
c906108c SS |
220 | verbose "Skipping breakpoint_command_test because of noargs." |
221 | return | |
222 | } | |
223 | ||
085dd6e6 | 224 | gdb_test "set args 6" "" "set args in breakpoint_command_test" |
c906108c | 225 | if { ![runto factorial] } then { gdb_suppress_tests; } |
42f5c13f MS |
226 | # Don't depend upon argument passing, since most simulators don't |
227 | # currently support it. Bash value variable to be what we want. | |
c906108c SS |
228 | gdb_test "p value=6" "" "set value to 6 in progvar_simple_if_test #2" |
229 | delete_breakpoints | |
230 | gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2" | |
231 | gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \ | |
085dd6e6 | 232 | "End with.*" "commands in breakpoint_command_test" |
42f5c13f MS |
233 | gdb_test "continue" \ |
234 | "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \ | |
c906108c SS |
235 | "continue in breakpoint_command_test" |
236 | gdb_test "print value" " = 5" "print value in breakpoint_command_test" | |
237 | gdb_stop_suppressing_tests; | |
238 | } | |
239 | ||
240 | # Test a simple user defined command (with arguments) | |
241 | proc user_defined_command_test {} { | |
242 | global gdb_prompt | |
243 | ||
244 | gdb_test "set \$foo = 4" "" "set foo in user_defined_command_test" | |
245 | ||
246 | send_gdb "define mycommand\n" | |
247 | gdb_expect { | |
248 | -re "End with" { | |
249 | pass "define mycommand in user_defined_command_test" | |
250 | } | |
251 | default { | |
252 | fail "(timeout or eof) define mycommand in user_defined_command_test" | |
253 | } | |
254 | } | |
255 | # This test should alternate between 0xdeadbeef and 0xfeedface two times. | |
42f5c13f MS |
256 | gdb_test "while \$arg0 > 0\nset \$arg0 -= 1\nif \(\$arg0 % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \ |
257 | "" \ | |
258 | "enter commands in user_defined_command_test" | |
259 | ||
260 | gdb_test "mycommand \$foo" \ | |
261 | "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \ | |
262 | "execute user defined command in user_defined_command_test" | |
263 | gdb_test "show user mycommand" \ | |
e6ccd35f | 264 | " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \ |
42f5c13f | 265 | "display user command in user_defined_command_test" |
c906108c SS |
266 | } |
267 | ||
085dd6e6 JM |
268 | proc watchpoint_command_test {} { |
269 | global noargs | |
270 | global gdb_prompt | |
271 | ||
beb998c6 | 272 | if [target_info exists noargs] { |
085dd6e6 JM |
273 | verbose "Skipping watchpoint_command_test because of noargs." |
274 | return | |
275 | } | |
276 | ||
277 | gdb_test "set args 6" "" "set args in watchpoint_command_test" | |
278 | if { ![runto factorial] } then { return } | |
279 | delete_breakpoints | |
280 | ||
281 | # Verify that we can create a watchpoint, and give it a commands | |
282 | # list that continues the inferior. We set the watchpoint on a | |
283 | # local variable, too, so that it self-deletes when the watched | |
284 | # data goes out of scope. | |
285 | # | |
286 | # What should happen is: Each time the watchpoint triggers, it | |
287 | # continues the inferior. Eventually, the watchpoint will self- | |
288 | # delete, when the watched variable is out of scope. But by that | |
289 | # time, the inferior should have exited. GDB shouldn't crash or | |
290 | # anything untoward as a result of this. | |
291 | # | |
292 | set wp_id -1 | |
293 | ||
294 | send_gdb "watch local_var\n" | |
295 | gdb_expect { | |
296 | -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" { | |
297 | set wp_id $expect_out(1,string) | |
298 | pass "watch local_var" | |
299 | } | |
300 | -re "$gdb_prompt $"\ | |
301 | {fail "watch local_var"} | |
302 | timeout {fail "(timeout) watch local_var"} | |
303 | } | |
7a292a7a | 304 | |
085dd6e6 JM |
305 | if {$wp_id == -1} {return} |
306 | ||
307 | send_gdb "commands $wp_id\n" | |
308 | gdb_expect { | |
42f5c13f MS |
309 | -re "Type commands for when breakpoint $wp_id is hit, one per line.*>" { |
310 | pass "begin commands on watch" | |
311 | } | |
312 | -re "$gdb_prompt $" {fail "begin commands on watch"} | |
313 | timeout {fail "(timeout) begin commands on watch"} | |
085dd6e6 JM |
314 | } |
315 | send_gdb "print value\n" | |
316 | gdb_expect { | |
42f5c13f MS |
317 | -re ">" {pass "add print command to watch"} |
318 | -re "$gdb_prompt $" {fail "add print command to watch"} | |
319 | timeout {fail "(timeout) add print command to watch"} | |
085dd6e6 JM |
320 | } |
321 | send_gdb "continue\n" | |
322 | gdb_expect { | |
42f5c13f MS |
323 | -re ">" {pass "add continue command to watch"} |
324 | -re "$gdb_prompt $" {fail "add continue command to watch"} | |
325 | timeout {fail "(timeout) add continue command to watch"} | |
085dd6e6 JM |
326 | } |
327 | send_gdb "end\n" | |
328 | gdb_expect { | |
7dbd117d MC |
329 | -re "$gdb_prompt $" {pass "end commands on watch"} |
330 | timeout {fail "(timeout) end commands on watch"} | |
085dd6e6 JM |
331 | } |
332 | send_gdb "continue\n" | |
333 | gdb_expect { | |
42f5c13f MS |
334 | -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:57.*$gdb_prompt $" { |
335 | pass "continue with watch" | |
336 | } | |
337 | -re "$gdb_prompt $" {fail "continue with watch"} | |
338 | timeout {fail "(timeout) continue with watch"} | |
085dd6e6 JM |
339 | } |
340 | } | |
7a292a7a SS |
341 | |
342 | proc test_command_prompt_position {} { | |
343 | global gdb_prompt | |
344 | ||
beb998c6 | 345 | if [target_info exists noargs] { |
7a292a7a SS |
346 | verbose "Skipping test_command_prompt_position because of noargs." |
347 | return | |
348 | } | |
349 | ||
350 | if { ![runto factorial] } then { gdb_suppress_tests; } | |
42f5c13f MS |
351 | # Don't depend upon argument passing, since most simulators don't |
352 | # currently support it. Bash value variable to be what we want. | |
7a292a7a | 353 | delete_breakpoints |
7dbd117d | 354 | gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #3" |
7a292a7a SS |
355 | gdb_test "p value=5" "" "set value to 5 in test_command_prompt_position" |
356 | # All this test should do is print 0xdeadbeef once. | |
42f5c13f MS |
357 | gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \ |
358 | "\\\$\[0-9\]* = 0xdeadbeef" \ | |
359 | "if test in test_command_prompt_position" | |
360 | ||
361 | # Now let's test for the correct position of the '>' in gdb's | |
362 | # prompt for commands. It should be at the beginning of the line, | |
363 | # and not after one space. | |
7a292a7a SS |
364 | |
365 | send_gdb "commands\n" | |
366 | gdb_expect { | |
42f5c13f MS |
367 | -re "Type commands.*End with.*\[\r\n\]>$" { |
368 | send_gdb "printf \"Now the value is %d\\n\", value\n" | |
369 | gdb_expect { | |
370 | -re "^printf.*value\r\n>$" { | |
371 | send_gdb "end\n" | |
372 | gdb_expect { | |
373 | -re "^end\r\n$gdb_prompt $" { | |
374 | pass "> OK in test_command_prompt_position" | |
375 | } | |
376 | -re ".*$gdb_prompt $" { | |
377 | fail "some other message in test_command_prompt_position" | |
378 | } | |
379 | timeout { | |
380 | fail "(timeout) 1 in test_command_prompt_position" | |
381 | } | |
382 | } | |
383 | } | |
384 | -re "^ >$" { fail "> not OK in test_command_prompt_position" } | |
385 | -re ".*$gdb_prompt $" { | |
386 | fail "wrong message in test_command_prompt_position" | |
387 | } | |
388 | timeout { | |
389 | fail "(timeout) 2 in test_command_prompt_position " | |
390 | } | |
391 | } | |
392 | } | |
393 | -re "Type commands.*End with.*\[\r\n\] >$" { | |
394 | fail "prompt not OK in test_command_prompt_position" | |
395 | } | |
396 | -re ".*$gdb_prompt $" { | |
397 | fail "commands in test_command_prompt_position" | |
7a292a7a | 398 | } |
42f5c13f MS |
399 | timeout { fail "(timeout) 3 commands in test_command_prompt_position" } |
400 | } | |
7a292a7a SS |
401 | |
402 | gdb_stop_suppressing_tests; | |
403 | } | |
404 | ||
405 | ||
003ba290 FN |
406 | |
407 | proc deprecated_command_test {} { | |
003ba290 | 408 | gdb_test "maintenance deprecate blah" "Can't find command.*" \ |
7dbd117d | 409 | "tried to deprecate non-existing command" |
003ba290 | 410 | |
7dbd117d | 411 | gdb_test "maintenance deprecate p \"new_p\"" "" "maintenance deprecate p \"new_p\" /1/" |
42f5c13f MS |
412 | gdb_test "p 5" \ |
413 | "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \ | |
414 | "p deprecated warning, with replacement" | |
7dbd117d | 415 | gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /1/" |
003ba290 | 416 | |
7dbd117d | 417 | gdb_test "maintenance deprecate p \"new_p\"" "" "maintenance deprecate p \"new_p\" /2/" |
003ba290 | 418 | gdb_test "maintenance deprecate print \"new_print\"" "" |
42f5c13f MS |
419 | gdb_test "p 5" \ |
420 | "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \ | |
421 | "both alias and command are deprecated" | |
7dbd117d | 422 | gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /2/" |
003ba290 | 423 | |
42f5c13f MS |
424 | gdb_test "maintenance deprecate set remote memory-read-packet-size \"srm\" " \ |
425 | "" \ | |
7dbd117d | 426 | "deprecate long command /1/" |
42f5c13f MS |
427 | gdb_test "set remote memory-read-packet-size" \ |
428 | "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \ | |
7dbd117d | 429 | "long command deprecated /1/" |
42f5c13f MS |
430 | |
431 | gdb_test "maintenance deprecate set remote memory-read-packet-size" \ | |
432 | "" \ | |
7dbd117d | 433 | "deprecate long command /2/" |
42f5c13f MS |
434 | gdb_test "set remote memory-read-packet-size" \ |
435 | "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \ | |
7dbd117d | 436 | "long command deprecated with no alternative /2/" |
42f5c13f MS |
437 | |
438 | gdb_test "maintenance deprecate" \ | |
439 | "\"maintenance deprecate\".*" \ | |
440 | "deprecate with no arguments" | |
003ba290 FN |
441 | } |
442 | ||
c2b8ed2c MS |
443 | proc bp_deleted_in_command_test {} { |
444 | global gdb_prompt | |
445 | ||
446 | gdb_test "set args 1" "" "set args in bp_deleted_in_command_test" | |
447 | delete_breakpoints | |
448 | ||
449 | # Create a breakpoint, and associate a command-list to it, with | |
450 | # one command that deletes this breakpoint. | |
451 | gdb_test "break factorial" \ | |
452 | "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \ | |
453 | "breakpoint in bp_deleted_in_command_test" | |
454 | ||
455 | send_gdb "commands\n" | |
456 | gdb_expect { | |
457 | -re "Type commands for when breakpoint .* is hit, one per line.*>" { | |
458 | pass "begin commands in bp_deleted_in_command_test" | |
459 | } | |
460 | -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"} | |
461 | timeout {fail "(timeout) begin commands bp_deleted_in_command_test"} | |
462 | } | |
463 | send_gdb "silent\n" | |
464 | gdb_expect { | |
465 | -re ">" {pass "add silent command"} | |
466 | -re "$gdb_prompt $" {fail "add silent command"} | |
467 | timeout {fail "(timeout) add silent command"} | |
468 | } | |
469 | send_gdb "clear factorial\n" | |
470 | gdb_expect { | |
471 | -re ">" {pass "add clear command"} | |
472 | -re "$gdb_prompt $" {fail "add clear command"} | |
473 | timeout {fail "(timeout) add clear command"} } | |
474 | send_gdb "printf \"factorial command-list executed\\n\"\n" | |
475 | gdb_expect { | |
476 | -re ">" {pass "add printf command"} | |
477 | -re "$gdb_prompt $" {fail "add printf command"} | |
478 | timeout {fail "(timeout) add printf command"} | |
479 | } | |
480 | send_gdb "cont\n" | |
481 | gdb_expect { | |
482 | -re ">" {pass "add cont command"} | |
483 | -re "$gdb_prompt $" {fail "add cont command"} | |
484 | timeout {fail "(timeout) add cont command"} } | |
485 | send_gdb "end\n" | |
486 | gdb_expect { | |
487 | -re "$gdb_prompt $" {pass "end commands"} | |
488 | timeout {fail "(timeout) end commands"} | |
489 | } | |
003ba290 | 490 | |
c2b8ed2c MS |
491 | gdb_run_cmd |
492 | gdb_expect { | |
b2b4a1b5 | 493 | -re ".*factorial command-list executed.*1.*$gdb_prompt $" { |
c2b8ed2c MS |
494 | pass "run factorial until breakpoint" |
495 | } | |
496 | -re ".*$gdb_prompt $" { | |
497 | fail "run factorial until breakpoint" | |
498 | } | |
499 | default { fail "(timeout) run factorial until breakpoint" } | |
500 | timeout { fail "(timeout) run factorial until breakpoint" } | |
501 | } | |
502 | } | |
503 | ||
504 | proc temporary_breakpoint_commands {} { | |
505 | global gdb_prompt | |
506 | ||
507 | gdb_test "set args 1" "" "set args in temporary_breakpoint_commands" | |
508 | delete_breakpoints | |
509 | ||
510 | # Create a temporary breakpoint, and associate a commands list to it. | |
511 | # This test will verify that this commands list is executed when the | |
512 | # breakpoint is hit. | |
513 | gdb_test "tbreak factorial" \ | |
514 | "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \ | |
515 | "breakpoint in temporary_breakpoint_commands" | |
516 | ||
517 | send_gdb "commands\n" | |
518 | gdb_expect { | |
519 | -re "Type commands for when breakpoint .* is hit, one per line.*>" { | |
520 | pass "begin commands in bp_deleted_in_command_test" | |
521 | } | |
522 | -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"} | |
523 | timeout {fail "(timeout) begin commands bp_deleted_in_command_test"} | |
524 | } | |
525 | send_gdb "silent\n" | |
526 | gdb_expect { | |
527 | -re ">" {pass "add silent tbreak command"} | |
528 | -re "$gdb_prompt $" {fail "add silent tbreak command"} | |
529 | timeout {fail "(timeout) add silent tbreak command"} | |
530 | } | |
531 | send_gdb "printf \"factorial tbreak commands executed\\n\"\n" | |
532 | gdb_expect { | |
533 | -re ">" {pass "add printf tbreak command"} | |
534 | -re "$gdb_prompt $" {fail "add printf tbreak command"} | |
535 | timeout {fail "(timeout) add printf tbreak command"} | |
536 | } | |
537 | send_gdb "cont\n" | |
538 | gdb_expect { | |
539 | -re ">" {pass "add cont tbreak command"} | |
540 | -re "$gdb_prompt $" {fail "add cont tbreak command"} | |
541 | timeout {fail "(timeout) add cont tbreak command"} } | |
542 | send_gdb "end\n" | |
543 | gdb_expect { | |
544 | -re "$gdb_prompt $" {pass "end tbreak commands"} | |
545 | timeout {fail "(timeout) end tbreak commands"} | |
546 | } | |
547 | ||
548 | gdb_run_cmd | |
549 | gdb_expect { | |
b2b4a1b5 | 550 | -re ".*factorial tbreak commands executed.*1.*$gdb_prompt $" { |
c2b8ed2c MS |
551 | pass "run factorial until temporary breakpoint" |
552 | } | |
553 | timeout { fail "(timeout) run factorial until temporary breakpoint" } | |
554 | } | |
555 | } | |
556 | ||
c906108c SS |
557 | gdbvar_simple_if_test |
558 | gdbvar_simple_while_test | |
559 | gdbvar_complex_if_while_test | |
560 | progvar_simple_if_test | |
561 | progvar_simple_while_test | |
562 | progvar_complex_if_while_test | |
563 | if_while_breakpoint_command_test | |
564 | infrun_breakpoint_command_test | |
565 | breakpoint_command_test | |
566 | user_defined_command_test | |
085dd6e6 | 567 | watchpoint_command_test |
7a292a7a | 568 | test_command_prompt_position |
003ba290 | 569 | deprecated_command_test |
c2b8ed2c MS |
570 | bp_deleted_in_command_test |
571 | temporary_breakpoint_commands |