]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/watch-cond.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / watch-cond.exp
1 # Copyright 2010-2024 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 #
17 # Tests involving watchpoint conditions with local expressions.
18 #
19
20 # The allow_hw_watchpoint_tests checks if watchpoints are supported by the
21 # processor. On PowerPC, the check runs a small test program under gdb
22 # to determine if the Power processor supports HW watchpoints. The check
23 # must be done before starting the test so as to not disrupt the execution
24 # of the actual test.
25
26 set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests]
27
28 standard_testfile .c
29
30 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
31 return -1
32 }
33
34 # Disable hardware watchpoints if necessary.
35 if {!$allow_hw_watchpoint_tests_p} {
36 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
37 }
38
39 if {![runto_main]} {
40 return
41 }
42
43 gdb_test "watch global if q > 10" \
44 "atchpoint .*: global" \
45 "set write watchpoint on global variable, local condition"
46
47 gdb_test "continue" \
48 "Old value = 10.*New value = 11.*" \
49 "watchpoint with global expression, local condition evaluates in correct frame"
50
51 clean_restart ${testfile}
52
53 # Disable hardware watchpoints if necessary.
54 if {!$allow_hw_watchpoint_tests_p} {
55 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
56 }
57
58 if {![runto_main]} {
59 return
60 }
61
62 gdb_test "watch q if q > 10" \
63 "atchpoint .*: q" \
64 "set write watchpoint on local variable, local condition"
65
66 gdb_test "continue" \
67 "Old value = 10.*New value = 11.*" \
68 "watchpoint with local expression, local condition evaluates in correct frame"
69
70 clean_restart ${testfile}
71
72 # Disable hardware watchpoints if necessary.
73 if {!$allow_hw_watchpoint_tests_p} {
74 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
75 }
76
77 if {![runto_main]} {
78 return
79 }
80
81 gdb_test "watch global2" \
82 "atchpoint.*" \
83 "set write watchpoint on global2 variable"
84
85 gdb_test "continue" \
86 "Old value = 0.*New value = 1.*" \
87 "watchpoint on global2 variable triggers"
88
89 gdb_test_no_output "condition 2 *foo > 10" \
90 "condition of watchpoint 2 changes"
91
92 gdb_test "continue" \
93 ".*condition cannot be tested in the current scope.*Old value = 1.*New value = 2.*" \
94 "watchpoint stops with untestable local expression"