1 # Copyright 1988-2013 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # test special commands (if, while, etc)
20 if { [prepare_for_testing commands.exp commands run.c {debug additional_flags=-DFAKEARGV}] } {
24 proc gdbvar_simple_if_test {} {
27 gdb_test_no_output "set \$foo = 0" "set foo in gdbvar_simple_if_test"
28 # All this test should do is print 0xdeadbeef once.
29 gdb_test "if \$foo == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
30 "\\\$\[0-9\]* = 0xdeadbeef" "gdbvar_simple_if_test #1"
31 # All this test should do is print 0xfeedface once.
32 gdb_test "if \$foo == 0\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
33 "\\\$\[0-9\]* = 0xfeedface" "gdbvar_simple_if_test #2"
36 proc gdbvar_simple_while_test {} {
39 gdb_test_no_output "set \$foo = 5" "set foo in gdbvar_simple_while_test"
40 # This test should print 0xfeedface five times.
41 gdb_test "while \$foo > 0\np/x 0xfeedface\nset \$foo -= 1\nend" \
42 "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
43 "gdbvar_simple_while_test #1"
46 proc gdbvar_complex_if_while_test {} {
49 gdb_test_no_output "set \$foo = 4" \
50 "set foo in gdbvar complex_if_while_test"
51 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
52 gdb_test "while \$foo > 0\nset \$foo -= 1\nif \(\$foo % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
53 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
54 "gdbvar_complex_if_while_test #1"
57 proc progvar_simple_if_test {} {
60 if [target_info exists noargs] {
61 verbose "Skipping progvar_simple_if_test because of noargs."
65 if { ![runto factorial] } then { gdb_suppress_tests; }
66 # Don't depend upon argument passing, since most simulators don't
67 # currently support it. Bash value variable to be what we want.
68 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #1"
69 # All this test should do is print 0xdeadbeef once.
70 gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
71 "\\\$\[0-9\]* = 0xdeadbeef" \
72 "progvar_simple_if_test #1"
73 # All this test should do is print 0xfeedface once.
74 gdb_test "if value == 5\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
75 "\\\$\[0-9\]* = 0xfeedface" \
76 "progvar_simple_if_test #2"
77 gdb_stop_suppressing_tests
80 proc progvar_simple_while_test {} {
83 if [target_info exists noargs] {
84 verbose "Skipping progvar_simple_while_test because of noargs."
88 gdb_test_no_output "set args 5" "set args in progvar_simple_while_test"
89 if { ![runto factorial] } then { gdb_suppress_tests }
90 # Don't depend upon argument passing, since most simulators don't
91 # currently support it. Bash value variable to be what we want.
92 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #2"
93 # This test should print 0xfeedface five times.
94 gdb_test "while value > 0\np/x 0xfeedface\nset value -= 1\nend" \
95 "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
96 "progvar_simple_while_test #1"
97 gdb_stop_suppressing_tests
100 proc progvar_complex_if_while_test {} {
103 if [target_info exists noargs] {
104 verbose "Skipping progvar_simple_if_while_test because of noargs."
108 gdb_test_no_output "set args 4" \
109 "set args in progvar_complex_if_while_test"
110 if { ![runto factorial] } then { gdb_suppress_tests }
111 # Don't depend upon argument passing, since most simulators don't
112 # currently support it. Bash value variable to be what we want.
113 gdb_test "p value=4" ".*" "set value to 4 in progvar_simple_if_test"
114 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
115 gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
116 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
117 "progvar_complex_if_while_test #1"
118 gdb_stop_suppressing_tests
121 proc if_while_breakpoint_command_test {} {
122 if [target_info exists noargs] {
123 verbose "Skipping if_while_breakpoint_command_test because of noargs."
127 gdb_test_no_output "set args 5" \
128 "set args in if_while_breakpoint_command_test"
129 if { ![runto factorial] } then { gdb_suppress_tests }
130 # Don't depend upon argument passing, since most simulators don't
131 # currently support it. Bash value variable to be what we want.
132 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test"
134 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #1"
136 gdb_test_multiple "commands" \
137 "commands in if_while_breakpoint_command_test" {
139 pass "commands in if_while_breakpoint_command_test"
143 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
144 gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
146 "commands part 2 in if_while_breakpoint_command_test"
147 gdb_test "continue" \
148 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
149 "if_while_breakpoint_command_test #1"
150 gdb_test "info break" \
151 "while.*set.*if.*p/x.*else.*p/x.*end.*" \
152 "info break in if_while_breakpoint_command_test"
153 gdb_stop_suppressing_tests
156 # Test that we can run the inferior from breakpoint commands.
158 # The expected behavior is that all commands after the first "step"
159 # shall be ignored. See the gdb manual, "Break Commands",
160 # subsection "Breakpoint command lists".
162 proc infrun_breakpoint_command_test {} {
163 if [target_info exists noargs] {
164 verbose "Skipping infrun_breakpoint_command_test because of noargs."
168 gdb_test_no_output "set args 6" \
169 "set args in infrun_breakpoint_command_test"
170 if { ![runto factorial] } then { gdb_suppress_tests }
171 # Don't depend upon argument passing, since most simulators don't
172 # currently support it. Bash value variable to be what we want.
173 gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #1"
175 gdb_test "break factorial if value == 5" "Breakpoint.*at.*"
177 # infrun_breakpoint_command_test - This test was broken into two parts
178 # to get around a synchronization problem in expect.
179 # part1: issue the gdb command "commands"
180 # part2: send the list of commands
181 gdb_test_multiple "commands" \
182 "commands in infrun_breakpoint_command_test #1" {
184 pass "commands in infrun_breakpoint_command_test #1"
187 gdb_test "step\nstep\nstep\nstep\nend" "" \
188 "commands in infrun_breakpoint_command_test #2"
190 gdb_test "continue" \
191 "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*" \
192 "continue in infrun_breakpoint_command_test"
194 gdb_stop_suppressing_tests
197 proc breakpoint_command_test {} {
198 if [target_info exists noargs] {
199 verbose "Skipping breakpoint_command_test because of noargs."
203 gdb_test_no_output "set args 6" "set args in breakpoint_command_test"
204 if { ![runto factorial] } then { gdb_suppress_tests; }
205 # Don't depend upon argument passing, since most simulators don't
206 # currently support it. Bash value variable to be what we want.
207 gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #2"
209 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2"
210 gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \
211 "End with.*" "commands in breakpoint_command_test"
212 gdb_test "continue" \
213 "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \
214 "continue in breakpoint_command_test"
215 gdb_test "print value" " = 5" "print value in breakpoint_command_test"
216 gdb_stop_suppressing_tests
219 # Test a simple user defined command (with arguments)
220 proc user_defined_command_test {} {
223 gdb_test_no_output "set \$foo = 4" \
224 "set foo in user_defined_command_test"
226 gdb_test_multiple "define mycommand" \
227 "define mycommand in user_defined_command_test" {
229 pass "define mycommand in user_defined_command_test"
233 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
234 gdb_test "while \$arg0 > 0\nset \$arg0 -= 1\nif \(\$arg0 % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
236 "enter commands in user_defined_command_test"
238 gdb_test "mycommand \$foo" \
239 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
240 "execute user defined command in user_defined_command_test"
241 gdb_test "show user mycommand" \
242 " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
243 "display user command in user_defined_command_test"
246 proc watchpoint_command_test {} {
250 if [target_info exists noargs] {
251 verbose "Skipping watchpoint_command_test because of noargs."
255 # Disable hardware watchpoints if necessary.
256 if [target_info exists gdb,no_hardware_watchpoints] {
257 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
260 gdb_test_no_output "set args 6" "set args in watchpoint_command_test"
261 if { ![runto factorial] } then { return }
264 # Verify that we can create a watchpoint, and give it a commands
265 # list that continues the inferior. We set the watchpoint on a
266 # local variable, too, so that it self-deletes when the watched
267 # data goes out of scope.
269 # What should happen is: Each time the watchpoint triggers, it
270 # continues the inferior. Eventually, the watchpoint will self-
271 # delete, when the watched variable is out of scope. But by that
272 # time, the inferior should have exited. GDB shouldn't crash or
273 # anything untoward as a result of this.
277 gdb_test_multiple "watch local_var" "watch local_var" {
278 -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
279 set wp_id $expect_out(1,string)
280 pass "watch local_var"
284 if {$wp_id == -1} {return}
286 gdb_test_multiple "commands $wp_id" "begin commands on watch" {
287 -re "Type commands for breakpoint.*, one per line.*>$" {
288 pass "begin commands on watch"
291 # See the 'No symbol "value...' fail below. This command will
292 # fail if it's executed in the wrong frame. If adjusting the
293 # test, make sure this property holds.
294 gdb_test_multiple "print value" "add print command to watch" {
296 pass "add print command to watch"
299 gdb_test_multiple "continue" "add continue command to watch" {
301 pass "add continue command to watch"
306 "end commands on watch"
308 set test "continue with watch"
309 gdb_test_multiple "continue" "$test" {
310 -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
311 # Happens if GDB actually runs the watchpoints commands,
312 # even though the watchpoint was deleted for not being in
316 -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:(53|77).*$gdb_prompt $" {
322 proc test_command_prompt_position {} {
325 if [target_info exists noargs] {
326 verbose "Skipping test_command_prompt_position because of noargs."
330 if { ![runto factorial] } then { gdb_suppress_tests; }
331 # Don't depend upon argument passing, since most simulators don't
332 # currently support it. Bash value variable to be what we want.
334 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #3"
335 gdb_test "p value=5" ".*" "set value to 5 in test_command_prompt_position"
336 # All this test should do is print 0xdeadbeef once.
337 gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
338 "\\\$\[0-9\]* = 0xdeadbeef" \
339 "if test in test_command_prompt_position"
341 # Now let's test for the correct position of the '>' in gdb's
342 # prompt for commands. It should be at the beginning of the line,
343 # and not after one space.
345 send_gdb "commands\n"
347 -re "Type commands.*End with.*\[\r\n\]>$" {
348 send_gdb "printf \"Now the value is %d\\n\", value\n"
350 -re "^printf.*value\r\n>$" {
353 -re "^end\r\n$gdb_prompt $" {
354 pass "> OK in test_command_prompt_position"
356 -re ".*$gdb_prompt $" {
357 fail "some other message in test_command_prompt_position"
360 fail "(timeout) 1 in test_command_prompt_position"
364 -re "^ >$" { fail "> not OK in test_command_prompt_position" }
365 -re ".*$gdb_prompt $" {
366 fail "wrong message in test_command_prompt_position"
369 fail "(timeout) 2 in test_command_prompt_position "
373 -re "Type commands.*End with.*\[\r\n\] >$" {
374 fail "prompt not OK in test_command_prompt_position"
376 -re ".*$gdb_prompt $" {
377 fail "commands in test_command_prompt_position"
379 timeout { fail "(timeout) 3 commands in test_command_prompt_position" }
382 gdb_stop_suppressing_tests
387 proc deprecated_command_test {} {
388 gdb_test "maintenance deprecate blah" "Can't find command.*" \
389 "tried to deprecate non-existing command"
391 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/"
393 "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \
394 "p deprecated warning, with replacement"
395 gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /1/"
397 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/"
398 gdb_test_no_output "maintenance deprecate print \"new_print\""
400 "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \
401 "both alias and command are deprecated"
402 gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /2/"
404 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size \"srm\" " \
405 "deprecate long command /1/"
406 gdb_test "set remote memory-read-packet-size" \
407 "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \
408 "long command deprecated /1/"
410 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size" \
411 "deprecate long command /2/"
412 gdb_test "set remote memory-read-packet-size" \
413 "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \
414 "long command deprecated with no alternative /2/"
416 gdb_test "maintenance deprecate" \
417 "\"maintenance deprecate\".*" \
418 "deprecate with no arguments"
421 proc bp_deleted_in_command_test {} {
424 if [target_info exists noargs] {
425 verbose "Skipping bp_deleted_in_command_test because of noargs."
429 gdb_test_no_output "set args 1" \
430 "set args in bp_deleted_in_command_test"
433 # Create a breakpoint, and associate a command-list to it, with
434 # one command that deletes this breakpoint.
435 gdb_test "break factorial" \
436 "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
437 "breakpoint in bp_deleted_in_command_test"
439 gdb_test_multiple "commands" "begin commands in bp_deleted_in_command_test" {
440 -re "Type commands for breakpoint.*>$" {
441 pass "begin commands in bp_deleted_in_command_test"
444 gdb_test_multiple "silent" "add silent command" {
446 pass "add silent command"
449 gdb_test_multiple "clear factorial" "add clear command" {
451 pass "add clear command"
454 gdb_test_multiple "printf \"factorial command-list executed\\n\"" \
455 "add printf command" {
457 pass "add printf command"
460 gdb_test_multiple "cont" "add cont command" {
462 pass "add cont command"
471 -re ".*factorial command-list executed.*$gdb_prompt $" {
472 pass "run factorial until breakpoint"
474 -re ".*$gdb_prompt $" {
475 fail "run factorial until breakpoint"
477 default { fail "(timeout) run factorial until breakpoint" }
478 timeout { fail "(timeout) run factorial until breakpoint" }
482 proc temporary_breakpoint_commands {} {
485 if [target_info exists noargs] {
486 verbose "Skipping temporary_breakpoint_commands because of noargs."
490 gdb_test_no_output "set args 1" \
491 "set args in temporary_breakpoint_commands"
494 # Create a temporary breakpoint, and associate a commands list to it.
495 # This test will verify that this commands list is executed when the
497 gdb_test "tbreak factorial" \
498 "Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
499 "breakpoint in temporary_breakpoint_commands"
501 gdb_test_multiple "commands" \
502 "begin commands in bp_deleted_in_command_test" {
503 -re "Type commands for breakpoint.*>$" {
504 pass "begin commands in bp_deleted_in_command_test"
507 gdb_test_multiple "silent" "add silent tbreak command" {
509 pass "add silent tbreak command"
512 gdb_test_multiple "printf \"factorial tbreak commands executed\\n\"" \
513 "add printf tbreak command" {
515 pass "add printf tbreak command"
518 gdb_test_multiple "cont" "add cont tbreak command" {
520 pass "add cont tbreak command"
525 "end tbreak commands"
529 -re ".*factorial tbreak commands executed.*$gdb_prompt $" {
530 pass "run factorial until temporary breakpoint"
532 timeout { fail "(timeout) run factorial until temporary breakpoint" }
536 # Test that GDB can handle $arg0 outside of user functions without
538 proc stray_arg0_test { } {
539 gdb_test "print \$arg0" \
540 "\\\$\[0-9\]* = void" \
543 gdb_test "if 1 == 1\nprint \$arg0\nend" \
544 "\\\$\[0-9\]* = void" \
547 gdb_test "print \$arg0 = 1" \
551 gdb_test "print \$arg0" \
556 # Test that GDB is able to source a file with an indented comment.
557 proc source_file_with_indented_comment {} {
558 set fd [open "file1" w]
566 gdb_test "source file1" "Done!" "source file with indented comment"
569 # Test that GDB can handle arguments when sourcing files recursively.
570 # If the arguments are overwritten with ####### then the test has failed.
571 proc recursive_source_test {} {
572 set fd [open "file1" w]
578 set fd [open "file2" w]
581 echo 1: <<<$arg0>>>\n
583 echo 2: <<<$arg0>>>\n
587 set fd [open "file3" w]
590 #################################################################"
593 gdb_test "source file1" \
594 "1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
595 "recursive source test"
602 proc gdb_test_no_prompt { command result msg } {
605 set msg "$command - $msg"
606 set result "^[string_to_regexp $command]\r\n$result$"
607 gdb_test_multiple $command $msg {
620 proc if_commands_test {} {
623 gdb_test_no_output "set \$tem = 1" "set \$tem in if_commands_test"
625 set test "if_commands_test 1"
626 gdb_test_no_prompt "if \$tem == 2" { >} $test
627 gdb_test_no_prompt "break main" { >} $test
628 gdb_test_no_prompt "else" { >} $test
629 gdb_test_no_prompt "break factorial" { >} $test
630 gdb_test_no_prompt "commands" { >} $test
631 gdb_test_no_prompt "silent" { >} $test
632 gdb_test_no_prompt "set \$tem = 3" { >} $test
633 gdb_test_no_prompt "continue" { >} $test
634 gdb_test_multiple "end" "first end - $test" {
636 pass "first end - $test"
639 fail "first end - $test"
642 gdb_test_multiple "end" "second end - $test" {
643 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
644 pass "second end - $test"
646 -re "Undefined command: \"silent\".*$gdb_prompt $" {
647 fail "second end - $test"
651 set test "if_commands_test 2"
652 gdb_test_no_prompt "if \$tem == 1" { >} $test
653 gdb_test_no_prompt "break main" { >} $test
654 gdb_test_no_prompt "else" { >} $test
655 gdb_test_no_prompt "break factorial" { >} $test
656 gdb_test_no_prompt "commands" { >} $test
657 gdb_test_no_prompt "silent" { >} $test
658 gdb_test_no_prompt "set \$tem = 3" { >} $test
659 gdb_test_no_prompt "continue" { >} $test
660 gdb_test_multiple "end" "first end - $test" {
662 pass "first end - $test"
665 fail "first end - $test"
668 gdb_test_multiple "end" "second end - $test" {
669 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
670 pass "second end - $test"
675 # Verify an error during "commands" commands execution will prevent any other
676 # "commands" from other breakpoints at the same location to be executed.
678 proc error_clears_commands_left {} {
679 set test "hook-stop 1"
680 gdb_test_multiple {define hook-stop} $test {
681 -re "End with a line saying just \"end\"\\.\r\n>$" {
685 set test "hook-stop 1a"
686 gdb_test_multiple {echo hook-stop1\n} $test {
691 gdb_test_no_output "end" "hook-stop 1b"
694 gdb_breakpoint "main"
696 set test "main commands 1"
697 gdb_test_multiple {commands $bpnum} $test {
698 -re "End with a line saying just \"end\"\\.\r\n>$" {
702 set test "main commands 1a"
703 gdb_test_multiple {echo cmd1\n} $test {
708 set test "main commands 1b"
709 gdb_test_multiple {errorcommandxy\n} $test {
714 gdb_test_no_output "end" "main commands 1c"
716 gdb_breakpoint "main"
717 set test "main commands 2"
718 gdb_test_multiple {commands $bpnum} $test {
719 -re "End with a line saying just \"end\"\\.\r\n>$" {
723 set test "main commands 2a"
724 gdb_test_multiple {echo cmd2\n} $test {
729 set test "main commands 2b"
730 gdb_test_multiple {errorcommandyz\n} $test {
735 gdb_test_no_output "end" "main commands 2c"
738 gdb_test "" "hook-stop1\r\n.*\r\ncmd1\r\nUndefined command: \"errorcommandxy\"\\. Try \"help\"\\." "cmd1 error"
740 gdb_test {echo idle\n} "\r\nidle" "no cmd2"
743 proc redefine_hook_test {} {
746 gdb_test "define one\nend" \
750 gdb_test "define hook-one\necho hibob\\n\nend" \
754 gdb_test_multiple "define one" "redefine one" {
755 -re "Redefine command .one.. .y or n. $" {
761 pass "define one in redefine_hook_test"
764 fail "(timeout or eof) define one in redefine_hook_test"
770 "enter commands for one redefinition in redefine_hook_test"
774 "execute one command in redefine_hook_test"
777 proc redefine_backtrace_test {} {
780 gdb_test_multiple "define backtrace" "define backtrace" {
781 -re "Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
782 pass "define backtrace"
786 gdb_test_multiple "y" "expect response to define backtrace" {
787 -re "End with a line saying just \"end\"\\.\r\n>$" {
788 pass "expect response to define backtrace"
792 gdb_test "echo hibob\\n\nend" \
794 "enter commands in redefine_backtrace_test"
796 gdb_test "backtrace" \
798 "execute backtrace command in redefine_backtrace_test"
801 "execute bt command in redefine_backtrace_test"
804 gdbvar_simple_if_test
805 gdbvar_simple_while_test
806 gdbvar_complex_if_while_test
807 progvar_simple_if_test
808 progvar_simple_while_test
809 progvar_complex_if_while_test
810 if_while_breakpoint_command_test
811 infrun_breakpoint_command_test
812 breakpoint_command_test
813 user_defined_command_test
814 watchpoint_command_test
815 test_command_prompt_position
816 deprecated_command_test
817 bp_deleted_in_command_test
818 temporary_breakpoint_commands
820 source_file_with_indented_comment
821 recursive_source_test
823 error_clears_commands_left
825 # This one should come last, as it redefines "backtrace".
826 redefine_backtrace_test