]>
Commit | Line | Data |
---|---|---|
02506ff1 MS |
1 | # Copyright 2008, 2009 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 precord dumpfile | |
18 | # debugging with watchpoints. | |
19 | ||
20 | # This test suitable only for process record-replay | |
21 | if ![target_info exists gdb,use_precord] { | |
22 | return | |
23 | } | |
24 | ||
25 | set testfile "watch-reverse" | |
26 | set srcfile ${testfile}.c | |
27 | set binfile ${objdir}/${subdir}/${testfile} | |
28 | ||
29 | if { [prepare_for_testing $testfile.exp $testfile $srcfile] } { | |
30 | return -1 | |
31 | } | |
32 | ||
33 | runto main | |
34 | ||
35 | if [target_info exists gdb,use_precord] { | |
36 | # Activate process record/replay | |
37 | gdb_test "record" "" "Turn on process record" | |
38 | # FIXME: command ought to acknowledge, so we can test if it succeeded. | |
39 | } | |
40 | ||
41 | set end_location [gdb_get_line_number "end of main" ] | |
42 | gdb_test "break $end_location" \ | |
43 | "Breakpoint $decimal at .*/$srcfile, line $end_location\." \ | |
44 | "BP at end of main" | |
45 | ||
46 | gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" | |
47 | ||
48 | gdb_test "record save watch.precsave" \ | |
49 | "Saved core file watch.precsave with execution log\." \ | |
50 | "save process recfile" | |
51 | ||
52 | gdb_test "kill" "" "Kill process, prepare to debug log file" \ | |
53 | "Kill the program being debugged\\? \\(y or n\\) " "y" | |
54 | ||
55 | gdb_test "record restore watch.precsave" \ | |
56 | "Program terminated with signal .*" \ | |
57 | "reload core file" | |
58 | ||
59 | # Only software watchpoints can be used in reverse | |
60 | gdb_test "set can-use-hw-watchpoints 0" "" "" | |
61 | ||
62 | gdb_test "break marker1" \ | |
63 | "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ | |
64 | "set breakpoint at marker1" | |
65 | ||
66 | gdb_test "break marker2" \ | |
67 | "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ | |
68 | "set breakpoint at marker2" | |
69 | ||
70 | gdb_continue_to_breakpoint "marker1" ".*/$srcfile:.*" | |
71 | ||
72 | gdb_test "watch ival3" \ | |
73 | ".*\[Ww\]atchpoint $decimal: ival3.*" \ | |
74 | "set watchpoint on ival3" | |
75 | ||
76 | # Continue until first change, from -1 to 0 | |
77 | ||
78 | gdb_test "continue" \ | |
79 | ".*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" \ | |
80 | "watchpoint hit, first time" | |
81 | ||
82 | # Continue until the next change, from 0 to 1. | |
83 | gdb_test "continue" \ | |
84 | ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" \ | |
85 | "watchpoint hit, second time" | |
86 | ||
87 | # Continue until the next change, from 1 to 2. | |
88 | gdb_test "continue" \ | |
89 | ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" \ | |
90 | "watchpoint hit, third time" | |
91 | ||
92 | # Continue until the next change, from 2 to 3. | |
93 | gdb_test "continue" \ | |
94 | ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" \ | |
95 | "watchpoint hit, fourth time" | |
96 | ||
97 | # Continue until the next change, from 3 to 4. | |
98 | # Note that this one is outside the loop. | |
99 | ||
100 | gdb_test "continue" \ | |
101 | ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" \ | |
102 | "watchpoint hit, fifth time" | |
103 | ||
104 | # Continue until we hit the finishing marker function. | |
105 | # Make sure we hit no more watchpoints. | |
106 | ||
107 | gdb_continue_to_breakpoint "marker2" ".*/$srcfile:.*" | |
108 | ||
109 | ### | |
110 | ### | |
111 | ### | |
112 | ||
113 | # FIXME 'set exec-dir' command should give some output so we can test. | |
114 | gdb_test "set exec-direction reverse" "" "set reverse" | |
115 | ||
116 | # Reverse until the previous change, from 4 to 3 | |
117 | # Note that this one is outside the loop | |
118 | ||
119 | gdb_test "continue" \ | |
120 | ".*\[Ww\]atchpoint.*ival3.*Old value = 4.*New value = 3.*ival3 = count; ival4 = count;.*" \ | |
121 | "watchpoint hit in reverse, first time" | |
122 | ||
123 | # Reverse until the previous change, from 3 to 2. | |
124 | gdb_test "continue" \ | |
125 | ".*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 2.*ival3 = count; ival4 = count;.*" \ | |
126 | "watchpoint hit in reverse, second time" | |
127 | ||
128 | # Reverse until the previous change, from 2 to 1. | |
129 | gdb_test "continue" \ | |
130 | ".*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 1.*ival3 = count; ival4 = count;.*" \ | |
131 | "watchpoint hit in reverse, third time" | |
132 | ||
133 | # Reverse until the previous change, from 1 to 0. | |
134 | gdb_test "continue" \ | |
135 | ".*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 0.*ival3 = count; ival4 = count;.*" \ | |
136 | "watchpoint hit in reverse, fourth time" | |
137 | ||
138 | # Reverse until first change, from 0 to -1 | |
139 | ||
140 | gdb_test "continue" \ | |
141 | ".*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = -1.*ival3 = count; ival4 = count;.*" \ | |
142 | "watchpoint hit in reverse, fifth time" |