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.
proc do_test { with_bp } {
global executable
+ global gdb_prompt
+ global hex
if ${with_bp} {
set prefix "with thread-specific 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 .*"
# 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.
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.*"
}
}