]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make gdb.threads/step-over-trips-on-watchpoint.exp effective on !x86
authorPedro Alves <palves@redhat.com>
Fri, 10 Apr 2015 12:11:32 +0000 (13:11 +0100)
committerPedro Alves <palves@redhat.com>
Fri, 10 Apr 2015 12:11:32 +0000 (13:11 +0100)
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.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.c
gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp

index af6104a845b93608c91e94f34cc0c86b98ef6414..ec319abe8b5c2183217538d7256c95a18247e30f 100644 (file)
@@ -1,3 +1,12 @@
+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)
index 13404dad8db3c175023fcb2b308b01362ef9eba6..6cf97fb806325cb222f0bcd5f38028e5a8c213ca 100644 (file)
@@ -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);
     }
 
index b8fc6a842bbc4ceb5577a311a1d6e7ff4c44850b..17cd758addfc0c06fcea46bd1f2c4c1fedae8cec 100644 (file)
@@ -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.*"
            }
        }