1# Copyright 2010-2015 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 20standard_testfile .c 21 22if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } { 23 untested ${testfile}.exp 24 return -1 25} 26 27# Disable hardware watchpoints if necessary. 28if [target_info exists gdb,no_hardware_watchpoints] { 29 gdb_test_no_output "set can-use-hw-watchpoints 0" "" 30} 31 32if ![runto_main] then { 33 fail "Can't run to main" 34 return 35} 36 37gdb_test "watch global if q > 10" \ 38 "atchpoint .*: global" \ 39 "set write watchpoint on global variable, local condition" 40 41gdb_test "continue" \ 42 "Old value = 10.*New value = 11.*" \ 43 "watchpoint with global expression, local condition evaluates in correct frame" 44 45clean_restart ${testfile} 46 47# Disable hardware watchpoints if necessary. 48if [target_info exists gdb,no_hardware_watchpoints] { 49 gdb_test_no_output "set can-use-hw-watchpoints 0" "" 50} 51 52if ![runto_main] then { 53 fail "Can't run to main" 54 return 55} 56 57gdb_test "watch q if q > 10" \ 58 "atchpoint .*: q" \ 59 "set write watchpoint on local variable, local condition" 60 61gdb_test "continue" \ 62 "Old value = 10.*New value = 11.*" \ 63 "watchpoint with local expression, local condition evaluates in correct frame" 64 65clean_restart ${testfile} 66 67# Disable hardware watchpoints if necessary. 68if [target_info exists gdb,no_hardware_watchpoints] { 69 gdb_test_no_output "set can-use-hw-watchpoints 0" "" 70} 71 72if ![runto_main] then { 73 fail "Can't run to main" 74 return 75} 76 77gdb_test "watch global2" \ 78 "atchpoint.*" \ 79 "set write watchpoint on global2 variable" 80 81gdb_test "continue" \ 82 "Old value = 0.*New value = 1.*" \ 83 "watchpoint on global2 variable triggers" 84 85gdb_test_no_output "condition 2 *foo > 10" \ 86 "condition of watchpoint 2 changes" 87 88gdb_test "continue" \ 89 ".*condition cannot be tested in the current scope.*Old value = 1.*New value = 2.*" \ 90 "watchpoint stops with untestable local expression" 91