1 # Copyright
1988-2019 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 clearing the commands of several breakpoints with one single
"end".
285 proc_with_prefix breakpoint_clear_command_test
{} {
286 runto_or_return factorial
290 gdb_test
"break factorial" "Breakpoint.*at.*"
291 gdb_test_no_output
"set \$bpnumfactorial = \$bpnum"
292 gdb_test
"break main" "Breakpoint.*at.*"
293 gdb_test_no_output
"set \$bpnummain = \$bpnum"
297 {commands $bpnumfactorial $bpnummain
} \
301 "set commands of two breakpoints to print 1234321"
302 gdb_test
"info breakpoints" \
305 "${any}in factorial${any}" \
306 "${any}print 1234321${any}" \
307 "${any}in main${any}" \
308 "${any}print 1234321${any}" \
310 "print 1234321 command present in the two breakpoints"
313 {commands $bpnumfactorial $bpnummain
} \
316 "clear the command list of the two breakpoints"
317 gdb_test
"info breakpoints" \
320 "${any}in factorial${any}" \
321 "${any}in main${any}" \
323 "print 1234321 command is not present anymore in the two breakpoints"
326 # Test a simple user defined command
(with arguments
)
327 proc_with_prefix user_defined_command_test
{} {
330 gdb_test_no_output
"set \$foo = 4" "set foo"
332 gdb_test_multiple
"define mycommand" "define mycommand" {
334 pass
"define mycommand"
338 # This test should alternate between
0xdeadbeef and
0xfeedface two times.
343 { if ($arg0
% 2) == 1} \
354 set valnum_re
"\\\$$decimal"
359 "$valnum_re = 0xdeadbeef" \
360 "$valnum_re = 0xfeedface" \
361 "$valnum_re = 0xdeadbeef" \
362 "$valnum_re = 0xfeedface"] \
363 "execute user-defined command"
364 gdb_test
"show user mycommand" \
365 " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
366 "display user command"
368 # Create and test a user
-defined command with an empty body.
369 gdb_test_multiple
"define myemptycommand" "define myemptycommand" {
371 pass
"define myemptycommand"
376 "end definition of user-defined command with empty body"
378 gdb_test_no_output
"myemptycommand" \
379 "execute user-defined empty command"
381 gdb_test
"show user" \
382 "User command \"myemptycommand.*" \
383 "display empty command in command list"
385 gdb_test
"show user myemptycommand" \
386 "User command \"myemptycommand.*" \
387 "display user-defined empty command"
390 # Test that the case with which the command was defined is preserved.
392 proc_with_prefix user_defined_command_case_sensitivity
{} {
393 #
Define a first command with mixed case
name.
394 set test
"define Homer-Simpson"
395 gdb_test_multiple $test $test
{
401 gdb_test
"print 123\nend" "" "enter commands 1"
403 #
Define a second command
, same
name but different case.
404 set test
"define HomeR-SimpsoN"
405 gdb_test_multiple $test $test
{
411 gdb_test
"print 456\nend" "" "enter commands 2"
413 gdb_test
"Homer-Simpson" " = 123" "execute command Homer-Simpson"
414 gdb_test
"HomeR-SimpsoN" " = 456" "execute command HomeR-SimpsoN"
415 gdb_test
"HOMER-SIMPSON" "Undefined command.*" "try to call in upper case"
416 gdb_test
"homer-simpson" "Undefined command.*" "try to call in lower case"
419 # Test that
"eval" in a user-defined command expands $argc/$argN.
421 proc_with_prefix user_defined_command_args_eval
{} {
422 gdb_test_multiple
"define command_args_eval" \
423 "define command_args_eval" {
429 # Make a command that constructs references to $argc and $argN via
433 {eval
"printf \"argc = %%d,\", $arg%c", 'c'} \
436 { eval
"printf \" %%d\", $arg%d", $i} \
444 gdb_test
"command_args_eval 1 2 3" "argc = 3, 1 2 3" "execute command"
447 # Test that the $argc
/$argN variables are pushed
on/popped from the
448 #
args stack correctly when a user
-defined command calls another
449 # user
-defined command
(or in this case
, recurses
).
451 proc_with_prefix user_defined_command_args_stack_test
{} {
452 gdb_test_multiple
"define args_stack_command" \
453 "define args_stack_command" {
459 # Make a command that refers to $argc
/$argN before and after
460 # recursing. Also
, vary the number of arguments passed to each
464 {printf
"before, argc = %d,", $argc} \
467 { eval
"printf \" %%d\", $arg%d", $i} \
474 { args_stack_command
21 22} \
477 { args_stack_command
11} \
481 {printf
"after, argc = %d,", $argc} \
484 { eval
"printf \" %%d\", $arg%d", $i} \
494 "before, argc = 3, 31 32 33" \
495 "before, argc = 2, 21 22" \
496 "before, argc = 1, 11" \
497 "after, argc = 1, 11" \
498 "after, argc = 2, 21 22" \
499 "after, argc = 3, 31 32 33"]
500 gdb_test
"args_stack_command 31 32 33" $expected "execute command"
503 # Test a simple user defined command with many arguments. GDB
<= 7.12
504 # used to have a hard coded
limit of
10 arguments.
506 proc_with_prefix user_defined_command_manyargs_test
{} {
507 set test
"define command"
508 gdb_test_multiple
"define manyargs" $test {
514 #
Define a function that doubles its arguments.
517 {printf
"nargs=%d:", $argc} \
520 { eval
"printf \" %%d\", 2 * $arg%d\n", $i} \
528 # Some
random number of arguments
, as long as higher than
10.
532 for {set i
1} {$i
<= $nargs
} {incr i
} {
536 set expected
"nargs=$nargs:"
537 for {set i
1} {$i
<= $nargs
} {incr i
} {
538 append expected
" " [expr 2 * $i]
541 gdb_test $cmd $expected
"execute command"
544 proc_with_prefix watchpoint_command_test
{} {
547 # Disable hardware watchpoints
if necessary.
548 if [target_info
exists gdb
,no_hardware_watchpoints
] {
549 gdb_test_no_output
"set can-use-hw-watchpoints 0" ""
552 runto_or_return factorial
556 # Verify that we can create a watchpoint
, and give it a commands
557 # list that continues the inferior. We
set the watchpoint
on a
558 # local
variable, too
, so that it self
-deletes when the watched
559 # data goes out of scope.
561 # What should happen is
: Each time the watchpoint triggers
, it
562 # continues the inferior. Eventually
, the watchpoint will self
-
563 #
delete, when the watched
variable is out of scope. But by that
564 # time
, the inferior should have exited. GDB shouldn
't crash or
565 # anything untoward as a result of this.
569 gdb_test_multiple "watch local_var" "watch local_var" {
570 -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
571 set wp_id $expect_out(1,string)
572 pass "watch local_var"
576 if {$wp_id == -1} {return}
578 gdb_test_multiple "commands $wp_id" "begin commands on watch" {
579 -re "Type commands for breakpoint.*, one per line.*>$" {
580 pass "begin commands on watch"
583 # See the 'No symbol
"value...' fail below. This command will
584 # fail
if it
's executed in the wrong frame. If adjusting the
585 # test, make sure this property holds.
586 gdb_test_multiple "print value" "add print command to watch" {
588 pass "add print command to watch"
591 gdb_test_multiple "continue" "add continue command to watch" {
593 pass "add continue command to watch"
598 "end commands on watch"
600 set test "continue with watch"
601 set lno_1 [gdb_get_line_number "commands.exp: hw local_var out of scope" "run.c"]
602 set lno_2 [gdb_get_line_number "commands.exp: local_var out of scope" "run.c"]
603 gdb_test_multiple "continue" "$test" {
604 -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
605 # Happens if GDB actually runs the watchpoints commands,
606 # even though the watchpoint was deleted for not being in
610 -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 $" {
616 proc_with_prefix test_command_prompt_position {} {
620 runto_or_return factorial
622 # Don't depend upon
argument passing
, since most simulators don
't
623 # currently support it. Bash value variable to be what we want.
625 gdb_test "break factorial" "Breakpoint.*at.*"
626 gdb_test "p value=5" ".*" "set value to 5"
627 # All this test should do is print 0xdeadbeef once.
635 "$valnum_re = 0xdeadbeef" \
638 # Now let's test
for the correct position of the
'>' in gdb
's
639 # prompt for commands. It should be at the beginning of the line,
640 # and not after one space.
643 gdb_test_multiple "commands" $test {
644 -re "Type commands.*End with.*\[\r\n\]>$" {
645 gdb_test_multiple "printf \"Now the value is %d\\n\", value" $test {
646 -re "^printf.*value\r\n>$" {
647 gdb_test_multiple "end" $test {
648 -re "^end\r\n$gdb_prompt $" {
660 proc_with_prefix deprecated_command_test {} {
661 gdb_test "maintenance deprecate blah" "Can't find command.
*" \
662 "tried to deprecate non-existing command"
664 gdb_test_no_output
"maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/"
666 "Warning: 'p', an alias for the command 'print' is deprecated.*Use 'new_p'.*" \
667 "p deprecated warning, with replacement"
668 gdb_test
"p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /1/"
670 gdb_test_no_output
"maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/"
671 gdb_test_no_output
"maintenance deprecate print \"new_print\""
673 "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \
674 "both alias and command are deprecated"
675 gdb_test
"p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /2/"
677 gdb_test_no_output
"maintenance deprecate set remote memory-read-packet-size \"srm\" " \
678 "deprecate long command /1/"
679 gdb_test
"set remote memory-read-packet-size" \
680 "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \
681 "long command deprecated /1/"
683 gdb_test_no_output
"maintenance deprecate set remote memory-read-packet-size" \
684 "deprecate long command /2/"
685 gdb_test
"set remote memory-read-packet-size" \
686 "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \
687 "long command deprecated with no alternative /2/"
689 gdb_test
"maintenance deprecate" \
690 "\"maintenance deprecate\".*" \
691 "deprecate with no arguments"
694 proc_with_prefix bp_deleted_in_command_test
{} {
699 # Create a breakpoint
, and associate a command
-list to it
, with
700 # one command that deletes this breakpoint.
701 gdb_test
"break factorial" \
702 "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\."
704 gdb_test_multiple
"commands" "begin commands" {
705 -re
"Type commands for breakpoint.*>$" {
706 pass
"begin commands"
709 gdb_test_multiple
"silent" "add silent command" {
711 pass
"add silent command"
714 gdb_test_multiple
"clear factorial" "add clear command" {
716 pass
"add clear command"
719 gdb_test_multiple
"printf \"factorial command-list executed\\n\"" \
720 "add printf command" {
722 pass
"add printf command"
725 gdb_test_multiple
"cont" "add cont command" {
727 pass
"add cont command"
735 gdb_test
"" "factorial command-list executed.*" "run factorial until breakpoint"
738 proc_with_prefix temporary_breakpoint_commands
{} {
741 # Create a temporary breakpoint
, and associate a commands list to it.
742 # This test will verify that this commands list is executed when the
744 gdb_test
"tbreak factorial" \
745 "Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
748 gdb_test_multiple
"commands" \
749 "begin commands in bp_deleted_in_command_test" {
750 -re
"Type commands for breakpoint.*>$" {
751 pass
"begin commands"
754 gdb_test_multiple
"silent" "add silent tbreak command" {
756 pass
"add silent tbreak command"
759 gdb_test_multiple
"printf \"factorial tbreak commands executed\\n\"" \
760 "add printf tbreak command" {
762 pass
"add printf tbreak command"
765 gdb_test_multiple
"cont" "add cont tbreak command" {
767 pass
"add cont tbreak command"
772 "end tbreak commands"
775 gdb_test
"" "factorial tbreak commands executed.*" \
776 "run factorial until temporary breakpoint"
779 # Test that GDB can handle $arg0 outside of user functions without
781 proc_with_prefix stray_arg0_test
{ } {
784 gdb_test
"print \$arg0" \
785 "$valnum_re = void" \
788 gdb_test
"if 1 == 1\nprint \$arg0\nend" \
789 "$valnum_re = void" \
792 gdb_test
"print \$arg0 = 1" \
796 gdb_test
"print \$arg0" \
801 # Test that GDB is able to source a file with an indented comment.
802 proc_with_prefix source_file_with_indented_comment
{} {
803 set file1
[standard_output_file file1
]
805 set fd
[open
"$file1" w]
813 gdb_test
"source $file1" "Done!" "source file"
816 # Test that GDB can handle arguments when sourcing files recursively.
817 #
If the arguments are overwritten with #######
then the test has failed.
818 proc_with_prefix recursive_source_test
{} {
819 set file1
[standard_output_file file1
]
820 set file2
[standard_output_file file2
]
821 set file3
[standard_output_file file3
]
823 set fd
[open
"$file1" w]
829 set fd
[open
"$file2" w]
832 echo
1: <<<\$arg0
>>>\\n
834 echo
2: <<<\$arg0
>>>\\n
838 set fd
[open
"$file3" w]
841 #################################################################
"
844 gdb_test
"source $file1" \
845 "1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
853 proc gdb_test_no_prompt
{ command result msg
} {
854 set msg
"$command - $msg"
855 set result
"^[string_to_regexp $command]\r\n$result$"
856 gdb_test_multiple $command $msg
{
869 proc_with_prefix if_commands_test
{} {
872 gdb_test_no_output
"set \$tem = 1" "set \$tem"
874 set test
"if_commands_test 1"
875 gdb_test_no_prompt
"if \$tem == 2" { >} $test
876 gdb_test_no_prompt
"break main" { >} $test
877 gdb_test_no_prompt
"else" { >} $test
878 gdb_test_no_prompt
"break factorial" { >} $test
879 gdb_test_no_prompt
"commands" { >} $test
880 gdb_test_no_prompt
"silent" { >} $test
881 gdb_test_no_prompt
"set \$tem = 3" { >} $test
882 gdb_test_no_prompt
"continue" { >} $test
883 gdb_test_multiple
"end" "first end - $test" {
885 pass
"first end - $test"
888 fail
"first end - $test"
891 gdb_test_multiple
"end" "second end - $test" {
892 -re
"Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
893 pass
"second end - $test"
895 -re
"Undefined command: \"silent\".*$gdb_prompt $" {
896 fail
"second end - $test"
900 set test
"if_commands_test 2"
901 gdb_test_no_prompt
"if \$tem == 1" { >} $test
902 gdb_test_no_prompt
"break main" { >} $test
903 gdb_test_no_prompt
"else" { >} $test
904 gdb_test_no_prompt
"break factorial" { >} $test
905 gdb_test_no_prompt
"commands" { >} $test
906 gdb_test_no_prompt
"silent" { >} $test
907 gdb_test_no_prompt
"set \$tem = 3" { >} $test
908 gdb_test_no_prompt
"continue" { >} $test
909 gdb_test_multiple
"end" "first end - $test" {
911 pass
"first end - $test"
914 fail
"first end - $test"
917 gdb_test_multiple
"end" "second end - $test" {
918 -re
"Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
919 pass
"second end - $test"
924 # Verify an error during
"commands" commands execution will prevent any other
925 #
"commands" from other breakpoints at the same location to be executed.
927 proc_with_prefix error_clears_commands_left
{} {
928 set test
"hook-stop 1"
929 gdb_test_multiple
{define hook
-stop
} $test
{
930 -re
"End with a line saying just \"end\"\\.\r\n>$" {
934 set test
"hook-stop 1a"
935 gdb_test_multiple
{echo hook
-stop1
\n} $test
{
940 gdb_test_no_output
"end" "hook-stop 1b"
943 gdb_breakpoint
"main"
945 set test
"main commands 1"
946 gdb_test_multiple
{commands $bpnum
} $test
{
947 -re
"End with a line saying just \"end\"\\.\r\n>$" {
951 set test
"main commands 1a"
952 gdb_test_multiple
{echo cmd1
\n} $test
{
957 set test
"main commands 1b"
958 gdb_test_multiple
{errorcommandxy
\n} $test
{
963 gdb_test_no_output
"end" "main commands 1c"
965 gdb_breakpoint
"main"
966 set test
"main commands 2"
967 gdb_test_multiple
{commands $bpnum
} $test
{
968 -re
"End with a line saying just \"end\"\\.\r\n>$" {
972 set test
"main commands 2a"
973 gdb_test_multiple
{echo cmd2
\n} $test
{
978 set test
"main commands 2b"
979 gdb_test_multiple
{errorcommandyz
\n} $test
{
984 gdb_test_no_output
"end" "main commands 2c"
993 "Undefined command: \"errorcommandxy\"\\. Try \"help\"\\."] \
996 gdb_test
{echo idle
\n} "\r\nidle" "no cmd2"
999 proc_with_prefix redefine_hook_test
{} {
1015 set test
"redefine one"
1016 gdb_test_multiple
"define one" $test {
1017 -re
"Redefine command .one.. .y or n. $" {
1027 gdb_test
"end" "" "enter commands for one redefinition"
1029 gdb_test
"one" "hibob" "execute one command"
1032 proc_with_prefix redefine_backtrace_test
{} {
1033 gdb_test_multiple
"define backtrace" "define backtrace" {
1034 -re
"Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
1035 pass
"define backtrace"
1039 gdb_test_multiple
"y" "expect response to define backtrace" {
1040 -re
"End with a line saying just \"end\"\\.\r\n>$" {
1041 pass
"expect response to define backtrace"
1052 gdb_test
"backtrace" "hibob" "execute backtrace command"
1053 gdb_test
"bt" "hibob" "execute bt command"
1056 # Test using
"if" and "while" without args when building a command list.
1058 proc define_if_without_arg_test
{} {
1059 foreach cmd
{if while define} {
1060 set test
"define some_command_$cmd"
1061 gdb_test_multiple $test $test
{
1067 gdb_test
"$cmd" "$cmd command requires an argument." "type $cmd without args"
1071 # Test the loop_break command.
1073 proc_with_prefix loop_break_test
{} {
1074 gdb_test_no_output
"set \$a = 0" "initialize \$a"
1075 gdb_test_no_output
"set \$total = 0" "initialize \$total"
1088 " set \$total = \$total + 1" \
1089 " set \$b = \$b + 1" \
1091 " set \$a = \$a + 1" \
1096 gdb_test
"print \$a" " = 4" "validate \$a"
1097 gdb_test
"print \$b" " = 2" "validate \$b"
1098 gdb_test
"print \$total" " = 8" "validate \$total"
1101 # Test the loop_continue command.
1103 proc_with_prefix loop_continue_test
{} {
1104 gdb_test_no_output
"set \$a = 0" "initialize \$a"
1105 gdb_test_no_output
"set \$total = 0" "initialize \$total"
1110 " set \$a = \$a + 1" \
1116 " set \$b = \$b + 1" \
1120 " set \$total = \$total + 1" \
1126 gdb_test
"print \$a" " = 5" "validate \$a"
1127 gdb_test
"print \$b" " = 5" "validate \$b"
1128 gdb_test
"print \$total" " = 16" "validate \$total"
1131 # Test an input line split with a continuation character
(backslash
)
1132 #
while entering a multi
-line command
(in a secondary prompt
).
1134 proc_with_prefix backslash_in_multi_line_command_test
{} {
1135 set dg_ver
[dejagnu_version
]
1136 set dg_major
[lindex $dg_ver
0]
1137 set dg_minor
[lindex $dg_ver
1]
1139 # With older versions of DejaGnu
, the
"\\\n" we send gets replaced with a
1140 # space
, thus breaking the test. Just skip it in that case.
1141 if { $dg_major
== 1 && $dg_minor
< 5 } {
1142 untested
"dejagnu version is too old"
1146 gdb_breakpoint
"main"
1148 gdb_test_multiple
"commands" "commands" {
1149 -re
"End with a line saying just \"end\"\\.\r\n>$" {
1154 set test
"input line split with backslash"
1155 send_gdb
"print \\\nargc\n"
1156 gdb_test_multiple
"" $test {
1157 -re
"^print \\\\\r\nargc\r\n>$" {
1162 gdb_test_no_output
"end"
1164 # Input
any command
, just to be sure the readline state is sane.
1165 # In PR
21218, this would trigger the infamous
:
1166 # readline
: readline_callback_read_char
() called with no handler
!
1167 gdb_test
"print 1" "" "run command"
1170 gdbvar_simple_if_test
1171 gdbvar_simple_while_test
1172 gdbvar_complex_if_while_test
1173 progvar_simple_if_test
1174 progvar_simple_while_test
1175 progvar_complex_if_while_test
1176 if_while_breakpoint_command_test
1177 infrun_breakpoint_command_test
1178 breakpoint_command_test
1179 breakpoint_clear_command_test
1180 user_defined_command_test
1181 user_defined_command_case_sensitivity
1182 user_defined_command_args_eval
1183 user_defined_command_args_stack_test
1184 user_defined_command_manyargs_test
1185 watchpoint_command_test
1186 test_command_prompt_position
1187 deprecated_command_test
1188 bp_deleted_in_command_test
1189 temporary_breakpoint_commands
1191 source_file_with_indented_comment
1192 recursive_source_test
1194 error_clears_commands_left
1196 backslash_in_multi_line_command_test
1197 define_if_without_arg_test
1200 # This one should come last
, as it redefines
"backtrace".
1201 redefine_backtrace_test