Commit | Line | Data |
---|---|---|
2adfaa28 PA |
1 | # Copyright (C) 2014 Free Software Foundation, Inc. |
2 | ||
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. | |
7 | # | |
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. | |
12 | # | |
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/>. | |
15 | ||
16 | # Test that when a step-over trips on a watchpoint, that watchpoint is | |
17 | # reported. | |
18 | ||
19 | standard_testfile | |
20 | set executable ${testfile} | |
21 | ||
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 | |
24 | # watchpoints. | |
25 | if {[skip_hw_watchpoint_tests]} { | |
26 | return 0 | |
27 | } | |
28 | ||
29 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ | |
30 | executable [list debug "incdir=${objdir}"]] != "" } { | |
31 | return -1 | |
32 | } | |
33 | ||
34 | proc do_test { with_bp } { | |
35 | global executable | |
36 | ||
37 | if ${with_bp} { | |
38 | set prefix "with thread-specific bp" | |
39 | } else { | |
40 | set prefix "no thread-specific bp" | |
41 | } | |
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 | |
47 | ||
48 | if ![runto_main] { | |
49 | continue | |
50 | } | |
51 | ||
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" | |
55 | ||
56 | gdb_test_no_output "set scheduler-locking on" | |
57 | ||
58 | delete_breakpoints | |
59 | ||
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 .*" | |
66 | ||
67 | if ${with_bp} { | |
68 | # Set a thread-specific breakpoint (for the wrong | |
69 | # thread) right after instruction that triggers | |
70 | # the watchpoint. | |
71 | set linenum [gdb_get_line_number "set thread-specific breakpoint here"] | |
72 | gdb_test "b $linenum thread 1" | |
73 | } | |
74 | ||
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" | |
78 | ||
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.*" | |
84 | } | |
85 | } | |
86 | } | |
87 | } | |
88 | ||
89 | do_test 0 | |
90 | do_test 1 |