192555Sdes# Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
276259Sgreen
376259Sgreen# This program is free software; you can redistribute it and/or modify
476259Sgreen# it under the terms of the GNU General Public License as published by
576259Sgreen# the Free Software Foundation; either version 3 of the License, or
676259Sgreen# (at your option) any later version.
776259Sgreen#
876259Sgreen# This program is distributed in the hope that it will be useful,
976259Sgreen# but WITHOUT ANY WARRANTY; without even the implied warranty of
1076259Sgreen# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1176259Sgreen# GNU General Public License for more details.
1276259Sgreen#
1376259Sgreen# You should have received a copy of the GNU General Public License
1476259Sgreen# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1576259Sgreen
1676259Sgreenif $tracelevel then {
1776259Sgreen    strace $tracelevel
1876259Sgreen}
1976259Sgreen
2076259Sgreenif {[skip_hw_watchpoint_tests]} {
2176259Sgreen    return 0
2276259Sgreen}
2376259Sgreen
2476259Sgreenset testfile "pr11022"
2576259Sgreenset srcfile ${testfile}.c
2676259Sgreenset binfile ${objdir}/${subdir}/${testfile}
2776259Sgreenif  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
2876259Sgreen     untested pr11022.exp
2976259Sgreen     return -1
3092555Sdes}
3192555Sdes
3276259Sgreen# Start with a fresh gdb.
3376259Sgreen
3476259Sgreengdb_exit
3576259Sgreengdb_start
3676259Sgreengdb_reinitialize_dir $srcdir/$subdir
3776259Sgreengdb_load ${binfile}
3876259Sgreen
3976259Sgreenif ![runto_main] then {
4076259Sgreen    fail "Can't run to main"
4176259Sgreen    return 0
4292555Sdes}
4392555Sdes
4476259Sgreengdb_test "break [gdb_get_line_number "break here"]" \
4576259Sgreen	".*Breakpoint.* at .*" \
4692555Sdes	"set breakpoint"
4776259Sgreen
4892555Sdesgdb_test "watch x" ".*Hardware watchpoint.*" "set watchpoint"
4992555Sdesgdb_test "continue" ".*break here.*" "breakpoint hit"
5076259Sgreengdb_test "continue" ".*Hardware watchpoint.*Old value = 0.*New value = 42.*" \
5192555Sdes    "watchpoint hit"
5292555Sdesgdb_test "continue" ".*break here.*" "breakpoint hit 2"
5392555Sdesgdb_test_no_output "set var x = 1"
5492555Sdesgdb_test "continue" ".*Hardware watchpoint.*Old value = 1.*New value = 42.*" \
5592555Sdes    "watchpoint hit 2"
5692555Sdes