1 # Copyright 1988, 1990-1992, 1994-1995, 1997-2003, 2005-2012 Free
2 # Software Foundation, Inc.
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 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # test special commands (if, while, etc)
25 if { [prepare_for_testing commands.exp commands run.c {debug additional_flags=-DFAKEARGV}] } {
29 proc gdbvar_simple_if_test {} {
32 gdb_test_no_output "set \$foo = 0" "set foo in gdbvar_simple_if_test"
33 # All this test should do is print 0xdeadbeef once.
34 gdb_test "if \$foo == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
35 "\\\$\[0-9\]* = 0xdeadbeef" "gdbvar_simple_if_test #1"
36 # All this test should do is print 0xfeedface once.
37 gdb_test "if \$foo == 0\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
38 "\\\$\[0-9\]* = 0xfeedface" "gdbvar_simple_if_test #2"
41 proc gdbvar_simple_while_test {} {
44 gdb_test_no_output "set \$foo = 5" "set foo in gdbvar_simple_while_test"
45 # This test should print 0xfeedface five times.
46 gdb_test "while \$foo > 0\np/x 0xfeedface\nset \$foo -= 1\nend" \
47 "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
48 "gdbvar_simple_while_test #1"
51 proc gdbvar_complex_if_while_test {} {
54 gdb_test_no_output "set \$foo = 4" \
55 "set foo in gdbvar complex_if_while_test"
56 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
57 gdb_test "while \$foo > 0\nset \$foo -= 1\nif \(\$foo % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
58 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
59 "gdbvar_complex_if_while_test #1"
62 proc progvar_simple_if_test {} {
65 if [target_info exists noargs] {
66 verbose "Skipping progvar_simple_if_test because of noargs."
70 if { ![runto factorial] } then { gdb_suppress_tests; }
71 # Don't depend upon argument passing, since most simulators don't
72 # currently support it. Bash value variable to be what we want.
73 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #1"
74 # All this test should do is print 0xdeadbeef once.
75 gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
76 "\\\$\[0-9\]* = 0xdeadbeef" \
77 "progvar_simple_if_test #1"
78 # All this test should do is print 0xfeedface once.
79 gdb_test "if value == 5\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
80 "\\\$\[0-9\]* = 0xfeedface" \
81 "progvar_simple_if_test #2"
82 gdb_stop_suppressing_tests;
85 proc progvar_simple_while_test {} {
88 if [target_info exists noargs] {
89 verbose "Skipping progvar_simple_while_test because of noargs."
93 gdb_test_no_output "set args 5" "set args in progvar_simple_while_test"
94 if { ![runto factorial] } then { gdb_suppress_tests }
95 # Don't depend upon argument passing, since most simulators don't
96 # currently support it. Bash value variable to be what we want.
97 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #2"
98 # This test should print 0xfeedface five times.
99 gdb_test "while value > 0\np/x 0xfeedface\nset value -= 1\nend" \
100 "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
101 "progvar_simple_while_test #1"
102 gdb_stop_suppressing_tests;
105 proc progvar_complex_if_while_test {} {
108 if [target_info exists noargs] {
109 verbose "Skipping progvar_simple_if_while_test because of noargs."
113 gdb_test_no_output "set args 4" \
114 "set args in progvar_complex_if_while_test"
115 if { ![runto factorial] } then { gdb_suppress_tests }
116 # Don't depend upon argument passing, since most simulators don't
117 # currently support it. Bash value variable to be what we want.
118 gdb_test "p value=4" ".*" "set value to 4 in progvar_simple_if_test"
119 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
120 gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
121 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
122 "progvar_complex_if_while_test #1"
123 gdb_stop_suppressing_tests;
126 proc if_while_breakpoint_command_test {} {
127 if [target_info exists noargs] {
128 verbose "Skipping if_while_breakpoint_command_test because of noargs."
132 gdb_test_no_output "set args 5" \
133 "set args in if_while_breakpoint_command_test"
134 if { ![runto factorial] } then { gdb_suppress_tests }
135 # Don't depend upon argument passing, since most simulators don't
136 # currently support it. Bash value variable to be what we want.
137 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test"
139 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #1"
141 gdb_test_multiple "commands" \
142 "commands in if_while_breakpoint_command_test" {
144 pass "commands in if_while_breakpoint_command_test"
148 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
149 gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
151 "commands part 2 in if_while_breakpoint_command_test"
152 gdb_test "continue" \
153 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
154 "if_while_breakpoint_command_test #1"
155 gdb_test "info break" \
156 "while.*set.*if.*p/x.*else.*p/x.*end.*" \
157 "info break in if_while_breakpoint_command_test"
158 gdb_stop_suppressing_tests;
161 # Test that we can run the inferior from breakpoint commands.
163 # The expected behavior is that all commands after the first "step"
164 # shall be ignored. See the gdb manual, "Break Commands",
165 # subsection "Breakpoint command lists".
167 proc infrun_breakpoint_command_test {} {
168 if [target_info exists noargs] {
169 verbose "Skipping infrun_breakpoint_command_test because of noargs."
173 gdb_test_no_output "set args 6" \
174 "set args in infrun_breakpoint_command_test"
175 if { ![runto factorial] } then { gdb_suppress_tests }
176 # Don't depend upon argument passing, since most simulators don't
177 # currently support it. Bash value variable to be what we want.
178 gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #1"
180 gdb_test "break factorial if value == 5" "Breakpoint.*at.*"
182 # infrun_breakpoint_command_test - This test was broken into two parts
183 # to get around a synchronization problem in expect.
184 # part1: issue the gdb command "commands"
185 # part2: send the list of commands
186 gdb_test_multiple "commands" \
187 "commands in infrun_breakpoint_command_test #1" {
189 pass "commands in infrun_breakpoint_command_test #1"
192 gdb_test "step\nstep\nstep\nstep\nend" "" \
193 "commands in infrun_breakpoint_command_test #2"
195 gdb_test "continue" \
196 "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*" \
197 "continue in infrun_breakpoint_command_test"
199 gdb_stop_suppressing_tests;
202 proc breakpoint_command_test {} {
203 if [target_info exists noargs] {
204 verbose "Skipping breakpoint_command_test because of noargs."
208 gdb_test_no_output "set args 6" "set args in breakpoint_command_test"
209 if { ![runto factorial] } then { gdb_suppress_tests; }
210 # Don't depend upon argument passing, since most simulators don't
211 # currently support it. Bash value variable to be what we want.
212 gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #2"
214 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2"
215 gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \
216 "End with.*" "commands in breakpoint_command_test"
217 gdb_test "continue" \
218 "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \
219 "continue in breakpoint_command_test"
220 gdb_test "print value" " = 5" "print value in breakpoint_command_test"
221 gdb_stop_suppressing_tests;
224 # Test a simple user defined command (with arguments)
225 proc user_defined_command_test {} {
228 gdb_test_no_output "set \$foo = 4" \
229 "set foo in user_defined_command_test"
231 gdb_test_multiple "define mycommand" \
232 "define mycommand in user_defined_command_test" {
234 pass "define mycommand in user_defined_command_test"
238 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
239 gdb_test "while \$arg0 > 0\nset \$arg0 -= 1\nif \(\$arg0 % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
241 "enter commands in user_defined_command_test"
243 gdb_test "mycommand \$foo" \
244 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
245 "execute user defined command in user_defined_command_test"
246 gdb_test "show user mycommand" \
247 " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
248 "display user command in user_defined_command_test"
251 proc watchpoint_command_test {} {
255 if [target_info exists noargs] {
256 verbose "Skipping watchpoint_command_test because of noargs."
260 # Disable hardware watchpoints if necessary.
261 if [target_info exists gdb,no_hardware_watchpoints] {
262 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
265 gdb_test_no_output "set args 6" "set args in watchpoint_command_test"
266 if { ![runto factorial] } then { return }
269 # Verify that we can create a watchpoint, and give it a commands
270 # list that continues the inferior. We set the watchpoint on a
271 # local variable, too, so that it self-deletes when the watched
272 # data goes out of scope.
274 # What should happen is: Each time the watchpoint triggers, it
275 # continues the inferior. Eventually, the watchpoint will self-
276 # delete, when the watched variable is out of scope. But by that
277 # time, the inferior should have exited. GDB shouldn't crash or
278 # anything untoward as a result of this.
282 gdb_test_multiple "watch local_var" "watch local_var" {
283 -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
284 set wp_id $expect_out(1,string)
285 pass "watch local_var"
289 if {$wp_id == -1} {return}
291 gdb_test_multiple "commands $wp_id" "begin commands on watch" {
292 -re "Type commands for breakpoint.*, one per line.*>$" {
293 pass "begin commands on watch"
296 # See the 'No symbol "value...' fail below. This command will
297 # fail if it's executed in the wrong frame. If adjusting the
298 # test, make sure this property holds.
299 gdb_test_multiple "print value" "add print command to watch" {
301 pass "add print command to watch"
304 gdb_test_multiple "continue" "add continue command to watch" {
306 pass "add continue command to watch"
311 "end commands on watch"
313 set test "continue with watch"
314 gdb_test_multiple "continue" "$test" {
315 -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
316 # Happens if GDB actually runs the watchpoints commands,
317 # even though the watchpoint was deleted for not being in
321 -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 $" {
327 proc test_command_prompt_position {} {
330 if [target_info exists noargs] {
331 verbose "Skipping test_command_prompt_position because of noargs."
335 if { ![runto factorial] } then { gdb_suppress_tests; }
336 # Don't depend upon argument passing, since most simulators don't
337 # currently support it. Bash value variable to be what we want.
339 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #3"
340 gdb_test "p value=5" ".*" "set value to 5 in test_command_prompt_position"
341 # All this test should do is print 0xdeadbeef once.
342 gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
343 "\\\$\[0-9\]* = 0xdeadbeef" \
344 "if test in test_command_prompt_position"
346 # Now let's test for the correct position of the '>' in gdb's
347 # prompt for commands. It should be at the beginning of the line,
348 # and not after one space.
350 send_gdb "commands\n"
352 -re "Type commands.*End with.*\[\r\n\]>$" {
353 send_gdb "printf \"Now the value is %d\\n\", value\n"
355 -re "^printf.*value\r\n>$" {
358 -re "^end\r\n$gdb_prompt $" {
359 pass "> OK in test_command_prompt_position"
361 -re ".*$gdb_prompt $" {
362 fail "some other message in test_command_prompt_position"
365 fail "(timeout) 1 in test_command_prompt_position"
369 -re "^ >$" { fail "> not OK in test_command_prompt_position" }
370 -re ".*$gdb_prompt $" {
371 fail "wrong message in test_command_prompt_position"
374 fail "(timeout) 2 in test_command_prompt_position "
378 -re "Type commands.*End with.*\[\r\n\] >$" {
379 fail "prompt not OK in test_command_prompt_position"
381 -re ".*$gdb_prompt $" {
382 fail "commands in test_command_prompt_position"
384 timeout { fail "(timeout) 3 commands in test_command_prompt_position" }
387 gdb_stop_suppressing_tests;
392 proc deprecated_command_test {} {
393 gdb_test "maintenance deprecate blah" "Can't find command.*" \
394 "tried to deprecate non-existing command"
396 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/"
398 "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \
399 "p deprecated warning, with replacement"
400 gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /1/"
402 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/"
403 gdb_test_no_output "maintenance deprecate print \"new_print\""
405 "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \
406 "both alias and command are deprecated"
407 gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /2/"
409 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size \"srm\" " \
410 "deprecate long command /1/"
411 gdb_test "set remote memory-read-packet-size" \
412 "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \
413 "long command deprecated /1/"
415 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size" \
416 "deprecate long command /2/"
417 gdb_test "set remote memory-read-packet-size" \
418 "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \
419 "long command deprecated with no alternative /2/"
421 gdb_test "maintenance deprecate" \
422 "\"maintenance deprecate\".*" \
423 "deprecate with no arguments"
426 proc bp_deleted_in_command_test {} {
429 if [target_info exists noargs] {
430 verbose "Skipping bp_deleted_in_command_test because of noargs."
434 gdb_test_no_output "set args 1" \
435 "set args in bp_deleted_in_command_test"
438 # Create a breakpoint, and associate a command-list to it, with
439 # one command that deletes this breakpoint.
440 gdb_test "break factorial" \
441 "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
442 "breakpoint in bp_deleted_in_command_test"
444 gdb_test_multiple "commands" "begin commands in bp_deleted_in_command_test" {
445 -re "Type commands for breakpoint.*>$" {
446 pass "begin commands in bp_deleted_in_command_test"
449 gdb_test_multiple "silent" "add silent command" {
451 pass "add silent command"
454 gdb_test_multiple "clear factorial" "add clear command" {
456 pass "add clear command"
459 gdb_test_multiple "printf \"factorial command-list executed\\n\"" \
460 "add printf command" {
462 pass "add printf command"
465 gdb_test_multiple "cont" "add cont command" {
467 pass "add cont command"
476 -re ".*factorial command-list executed.*$gdb_prompt $" {
477 pass "run factorial until breakpoint"
479 -re ".*$gdb_prompt $" {
480 fail "run factorial until breakpoint"
482 default { fail "(timeout) run factorial until breakpoint" }
483 timeout { fail "(timeout) run factorial until breakpoint" }
487 proc temporary_breakpoint_commands {} {
490 if [target_info exists noargs] {
491 verbose "Skipping temporary_breakpoint_commands because of noargs."
495 gdb_test_no_output "set args 1" \
496 "set args in temporary_breakpoint_commands"
499 # Create a temporary breakpoint, and associate a commands list to it.
500 # This test will verify that this commands list is executed when the
502 gdb_test "tbreak factorial" \
503 "Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
504 "breakpoint in temporary_breakpoint_commands"
506 gdb_test_multiple "commands" \
507 "begin commands in bp_deleted_in_command_test" {
508 -re "Type commands for breakpoint.*>$" {
509 pass "begin commands in bp_deleted_in_command_test"
512 gdb_test_multiple "silent" "add silent tbreak command" {
514 pass "add silent tbreak command"
517 gdb_test_multiple "printf \"factorial tbreak commands executed\\n\"" \
518 "add printf tbreak command" {
520 pass "add printf tbreak command"
523 gdb_test_multiple "cont" "add cont tbreak command" {
525 pass "add cont tbreak command"
530 "end tbreak commands"
534 -re ".*factorial tbreak commands executed.*$gdb_prompt $" {
535 pass "run factorial until temporary breakpoint"
537 timeout { fail "(timeout) run factorial until temporary breakpoint" }
541 # Test that GDB can handle $arg0 outside of user functions without
543 proc stray_arg0_test { } {
544 gdb_test "print \$arg0" \
545 "\\\$\[0-9\]* = void" \
548 gdb_test "if 1 == 1\nprint \$arg0\nend" \
549 "\\\$\[0-9\]* = void" \
552 gdb_test "print \$arg0 = 1" \
556 gdb_test "print \$arg0" \
561 # Test that GDB is able to source a file with an indented comment.
562 proc source_file_with_indented_comment {} {
563 set fd [open "file1" w]
571 gdb_test "source file1" "Done!" "source file with indented comment"
574 # Test that GDB can handle arguments when sourcing files recursively.
575 # If the arguments are overwritten with ####### then the test has failed.
576 proc recursive_source_test {} {
577 set fd [open "file1" w]
583 set fd [open "file2" w]
586 echo 1: <<<$arg0>>>\n
588 echo 2: <<<$arg0>>>\n
592 set fd [open "file3" w]
595 #################################################################"
598 gdb_test "source file1" \
599 "1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
600 "recursive source test"
607 proc gdb_test_no_prompt { command result msg } {
610 set msg "$command - $msg"
611 set result "^[string_to_regexp $command]\r\n$result$"
612 gdb_test_multiple $command $msg {
625 proc if_commands_test {} {
628 gdb_test_no_output "set \$tem = 1" "set \$tem in if_commands_test"
630 set test "if_commands_test 1"
631 gdb_test_no_prompt "if \$tem == 2" { >} $test
632 gdb_test_no_prompt "break main" { >} $test
633 gdb_test_no_prompt "else" { >} $test
634 gdb_test_no_prompt "break factorial" { >} $test
635 gdb_test_no_prompt "commands" { >} $test
636 gdb_test_no_prompt "silent" { >} $test
637 gdb_test_no_prompt "set \$tem = 3" { >} $test
638 gdb_test_no_prompt "continue" { >} $test
639 gdb_test_multiple "end" "first end - $test" {
641 pass "first end - $test"
644 fail "first end - $test"
647 gdb_test_multiple "end" "second end - $test" {
648 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
649 pass "second end - $test"
651 -re "Undefined command: \"silent\".*$gdb_prompt $" {
652 fail "second end - $test"
656 set test "if_commands_test 2"
657 gdb_test_no_prompt "if \$tem == 1" { >} $test
658 gdb_test_no_prompt "break main" { >} $test
659 gdb_test_no_prompt "else" { >} $test
660 gdb_test_no_prompt "break factorial" { >} $test
661 gdb_test_no_prompt "commands" { >} $test
662 gdb_test_no_prompt "silent" { >} $test
663 gdb_test_no_prompt "set \$tem = 3" { >} $test
664 gdb_test_no_prompt "continue" { >} $test
665 gdb_test_multiple "end" "first end - $test" {
667 pass "first end - $test"
670 fail "first end - $test"
673 gdb_test_multiple "end" "second end - $test" {
674 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
675 pass "second end - $test"
680 # Verify an error during "commands" commands execution will prevent any other
681 # "commands" from other breakpoints at the same location to be executed.
683 proc error_clears_commands_left {} {
684 set test "hook-stop 1"
685 gdb_test_multiple {define hook-stop} $test {
686 -re "End with a line saying just \"end\"\\.\r\n>$" {
690 set test "hook-stop 1a"
691 gdb_test_multiple {echo hook-stop1\n} $test {
696 gdb_test_no_output "end" "hook-stop 1b"
699 gdb_breakpoint "main"
701 set test "main commands 1"
702 gdb_test_multiple {commands $bpnum} $test {
703 -re "End with a line saying just \"end\"\\.\r\n>$" {
707 set test "main commands 1a"
708 gdb_test_multiple {echo cmd1\n} $test {
713 set test "main commands 1b"
714 gdb_test_multiple {errorcommandxy\n} $test {
719 gdb_test_no_output "end" "main commands 1c"
721 gdb_breakpoint "main"
722 set test "main commands 2"
723 gdb_test_multiple {commands $bpnum} $test {
724 -re "End with a line saying just \"end\"\\.\r\n>$" {
728 set test "main commands 2a"
729 gdb_test_multiple {echo cmd2\n} $test {
734 set test "main commands 2b"
735 gdb_test_multiple {errorcommandyz\n} $test {
740 gdb_test_no_output "end" "main commands 2c"
743 gdb_test "" "hook-stop1\r\n.*\r\ncmd1\r\nUndefined command: \"errorcommandxy\"\\. Try \"help\"\\." "cmd1 error"
745 gdb_test {echo idle\n} "\r\nidle" "no cmd2"
748 proc redefine_hook_test {} {
751 gdb_test "define one\nend" \
755 gdb_test "define hook-one\necho hibob\\n\nend" \
759 gdb_test_multiple "define one" "redefine one" {
760 -re "Redefine command .one.. .y or n. $" {
766 pass "define one in redefine_hook_test"
769 fail "(timeout or eof) define one in redefine_hook_test"
775 "enter commands for one redefinition in redefine_hook_test"
779 "execute one command in redefine_hook_test"
782 proc redefine_backtrace_test {} {
785 gdb_test_multiple "define backtrace" "define backtrace" {
786 -re "Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
787 pass "define backtrace"
791 gdb_test_multiple "y" "expect response to define backtrace" {
792 -re "End with a line saying just \"end\"\\.\r\n>$" {
793 pass "expect response to define backtrace"
797 gdb_test "echo hibob\\n\nend" \
799 "enter commands in redefine_backtrace_test"
801 gdb_test "backtrace" \
803 "execute backtrace command in redefine_backtrace_test"
806 "execute bt command in redefine_backtrace_test"
809 gdbvar_simple_if_test
810 gdbvar_simple_while_test
811 gdbvar_complex_if_while_test
812 progvar_simple_if_test
813 progvar_simple_while_test
814 progvar_complex_if_while_test
815 if_while_breakpoint_command_test
816 infrun_breakpoint_command_test
817 breakpoint_command_test
818 user_defined_command_test
819 watchpoint_command_test
820 test_command_prompt_position
821 deprecated_command_test
822 bp_deleted_in_command_test
823 temporary_breakpoint_commands
825 source_file_with_indented_comment
826 recursive_source_test
828 error_clears_commands_left
830 # This one should come last, as it redefines "backtrace".
831 redefine_backtrace_test