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.exp99
1 files changed, 95 insertions, 4 deletions
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 72356ec..62d9f10 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -93,6 +93,7 @@ proc progvar_simple_while_test {} {
return
}
+ gdb_test "set args 5" "" "set args in progvar_simple_while_test"
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't currently
# support it. Bash value variable to be what we want.
@@ -110,6 +111,7 @@ proc progvar_complex_if_while_test {} {
return
}
+ gdb_test "set args 4" "" "set args in progvar_complex_if_while_test"
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't currently
# support it. Bash value variable to be what we want.
@@ -125,6 +127,7 @@ proc if_while_breakpoint_command_test {} {
return
}
+ gdb_test "set args 5" "" "set args in if_while_breakpoint_command_test"
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't currently
# support it. Bash value variable to be what we want.
@@ -155,6 +158,7 @@ proc infrun_breakpoint_command_test {} {
return
}
+ gdb_test "set args 6" "" "set args in progvar_simple_while_test"
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't currently
# support it. Bash value variable to be what we want.
@@ -177,8 +181,14 @@ proc infrun_breakpoint_command_test {} {
}
gdb_test "step\nstep\nstep\nstep\nbt\nend" "" \
"commands in infrun_breakpoint_command_test #2"
-
- gdb_test "continue" "Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*
+
+ if { [istarget "hppa*-hp-hpux*"] } {
+ gdb_test "continue" \
+ "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*" \
+ "contiune in infrun_breakpoint_command_test"
+ } else {
+ gdb_test "continue" \
+ "Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*
\[0-9\]*\[ \]*if \\(value > 1\\) \{.*
\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*
factorial \\(value=4\\) at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*
@@ -190,7 +200,9 @@ factorial \\(value=3\\) at .*
#2 \[0-9a-fx\]* in factorial \\(value=5\\).*
#3 \[0-9a-fx\]* in factorial \\(value=6\\).*
#4 \[0-9a-fx\]* in main \\(.*\\).*" \
- "continue in infrun_breakpoint_command_test";
+ "continue in infrun_breakpoint_command_test";
+ }
+
gdb_stop_suppressing_tests;
}
@@ -200,6 +212,7 @@ proc breakpoint_command_test {} {
return
}
+ gdb_test "set args 6" "" "set args in breakpoint_command_test"
if { ![runto factorial] } then { gdb_suppress_tests; }
# Don't depend upon argument passing, since most simulators don't currently
# support it. Bash value variable to be what we want.
@@ -207,7 +220,7 @@ proc breakpoint_command_test {} {
delete_breakpoints
gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2"
gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \
- "Type commands.*\nEnd with.*" "commands in breakpoint_command_test"
+ "End with.*" "commands in breakpoint_command_test"
gdb_test "continue" "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \
"continue in breakpoint_command_test"
gdb_test "print value" " = 5" "print value in breakpoint_command_test"
@@ -236,7 +249,84 @@ proc user_defined_command_test {} {
gdb_test "show user mycommand" "while.*set.*if.*p/x.*else.*p/x.*end.*" "display user command in user_defined_command_test"
}
+proc watchpoint_command_test {} {
+ global noargs
+ global gdb_prompt
+
+ if [target_info exists noargs] {
+ verbose "Skipping watchpoint_command_test because of noargs."
+ return
+ }
+
+ gdb_test "set args 6" "" "set args in watchpoint_command_test"
+ if { ![runto factorial] } then { return }
+ delete_breakpoints
+
+ # Verify that we can create a watchpoint, and give it a commands
+ # list that continues the inferior. We set the watchpoint on a
+ # local variable, too, so that it self-deletes when the watched
+ # data goes out of scope.
+ #
+ # What should happen is: Each time the watchpoint triggers, it
+ # continues the inferior. Eventually, the watchpoint will self-
+ # delete, when the watched variable is out of scope. But by that
+ # time, the inferior should have exited. GDB shouldn't crash or
+ # anything untoward as a result of this.
+ #
+ set wp_id -1
+
+ send_gdb "watch local_var\n"
+ gdb_expect {
+ -re ".*\[Ww\]atchpoint (\[0-9\]*): local_var.*$gdb_prompt $" {
+ set wp_id $expect_out(1,string)
+ pass "watch local_var"
+ }
+ -re "$gdb_prompt $"\
+ {fail "watch local_var"}
+ timeout {fail "(timeout) watch local_var"}
+ }
+ if {$wp_id == -1} {return}
+
+ send_gdb "commands $wp_id\n"
+ gdb_expect {
+ -re "Type commands for when breakpoint $wp_id is hit, one per line.*>"\
+ {pass "begin commands on watch"}
+ -re "$gdb_prompt $"\
+ {fail "begin commands on watch"}
+ timeout {fail "(timeout) begin commands on watch"}
+ }
+ send_gdb "print value\n"
+ gdb_expect {
+ -re ">"\
+ {pass "add print command to watch"}
+ -re "$gdb_prompt $"\
+ {fail "add print command to watch"}
+ timeout {fail "(timeout) add print command to watch"}
+ }
+ send_gdb "continue\n"
+ gdb_expect {
+ -re ">"\
+ {pass "add continue command to watch"}
+ -re "$gdb_prompt $"\
+ {fail "add continue command to watch"}
+ timeout {fail "(timeout) add continue command to watch"}
+ }
+ send_gdb "end\n"
+ gdb_expect {
+ -re "$gdb_prompt $"\
+ {pass "begin commands on watch"}
+ timeout {fail "(timeout) begin commands on watch"}
+ }
+ send_gdb "continue\n"
+ gdb_expect {
+ -re "Continuing.*\[Ww\]atchpoint $wp_id deleted because the program has left the block in.*which its expression is valid.*run.c:57.*"\
+ {pass "continue with watch"}
+ -re "$gdb_prompt $"\
+ {fail "continue with watch"}
+ timeout {fail "(timeout) continue with watch"}
+ }
+}
proc test_command_prompt_position {} {
global gdb_prompt
@@ -295,6 +385,7 @@ if_while_breakpoint_command_test
infrun_breakpoint_command_test
breakpoint_command_test
user_defined_command_test
+watchpoint_command_test
test_command_prompt_position