1 # Copyright
1988-2024 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
17 # test special commands
(if, while, etc
)
20 # The allow_hw_watchpoint_tests checks
if watchpoints are supported by the
21 # processor.
On PowerPC
, the check runs a small test
program under gdb
22 # to determine
if the Power processor supports HW watchpoints. The check
23 # must be done before starting the test so as to not disrupt the execution
26 set allow_hw_watchpoint_tests_p
[allow_hw_watchpoint_tests
]
28 standard_testfile run.c
32 lappend flags additional_flags
=-DFAKEARGV
33 lappend_include_file flags $srcdir
/lib
/unbuffer_output.c
35 if { [prepare_for_testing
"failed to prepare" $testfile $srcfile $flags] } {
39 # Run to FUNCTION.
If that fails
, issue a FAIL and make the caller
42 proc runto_or_return
{function
} {
43 if { ![runto factorial
] } {
48 proc_with_prefix gdbvar_simple_if_test
{} {
51 gdb_test_no_output
"set \$foo = 0" "set foo"
52 # All this test should
do is print
0xdeadbeef once.
60 "$valnum_re = 0xdeadbeef" \
63 # All this test should
do is print
0xfeedface once.
71 "$valnum_re = 0xfeedface" \
75 proc_with_prefix gdbvar_simple_while_test
{} {
78 gdb_test_no_output
"set \$foo = 5" "set foo"
79 # This test should print
0xfeedface five times.
87 "$valnum_re = 0xfeedface" \
88 "$valnum_re = 0xfeedface" \
89 "$valnum_re = 0xfeedface" \
90 "$valnum_re = 0xfeedface" \
91 "$valnum_re = 0xfeedface"] \
95 proc_with_prefix gdbvar_complex_if_while_test
{} {
98 gdb_test_no_output
"set \$foo = 4" "set foo"
99 # This test should alternate between
0xdeadbeef and
0xfeedface two times.
104 { if ($foo
% 2) == 1} \
111 "$valnum_re = 0xdeadbeef" \
112 "$valnum_re = 0xfeedface" \
113 "$valnum_re = 0xdeadbeef" \
114 "$valnum_re = 0xfeedface"] \
118 proc_with_prefix progvar_simple_if_test
{} {
121 runto_or_return factorial
123 # Don
't depend upon argument passing, since most simulators don't
124 # currently support it. Bash value
variable to be what we want.
125 gdb_test
"p value=5" " = 5" "set value to 5"
126 # All this test should
do is print
0xdeadbeef once.
134 "$valnum_re = 0xdeadbeef" \
137 # All this test should
do is print
0xfeedface once.
145 "$valnum_re = 0xfeedface" \
149 proc_with_prefix progvar_simple_while_test
{} {
152 runto_or_return factorial
154 # Don
't depend upon argument passing, since most simulators don't
155 # currently support it. Bash value
variable to be what we want.
156 gdb_test
"p value=5" " = 5" "set value to 5"
157 # This test should print
0xfeedface five times.
165 "$valnum_re = 0xfeedface" \
166 "$valnum_re = 0xfeedface" \
167 "$valnum_re = 0xfeedface" \
168 "$valnum_re = 0xfeedface" \
169 "$valnum_re = 0xfeedface"] \
173 proc_with_prefix progvar_complex_if_while_test
{} {
176 runto_or_return factorial
178 # Don
't depend upon argument passing, since most simulators don't
179 # currently support it. Bash value
variable to be what we want.
180 gdb_test
"p value=4" " = 4" "set value to 4"
181 # This test should alternate between
0xdeadbeef and
0xfeedface two
187 { if (value
% 2) == 1} \
194 "$valnum_re = 0xdeadbeef" \
195 "$valnum_re = 0xfeedface" \
196 "$valnum_re = 0xdeadbeef" \
197 "$valnum_re = 0xfeedface"] \
201 proc_with_prefix if_while_breakpoint_command_test
{} {
204 runto_or_return factorial
206 # Don
't depend upon argument passing, since most simulators don't
207 # currently support it. Bash value
variable to be what we want.
208 gdb_test
"p value=5" " = 5" "set value to 5"
210 gdb_test
"break factorial" "Breakpoint.*at.*"
212 gdb_test_multiple
"commands" "commands" {
218 # This test should alternate between
0xdeadbeef and
0xfeedface two times.
223 { if (value
% 2) == 1} \
235 "$valnum_re = 0xdeadbeef" \
236 "$valnum_re = 0xfeedface" \
237 "$valnum_re = 0xdeadbeef" \
238 "$valnum_re = 0xfeedface"] \
240 gdb_test
"info break" "while.*set.*if.*p/x.*else.*p/x.*end.*"
243 # Test that we can run the inferior from breakpoint commands.
245 # The expected behavior is that all commands after the first
"step"
246 # shall be ignored. See the gdb manual
, "Break Commands",
247 # subsection
"Breakpoint command lists".
249 proc_with_prefix infrun_breakpoint_command_test
{} {
250 runto_or_return factorial
252 # Don
't depend upon argument passing, since most simulators don't
253 # currently support it. Bash value
variable to be what we want.
254 gdb_test
"p value=6" " = 6" "set value to 6"
256 gdb_test
"break factorial if value == 5" "Breakpoint.*at.*"
258 # infrun_breakpoint_command_test
- This test was broken into two parts
259 # to
get around a synchronization problem in expect.
260 # part1
: issue the gdb command
"commands"
261 # part2
: send the list of commands
263 set test
"commands #1"
264 gdb_test_multiple
"commands" $test {
269 gdb_test
"step\nstep\nstep\nstep\nend" "" \
272 gdb_test
"continue" \
273 "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*"
276 proc_with_prefix breakpoint_command_test
{} {
277 runto_or_return factorial
279 # Don
't depend upon argument passing, since most simulators don't
280 # currently support it. Bash value
variable to be what we want.
281 gdb_test
"p value=6" " = 6" "set value to 6"
283 gdb_test
"break factorial" "Breakpoint.*at.*"
287 { printf
"Now the value is %d\n", value} \
291 gdb_test
"continue" \
292 "Breakpoint \[0-9\]*, factorial.*Now the value is 5"
293 gdb_test
"print value" " = 5"
296 # Test clearing the commands of several breakpoints with one single
"end".
297 proc_with_prefix breakpoint_clear_command_test
{} {
298 runto_or_return factorial
302 gdb_test
"break factorial" "Breakpoint.*at.*"
303 gdb_test_no_output
"set \$bpnumfactorial = \$bpnum"
304 gdb_test
"break -q main" "Breakpoint.*at.*"
305 gdb_test_no_output
"set \$bpnummain = \$bpnum"
309 {commands $bpnumfactorial $bpnummain
} \
313 "set commands of two breakpoints to print 1234321"
314 gdb_test
"info breakpoints" \
317 "${any}in factorial${any}" \
318 "${any}print 1234321${any}" \
319 "${any}in main${any}" \
320 "${any}print 1234321${any}" \
322 "print 1234321 command present in the two breakpoints"
325 {commands $bpnumfactorial $bpnummain
} \
328 "clear the command list of the two breakpoints"
329 gdb_test
"info breakpoints" \
332 "${any}in factorial${any}" \
333 "${any}in main${any}" \
335 "print 1234321 command is not present anymore in the two breakpoints"
338 # Test a simple user defined command
(with arguments
)
339 proc_with_prefix user_defined_command_test
{} {
342 gdb_test_no_output
"set \$foo = 4" "set foo"
344 gdb_test_multiple
"define mycommand" "define mycommand" {
346 pass
"define mycommand"
350 # This test should alternate between
0xdeadbeef and
0xfeedface two times.
355 { if ($arg0
% 2) == 1} \
366 set valnum_re
"\\\$$decimal"
371 "$valnum_re = 0xdeadbeef" \
372 "$valnum_re = 0xfeedface" \
373 "$valnum_re = 0xdeadbeef" \
374 "$valnum_re = 0xfeedface"] \
375 "execute user-defined command"
376 gdb_test
"show user mycommand" \
377 " while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
378 "display user command"
380 # Create and test a user
-defined command with an empty body.
381 gdb_test_multiple
"define myemptycommand" "define myemptycommand" {
383 pass
"define myemptycommand"
388 "end definition of user-defined command with empty body"
390 gdb_test_no_output
"myemptycommand" \
391 "execute user-defined empty command"
393 gdb_test
"show user" \
394 "User command \"myemptycommand.*" \
395 "display empty command in command list"
397 gdb_test
"show user myemptycommand" \
398 "User command \"myemptycommand.*" \
399 "display user-defined empty command"
402 # Test that the case with which the command was defined is preserved.
404 proc_with_prefix user_defined_command_case_sensitivity
{} {
405 #
Define a first command with mixed case
name.
406 set test
"define Homer-Simpson"
407 gdb_test_multiple $test $test
{
413 gdb_test
"print 123\nend" "" "enter commands 1"
415 #
Define a second command
, same
name but different case.
416 set test
"define HomeR-SimpsoN"
417 gdb_test_multiple $test $test
{
423 gdb_test
"print 456\nend" "" "enter commands 2"
425 gdb_test
"Homer-Simpson" " = 123" "execute command Homer-Simpson"
426 gdb_test
"HomeR-SimpsoN" " = 456" "execute command HomeR-SimpsoN"
427 gdb_test
"HOMER-SIMPSON" "Undefined command.*" "try to call in upper case"
428 gdb_test
"homer-simpson" "Undefined command.*" "try to call in lower case"
431 # Test that
"eval" in a user-defined command expands $argc/$argN.
433 proc_with_prefix user_defined_command_args_eval
{} {
434 gdb_test_multiple
"define command_args_eval" \
435 "define command_args_eval" {
441 # Make a command that constructs references to $argc and $argN via
445 {eval
"printf \"argc = %%d,\", $arg%c", 'c'} \
448 { eval
"printf \" %%d\", $arg%d", $i} \
456 gdb_test
"command_args_eval 1 2 3" "argc = 3, 1 2 3" "execute command"
459 # Test that the $argc
/$argN variables are pushed
on/popped from the
460 #
args stack correctly when a user
-defined command calls another
461 # user
-defined command
(or in this case
, recurses
).
463 proc_with_prefix user_defined_command_args_stack_test
{} {
464 gdb_test_multiple
"define args_stack_command" \
465 "define args_stack_command" {
471 # Make a command that refers to $argc
/$argN before and after
472 # recursing. Also
, vary the number of arguments passed to each
476 {printf
"before, argc = %d,", $argc} \
479 { eval
"printf \" %%d\", $arg%d", $i} \
486 { args_stack_command
21 22} \
489 { args_stack_command
11} \
493 {printf
"after, argc = %d,", $argc} \
496 { eval
"printf \" %%d\", $arg%d", $i} \
506 "before, argc = 3, 31 32 33" \
507 "before, argc = 2, 21 22" \
508 "before, argc = 1, 11" \
509 "after, argc = 1, 11" \
510 "after, argc = 2, 21 22" \
511 "after, argc = 3, 31 32 33"]
512 gdb_test
"args_stack_command 31 32 33" $expected "execute command"
515 # Test a simple user defined command with many arguments. GDB
<= 7.12
516 # used to have a hard coded
limit of
10 arguments.
518 proc_with_prefix user_defined_command_manyargs_test
{} {
519 set test
"define command"
520 gdb_test_multiple
"define manyargs" $test {
526 #
Define a function that doubles its arguments.
529 {printf
"nargs=%d:", $argc} \
532 { eval
"printf \" %%d\", 2 * $arg%d\n", $i} \
540 # Some
random number of arguments
, as long as higher than
10.
544 for {set i
1} {$i
<= $nargs
} {incr i
} {
548 set expected
"nargs=$nargs:"
549 for {set i
1} {$i
<= $nargs
} {incr i
} {
550 append expected
" " [expr 2 * $i]
553 gdb_test $cmd $expected
"execute command"
556 proc_with_prefix watchpoint_command_test
{} {
558 global allow_hw_watchpoint_tests_p
560 # Disable hardware watchpoints
if necessary.
561 if {!$allow_hw_watchpoint_tests_p
} {
562 gdb_test_no_output
"set can-use-hw-watchpoints 0" ""
565 runto_or_return factorial
569 # Verify that we can create a watchpoint
, and give it a commands
570 # list that continues the inferior. We
set the watchpoint
on a
571 # local
variable, too
, so that it self
-deletes when the watched
572 # data goes out of scope.
574 # What should happen is
: Each time the watchpoint triggers
, it
575 # continues the inferior. Eventually
, the watchpoint will self
-
576 #
delete, when the watched
variable is out of scope. But by that
577 # time
, the inferior should have exited. GDB shouldn
't crash or
578 # anything untoward as a result of this.
582 gdb_test_multiple "watch local_var" "watch local_var" {
583 -re "\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
584 set wp_id $expect_out(1,string)
585 pass "watch local_var"
589 if {$wp_id == -1} {return}
591 gdb_test_multiple "commands $wp_id" "begin commands on watch" {
592 -re "Type commands for breakpoint.*, one per line.*>$" {
593 pass "begin commands on watch"
596 # See the 'No symbol
"value...' fail below. This command will
597 # fail
if it
's executed in the wrong frame. If adjusting the
598 # test, make sure this property holds.
599 gdb_test_multiple "print value" "add print command to watch" {
601 pass "add print command to watch"
604 gdb_test_multiple "continue" "add continue command to watch" {
606 pass "add continue command to watch"
611 "end commands on watch"
613 set test "continue with watch"
614 set lno_1 [gdb_get_line_number "commands.exp: hw local_var out of scope" "run.c"]
615 set lno_2 [gdb_get_line_number "commands.exp: local_var out of scope" "run.c"]
616 gdb_test_multiple "continue" "$test" {
617 -re "No symbol \"value\" in current context.\r\n$gdb_prompt $" {
618 # Happens if GDB actually runs the watchpoints commands,
619 # even though the watchpoint was deleted for not being in
623 -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 $" {
629 proc_with_prefix test_command_prompt_position {} {
633 runto_or_return factorial
635 # Don't depend upon
argument passing
, since most simulators don
't
636 # currently support it. Bash value variable to be what we want.
638 gdb_test "break factorial" "Breakpoint.*at.*"
639 gdb_test "p value=5" ".*" "set value to 5"
640 # All this test should do is print 0xdeadbeef once.
648 "$valnum_re = 0xdeadbeef" \
651 # Now let's test
for the correct position of the
'>' in gdb
's
652 # prompt for commands. It should be at the beginning of the line,
653 # and not after one space.
656 gdb_test_multiple "commands" $test {
657 -re "Type commands.*End with.*\[\r\n\]>$" {
658 gdb_test_multiple "printf \"Now the value is %d\\n\", value" $test {
659 -re "^printf.*value\r\n>$" {
660 gdb_test_multiple "end" $test {
661 -re "^end\r\n$gdb_prompt $" {
673 proc_with_prefix deprecated_command_test {} {
674 gdb_test "maintenance deprecate blah" "Can't find command.
*" \
675 "tried to deprecate non-existing command"
677 gdb_test_no_output
"maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /1/"
679 "Warning: 'p', an alias for the command 'print', is deprecated.*Use 'new_p'.*" \
680 "p deprecated warning, with replacement"
681 gdb_test
"p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /1/"
683 gdb_test_no_output
"maintenance deprecate p \"new_p\"" "maintenance deprecate p \"new_p\" /2/"
684 gdb_test_no_output
"maintenance deprecate print \"new_print\""
686 "Warning: command 'print' \\(p\\) is deprecated.*Use 'new_print'.*" \
687 "both alias and command are deprecated"
688 gdb_test
"p 5" ".\[0-9\]* = 5.*" "deprecated warning goes away /2/"
690 gdb_test_no_output
"maintenance deprecate set remote memory-read-packet-size \"srm\" " \
691 "deprecate long command /1/"
692 gdb_test
"set remote memory-read-packet-size" \
693 "Warning: command 'set remote memory-read-packet-size' is deprecated.*Use 'srm'.*" \
694 "long command deprecated /1/"
696 gdb_test_no_output
"maintenance deprecate set remote memory-read-packet-size" \
697 "deprecate long command /2/"
698 gdb_test
"set remote memory-read-packet-size" \
699 "Warning: command 'set remote memory-read-packet-size' is deprecated.*No alternative known.*" \
700 "long command deprecated with no alternative /2/"
702 gdb_test
"maintenance deprecate" \
703 "\"maintenance deprecate\".*" \
704 "deprecate with no arguments"
706 # Test that an alias with a prefix still gives a warning.
707 set file1
[standard_output_file xxx_yyy_cmd
]
708 set fd
[open
"$file1" w]
711 echo in command xxx_yyy
\\n
714 alias
set qqq_aaa
=set xxx_yyy
715 maintenance deprecate
set qqq_aaa
"
717 gdb_test_no_output
"source $file1" \
718 "source file containing xxx_yyy command and its alias"
719 gdb_test
"set qqq_aaa" \
720 "Warning: 'set qqq_aaa', an alias for the command 'set xxx_yyy', is deprecated\\.\r\n.*No alternative known\\..*" \
721 "deprecated alias with prefix give a warning"
724 # Test that the help
for a command does not
show deprecated aliases.
726 proc_with_prefix deprecated_command_alias_help_test
{} {
727 gdb_test_multiline
"define real_command" \
728 "define real_command" "End with a line saying just \"end\"\\." \
732 gdb_test_no_output
"alias alias_command = real_command"
733 gdb_test_no_output
"alias alias_with_args_command = real_command 123"
735 gdb_test
"help real_command" \
736 "real_command, alias_with_args_command, alias_command\r\n alias alias_with_args_command = real_command 123\r\nUser-defined." \
737 "help real_command, before"
738 gdb_test_no_output
"maintenance deprecate alias_command"
739 gdb_test_no_output
"maintenance deprecate alias_with_args_command"
740 gdb_test
"help real_command" \
742 "help real_command, after"
745 proc_with_prefix bp_deleted_in_command_test
{} {
750 # Create a breakpoint
, and associate a command
-list to it
, with
751 # one command that deletes this breakpoint.
752 gdb_test
"break factorial" \
753 "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\."
755 gdb_test_multiple
"commands" "begin commands" {
756 -re
"Type commands for breakpoint.*>$" {
757 pass
"begin commands"
760 gdb_test_multiple
"silent" "add silent command" {
762 pass
"add silent command"
765 gdb_test_multiple
"clear factorial" "add clear command" {
767 pass
"add clear command"
770 gdb_test_multiple
"printf \"factorial command-list executed\\n\"" \
771 "add printf command" {
773 pass
"add printf command"
776 gdb_test_multiple
"cont" "add cont command" {
778 pass
"add cont command"
786 gdb_test
"" "factorial command-list executed.*" "run factorial until breakpoint"
789 proc_with_prefix temporary_breakpoint_commands
{} {
792 # Create a temporary breakpoint
, and associate a commands list to it.
793 # This test will verify that this commands list is executed when the
795 gdb_test
"tbreak factorial" \
796 "Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
799 gdb_test_multiple
"commands" \
800 "begin commands in bp_deleted_in_command_test" {
801 -re
"Type commands for breakpoint.*>$" {
802 pass
"begin commands"
805 gdb_test_multiple
"silent" "add silent tbreak command" {
807 pass
"add silent tbreak command"
810 gdb_test_multiple
"printf \"factorial tbreak commands executed\\n\"" \
811 "add printf tbreak command" {
813 pass
"add printf tbreak command"
816 gdb_test_multiple
"cont" "add cont tbreak command" {
818 pass
"add cont tbreak command"
823 "end tbreak commands"
826 gdb_test
"" "factorial tbreak commands executed.*" \
827 "run factorial until temporary breakpoint"
830 # Test that GDB can handle $arg0 outside of user functions without
832 proc_with_prefix stray_arg0_test
{ } {
835 gdb_test
"print \$arg0" \
836 "$valnum_re = void" \
839 gdb_test
"if 1 == 1\nprint \$arg0\nend" \
840 "$valnum_re = void" \
843 gdb_test
"print \$arg0 = 1" \
847 gdb_test
"print \$arg0" \
852 # Test that GDB is able to source a file with an indented comment.
853 proc_with_prefix source_file_with_indented_comment
{} {
854 set file1
[standard_output_file source_file_with_indented_comment
]
856 set fd
[open
"$file1" w]
864 gdb_test
"source $file1" "Done!" "source file"
867 # Test that GDB can handle arguments when sourcing files recursively.
868 #
If the arguments are overwritten with #######
then the test has failed.
869 proc_with_prefix recursive_source_test
{} {
870 set file1
[standard_output_file recursive_source_1
]
871 set file2
[standard_output_file recursive_source_2
]
872 set file3
[standard_output_file recursive_source_3
]
874 set fd
[open
"$file1" w]
880 set fd
[open
"$file2" w]
883 echo
1: <<<\$arg0
>>>\\n
885 echo
2: <<<\$arg0
>>>\\n
889 set fd
[open
"$file3" w]
892 #################################################################
"
895 gdb_test
"source $file1" \
896 "1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
900 proc gdb_test_no_prompt
{ command result msg
} {
901 set msg
"$command - $msg"
902 set result
"^[string_to_regexp $command]\r\n$result$"
903 gdb_test_multiple $command $msg
{
916 proc_with_prefix if_commands_test
{} {
919 gdb_test_no_output
"set \$tem = 1" "set \$tem"
921 set test
"if_commands_test 1"
922 gdb_test_no_prompt
"if \$tem == 2" { >} $test
923 gdb_test_no_prompt
"break -q main" { >} $test
924 gdb_test_no_prompt
"else" { >} $test
925 gdb_test_no_prompt
"break factorial" { >} $test
926 gdb_test_no_prompt
"commands" { >} $test
927 gdb_test_no_prompt
"silent" { >} $test
928 gdb_test_no_prompt
"set \$tem = 3" { >} $test
929 gdb_test_no_prompt
"continue" { >} $test
930 gdb_test_multiple
"end" "first end - $test" {
932 pass
"first end - $test"
935 fail
"first end - $test"
938 gdb_test_multiple
"end" "second end - $test" {
939 -re
"Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
940 pass
"second end - $test"
942 -re
"Undefined command: \"silent\".*$gdb_prompt $" {
943 fail
"second end - $test"
947 set test
"if_commands_test 2"
948 gdb_test_no_prompt
"if \$tem == 1" { >} $test
949 gdb_test_no_prompt
"break -q main" { >} $test
950 gdb_test_no_prompt
"else" { >} $test
951 gdb_test_no_prompt
"break factorial" { >} $test
952 gdb_test_no_prompt
"commands" { >} $test
953 gdb_test_no_prompt
"silent" { >} $test
954 gdb_test_no_prompt
"set \$tem = 3" { >} $test
955 gdb_test_no_prompt
"continue" { >} $test
956 gdb_test_multiple
"end" "first end - $test" {
958 pass
"first end - $test"
961 fail
"first end - $test"
964 gdb_test_multiple
"end" "second end - $test" {
965 -re
"Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\.\r\n$gdb_prompt $" {
966 pass
"second end - $test"
971 # Verify an error during
"commands" commands execution will prevent any other
972 #
"commands" from other breakpoints at the same location to be executed.
974 proc_with_prefix error_clears_commands_left
{} {
975 set test
"hook-stop 1"
976 gdb_test_multiple
{define hook
-stop
} $test
{
977 -re
"End with a line saying just \"end\"\\.\r\n>$" {
981 set test
"hook-stop 1a"
982 gdb_test_multiple
{echo hook
-stop1
\n} $test
{
987 gdb_test_no_output
"end" "hook-stop 1b"
990 gdb_breakpoint
"main"
992 set test
"main commands 1"
993 gdb_test_multiple
{commands $bpnum
} $test
{
994 -re
"End with a line saying just \"end\"\\.\r\n>$" {
998 set test
"main commands 1a"
999 gdb_test_multiple
{echo cmd1
\n} $test
{
1004 set test
"main commands 1b"
1005 gdb_test_multiple
{errorcommandxy
\n} $test
{
1010 gdb_test_no_output
"end" "main commands 1c"
1012 gdb_breakpoint
"main"
1013 set test
"main commands 2"
1014 gdb_test_multiple
{commands $bpnum
} $test
{
1015 -re
"End with a line saying just \"end\"\\.\r\n>$" {
1019 set test
"main commands 2a"
1020 gdb_test_multiple
{echo cmd2
\n} $test
{
1025 set test
"main commands 2b"
1026 gdb_test_multiple
{errorcommandyz
\n} $test
{
1031 gdb_test_no_output
"end" "main commands 2c"
1040 "Undefined command: \"errorcommandxy\"\\. Try \"help\"\\."] \
1043 gdb_test
{echo idle
\n} "\r\nidle" "no cmd2"
1046 proc_with_prefix redefine_hook_test
{} {
1062 set test
"redefine one"
1063 gdb_test_multiple
"define one" $test {
1064 -re
"Redefine command .one.. .y or n. $" {
1074 gdb_test
"end" "" "enter commands for one redefinition"
1076 gdb_test
"one" "hibob" "execute one command"
1079 proc_with_prefix redefine_backtrace_test
{} {
1080 gdb_test_multiple
"define backtrace" "define backtrace" {
1081 -re
"Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
1082 pass
"define backtrace"
1086 gdb_test_multiple
"y" "expect response to define backtrace" {
1087 -re
"End with a line saying just \"end\"\\.\r\n>$" {
1088 pass
"expect response to define backtrace"
1099 gdb_test
"backtrace" "hibob" "execute backtrace command"
1100 gdb_test
"bt" "hibob" "execute bt command"
1103 # Test using
"if" and "while" without args when building a command list.
1105 proc define_if_without_arg_test
{} {
1106 foreach cmd
{if while define} {
1107 set test
"define some_command_$cmd"
1108 gdb_test_multiple $test $test
{
1114 gdb_test
"$cmd" "$cmd command requires an argument." "type $cmd without args"
1118 # Test the loop_break command.
1120 proc_with_prefix loop_break_test
{} {
1121 gdb_test_no_output
"set \$a = 0" "initialize \$a"
1122 gdb_test_no_output
"set \$total = 0" "initialize \$total"
1135 " set \$total = \$total + 1" \
1136 " set \$b = \$b + 1" \
1138 " set \$a = \$a + 1" \
1143 gdb_test
"print \$a" " = 4" "validate \$a"
1144 gdb_test
"print \$b" " = 2" "validate \$b"
1145 gdb_test
"print \$total" " = 8" "validate \$total"
1148 # Test the loop_continue command.
1150 proc_with_prefix loop_continue_test
{} {
1151 gdb_test_no_output
"set \$a = 0" "initialize \$a"
1152 gdb_test_no_output
"set \$total = 0" "initialize \$total"
1157 " set \$a = \$a + 1" \
1163 " set \$b = \$b + 1" \
1167 " set \$total = \$total + 1" \
1173 gdb_test
"print \$a" " = 5" "validate \$a"
1174 gdb_test
"print \$b" " = 5" "validate \$b"
1175 gdb_test
"print \$total" " = 16" "validate \$total"
1178 # Test an input line split with a continuation character
(backslash
)
1179 #
while entering a multi
-line command
(in a secondary prompt
).
1181 proc_with_prefix backslash_in_multi_line_command_test
{} {
1182 set dg_ver
[dejagnu_version
]
1183 set dg_major
[lindex $dg_ver
0]
1184 set dg_minor
[lindex $dg_ver
1]
1186 # With older versions of DejaGnu
, the
"\\\n" we send gets replaced with a
1187 # space
, thus breaking the test. Just skip it in that case.
1188 if { $dg_major
== 1 && $dg_minor
< 5 } {
1189 untested
"dejagnu version is too old"
1193 gdb_breakpoint
"main"
1195 gdb_test_multiple
"commands" "commands" {
1196 -re
"End with a line saying just \"end\"\\.\r\n>$" {
1201 set test
"input line split with backslash"
1202 send_gdb
"print \\\nargc\n"
1203 gdb_test_multiple
"" $test {
1204 -re
"^print \\\\\r\nargc\r\n>$" {
1209 gdb_test_no_output
"end"
1211 # Input
any command
, just to be sure the readline state is sane.
1212 # In PR
21218, this would trigger the infamous
:
1213 # readline
: readline_callback_read_char
() called with no handler
!
1214 gdb_test
"print 1" "" "run command"
1217 gdbvar_simple_if_test
1218 gdbvar_simple_while_test
1219 gdbvar_complex_if_while_test
1220 progvar_simple_if_test
1221 progvar_simple_while_test
1222 progvar_complex_if_while_test
1223 if_while_breakpoint_command_test
1224 infrun_breakpoint_command_test
1225 breakpoint_command_test
1226 breakpoint_clear_command_test
1227 user_defined_command_test
1228 user_defined_command_case_sensitivity
1229 user_defined_command_args_eval
1230 user_defined_command_args_stack_test
1231 user_defined_command_manyargs_test
1232 watchpoint_command_test
1233 test_command_prompt_position
1234 deprecated_command_test
1235 deprecated_command_alias_help_test
1236 bp_deleted_in_command_test
1237 temporary_breakpoint_commands
1239 source_file_with_indented_comment
1240 recursive_source_test
1242 error_clears_commands_left
1244 backslash_in_multi_line_command_test
1245 define_if_without_arg_test
1248 # This one should come last
, as it redefines
"backtrace".
1249 redefine_backtrace_test