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.exp115
1 files changed, 115 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index dfaf965..3db28b1 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -440,7 +440,120 @@ proc deprecated_command_test {} {
"deprecate with no arguments"
}
+proc bp_deleted_in_command_test {} {
+ global gdb_prompt
+
+ gdb_test "set args 1" "" "set args in bp_deleted_in_command_test"
+ delete_breakpoints
+
+ # Create a breakpoint, and associate a command-list to it, with
+ # one command that deletes this breakpoint.
+ gdb_test "break factorial" \
+ "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \
+ "breakpoint in bp_deleted_in_command_test"
+
+ send_gdb "commands\n"
+ gdb_expect {
+ -re "Type commands for when breakpoint .* is hit, one per line.*>" {
+ pass "begin commands in bp_deleted_in_command_test"
+ }
+ -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"}
+ timeout {fail "(timeout) begin commands bp_deleted_in_command_test"}
+ }
+ send_gdb "silent\n"
+ gdb_expect {
+ -re ">" {pass "add silent command"}
+ -re "$gdb_prompt $" {fail "add silent command"}
+ timeout {fail "(timeout) add silent command"}
+ }
+ send_gdb "clear factorial\n"
+ gdb_expect {
+ -re ">" {pass "add clear command"}
+ -re "$gdb_prompt $" {fail "add clear command"}
+ timeout {fail "(timeout) add clear command"} }
+ send_gdb "printf \"factorial command-list executed\\n\"\n"
+ gdb_expect {
+ -re ">" {pass "add printf command"}
+ -re "$gdb_prompt $" {fail "add printf command"}
+ timeout {fail "(timeout) add printf command"}
+ }
+ send_gdb "cont\n"
+ gdb_expect {
+ -re ">" {pass "add cont command"}
+ -re "$gdb_prompt $" {fail "add cont command"}
+ timeout {fail "(timeout) add cont command"} }
+ send_gdb "end\n"
+ gdb_expect {
+ -re "$gdb_prompt $" {pass "end commands"}
+ timeout {fail "(timeout) end commands"}
+ }
+ gdb_run_cmd
+ gdb_expect {
+ -re ".*factorial command-list executed.*1.*Program exited normally.*$gdb_prompt $" {
+ pass "run factorial until breakpoint"
+ }
+ -re ".*$gdb_prompt $" {
+ fail "run factorial until breakpoint"
+ }
+ default { fail "(timeout) run factorial until breakpoint" }
+ timeout { fail "(timeout) run factorial until breakpoint" }
+ }
+}
+
+proc temporary_breakpoint_commands {} {
+ global gdb_prompt
+
+ gdb_test "set args 1" "" "set args in temporary_breakpoint_commands"
+ delete_breakpoints
+
+ # Create a temporary breakpoint, and associate a commands list to it.
+ # This test will verify that this commands list is executed when the
+ # breakpoint is hit.
+ gdb_test "tbreak factorial" \
+ "Breakpoint \[0-9\]+ at .*: file .*/run.c, line \[0-9\]+\." \
+ "breakpoint in temporary_breakpoint_commands"
+
+ send_gdb "commands\n"
+ gdb_expect {
+ -re "Type commands for when breakpoint .* is hit, one per line.*>" {
+ pass "begin commands in bp_deleted_in_command_test"
+ }
+ -re "$gdb_prompt $" {fail "begin commands in bp_deleted_in_command_test"}
+ timeout {fail "(timeout) begin commands bp_deleted_in_command_test"}
+ }
+ send_gdb "silent\n"
+ gdb_expect {
+ -re ">" {pass "add silent tbreak command"}
+ -re "$gdb_prompt $" {fail "add silent tbreak command"}
+ timeout {fail "(timeout) add silent tbreak command"}
+ }
+ send_gdb "printf \"factorial tbreak commands executed\\n\"\n"
+ gdb_expect {
+ -re ">" {pass "add printf tbreak command"}
+ -re "$gdb_prompt $" {fail "add printf tbreak command"}
+ timeout {fail "(timeout) add printf tbreak command"}
+ }
+ send_gdb "cont\n"
+ gdb_expect {
+ -re ">" {pass "add cont tbreak command"}
+ -re "$gdb_prompt $" {fail "add cont tbreak command"}
+ timeout {fail "(timeout) add cont tbreak command"} }
+ send_gdb "end\n"
+ gdb_expect {
+ -re "$gdb_prompt $" {pass "end tbreak commands"}
+ timeout {fail "(timeout) end tbreak commands"}
+ }
+
+ gdb_run_cmd
+ gdb_expect {
+ -re ".*factorial tbreak commands executed.*1.*Program exited normally.*" {
+ pass "run factorial until temporary breakpoint"
+ }
+ timeout { fail "(timeout) run factorial until temporary breakpoint" }
+ }
+}
+
gdbvar_simple_if_test
gdbvar_simple_while_test
gdbvar_complex_if_while_test
@@ -454,3 +567,5 @@ user_defined_command_test
watchpoint_command_test
test_command_prompt_position
deprecated_command_test
+bp_deleted_in_command_test
+temporary_breakpoint_commands