1# Copyright 2008-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# Based on a file written by Fred Fish. (fnf@cygnus.com) 17# This file is part of the GDB testsuite. It tests reverse debugging 18# with watchpoints. 19 20 21if ![supports_reverse] { 22 return 23} 24 25standard_testfile 26 27if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { 28 return -1 29} 30 31runto main 32 33if [supports_process_record] { 34 # Activate process record/replay 35 gdb_test_no_output "record" "Turn on process record" 36} 37 38# Test software watchpoints 39gdb_test_no_output "set can-use-hw-watchpoints 0" "disable hw watchpoints" 40 41gdb_test "break marker1" \ 42 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ 43 "set breakpoint at marker1" 44 45gdb_test "break marker2" \ 46 "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ 47 "set breakpoint at marker2" 48 49gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*" 50 51gdb_test "watch ival3" \ 52 ".*\[Ww\]atchpoint $decimal: ival3.*" \ 53 "set watchpoint on ival3" 54 55# Continue until first change, from -1 to 0 56 57gdb_test "continue" \ 58 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \ 59 "watchpoint hit, first time" 60 61# Continue until the next change, from 0 to 1. 62gdb_test "continue" \ 63 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \ 64 "watchpoint hit, second time" 65 66# Continue until the next change, from 1 to 2. 67gdb_test "continue" \ 68 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \ 69 "watchpoint hit, third time" 70 71# Continue until the next change, from 2 to 3. 72gdb_test "continue" \ 73 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \ 74 "watchpoint hit, fourth time" 75 76# Continue until the next change, from 3 to 4. 77# Note that this one is outside the loop. 78 79gdb_test "continue" \ 80 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \ 81 "watchpoint hit, fifth time" 82 83# Continue until we hit the finishing marker function. 84# Make sure we hit no more watchpoints. 85 86gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" 87 88### 89### 90### 91 92gdb_test_no_output "set exec-direction reverse" "set reverse" 93 94# Reverse until the previous change, from 4 to 3 95# Note that this one is outside the loop 96 97gdb_test "continue" \ 98 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \ 99 "watchpoint hit in reverse, first time" 100 101# Reverse until the previous change, from 3 to 2. 102gdb_test "continue" \ 103 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \ 104 "watchpoint hit in reverse, second time" 105 106# Reverse until the previous change, from 2 to 1. 107gdb_test "continue" \ 108 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \ 109 "watchpoint hit in reverse, third time" 110 111# Reverse until the previous change, from 1 to 0. 112gdb_test "continue" \ 113 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \ 114 "watchpoint hit in reverse, fourth time" 115 116# Reverse until first change, from 0 to -1 117 118gdb_test "continue" \ 119 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \ 120 "watchpoint hit in reverse, fifth time" 121 122gdb_test_no_output "set can-use-hw-watchpoints 1" "enable hw watchpoints" 123 124### 125### 126### 127 128gdb_test_no_output "set exec-direction forward" "set forward" 129 130# Continue until first change, from -1 to 0 131 132gdb_test "continue" \ 133 ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \ 134 "watchpoint hit, forward replay, first time" 135 136# Continue until the next change, from 0 to 1. 137gdb_test "continue" \ 138 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \ 139 "watchpoint hit, forward replay, second time" 140 141# Continue until the next change, from 1 to 2. 142gdb_test "continue" \ 143 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \ 144 "watchpoint hit, forward replay, third time" 145 146# Continue until the next change, from 2 to 3. 147gdb_test "continue" \ 148 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \ 149 "watchpoint hit, forward replay, fourth time" 150 151# Continue until the next change, from 3 to 4. 152# Note that this one is outside the loop. 153 154gdb_test "continue" \ 155 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \ 156 "watchpoint hit, forward replay, fifth time" 157 158# Continue until we hit the finishing marker function. 159# Make sure we hit no more watchpoints. 160 161gdb_test "continue" "marker2 .*" "replay forward to marker2" 162 163### 164### 165### 166 167gdb_test_no_output "set exec-direction reverse" "set reverse" 168 169# Reverse until the previous change, from 4 to 3 170# Note that this one is outside the loop 171 172gdb_test "continue" \ 173 ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \ 174 "watchpoint hit in reverse, HW, first time" 175 176# Reverse until the previous change, from 3 to 2. 177gdb_test "continue" \ 178 ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \ 179 "watchpoint hit in reverse, HW, second time" 180 181# Reverse until the previous change, from 2 to 1. 182gdb_test "continue" \ 183 ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \ 184 "watchpoint hit in reverse, HW, third time" 185 186# Reverse until the previous change, from 1 to 0. 187gdb_test "continue" \ 188 ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \ 189 "watchpoint hit in reverse, HW, fourth time" 190 191# Reverse until first change, from 0 to -1 192 193gdb_test "continue" \ 194 ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \ 195 "watchpoint hit in reverse, HW, fifth time" 196 197