]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/i386-dr3-watch.exp
Update year range in copyright notice of all files owned by the GDB project.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-dr3-watch.exp
1 # Copyright 2011-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 # 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.
22 if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
23 return 0
24 }
25
26 standard_testfile
27
28 if [prepare_for_testing ${testfile}.exp ${binfile} ${srcfile} {debug $additional_flags}] {
29 untested "failed to compile ${testfile}"
30 return -1
31 }
32
33 if ![runto_main] then {
34 untested "could not run to main"
35 return -1
36 }
37
38 gdb_test_no_output "set breakpoint always-inserted on"
39
40 # Test that we handle watchpoints in all of DR0-DR3.
41
42 gdb_test "watch i1" "Hardware watchpoint .*: i1"
43 gdb_test "watch i2" "Hardware watchpoint .*: i2"
44 gdb_test "watch i3" "Hardware watchpoint .*: i3"
45 gdb_test "watch i4" "Hardware watchpoint .*: i4"
46
47 gdb_test "c" "Hardware watchpoint.*: i1.*" "continue to i1 watchpoint"
48 gdb_test "c" "Hardware watchpoint.*: i2.*" "continue to i2 watchpoint"
49 gdb_test "c" "Hardware watchpoint.*: i3.*" "continue to i3 watchpoint"
50 gdb_test "c" "Hardware watchpoint.*: i4.*" "continue to i4 watchpoint"
51
52 delete_breakpoints
53
54 # Regression test for a bug where the i386 watchpoints support backend
55 # would leave some debug registers occupied even if not enough debug
56 # registers were available to cover a single watchpoint location.
57
58 gdb_test "watch i1" \
59 "Hardware watchpoint .*: i1" \
60 "set watchpoint occuping one debug register"
61
62 # gap1 too long to fit the 3 left over debug registers (but would fit
63 # 4 if all were available).
64 set test "watchpoint on gap1 does not fit debug registers"
65 gdb_test_multiple "watch gap1" "$test" {
66 -re "Hardware watchpoint .*: gap1.*Warning:.*Could not insert hardware watchpoint.*You may have requested too many.*\r\n$gdb_prompt $" {
67 pass $test
68 }
69 -re "Hardware watchpoint .*: gap1\r\n$gdb_prompt $" {
70 pass "$test (target emulates hardware watchpoints)"
71 return
72 }
73 -re "Watchpoint .*: gap1\r\n$gdb_prompt $" {
74 pass "$test (gdb figured out itself the watchpoint does not fit)"
75 return
76 }
77 }
78
79 # Start over.
80 gdb_test "delete" \
81 "" \
82 "delete all watchpoints" \
83 {Delete all breakpoints\? \(y or n\) $} \
84 "y"
85
86 # If debug registers were left occupied by mistake, we'll fail to set
87 # some of these watchpoints. Each watchpoint should fit in one of the
88 # 4 debug registers available.
89 gdb_test "watch i1" "Hardware watchpoint .*: i1" "watch i1 still fits"
90 gdb_test "watch i2" "Hardware watchpoint .*: i2" "watch i2 still fits"
91 gdb_test "watch i3" "Hardware watchpoint .*: i3" "watch i3 still fits"
92 gdb_test "watch i4" "Hardware watchpoint .*: i4" "watch i4 still fits"