1 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test that when a step-over trips on a watchpoint, that watchpoint is
20 set executable ${testfile}
22 # This test verifies that a watchpoint is detected in a multithreaded
23 # program so the test is only meaningful on a system with hardware
25 if {[skip_hw_watchpoint_tests]} {
29 if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
30 executable [list debug "incdir=${objdir}"]] != "" } {
34 proc do_test { with_bp } {
38 set prefix "with thread-specific bp"
40 set prefix "no thread-specific bp"
42 with_test_prefix $prefix {
43 # Cover both stepping and non-stepping execution commands.
44 foreach command {"step" "next" "continue" } {
45 with_test_prefix $command {
46 clean_restart $executable
52 gdb_breakpoint [gdb_get_line_number "set wait-thread breakpoint here"]
53 gdb_continue_to_breakpoint "run to wait-thread breakpoint"
54 gdb_test "info threads" "2 .*\\\* 1.*" "info threads shows all threads"
56 gdb_test_no_output "set scheduler-locking on"
60 gdb_breakpoint [gdb_get_line_number "set breakpoint child here"]
61 gdb_test "thread 2" "Switching to .*"
62 gdb_continue_to_breakpoint "run to breakpoint in thread 2"
63 gdb_test "p counter = 0" " = 0" "unbreak loop in thread 2"
64 gdb_test "p watch_me = 0" " = 0" "clear watch_me"
65 gdb_test "watch watch_me" "Hardware watchpoint .*"
68 # Set a thread-specific breakpoint (for the wrong
69 # thread) right after instruction that triggers
71 set linenum [gdb_get_line_number "set thread-specific breakpoint here"]
72 gdb_test "b $linenum thread 1"
75 # Switch back to thread 1 and disable scheduler locking.
76 gdb_test "thread 1" "Switching to .*"
77 gdb_test_no_output "set scheduler-locking off"
79 # Thread 2 is still stopped at a breakpoint that needs to be
80 # stepped over before proceeding thread 1. However, right
81 # where the step-over lands there's another breakpoint
82 # installed, which should trap and be reported to the user.
83 gdb_test "$command" "Hardware watchpoint.*: watch_me.*New value = 1.*"