1 # Copyright 2010, 2011 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/>.
17 # Tests involving watchpoint conditions with local expressions.
20 set testfile "watch-cond"
21 set srcfile ${testfile}.c
22 set binfile ${objdir}/${subdir}/${testfile}
24 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
25 untested ${testfile}.exp
29 # Disable hardware watchpoints if necessary.
30 if [target_info exists gdb,no_hardware_watchpoints] {
31 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
34 if ![runto_main] then {
35 fail "Can't run to main"
39 gdb_test "watch global if q > 10" \
40 "atchpoint .*: global" \
41 "set write watchpoint on global variable, local condition"
44 "Old value = 10.*New value = 11.*" \
45 "watchpoint with global expression, local condition evaluates in correct frame"
47 clean_restart ${testfile}
49 # Disable hardware watchpoints if necessary.
50 if [target_info exists gdb,no_hardware_watchpoints] {
51 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
54 if ![runto_main] then {
55 fail "Can't run to main"
59 gdb_test "watch q if q > 10" \
61 "set write watchpoint on local variable, local condition"
64 "Old value = 10.*New value = 11.*" \
65 "watchpoint with local expression, local condition evaluates in correct frame"
67 clean_restart ${testfile}
69 # Disable hardware watchpoints if necessary.
70 if [target_info exists gdb,no_hardware_watchpoints] {
71 gdb_test_no_output "set can-use-hw-watchpoints 0" ""
74 if ![runto_main] then {
75 fail "Can't run to main"
79 gdb_test "watch global2" \
81 "set write watchpoint on global2 variable"
84 "Old value = 0.*New value = 1.*" \
85 "watchpoint on global2 variable triggers"
87 gdb_test_no_output "condition 2 *foo > 10" \
88 "condition of watchpoint 2 changes"
91 ".*condition cannot be tested in the current scope.*Old value = 1.*New value = 2.*" \
92 "watchpoint stops with untestable local expression"