aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/help.exp2
-rw-r--r--gdb/testsuite/gdb.base/watchpoint.c13
-rw-r--r--gdb/testsuite/gdb.base/watchpoint.exp19
3 files changed, 33 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp
index d270be1..6e70b9d 100644
--- a/gdb/testsuite/gdb.base/help.exp
+++ b/gdb/testsuite/gdb.base/help.exp
@@ -669,7 +669,7 @@ test_class_help "user-defined" {
"Use the \"define\" command to define a command\.\[\r\n\]+"
}
# test help watch
-gdb_test "help watch" "Set a watchpoint for an expression\.\[\r\n\]+A watchpoint stops execution of your program whenever the value of\[\r\n\]+an expression changes\." "help watch"
+gdb_test "help watch" "Set a watchpoint for an expression\.\[\r\n\]+Usage: watch .-l.-location. EXPRESSION\[\r\n\]+A watchpoint stops execution of your program whenever the value of\[\r\n\]+an expression changes\.\[\r\n\]+If -l or -location is given, this evaluates EXPRESSION and watches\[\r\n\]+the memory to which it refers\." "help watch"
# test help whatis
gdb_test "help whatis" "Print data type of expression EXP\." "help whatis"
# test help where
diff --git a/gdb/testsuite/gdb.base/watchpoint.c b/gdb/testsuite/gdb.base/watchpoint.c
index 8c212c1..9ef9253 100644
--- a/gdb/testsuite/gdb.base/watchpoint.c
+++ b/gdb/testsuite/gdb.base/watchpoint.c
@@ -126,6 +126,17 @@ func4 ()
global_ptr++;
}
+void
+func5 ()
+{
+ int val = 0, val2 = 23;
+ int *x = &val;
+
+ /* func5 breakpoint here */
+ x = &val2;
+ val = 27;
+}
+
int main ()
{
#ifdef usestubs
@@ -203,5 +214,7 @@ int main ()
func4 ();
+ func5 ();
+
return 0;
}
diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp
index 6029b5b..edc7ea0 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -615,6 +615,8 @@ proc test_watchpoint_and_breakpoint {} {
kfail "gdb/38" "next after watch x"
}
}
+
+ gdb_test_no_output "delete \$bpnum" "delete watch x"
}
}
@@ -628,6 +630,19 @@ proc test_constant_watchpoint {} {
gdb_test_no_output "delete \$bpnum" "delete watchpoint `7 + count'"
}
+proc test_watch_location {} {
+ gdb_breakpoint [gdb_get_line_number "func5 breakpoint here"]
+ gdb_continue_to_breakpoint "func5 breakpoint here"
+
+ gdb_test "watch -location *x" "atchpoint .*: .*" "watch -location .x"
+
+ gdb_test "continue" \
+ "Continuing.*\[Ww\]atchpoint .*: .*New value = 27.*" \
+ "continue with watch -location"
+
+ gdb_test_no_output "delete \$bpnum" "delete watch -location"
+}
+
proc test_inaccessible_watchpoint {} {
global gdb_prompt
@@ -678,6 +693,8 @@ proc test_watchpoint_in_big_blob {} {
gdb_test "watch buf" ".*atchpoint \[0-9\]+: buf"
gdb_test "cont" "Continuing.*atchpoint \[0-9\]+: buf\r\n\r\nOld value = .*testte\".*" "watchpoint on buf hit"
+
+ gdb_test_no_output "delete \$bpnum" "delete watch buf"
}
# Start with a fresh gdb.
@@ -853,6 +870,8 @@ if [initialize] then {
}
test_constant_watchpoint
+
+ test_watch_location
}
# Restore old timeout