1# Copyright 2011 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# x86 and amd64 gdbserver had a bug where a watchpoint triggered by
17# the DR3 debug register would trip on a bogus assertion.
18
19# This test relies on being able to set 4 hardware watchpoints.  Since
20# that is not a valid assumption across most targets, and we're
21# testing a x86 specific bug, skip everywhere else.
22if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
23    return 0
24}
25
26set testfile "i386-dr3-watch"
27set srcfile ${testfile}.c
28
29if [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug $additional_flags}] {
30    untested "failed to compile ${testfile}"
31    return -1
32}
33
34if ![runto_main] then {
35    untested "could not run to main"
36    return -1
37}
38
39gdb_test_no_output "set breakpoint always-inserted on"
40
41gdb_test "watch i1" "Hardware watchpoint .*: i1"
42gdb_test "watch i2" "Hardware watchpoint .*: i2"
43gdb_test "watch i3" "Hardware watchpoint .*: i3"
44gdb_test "watch i4" "Hardware watchpoint .*: i4"
45
46gdb_test "c" "Hardware watchpoint.*: i1.*" "continue to i1 watchpoint"
47gdb_test "c" "Hardware watchpoint.*: i2.*" "continue to i2 watchpoint"
48gdb_test "c" "Hardware watchpoint.*: i3.*" "continue to i3 watchpoint"
49gdb_test "c" "Hardware watchpoint.*: i4.*" "continue to i4 watchpoint"
50