]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright 2009-2023 Free Software Foundation, Inc. |
087b74b2 PM |
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 | # This file was written by Pierre Muller. (muller@ics.u-strasbg.fr) | |
17 | ||
f760c4f2 CL |
18 | # The skip_hw_watchpoint_tests checks if watchpoints are supported by the |
19 | # processor. On PowerPC, the check runs a small test program under gdb | |
20 | # to determine if the Power processor supports HW watchpoints. The check | |
21 | # must be done before starting the test so as to not disrupt the execution | |
22 | # of the actual test. | |
23 | ||
24 | set skip_hw_watchpoint_tests_p [skip_hw_watchpoint_tests] | |
25 | ||
087b74b2 | 26 | |
62cef515 | 27 | standard_testfile |
087b74b2 PM |
28 | |
29 | set wp_set 1 | |
30 | ||
5b362f04 | 31 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
62cef515 | 32 | return -1 |
087b74b2 PM |
33 | } |
34 | ||
e8369a73 AB |
35 | with_test_prefix "before inferior start" { |
36 | # Ensure that if we turn off hardware watchpoints and set a watch point | |
37 | # before starting the inferior the watchpoint created will not be a | |
38 | # hardware watchpoint. | |
39 | gdb_test_no_output "set can-use-hw-watchpoints 0" "" | |
40 | gdb_test "watch ival1" "Watchpoint \[0-9\]+: ival1" \ | |
41 | "create watchpoint" | |
42 | ||
43 | # The next tests are written to match the current state of gdb: access | |
44 | # and read watchpoints require hardware watchpoint support, with this | |
45 | # turned off these can't be created. | |
46 | gdb_test "awatch ival1" \ | |
638aa5a1 | 47 | "Can't set read/access watchpoint when hardware watchpoints are disabled." \ |
e8369a73 AB |
48 | "create access watchpoint" |
49 | gdb_test "rwatch ival1" \ | |
638aa5a1 | 50 | "Can't set read/access watchpoint when hardware watchpoints are disabled." \ |
e8369a73 AB |
51 | "create read watchpoint" |
52 | } | |
53 | ||
54 | # This will turn hardware watchpoints back on and delete the watchpoint | |
55 | # we just created. | |
56 | clean_restart ${binfile} | |
57 | ||
b32306ca | 58 | # Disable hardware watchpoints if necessary. |
f760c4f2 | 59 | if {$skip_hw_watchpoint_tests_p} { |
35ec993f | 60 | gdb_test_no_output "set can-use-hw-watchpoints 0" "" |
b32306ca UW |
61 | } |
62 | ||
087b74b2 | 63 | runto_main |
de7ff789 MS |
64 | gdb_test "watch ival1" ".*" "" |
65 | gdb_test "watch ival3" ".*" "" | |
087b74b2 | 66 | |
97f2ed50 | 67 | set prev_timeout $timeout |
087b74b2 PM |
68 | set timeout 600 |
69 | ||
b64f5c88 | 70 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = -1.*New value = 0.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, first time" |
087b74b2 | 71 | |
b64f5c88 | 72 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" "watchpoint ival3 hit, first time" |
087b74b2 PM |
73 | |
74 | # Check that the ival3 hit count is reported correctly | |
cdc7edd7 | 75 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 1 time.*" "watchpoint hit count is 1" |
087b74b2 PM |
76 | |
77 | # Continue until the next change for ival1, from 0 to 1. | |
78 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = 0.*New value = 1.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, second time" | |
79 | ||
80 | # Check that the hit count for ival1 is reported correctly | |
cdc7edd7 | 81 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 2 times.*" "watchpoint ival1 hit count is 2" |
087b74b2 PM |
82 | |
83 | # Continue until the next change for ival3, from 0 to 1. | |
84 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time" | |
85 | ||
86 | # Check that the hit count is reported correctly | |
cdc7edd7 | 87 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 2 times.*" "watchpoint hit count is 2" |
087b74b2 PM |
88 | |
89 | # Continue until the next change, from 1 to 2. | |
90 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = 1.*New value = 2.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, third time" | |
91 | ||
92 | # Check that the hit count is reported correctly | |
cdc7edd7 | 93 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 3 times.*" "watchpoint ival1 hit count is 3" |
087b74b2 | 94 | # Disable ival1 watchpoint |
35ec993f | 95 | gdb_test_no_output "disable 2" "" |
087b74b2 PM |
96 | |
97 | # Continue until the next change, from 1 to 2. | |
98 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" "watchpoint hit, third time" | |
99 | ||
100 | # Check that the hit count is reported correctly | |
cdc7edd7 | 101 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 3 times.*" "watchpoint hit count is 3" |
087b74b2 PM |
102 | |
103 | # Continue until the next change, from 2 to 3. | |
104 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time" | |
105 | ||
106 | # Check that the hit count is reported correctly | |
cdc7edd7 | 107 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 4 times.*" "watchpoint hit count is 4" |
087b74b2 PM |
108 | |
109 | # Continue until the next change, from 3 to 4. | |
110 | # Note that this one is outside the loop. | |
111 | ||
112 | gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" "watchpoint hit, fifth time" | |
113 | ||
114 | # Check that the hit count is reported correctly | |
cdc7edd7 | 115 | gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 5 times.*" "watchpoint hit count is 5" |
087b74b2 | 116 | |
97f2ed50 | 117 | set timeout $prev_timeout |