1 # Copyright 1988-2014 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)
22 if { [prepare_for_testing commands.exp commands run.c {debug additional_flags=-DFAKEARGV}] } {
26 proc gdbvar_simple_if_test {} {
29 gdb_test_no_output "set \$foo = 0" "set foo in gdbvar_simple_if_test"
30 # All this test should do is print 0xdeadbeef once.
31 gdb_test "if \$foo == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
32 "\\\$\[0-9\]* = 0xdeadbeef" "gdbvar_simple_if_test #1"
33 # All this test should do is print 0xfeedface once.
34 gdb_test "if \$foo == 0\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
35 "\\\$\[0-9\]* = 0xfeedface" "gdbvar_simple_if_test #2"
38 proc gdbvar_simple_while_test {} {
41 gdb_test_no_output "set \$foo = 5" "set foo in gdbvar_simple_while_test"
42 # This test should print 0xfeedface five times.
43 gdb_test "while \$foo > 0\np/x 0xfeedface\nset \$foo -= 1\nend" \
44 "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
45 "gdbvar_simple_while_test #1"
48 proc gdbvar_complex_if_while_test {} {
51 gdb_test_no_output "set \$foo = 4" \
52 "set foo in gdbvar complex_if_while_test"
53 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
54 gdb_test "while \$foo > 0\nset \$foo -= 1\nif \(\$foo % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
55 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
56 "gdbvar_complex_if_while_test #1"
59 proc progvar_simple_if_test {} {
62 if [target_info exists noargs] {
63 verbose "Skipping progvar_simple_if_test because of noargs."
67 if { ![runto factorial] } then { gdb_suppress_tests; }
68 # Don't depend upon argument passing, since most simulators don't
69 # currently support it. Bash value variable to be what we want.
70 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #1"
71 # All this test should do is print 0xdeadbeef once.
72 gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
73 "\\\$\[0-9\]* = 0xdeadbeef" \
74 "progvar_simple_if_test #1"
75 # All this test should do is print 0xfeedface once.
76 gdb_test "if value == 5\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
77 "\\\$\[0-9\]* = 0xfeedface" \
78 "progvar_simple_if_test #2"
79 gdb_stop_suppressing_tests
82 proc progvar_simple_while_test {} {
85 if [target_info exists noargs] {
86 verbose "Skipping progvar_simple_while_test because of noargs."
90 gdb_test_no_output "set args 5" "set args in progvar_simple_while_test"
91 if { ![runto factorial] } then { gdb_suppress_tests }
92 # Don't depend upon argument passing, since most simulators don't
93 # currently support it. Bash value variable to be what we want.
94 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #2"
95 # This test should print 0xfeedface five times.
96 gdb_test "while value > 0\np/x 0xfeedface\nset value -= 1\nend" \
97 "\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
98 "progvar_simple_while_test #1"
99 gdb_stop_suppressing_tests
102 proc progvar_complex_if_while_test {} {
105 if [target_info exists noargs] {
106 verbose "Skipping progvar_simple_if_while_test because of noargs."
110 gdb_test_no_output "set args 4" \
111 "set args in progvar_complex_if_while_test"
112 if { ![runto factorial] } then { gdb_suppress_tests }
113 # Don't depend upon argument passing, since most simulators don't
114 # currently support it. Bash value variable to be what we want.
115 gdb_test "p value=4" ".*" "set value to 4 in progvar_simple_if_test"
116 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
117 gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
118 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
119 "progvar_complex_if_while_test #1"
120 gdb_stop_suppressing_tests
123 proc if_while_breakpoint_command_test {} {
124 if [target_info exists noargs] {
125 verbose "Skipping if_while_breakpoint_command_test because of noargs."
129 gdb_test_no_output "set args 5" \
130 "set args in if_while_breakpoint_command_test"
131 if { ![runto factorial] } then { gdb_suppress_tests }
132 # Don't depend upon argument passing, since most simulators don't
133 # currently support it. Bash value variable to be what we want.
134 gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test"
136 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #1"
138 gdb_test_multiple "commands" \
139 "commands in if_while_breakpoint_command_test" {
141 pass "commands in if_while_breakpoint_command_test"
145 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
146 gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
148 "commands part 2 in if_while_breakpoint_command_test"
149 gdb_test "continue" \
150 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
151 "if_while_breakpoint_command_test #1"
152 gdb_test "info break" \
153 "while.*set.*if.*p/x.*else.*p/x.*end.*" \
154 "info break in if_while_breakpoint_command_test"
155 gdb_stop_suppressing_tests
158 # Test that we can run the inferior from breakpoint commands.
160 # The expected behavior is that all commands after the first "step"
161 # shall be ignored. See the gdb manual, "Break Commands",
162 # subsection "Breakpoint command lists".
164 proc infrun_breakpoint_command_test {} {
165 if [target_info exists noargs] {
166 verbose "Skipping infrun_breakpoint_command_test because of noargs."
170 gdb_test_no_output "set args 6" \
171 "set args in infrun_breakpoint_command_test"
172 if { ![runto factorial] } then { gdb_suppress_tests }
173 # Don't depend upon argument passing, since most simulators don't
174 # currently support it. Bash value variable to be what we want.
175 gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #1"
177 gdb_test "break factorial if value == 5" "Breakpoint.*at.*"
179 # infrun_breakpoint_command_test - This test was broken into two parts
180 # to get around a synchronization problem in expect.
181 # part1: issue the gdb command "commands"
182 # part2: send the list of commands
183 gdb_test_multiple "commands" \
184 "commands in infrun_breakpoint_command_test #1" {
186 pass "commands in infrun_breakpoint_command_test #1"
189 gdb_test "step\nstep\nstep\nstep\nend" "" \
190 "commands in infrun_breakpoint_command_test #2"
192 gdb_test "continue" \
193 "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*" \
194 "continue in infrun_breakpoint_command_test"
196 gdb_stop_suppressing_tests
199 proc breakpoint_command_test {} {
200 if [target_info exists noargs] {
201 verbose "Skipping breakpoint_command_test because of noargs."
205 gdb_test_no_output "set args 6" "set args in breakpoint_command_test"
206 if { ![runto factorial] } then { gdb_suppress_tests; }
207 # Don't depend upon argument passing, since most simulators don't
208 # currently support it. Bash value variable to be what we want.
209 gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #2"
211 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2"
212 gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \
213 "End with.*" "commands in breakpoint_command_test"
214 gdb_test "continue" \
215 "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \
216 "continue in breakpoint_command_test"
217 gdb_test "print value" " = 5" "print value in breakpoint_command_test"
218 gdb_stop_suppressing_tests
221 # Test a simple user defined command (with arguments)
222 proc user_defined_command_test {} {
225 gdb_test_no_output "set \$foo = 4" \
226 "set foo in user_defined_command_test"
228 gdb_test_multiple "define mycommand" \
229 "define mycommand in user_defined_command_test" {
231 pass "define mycommand in user_defined_command_test"
235 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
236 gdb_test "while \$arg0 > 0\nset \$arg0 -= 1\nif \(\$arg0 % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
238 "enter commands in user_defined_command_test"
240 gdb_test "mycommand \$foo" \
241 "\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
242 "execute user defined command in user_defined_command_test"
243 gdb_test "show user mycommand" \
244 " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
245 "display user command in user_defined_command_test"
248 proc watchpoint_command_test {} {
252 if [target_info exists noargs] {
253 verbose "Skipping watchpoint_command_test because of noargs."
257 # Disable hardware watchpoints if necessary.
258 if [target_info exists gdb,no_hardware_watchpoints] {
259 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
262 gdb_test_no_output "set args 6" "set args in watchpoint_command_test"
263 if { ![runto factorial] } then { return }
266 # Verify that we can create a watchpoint, and give it a commands
267 # list that continues the inferior. We set the watchpoint on a
268 # local variable, too, so that it self-deletes when the watched
269 # data goes out of scope.
271 # What should happen is: Each time the watchpoint triggers, it
272 # continues the inferior. Eventually, the watchpoint will self-
273 # delete, when the watched variable is out of scope. But by that
274 # time, the inferior should have exited. GDB shouldn't crash or
275 # anything untoward as a result of this.
279 gdb_test_multiple "watch local_var" "watch local_var" {
280 -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
281 set wp_id $expect_out(1,string)
282 pass "watch local_var"
286 if {$wp_id == -1} {return}
288 gdb_test_multiple "commands $wp_id" "begin commands on watch" {
289 -re "Type commands for breakpoint.*, one per line.*>$" {
290 pass "begin commands on watch"
293 # See the 'No symbol "value...' fail below. This command will
294 # fail if it's executed in the wrong frame. If adjusting the
295 # test, make sure this property holds.
296 gdb_test_multiple "print value" "add print command to watch" {
298 pass "add print command to watch"
301 gdb_test_multiple "continue" "add continue command to watch" {
303 pass "add continue command to watch"
308 "end commands on watch"
310 set test "continue with watch"
311 set lno_1 [gdb_get_line_number "commands.exp: hw local_var out of scope" "run.c"]
312 set lno_2 [gdb_get_line_number "commands.exp: local_var out of scope" "run.c"]
313 gdb_test_multiple "continue" "$test" {
314 -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
315 # Happens if GDB actually runs the watchpoints commands,
316 # even though the watchpoint was deleted for not being in
320 -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:($lno_1|$lno_2).*$gdb_prompt $" {
326 proc test_command_prompt_position {} {
329 if [target_info exists noargs] {
330 verbose "Skipping test_command_prompt_position because of noargs."
334 if { ![runto factorial] } then { gdb_suppress_tests; }
335 # Don't depend upon argument passing, since most simulators don't
336 # currently support it. Bash value variable to be what we want.
338 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #3"
339 gdb_test "p value=5" ".*" "set value to 5 in test_command_prompt_position"
340 # All this test should do is print 0xdeadbeef once.
341 gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
342 "\\\$\[0-9\]* = 0xdeadbeef" \
343 "if test in test_command_prompt_position"
345 # Now let's test for the correct position of the '>' in gdb's
346 # prompt for commands. It should be at the beginning of the line,
347 # and not after one space.
349 send_gdb "commands\n"
351 -re "Type commands.*End with.*\[\r\n\]>$" {
352 send_gdb "printf \"Now the value is %d\\n\", value\n"
354 -re "^printf.*value\r\n>$" {
357 -re "^end\r\n$gdb_prompt $" {
358 pass "> OK in test_command_prompt_position"
360 -re ".*$gdb_prompt $" {
361 fail "some other message in test_command_prompt_position"
364 fail "(timeout) 1 in test_command_prompt_position"
368 -re "^ >$" { fail "> not OK in test_command_prompt_position" }
369 -re ".*$gdb_prompt $" {
370 fail "wrong message in test_command_prompt_position"
373 fail "(timeout) 2 in test_command_prompt_position "
377 -re "Type commands.*End with.*\[\r\n\] >$" {
378 fail "prompt not OK in test_command_prompt_position"
380 -re ".*$gdb_prompt $" {
381 fail "commands in test_command_prompt_position"
383 timeout { fail "(timeout) 3 commands in test_command_prompt_position" }
386 gdb_stop_suppressing_tests
391 proc deprecated_command_test {} {
392 gdb_test "maintenance deprecate blah" "Can't find command.*" \
393 "tried to deprecate non-existing command"
395 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/"
397 "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \
398 "p deprecated warning, with replacement"
399 gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /1/"
401 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/"
402 gdb_test_no_output "maintenance deprecate print \"new_print\""
404 "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \
405 "both alias and command are deprecated"
406 gdb_test "p 5" ".\[0-9\]* = 5.*" "Deprecated warning goes away /2/"
408 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size \"srm\" " \
409 "deprecate long command /1/"
410 gdb_test "set remote memory-read-packet-size" \
411 "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \
412 "long command deprecated /1/"
414 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size" \
415 "deprecate long command /2/"
416 gdb_test "set remote memory-read-packet-size" \
417 "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \
418 "long command deprecated with no alternative /2/"
420 gdb_test "maintenance deprecate" \
421 "\"maintenance deprecate\".*" \
422 "deprecate with no arguments"
425 proc bp_deleted_in_command_test {} {
428 if [target_info exists noargs] {
429 verbose "Skipping bp_deleted_in_command_test because of noargs."
433 gdb_test_no_output "set args 1" \
434 "set args in bp_deleted_in_command_test"
437 # Create a breakpoint, and associate a command-list to it, with
438 # one command that deletes this breakpoint.
439 gdb_test "break factorial" \
440 "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
441 "breakpoint in bp_deleted_in_command_test"
443 gdb_test_multiple "commands" "begin commands in bp_deleted_in_command_test" {
444 -re "Type commands for breakpoint.*>$" {
445 pass "begin commands in bp_deleted_in_command_test"
448 gdb_test_multiple "silent" "add silent command" {
450 pass "add silent command"
453 gdb_test_multiple "clear factorial" "add clear command" {
455 pass "add clear command"
458 gdb_test_multiple "printf \"factorial command-list executed\\n\"" \
459 "add printf command" {
461 pass "add printf command"
464 gdb_test_multiple "cont" "add cont command" {
466 pass "add cont command"
475 -re ".*factorial command-list executed.*$gdb_prompt $" {
476 pass "run factorial until breakpoint"
478 -re ".*$gdb_prompt $" {
479 fail "run factorial until breakpoint"
481 default { fail "(timeout) run factorial until breakpoint" }
482 timeout { fail "(timeout) run factorial until breakpoint" }
486 proc temporary_breakpoint_commands {} {
489 if [target_info exists noargs] {
490 verbose "Skipping temporary_breakpoint_commands because of noargs."
494 gdb_test_no_output "set args 1" \
495 "set args in temporary_breakpoint_commands"
498 # Create a temporary breakpoint, and associate a commands list to it.
499 # This test will verify that this commands list is executed when the
501 gdb_test "tbreak factorial" \
502 "Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
503 "breakpoint in temporary_breakpoint_commands"
505 gdb_test_multiple "commands" \
506 "begin commands in bp_deleted_in_command_test" {
507 -re "Type commands for breakpoint.*>$" {
508 pass "begin commands in bp_deleted_in_command_test"
511 gdb_test_multiple "silent" "add silent tbreak command" {
513 pass "add silent tbreak command"
516 gdb_test_multiple "printf \"factorial tbreak commands executed\\n\"" \
517 "add printf tbreak command" {
519 pass "add printf tbreak command"
522 gdb_test_multiple "cont" "add cont tbreak command" {
524 pass "add cont tbreak command"
529 "end tbreak commands"
533 -re ".*factorial tbreak commands executed.*$gdb_prompt $" {
534 pass "run factorial until temporary breakpoint"
536 timeout { fail "(timeout) run factorial until temporary breakpoint" }
540 # Test that GDB can handle $arg0 outside of user functions without
542 proc stray_arg0_test { } {
543 gdb_test "print \$arg0" \
544 "\\\$\[0-9\]* = void" \
547 gdb_test "if 1 == 1\nprint \$arg0\nend" \
548 "\\\$\[0-9\]* = void" \
551 gdb_test "print \$arg0 = 1" \
555 gdb_test "print \$arg0" \
560 # Test that GDB is able to source a file with an indented comment.
561 proc source_file_with_indented_comment {} {
562 set file1 [standard_output_file file1]
564 set fd [open "$file1" w]
572 gdb_test "source $file1" "Done!" "source file with indented comment"
575 # Test that GDB can handle arguments when sourcing files recursively.
576 # If the arguments are overwritten with ####### then the test has failed.
577 proc recursive_source_test {} {
578 set file1 [standard_output_file file1]
579 set file2 [standard_output_file file2]
580 set file3 [standard_output_file file3]
582 set fd [open "$file1" w]
588 set fd [open "$file2" w]
591 echo 1: <<<\$arg0>>>\\n
593 echo 2: <<<\$arg0>>>\\n
597 set fd [open "$file3" w]
600 #################################################################"
603 gdb_test "source $file1" \
604 "1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
605 "recursive source test"
612 proc gdb_test_no_prompt { command result msg } {
615 set msg "$command - $msg"
616 set result "^[string_to_regexp $command]\r\n$result$"
617 gdb_test_multiple $command $msg {
630 proc if_commands_test {} {
633 gdb_test_no_output "set \$tem = 1" "set \$tem in if_commands_test"
635 set test "if_commands_test 1"
636 gdb_test_no_prompt "if \$tem == 2" { >} $test
637 gdb_test_no_prompt "break main" { >} $test
638 gdb_test_no_prompt "else" { >} $test
639 gdb_test_no_prompt "break factorial" { >} $test
640 gdb_test_no_prompt "commands" { >} $test
641 gdb_test_no_prompt "silent" { >} $test
642 gdb_test_no_prompt "set \$tem = 3" { >} $test
643 gdb_test_no_prompt "continue" { >} $test
644 gdb_test_multiple "end" "first end - $test" {
646 pass "first end - $test"
649 fail "first end - $test"
652 gdb_test_multiple "end" "second end - $test" {
653 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
654 pass "second end - $test"
656 -re "Undefined command: \"silent\".*$gdb_prompt $" {
657 fail "second end - $test"
661 set test "if_commands_test 2"
662 gdb_test_no_prompt "if \$tem == 1" { >} $test
663 gdb_test_no_prompt "break main" { >} $test
664 gdb_test_no_prompt "else" { >} $test
665 gdb_test_no_prompt "break factorial" { >} $test
666 gdb_test_no_prompt "commands" { >} $test
667 gdb_test_no_prompt "silent" { >} $test
668 gdb_test_no_prompt "set \$tem = 3" { >} $test
669 gdb_test_no_prompt "continue" { >} $test
670 gdb_test_multiple "end" "first end - $test" {
672 pass "first end - $test"
675 fail "first end - $test"
678 gdb_test_multiple "end" "second end - $test" {
679 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
680 pass "second end - $test"
685 # Verify an error during "commands" commands execution will prevent any other
686 # "commands" from other breakpoints at the same location to be executed.
688 proc error_clears_commands_left {} {
689 set test "hook-stop 1"
690 gdb_test_multiple {define hook-stop} $test {
691 -re "End with a line saying just \"end\"\\.\r\n>$" {
695 set test "hook-stop 1a"
696 gdb_test_multiple {echo hook-stop1\n} $test {
701 gdb_test_no_output "end" "hook-stop 1b"
704 gdb_breakpoint "main"
706 set test "main commands 1"
707 gdb_test_multiple {commands $bpnum} $test {
708 -re "End with a line saying just \"end\"\\.\r\n>$" {
712 set test "main commands 1a"
713 gdb_test_multiple {echo cmd1\n} $test {
718 set test "main commands 1b"
719 gdb_test_multiple {errorcommandxy\n} $test {
724 gdb_test_no_output "end" "main commands 1c"
726 gdb_breakpoint "main"
727 set test "main commands 2"
728 gdb_test_multiple {commands $bpnum} $test {
729 -re "End with a line saying just \"end\"\\.\r\n>$" {
733 set test "main commands 2a"
734 gdb_test_multiple {echo cmd2\n} $test {
739 set test "main commands 2b"
740 gdb_test_multiple {errorcommandyz\n} $test {
745 gdb_test_no_output "end" "main commands 2c"
748 gdb_test "" "hook-stop1\r\n.*\r\ncmd1\r\nUndefined command: \"errorcommandxy\"\\. Try \"help\"\\." "cmd1 error"
750 gdb_test {echo idle\n} "\r\nidle" "no cmd2"
753 proc redefine_hook_test {} {
756 gdb_test "define one\nend" \
760 gdb_test "define hook-one\necho hibob\\n\nend" \
764 gdb_test_multiple "define one" "redefine one" {
765 -re "Redefine command .one.. .y or n. $" {
771 pass "define one in redefine_hook_test"
774 fail "(timeout or eof) define one in redefine_hook_test"
780 "enter commands for one redefinition in redefine_hook_test"
784 "execute one command in redefine_hook_test"
787 proc redefine_backtrace_test {} {
790 gdb_test_multiple "define backtrace" "define backtrace" {
791 -re "Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
792 pass "define backtrace"
796 gdb_test_multiple "y" "expect response to define backtrace" {
797 -re "End with a line saying just \"end\"\\.\r\n>$" {
798 pass "expect response to define backtrace"
802 gdb_test "echo hibob\\n\nend" \
804 "enter commands in redefine_backtrace_test"
806 gdb_test "backtrace" \
808 "execute backtrace command in redefine_backtrace_test"
811 "execute bt command in redefine_backtrace_test"
814 gdbvar_simple_if_test
815 gdbvar_simple_while_test
816 gdbvar_complex_if_while_test
817 progvar_simple_if_test
818 progvar_simple_while_test
819 progvar_complex_if_while_test
820 if_while_breakpoint_command_test
821 infrun_breakpoint_command_test
822 breakpoint_command_test
823 user_defined_command_test
824 watchpoint_command_test
825 test_command_prompt_position
826 deprecated_command_test
827 bp_deleted_in_command_test
828 temporary_breakpoint_commands
830 source_file_with_indented_comment
831 recursive_source_test
833 error_clears_commands_left
835 # This one should come last, as it redefines "backtrace".
836 redefine_backtrace_test