1 # Copyright 1988-2018 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 "failed to prepare" commands run.c {debug additional_flags=-DFAKEARGV}] } {
26 # Run to FUNCTION. If that fails, issue a FAIL and make the caller
29 proc runto_or_return {function} {
30 if { ![runto factorial] } {
31 fail "cannot run to $function"
36 proc_with_prefix gdbvar_simple_if_test {} {
39 gdb_test_no_output "set \$foo = 0" "set foo"
40 # All this test should do is print 0xdeadbeef once.
48 "$valnum_re = 0xdeadbeef" \
51 # All this test should do is print 0xfeedface once.
59 "$valnum_re = 0xfeedface" \
63 proc_with_prefix gdbvar_simple_while_test {} {
66 gdb_test_no_output "set \$foo = 5" "set foo"
67 # This test should print 0xfeedface five times.
75 "$valnum_re = 0xfeedface" \
76 "$valnum_re = 0xfeedface" \
77 "$valnum_re = 0xfeedface" \
78 "$valnum_re = 0xfeedface" \
79 "$valnum_re = 0xfeedface"] \
83 proc_with_prefix gdbvar_complex_if_while_test {} {
86 gdb_test_no_output "set \$foo = 4" "set foo"
87 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
92 { if ($foo % 2) == 1} \
99 "$valnum_re = 0xdeadbeef" \
100 "$valnum_re = 0xfeedface" \
101 "$valnum_re = 0xdeadbeef" \
102 "$valnum_re = 0xfeedface"] \
106 proc_with_prefix progvar_simple_if_test {} {
109 runto_or_return factorial
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=5" " = 5" "set value to 5"
114 # All this test should do is print 0xdeadbeef once.
122 "$valnum_re = 0xdeadbeef" \
125 # All this test should do is print 0xfeedface once.
133 "$valnum_re = 0xfeedface" \
137 proc_with_prefix progvar_simple_while_test {} {
140 runto_or_return factorial
142 # Don't depend upon argument passing, since most simulators don't
143 # currently support it. Bash value variable to be what we want.
144 gdb_test "p value=5" " = 5" "set value to 5"
145 # This test should print 0xfeedface five times.
153 "$valnum_re = 0xfeedface" \
154 "$valnum_re = 0xfeedface" \
155 "$valnum_re = 0xfeedface" \
156 "$valnum_re = 0xfeedface" \
157 "$valnum_re = 0xfeedface"] \
161 proc_with_prefix progvar_complex_if_while_test {} {
164 runto_or_return factorial
166 # Don't depend upon argument passing, since most simulators don't
167 # currently support it. Bash value variable to be what we want.
168 gdb_test "p value=4" " = 4" "set value to 4"
169 # This test should alternate between 0xdeadbeef and 0xfeedface two
175 { if (value % 2) == 1} \
182 "$valnum_re = 0xdeadbeef" \
183 "$valnum_re = 0xfeedface" \
184 "$valnum_re = 0xdeadbeef" \
185 "$valnum_re = 0xfeedface"] \
189 proc_with_prefix if_while_breakpoint_command_test {} {
192 runto_or_return factorial
194 # Don't depend upon argument passing, since most simulators don't
195 # currently support it. Bash value variable to be what we want.
196 gdb_test "p value=5" " = 5" "set value to 5"
198 gdb_test "break factorial" "Breakpoint.*at.*" "break factorial"
200 gdb_test_multiple "commands" "commands" {
206 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
211 { if (value % 2) == 1} \
223 "$valnum_re = 0xdeadbeef" \
224 "$valnum_re = 0xfeedface" \
225 "$valnum_re = 0xdeadbeef" \
226 "$valnum_re = 0xfeedface"] \
228 gdb_test "info break" "while.*set.*if.*p/x.*else.*p/x.*end.*"
231 # Test that we can run the inferior from breakpoint commands.
233 # The expected behavior is that all commands after the first "step"
234 # shall be ignored. See the gdb manual, "Break Commands",
235 # subsection "Breakpoint command lists".
237 proc_with_prefix infrun_breakpoint_command_test {} {
238 runto_or_return factorial
240 # Don't depend upon argument passing, since most simulators don't
241 # currently support it. Bash value variable to be what we want.
242 gdb_test "p value=6" " = 6" "set value to 6"
244 gdb_test "break factorial if value == 5" "Breakpoint.*at.*"
246 # infrun_breakpoint_command_test - This test was broken into two parts
247 # to get around a synchronization problem in expect.
248 # part1: issue the gdb command "commands"
249 # part2: send the list of commands
251 set test "commands #1"
252 gdb_test_multiple "commands" $test {
257 gdb_test "step\nstep\nstep\nstep\nend" "" \
260 gdb_test "continue" \
261 "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*"
264 proc_with_prefix breakpoint_command_test {} {
265 runto_or_return factorial
267 # Don't depend upon argument passing, since most simulators don't
268 # currently support it. Bash value variable to be what we want.
269 gdb_test "p value=6" " = 6" "set value to 6"
271 gdb_test "break factorial" "Breakpoint.*at.*"
275 { printf "Now the value is %d\n", value} \
279 gdb_test "continue" \
280 "Breakpoint \[0-9\]*, factorial.*Now the value is 5"
281 gdb_test "print value" " = 5"
284 # Test a simple user defined command (with arguments)
285 proc_with_prefix user_defined_command_test {} {
288 gdb_test_no_output "set \$foo = 4" "set foo"
290 gdb_test_multiple "define mycommand" "define mycommand" {
292 pass "define mycommand"
296 # This test should alternate between 0xdeadbeef and 0xfeedface two times.
301 { if ($arg0 % 2) == 1} \
312 set valnum_re "\\\$$decimal"
317 "$valnum_re = 0xdeadbeef" \
318 "$valnum_re = 0xfeedface" \
319 "$valnum_re = 0xdeadbeef" \
320 "$valnum_re = 0xfeedface"] \
321 "execute user-defined command"
322 gdb_test "show user mycommand" \
323 " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
324 "display user command"
326 # Create and test a user-defined command with an empty body.
327 gdb_test_multiple "define myemptycommand" "define myemptycommand" {
329 pass "define myemptycommand"
334 "end definition of user-defined command with empty body"
336 gdb_test_no_output "myemptycommand" \
337 "execute user-defined empty command"
339 gdb_test "show user" \
340 "User command \"myemptycommand.*" \
341 "display empty command in command list"
343 gdb_test "show user myemptycommand" \
344 "User command \"myemptycommand.*" \
345 "display user-defined empty command"
348 # Test that the case with which the command was defined is preserved.
350 proc_with_prefix user_defined_command_case_sensitivity {} {
351 # Define a first command with mixed case name.
352 set test "define Homer-Simpson"
353 gdb_test_multiple $test $test {
359 gdb_test "print 123\nend" "" "enter commands 1"
361 # Define a second command, same name but different case.
362 set test "define HomeR-SimpsoN"
363 gdb_test_multiple $test $test {
369 gdb_test "print 456\nend" "" "enter commands 2"
371 gdb_test "Homer-Simpson" " = 123" "execute command"
372 gdb_test "HomeR-SimpsoN" " = 456" "execute command"
373 gdb_test "HOMER-SIMPSON" "Undefined command.*" "try to call in upper case"
374 gdb_test "homer-simpson" "Undefined command.*" "try to call in lower case"
377 # Test that "eval" in a user-defined command expands $argc/$argN.
379 proc_with_prefix user_defined_command_args_eval {} {
380 gdb_test_multiple "define command_args_eval" \
381 "define command_args_eval" {
387 # Make a command that constructs references to $argc and $argN via
391 {eval "printf \"argc = %%d,\", $arg%c", 'c'} \
394 { eval "printf \" %%d\", $arg%d", $i} \
402 gdb_test "command_args_eval 1 2 3" "argc = 3, 1 2 3" "execute command"
405 # Test that the $argc/$argN variables are pushed on/popped from the
406 # args stack correctly when a user-defined command calls another
407 # user-defined command (or in this case, recurses).
409 proc_with_prefix user_defined_command_args_stack_test {} {
410 gdb_test_multiple "define args_stack_command" \
411 "define args_stack_command" {
417 # Make a command that refers to $argc/$argN before and after
418 # recursing. Also, vary the number of arguments passed to each
422 {printf "before, argc = %d,", $argc} \
425 { eval "printf \" %%d\", $arg%d", $i} \
432 { args_stack_command 21 22} \
435 { args_stack_command 11} \
439 {printf "after, argc = %d,", $argc} \
442 { eval "printf \" %%d\", $arg%d", $i} \
452 "before, argc = 3, 31 32 33" \
453 "before, argc = 2, 21 22" \
454 "before, argc = 1, 11" \
455 "after, argc = 1, 11" \
456 "after, argc = 2, 21 22" \
457 "after, argc = 3, 31 32 33"]
458 gdb_test "args_stack_command 31 32 33" $expected "execute command"
461 # Test a simple user defined command with many arguments. GDB <= 7.12
462 # used to have a hard coded limit of 10 arguments.
464 proc_with_prefix user_defined_command_manyargs_test {} {
465 set test "define command"
466 gdb_test_multiple "define manyargs" $test {
472 # Define a function that doubles its arguments.
475 {printf "nargs=%d:", $argc} \
478 { eval "printf \" %%d\", 2 * $arg%d\n", $i} \
486 # Some random number of arguments, as long as higher than 10.
490 for {set i 1} {$i <= $nargs} {incr i} {
494 set expected "nargs=$nargs:"
495 for {set i 1} {$i <= $nargs} {incr i} {
496 append expected " " [expr 2 * $i]
499 gdb_test $cmd $expected "execute command"
502 proc_with_prefix watchpoint_command_test {} {
505 # Disable hardware watchpoints if necessary.
506 if [target_info exists gdb,no_hardware_watchpoints] {
507 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
510 runto_or_return factorial
514 # Verify that we can create a watchpoint, and give it a commands
515 # list that continues the inferior. We set the watchpoint on a
516 # local variable, too, so that it self-deletes when the watched
517 # data goes out of scope.
519 # What should happen is: Each time the watchpoint triggers, it
520 # continues the inferior. Eventually, the watchpoint will self-
521 # delete, when the watched variable is out of scope. But by that
522 # time, the inferior should have exited. GDB shouldn't crash or
523 # anything untoward as a result of this.
527 gdb_test_multiple "watch local_var" "watch local_var" {
528 -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
529 set wp_id $expect_out(1,string)
530 pass "watch local_var"
534 if {$wp_id == -1} {return}
536 gdb_test_multiple "commands $wp_id" "begin commands on watch" {
537 -re "Type commands for breakpoint.*, one per line.*>$" {
538 pass "begin commands on watch"
541 # See the 'No symbol "value...' fail below. This command will
542 # fail if it's executed in the wrong frame. If adjusting the
543 # test, make sure this property holds.
544 gdb_test_multiple "print value" "add print command to watch" {
546 pass "add print command to watch"
549 gdb_test_multiple "continue" "add continue command to watch" {
551 pass "add continue command to watch"
556 "end commands on watch"
558 set test "continue with watch"
559 set lno_1 [gdb_get_line_number "commands.exp: hw local_var out of scope" "run.c"]
560 set lno_2 [gdb_get_line_number "commands.exp: local_var out of scope" "run.c"]
561 gdb_test_multiple "continue" "$test" {
562 -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
563 # Happens if GDB actually runs the watchpoints commands,
564 # even though the watchpoint was deleted for not being in
568 -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 $" {
574 proc_with_prefix test_command_prompt_position {} {
578 runto_or_return factorial
580 # Don't depend upon argument passing, since most simulators don't
581 # currently support it. Bash value variable to be what we want.
583 gdb_test "break factorial" "Breakpoint.*at.*"
584 gdb_test "p value=5" ".*" "set value to 5"
585 # All this test should do is print 0xdeadbeef once.
593 "$valnum_re = 0xdeadbeef" \
596 # Now let's test for the correct position of the '>' in gdb's
597 # prompt for commands. It should be at the beginning of the line,
598 # and not after one space.
601 gdb_test_multiple "commands" $test {
602 -re "Type commands.*End with.*\[\r\n\]>$" {
603 gdb_test_multiple "printf \"Now the value is %d\\n\", value" $test {
604 -re "^printf.*value\r\n>$" {
605 gdb_test_multiple "end" $test {
606 -re "^end\r\n$gdb_prompt $" {
618 proc_with_prefix deprecated_command_test {} {
619 gdb_test "maintenance deprecate blah" "Can't find command.*" \
620 "tried to deprecate non-existing command"
622 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/"
624 "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \
625 "p deprecated warning, with replacement"
626 gdb_test "p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /1/"
628 gdb_test_no_output "maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/"
629 gdb_test_no_output "maintenance deprecate print \"new_print\""
631 "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \
632 "both alias and command are deprecated"
633 gdb_test "p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /2/"
635 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size \"srm\" " \
636 "deprecate long command /1/"
637 gdb_test "set remote memory-read-packet-size" \
638 "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \
639 "long command deprecated /1/"
641 gdb_test_no_output "maintenance deprecate set remote memory-read-packet-size" \
642 "deprecate long command /2/"
643 gdb_test "set remote memory-read-packet-size" \
644 "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \
645 "long command deprecated with no alternative /2/"
647 gdb_test "maintenance deprecate" \
648 "\"maintenance deprecate\".*" \
649 "deprecate with no arguments"
652 proc_with_prefix bp_deleted_in_command_test {} {
657 # Create a breakpoint, and associate a command-list to it, with
658 # one command that deletes this breakpoint.
659 gdb_test "break factorial" \
660 "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\."
662 gdb_test_multiple "commands" "begin commands" {
663 -re "Type commands for breakpoint.*>$" {
664 pass "begin commands"
667 gdb_test_multiple "silent" "add silent command" {
669 pass "add silent command"
672 gdb_test_multiple "clear factorial" "add clear command" {
674 pass "add clear command"
677 gdb_test_multiple "printf \"factorial command-list executed\\n\"" \
678 "add printf command" {
680 pass "add printf command"
683 gdb_test_multiple "cont" "add cont command" {
685 pass "add cont command"
693 gdb_test "" "factorial command-list executed.*" "run factorial until breakpoint"
696 proc_with_prefix temporary_breakpoint_commands {} {
699 # Create a temporary breakpoint, and associate a commands list to it.
700 # This test will verify that this commands list is executed when the
702 gdb_test "tbreak factorial" \
703 "Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
706 gdb_test_multiple "commands" \
707 "begin commands in bp_deleted_in_command_test" {
708 -re "Type commands for breakpoint.*>$" {
709 pass "begin commands"
712 gdb_test_multiple "silent" "add silent tbreak command" {
714 pass "add silent tbreak command"
717 gdb_test_multiple "printf \"factorial tbreak commands executed\\n\"" \
718 "add printf tbreak command" {
720 pass "add printf tbreak command"
723 gdb_test_multiple "cont" "add cont tbreak command" {
725 pass "add cont tbreak command"
730 "end tbreak commands"
733 gdb_test "" "factorial tbreak commands executed.*" \
734 "run factorial until temporary breakpoint"
737 # Test that GDB can handle $arg0 outside of user functions without
739 proc_with_prefix stray_arg0_test { } {
742 gdb_test "print \$arg0" \
743 "$valnum_re = void" \
746 gdb_test "if 1 == 1\nprint \$arg0\nend" \
747 "$valnum_re = void" \
750 gdb_test "print \$arg0 = 1" \
754 gdb_test "print \$arg0" \
759 # Test that GDB is able to source a file with an indented comment.
760 proc_with_prefix source_file_with_indented_comment {} {
761 set file1 [standard_output_file file1]
763 set fd [open "$file1" w]
771 gdb_test "source $file1" "Done!" "source file"
774 # Test that GDB can handle arguments when sourcing files recursively.
775 # If the arguments are overwritten with ####### then the test has failed.
776 proc_with_prefix recursive_source_test {} {
777 set file1 [standard_output_file file1]
778 set file2 [standard_output_file file2]
779 set file3 [standard_output_file file3]
781 set fd [open "$file1" w]
787 set fd [open "$file2" w]
790 echo 1: <<<\$arg0>>>\\n
792 echo 2: <<<\$arg0>>>\\n
796 set fd [open "$file3" w]
799 #################################################################"
802 gdb_test "source $file1" \
803 "1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
811 proc gdb_test_no_prompt { command result msg } {
812 set msg "$command - $msg"
813 set result "^[string_to_regexp $command]\r\n$result$"
814 gdb_test_multiple $command $msg {
827 proc_with_prefix if_commands_test {} {
830 gdb_test_no_output "set \$tem = 1" "set \$tem"
832 set test "if_commands_test 1"
833 gdb_test_no_prompt "if \$tem == 2" { >} $test
834 gdb_test_no_prompt "break main" { >} $test
835 gdb_test_no_prompt "else" { >} $test
836 gdb_test_no_prompt "break factorial" { >} $test
837 gdb_test_no_prompt "commands" { >} $test
838 gdb_test_no_prompt "silent" { >} $test
839 gdb_test_no_prompt "set \$tem = 3" { >} $test
840 gdb_test_no_prompt "continue" { >} $test
841 gdb_test_multiple "end" "first end - $test" {
843 pass "first end - $test"
846 fail "first end - $test"
849 gdb_test_multiple "end" "second end - $test" {
850 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
851 pass "second end - $test"
853 -re "Undefined command: \"silent\".*$gdb_prompt $" {
854 fail "second end - $test"
858 set test "if_commands_test 2"
859 gdb_test_no_prompt "if \$tem == 1" { >} $test
860 gdb_test_no_prompt "break main" { >} $test
861 gdb_test_no_prompt "else" { >} $test
862 gdb_test_no_prompt "break factorial" { >} $test
863 gdb_test_no_prompt "commands" { >} $test
864 gdb_test_no_prompt "silent" { >} $test
865 gdb_test_no_prompt "set \$tem = 3" { >} $test
866 gdb_test_no_prompt "continue" { >} $test
867 gdb_test_multiple "end" "first end - $test" {
869 pass "first end - $test"
872 fail "first end - $test"
875 gdb_test_multiple "end" "second end - $test" {
876 -re "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
877 pass "second end - $test"
882 # Verify an error during "commands" commands execution will prevent any other
883 # "commands" from other breakpoints at the same location to be executed.
885 proc_with_prefix error_clears_commands_left {} {
886 set test "hook-stop 1"
887 gdb_test_multiple {define hook-stop} $test {
888 -re "End with a line saying just \"end\"\\.\r\n>$" {
892 set test "hook-stop 1a"
893 gdb_test_multiple {echo hook-stop1\n} $test {
898 gdb_test_no_output "end" "hook-stop 1b"
901 gdb_breakpoint "main"
903 set test "main commands 1"
904 gdb_test_multiple {commands $bpnum} $test {
905 -re "End with a line saying just \"end\"\\.\r\n>$" {
909 set test "main commands 1a"
910 gdb_test_multiple {echo cmd1\n} $test {
915 set test "main commands 1b"
916 gdb_test_multiple {errorcommandxy\n} $test {
921 gdb_test_no_output "end" "main commands 1c"
923 gdb_breakpoint "main"
924 set test "main commands 2"
925 gdb_test_multiple {commands $bpnum} $test {
926 -re "End with a line saying just \"end\"\\.\r\n>$" {
930 set test "main commands 2a"
931 gdb_test_multiple {echo cmd2\n} $test {
936 set test "main commands 2b"
937 gdb_test_multiple {errorcommandyz\n} $test {
942 gdb_test_no_output "end" "main commands 2c"
951 "Undefined command: \"errorcommandxy\"\\. Try \"help\"\\."] \
954 gdb_test {echo idle\n} "\r\nidle" "no cmd2"
957 proc_with_prefix redefine_hook_test {} {
973 set test "redefine one"
974 gdb_test_multiple "define one" $test {
975 -re "Redefine command .one.. .y or n. $" {
985 gdb_test "end" "" "enter commands for one redefinition"
987 gdb_test "one" "hibob" "execute one command"
990 proc_with_prefix redefine_backtrace_test {} {
991 gdb_test_multiple "define backtrace" "define backtrace" {
992 -re "Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
993 pass "define backtrace"
997 gdb_test_multiple "y" "expect response to define backtrace" {
998 -re "End with a line saying just \"end\"\\.\r\n>$" {
999 pass "expect response to define backtrace"
1010 gdb_test "backtrace" "hibob" "execute backtrace command"
1011 gdb_test "bt" "hibob" "execute bt command"
1014 # Test using "if" and "while" without args when building a command list.
1016 proc define_if_without_arg_test {} {
1017 foreach cmd {if while} {
1018 set test "define some_command_$cmd"
1019 gdb_test_multiple $test $test {
1025 gdb_test "$cmd" "if/while commands require arguments." "type $cmd without args"
1029 # Test the loop_break command.
1031 proc_with_prefix loop_break_test {} {
1032 gdb_test_no_output "set \$a = 0" "initialize \$a"
1033 gdb_test_no_output "set \$total = 0" "initialize \$total"
1046 " set \$total = \$total + 1" \
1047 " set \$b = \$b + 1" \
1049 " set \$a = \$a + 1" \
1054 gdb_test "print \$a" " = 4" "validate \$a"
1055 gdb_test "print \$b" " = 2" "validate \$b"
1056 gdb_test "print \$total" " = 8" "validate \$total"
1059 # Test the loop_continue command.
1061 proc_with_prefix loop_continue_test {} {
1062 gdb_test_no_output "set \$a = 0" "initialize \$a"
1063 gdb_test_no_output "set \$total = 0" "initialize \$total"
1068 " set \$a = \$a + 1" \
1074 " set \$b = \$b + 1" \
1078 " set \$total = \$total + 1" \
1084 gdb_test "print \$a" " = 5" "validate \$a"
1085 gdb_test "print \$b" " = 5" "validate \$b"
1086 gdb_test "print \$total" " = 16" "validate \$total"
1089 # Test an input line split with a continuation character (backslash)
1090 # while entering a multi-line command (in a secondary prompt).
1092 proc_with_prefix backslash_in_multi_line_command_test {} {
1093 set dg_ver [dejagnu_version]
1094 set dg_major [lindex $dg_ver 0]
1095 set dg_minor [lindex $dg_ver 1]
1097 # With older versions of DejaGnu, the "\\\n" we send gets replaced with a
1098 # space, thus breaking the test. Just skip it in that case.
1099 if { $dg_major == 1 && $dg_minor < 5 } {
1100 untested "dejagnu version is too old"
1104 gdb_breakpoint "main"
1106 gdb_test_multiple "commands" "commands" {
1107 -re "End with a line saying just \"end\"\\.\r\n>$" {
1112 set test "input line split with backslash"
1113 send_gdb "print \\\nargc\n"
1114 gdb_test_multiple "" $test {
1115 -re "^print \\\\\r\nargc\r\n>$" {
1120 gdb_test_no_output "end"
1122 # Input any command, just to be sure the readline state is sane.
1123 # In PR 21218, this would trigger the infamous:
1124 # readline: readline_callback_read_char() called with no handler!
1125 gdb_test "print 1" "" "run command"
1128 gdbvar_simple_if_test
1129 gdbvar_simple_while_test
1130 gdbvar_complex_if_while_test
1131 progvar_simple_if_test
1132 progvar_simple_while_test
1133 progvar_complex_if_while_test
1134 if_while_breakpoint_command_test
1135 infrun_breakpoint_command_test
1136 breakpoint_command_test
1137 user_defined_command_test
1138 user_defined_command_case_sensitivity
1139 user_defined_command_args_eval
1140 user_defined_command_args_stack_test
1141 user_defined_command_manyargs_test
1142 watchpoint_command_test
1143 test_command_prompt_position
1144 deprecated_command_test
1145 bp_deleted_in_command_test
1146 temporary_breakpoint_commands
1148 source_file_with_indented_comment
1149 recursive_source_test
1151 error_clears_commands_left
1153 backslash_in_multi_line_command_test
1154 define_if_without_arg_test
1157 # This one should come last, as it redefines "backtrace".
1158 redefine_backtrace_test