diff options
Diffstat (limited to 'gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp')
-rw-r--r-- | gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp | 44 |
1 files changed, 39 insertions, 5 deletions
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.*" } } |