1 |
227 |
jeremybenn |
# Copyright 2009, 2010 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 .
|
15 |
|
|
|
16 |
|
|
# This file was written by Pierre Muller. (muller@ics.u-strasbg.fr)
|
17 |
|
|
|
18 |
|
|
if $tracelevel then {
|
19 |
|
|
strace $tracelevel
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
set prms_id 0
|
23 |
|
|
set bug_id 0
|
24 |
|
|
|
25 |
|
|
set testfile "watchpoints"
|
26 |
|
|
set srcfile ${testfile}.c
|
27 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
28 |
|
|
|
29 |
|
|
set wp_set 1
|
30 |
|
|
|
31 |
|
|
if [get_compiler_info ${binfile}] {
|
32 |
|
|
return -1
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
36 |
|
|
untested watchpoint.exp
|
37 |
|
|
return -1
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
# Start with a fresh gdb.
|
41 |
|
|
|
42 |
|
|
gdb_exit
|
43 |
|
|
gdb_start
|
44 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
45 |
|
|
gdb_load $binfile
|
46 |
|
|
|
47 |
|
|
# Disable hardware watchpoints if necessary.
|
48 |
|
|
if [target_info exists gdb,no_hardware_watchpoints] {
|
49 |
|
|
gdb_test "set can-use-hw-watchpoints 0" "" ""
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
runto_main
|
53 |
|
|
gdb_test "watch ival1" "" ""
|
54 |
|
|
gdb_test "watch ival3" "" ""
|
55 |
|
|
|
56 |
|
|
set prev_timeout $timeout
|
57 |
|
|
set timeout 600
|
58 |
|
|
|
59 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = -1.*New value = 0.*ival1 = count; ival2 = count;.*" "watchpoint hit, first time"
|
60 |
|
|
|
61 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" "watchpoint hit, first time"
|
62 |
|
|
|
63 |
|
|
# Check that the ival3 hit count is reported correctly
|
64 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 1 time.*" "Watchpoint hit count is 1"
|
65 |
|
|
|
66 |
|
|
# Continue until the next change for ival1, from 0 to 1.
|
67 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = 0.*New value = 1.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, second time"
|
68 |
|
|
|
69 |
|
|
# Check that the hit count for ival1 is reported correctly
|
70 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 2 times.*" "Watchpoint ival1 hit count is 2"
|
71 |
|
|
|
72 |
|
|
# Continue until the next change for ival3, from 0 to 1.
|
73 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time"
|
74 |
|
|
|
75 |
|
|
# Check that the hit count is reported correctly
|
76 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 2 times.*" "Watchpoint hit count is 2"
|
77 |
|
|
|
78 |
|
|
# Continue until the next change, from 1 to 2.
|
79 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = 1.*New value = 2.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, third time"
|
80 |
|
|
|
81 |
|
|
# Check that the hit count is reported correctly
|
82 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 3 times.*" "Watchpoint ival1 hit count is 3"
|
83 |
|
|
# Disable ival1 watchpoint
|
84 |
|
|
gdb_test "disable 2" "" ""
|
85 |
|
|
|
86 |
|
|
# Continue until the next change, from 1 to 2.
|
87 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" "watchpoint hit, third time"
|
88 |
|
|
|
89 |
|
|
# Check that the hit count is reported correctly
|
90 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 3 times.*" "Watchpoint hit count is 3"
|
91 |
|
|
|
92 |
|
|
# Continue until the next change, from 2 to 3.
|
93 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time"
|
94 |
|
|
|
95 |
|
|
# Check that the hit count is reported correctly
|
96 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 4 times.*" "Watchpoint hit count is 4"
|
97 |
|
|
|
98 |
|
|
# Continue until the next change, from 3 to 4.
|
99 |
|
|
# Note that this one is outside the loop.
|
100 |
|
|
|
101 |
|
|
gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" "watchpoint hit, fifth time"
|
102 |
|
|
|
103 |
|
|
# Check that the hit count is reported correctly
|
104 |
|
|
gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 5 times.*" "Watchpoint hit count is 5"
|
105 |
|
|
|
106 |
|
|
set timeout $prev_timeout
|