1# Copyright 2009-2020 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
16if {[skip_hw_watchpoint_tests]} {
17    return 0
18}
19
20standard_testfile .c
21
22if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
23     untested "failed to compile"
24     return -1
25}
26
27# Start with a fresh gdb.
28
29clean_restart ${binfile}
30
31if ![runto_main] then {
32    fail "can't run to main"
33    return 0
34}
35
36gdb_test "break [gdb_get_line_number "break here"]" \
37	".*Breakpoint.* at .*" \
38	"set breakpoint"
39
40gdb_test "watch x" ".*Hardware watchpoint.*" "set watchpoint"
41gdb_test "continue" ".*break here.*" "breakpoint hit"
42gdb_test "continue" ".*Hardware watchpoint.*Old value = 0.*New value = 42.*" \
43    "watchpoint hit"
44gdb_test "continue" ".*break here.*" "breakpoint hit 2"
45gdb_test_no_output "set var x = 1"
46gdb_test "continue" ".*Hardware watchpoint.*Old value = 1.*New value = 42.*" \
47    "watchpoint hit 2"
48