aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/testsuite/ChangeLog9
-rw-r--r--gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c2
-rw-r--r--gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp44
3 files changed, 49 insertions, 6 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index af6104a..ec319ab 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
2015-04-10 Pedro Alves <palves@redhat.com>
+ * gdb.threads/step-over-trips-on-watchpoint.c (child_function):
+ Remove comment.
+ * gdb.threads/step-over-trips-on-watchpoint.exp (do_test): Find
+ both the address of the instruction that triggers the watchpoint
+ and the address of the instruction immediately after, and use
+ those addresses for the test. Fix comment.
+
+2015-04-10 Pedro Alves <palves@redhat.com>
+
* gdb.base/sigstep.exp (breakpoint_to_handler)
(breakpoint_to_handler_entry): New parameter 'displaced'. Use it.
Test "backtrace" in handler.
diff --git a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c
index 13404da..6cf97fb 100644
--- a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c
+++ b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c
@@ -36,7 +36,7 @@ child_function (void *arg)
counter++;
watch_me = 1; /* set breakpoint child here */
- other = 1; /* set thread-specific breakpoint here */
+ other = 1;
usleep (1);
}
diff --git a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
index b8fc6a8..17cd758 100644
--- a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
+++ b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
@@ -33,6 +33,8 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
proc do_test { with_bp } {
global executable
+ global gdb_prompt
+ global hex
if ${with_bp} {
set prefix "with thread-specific bp"
@@ -60,6 +62,38 @@ proc do_test { with_bp } {
gdb_breakpoint [gdb_get_line_number "set breakpoint child here"]
gdb_test "thread 2" "Switching to .*"
gdb_continue_to_breakpoint "run to breakpoint in thread 2"
+
+ set address_triggers_watch "<invalid>"
+ set after_address_triggers_watch "<invalid>"
+
+ # Let the watchpoint trigger once (with the other
+ # thread locked), in order to find both the address of
+ # the instruction that triggers the watchpoint and the
+ # address of the instruction immediately after.
+ with_test_prefix "find addresses" {
+ gdb_test "p watch_me = 0" " = 0" "clear watch_me"
+ gdb_test "watch watch_me" "Hardware watchpoint .*"
+
+ gdb_test "continue" \
+ "Hardware watchpoint.*: watch_me.*New value = 1.*" \
+ "continue to watchpoint"
+
+ set msg "find addresses"
+ gdb_test_multiple "disassemble" $msg {
+ -re " ($hex) \[^\r\n\]*\r\n=> ($hex) .*$gdb_prompt $" {
+ set address_triggers_watch $expect_out(1,string)
+ set after_address_triggers_watch $expect_out(2,string)
+ pass $msg
+ }
+ }
+
+ delete_breakpoints
+ }
+
+ gdb_breakpoint "*$address_triggers_watch"
+ gdb_continue_to_breakpoint \
+ "run to instruction that triggers watch in thread 2"
+
gdb_test "p counter = 0" " = 0" "unbreak loop in thread 2"
gdb_test "p watch_me = 0" " = 0" "clear watch_me"
gdb_test "watch watch_me" "Hardware watchpoint .*"
@@ -68,8 +102,7 @@ proc do_test { with_bp } {
# Set a thread-specific breakpoint (for the wrong
# thread) right after instruction that triggers
# the watchpoint.
- set linenum [gdb_get_line_number "set thread-specific breakpoint here"]
- gdb_test "b $linenum thread 1"
+ gdb_test "b *$after_address_triggers_watch thread 1"
}
# Switch back to thread 1 and disable scheduler locking.
@@ -77,9 +110,10 @@ proc do_test { with_bp } {
gdb_test_no_output "set scheduler-locking off"
# Thread 2 is still stopped at a breakpoint that needs to be
- # stepped over before proceeding thread 1. However, right
- # where the step-over lands there's another breakpoint
- # installed, which should trap and be reported to the user.
+ # stepped over before proceeding thread 1. However, the
+ # instruction that is under the breakpoint triggers a
+ # watchpoint, which should trap and be reported to the
+ # user.
gdb_test "$command" "Hardware watchpoint.*: watch_me.*New value = 1.*"
}
}