aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/commands.exp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.base/commands.exp')
-rw-r--r--gdb/testsuite/gdb.base/commands.exp129
1 files changed, 108 insertions, 21 deletions
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 4963743..17f113c 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -34,7 +34,6 @@ proc runto_or_return {function} {
}
proc_with_prefix gdbvar_simple_if_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 0" "set foo"
@@ -62,7 +61,6 @@ proc_with_prefix gdbvar_simple_if_test {} {
}
proc_with_prefix gdbvar_simple_while_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 5" "set foo"
@@ -83,7 +81,6 @@ proc_with_prefix gdbvar_simple_while_test {} {
}
proc_with_prefix gdbvar_complex_if_while_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 4" "set foo"
@@ -107,7 +104,6 @@ proc_with_prefix gdbvar_complex_if_while_test {} {
}
proc_with_prefix progvar_simple_if_test {} {
- global gdb_prompt
global valnum_re
runto_or_return factorial
@@ -139,7 +135,6 @@ proc_with_prefix progvar_simple_if_test {} {
}
proc_with_prefix progvar_simple_while_test {} {
- global gdb_prompt
global valnum_re
runto_or_return factorial
@@ -164,7 +159,6 @@ proc_with_prefix progvar_simple_while_test {} {
}
proc_with_prefix progvar_complex_if_while_test {} {
- global gdb_prompt
global valnum_re
runto_or_return factorial
@@ -289,7 +283,6 @@ proc_with_prefix breakpoint_command_test {} {
# Test a simple user defined command (with arguments)
proc_with_prefix user_defined_command_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 4" "set foo"
@@ -352,11 +345,38 @@ proc_with_prefix user_defined_command_test {} {
"display user-defined empty command"
}
+# Test that the case with which the command was defined is preserved.
+
+proc_with_prefix user_defined_command_case_sensitivity {} {
+ # Define a first command with mixed case name.
+ set test "define Homer-Simpson"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "print 123\nend" "" "enter commands 1"
+
+ # Define a second command, same name but different case.
+ set test "define HomeR-SimpsoN"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "print 456\nend" "" "enter commands 2"
+
+ gdb_test "Homer-Simpson" " = 123" "execute command"
+ gdb_test "HomeR-SimpsoN" " = 456" "execute command"
+ gdb_test "HOMER-SIMPSON" "Undefined command.*" "try to call in upper case"
+ gdb_test "homer-simpson" "Undefined command.*" "try to call in lower case"
+}
+
# Test that "eval" in a user-defined command expands $argc/$argN.
proc_with_prefix user_defined_command_args_eval {} {
- global gdb_prompt
-
gdb_test_multiple "define command_args_eval" \
"define command_args_eval" {
-re "End with" {
@@ -387,8 +407,6 @@ proc_with_prefix user_defined_command_args_eval {} {
# user-defined command (or in this case, recurses).
proc_with_prefix user_defined_command_args_stack_test {} {
- global gdb_prompt
-
gdb_test_multiple "define args_stack_command" \
"define args_stack_command" {
-re "End with" {
@@ -444,8 +462,6 @@ proc_with_prefix user_defined_command_args_stack_test {} {
# used to have a hard coded limit of 10 arguments.
proc_with_prefix user_defined_command_manyargs_test {} {
- global gdb_prompt
-
set test "define command"
gdb_test_multiple "define manyargs" $test {
-re "End with" {
@@ -678,8 +694,6 @@ proc_with_prefix bp_deleted_in_command_test {} {
}
proc_with_prefix temporary_breakpoint_commands {} {
- global gdb_prompt
-
delete_breakpoints
# Create a temporary breakpoint, and associate a commands list to it.
@@ -795,8 +809,6 @@ end"
}
proc gdb_test_no_prompt { command result msg } {
- global gdb_prompt
-
set msg "$command - $msg"
set result "^[string_to_regexp $command]\r\n$result$"
gdb_test_multiple $command $msg {
@@ -943,8 +955,6 @@ proc_with_prefix error_clears_commands_left {} {
}
proc_with_prefix redefine_hook_test {} {
- global gdb_prompt
-
gdb_test \
[multi_line_input \
"define one"\
@@ -978,8 +988,6 @@ proc_with_prefix redefine_hook_test {} {
}
proc_with_prefix redefine_backtrace_test {} {
- global gdb_prompt
-
gdb_test_multiple "define backtrace" "define backtrace" {
-re "Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
pass "define backtrace"
@@ -1003,6 +1011,81 @@ proc_with_prefix redefine_backtrace_test {} {
gdb_test "bt" "hibob" "execute bt command"
}
+# Test using "if" and "while" without args when building a command list.
+
+proc define_if_without_arg_test {} {
+ foreach cmd {if while} {
+ set test "define some_command_$cmd"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "$cmd" "if/while commands require arguments." "type $cmd without args"
+ }
+}
+
+# Test the loop_break command.
+
+proc_with_prefix loop_break_test {} {
+ gdb_test_no_output "set \$a = 0" "initialize \$a"
+ gdb_test_no_output "set \$total = 0" "initialize \$total"
+
+ gdb_test \
+ [multi_line_input \
+ "while \$a < 5" \
+ " if \$a == 4" \
+ " loop_break" \
+ " end" \
+ " set \$b = 0" \
+ " while \$b < 5" \
+ " if \$b == 2" \
+ " loop_break" \
+ " end" \
+ " set \$total = \$total + 1" \
+ " set \$b = \$b + 1" \
+ " end" \
+ " set \$a = \$a + 1" \
+ "end"] \
+ "" \
+ "run while loop"
+
+ gdb_test "print \$a" " = 4" "validate \$a"
+ gdb_test "print \$b" " = 2" "validate \$b"
+ gdb_test "print \$total" " = 8" "validate \$total"
+}
+
+# Test the loop_continue command.
+
+proc_with_prefix loop_continue_test {} {
+ gdb_test_no_output "set \$a = 0" "initialize \$a"
+ gdb_test_no_output "set \$total = 0" "initialize \$total"
+
+ gdb_test \
+ [multi_line_input \
+ "while \$a < 5" \
+ " set \$a = \$a + 1" \
+ " set \$b = 0" \
+ " if \$a == 4" \
+ " loop_continue" \
+ " end" \
+ " while \$b < 5" \
+ " set \$b = \$b + 1" \
+ " if \$b == 2" \
+ " loop_continue" \
+ " end" \
+ " set \$total = \$total + 1" \
+ " end" \
+ "end"] \
+ "" \
+ "run while loop"
+
+ gdb_test "print \$a" " = 5" "validate \$a"
+ gdb_test "print \$b" " = 5" "validate \$b"
+ gdb_test "print \$total" " = 16" "validate \$total"
+}
+
# Test an input line split with a continuation character (backslash)
# while entering a multi-line command (in a secondary prompt).
@@ -1052,6 +1135,7 @@ if_while_breakpoint_command_test
infrun_breakpoint_command_test
breakpoint_command_test
user_defined_command_test
+user_defined_command_case_sensitivity
user_defined_command_args_eval
user_defined_command_args_stack_test
user_defined_command_manyargs_test
@@ -1067,5 +1151,8 @@ if_commands_test
error_clears_commands_left
redefine_hook_test
backslash_in_multi_line_command_test
+define_if_without_arg_test
+loop_break_test
+loop_continue_test
# This one should come last, as it redefines "backtrace".
redefine_backtrace_test