aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-04-10 13:11:32 +0100
committerPedro Alves <palves@redhat.com>2015-04-10 13:11:32 +0100
commitebc90b50ce6377bf822c918eaf7c55bcd451ba45 (patch)
treee61887b72f020e1f654648af4abc88a4e2ebea71
parent11e6e4c72cce2961f80e282cc4d859e7c266e17d (diff)
downloadgdb-ebc90b50ce6377bf822c918eaf7c55bcd451ba45.zip
gdb-ebc90b50ce6377bf822c918eaf7c55bcd451ba45.tar.gz
gdb-ebc90b50ce6377bf822c918eaf7c55bcd451ba45.tar.bz2
Make gdb.threads/step-over-trips-on-watchpoint.exp effective on !x86
This test is currently failing like this on (at least) PPC64 and s390x: FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: step FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: next: next FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: with thread-specific bp: step: step FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: with thread-specific bp: next: next gdb.log: (gdb) PASS: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: set scheduler-locking off step wait_threads () at ../../../src/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c:49 49 return 1; /* in wait_threads */ (gdb) FAIL: gdb.threads/step-over-trips-on-watchpoint.exp: no thread-specific bp: step: step The problem is that the test assumes that both the "watch_me = 1;" and the "other = 1;" lines compile to a single instruction each, which happens to be true on x86, but no necessarily true everywhere else. The result is that the test doesn't really test what it wants to test. Fix it by looking for the instruction that triggers the watchpoint. gdb/ChangeLog: 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.
-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.*"
}
}