]>
Commit | Line | Data |
---|---|---|
cbb55fa7 MM |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
3666a048 | 3 | # Copyright 2015-2021 Free Software Foundation, Inc. |
cbb55fa7 MM |
4 | # |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
b5ac99b0 MM |
18 | if { [skip_btrace_tests] } { |
19 | unsupported "target does not support record-btrace" | |
20 | return -1 | |
21 | } | |
cbb55fa7 | 22 | |
cbb55fa7 MM |
23 | standard_testfile |
24 | if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debug}] != "" } { | |
b5ac99b0 | 25 | untested "failed to prepare" |
cbb55fa7 MM |
26 | return -1 |
27 | } | |
cbb55fa7 | 28 | |
0a1c7e28 MM |
29 | save_vars { GDBFLAGS } { |
30 | append GDBFLAGS " -ex \"set non-stop on\"" | |
31 | clean_restart $testfile | |
32 | } | |
cbb55fa7 MM |
33 | |
34 | if ![runto_main] { | |
b5ac99b0 | 35 | untested "failed to run to main" |
cbb55fa7 MM |
36 | return -1 |
37 | } | |
38 | ||
39 | # set up breakpoints | |
40 | set bp_1 [gdb_get_line_number "bp.1" $srcfile] | |
41 | set bp_2 [gdb_get_line_number "bp.2" $srcfile] | |
42 | set bp_3 [gdb_get_line_number "bp.3" $srcfile] | |
43 | ||
44 | gdb_breakpoint $bp_1 | |
45 | gdb_breakpoint $bp_2 | |
46 | ||
47 | # get the line number containing most of the trace | |
48 | set loop [gdb_get_line_number "loop" $srcfile] | |
49 | ||
50 | # a stop on the above line as reported by GDB | |
51 | set loop_line "$loop\[^\\\r\\\n\]*/\\\* loop \\\*/" | |
52 | ||
53 | # make sure $line matches the full expected output per thread. | |
54 | # and let's hope that GDB never mixes the output from different threads. | |
55 | proc gdb_cont_to { threads cmd line nthreads } { | |
56 | global gdb_prompt | |
57 | set full_cmd "thread apply $threads $cmd" | |
58 | ||
59 | # consume the prompt. since we started the command in the background, | |
60 | # the prompt precedes any further output except some errors. | |
61 | gdb_test_multiple "$full_cmd &" "$full_cmd: prompt" { | |
62 | -re "$gdb_prompt " { | |
1a1c0afc | 63 | pass $gdb_test_name |
cbb55fa7 MM |
64 | } |
65 | } | |
66 | ||
67 | # now check for the expected line - one per thread. | |
68 | for {set i 0} {$i < $nthreads} {incr i} { | |
1a1c0afc | 69 | gdb_test_multiple "" "$full_cmd: thread $i" { |
cbb55fa7 | 70 | -re "$line\[^\\\r\\\n\]*\r\n" { |
1a1c0afc | 71 | pass $gdb_test_name |
cbb55fa7 MM |
72 | } |
73 | } | |
74 | } | |
75 | } | |
76 | ||
77 | proc gdb_cont_to_bp_line { line threads nthreads } { | |
78 | gdb_cont_to $threads "continue" \ | |
79 | [multi_line \ | |
80 | "Breakpoint\[^\\\r\\\n\]*$line" \ | |
81 | "\[^\\\r\\\n\]*" \ | |
82 | ] \ | |
83 | $nthreads | |
84 | } | |
85 | ||
86 | proc gdb_cont_to_no_history { threads cmd nthreads } { | |
87 | gdb_cont_to $threads $cmd \ | |
88 | [multi_line \ | |
89 | "No more reverse-execution history\." \ | |
90 | "\[^\\\r\\\n\]*" \ | |
91 | "\[^\\\r\\\n\]*" \ | |
92 | ] \ | |
93 | $nthreads | |
94 | } | |
95 | ||
96 | # trace the code between the two breakpoints | |
1a1c0afc MM |
97 | with_test_prefix "prepare" { |
98 | gdb_cont_to_bp_line "$srcfile:$bp_1" all 2 | |
99 | } | |
100 | with_test_prefix "record" { | |
101 | gdb_test_no_output "record btrace" | |
102 | gdb_cont_to_bp_line "$srcfile:$bp_2" all 2 | |
103 | } | |
cbb55fa7 MM |
104 | |
105 | # we don't need those breakpoints any longer. | |
106 | # they will only disturb our stepping. | |
107 | delete_breakpoints | |
108 | ||
109 | # show the threads - this is useful for debugging fails | |
110 | gdb_test "thread apply all info rec" ".*" | |
111 | gdb_test "info threads" ".*" | |
112 | ||
113 | with_test_prefix "navigate" { | |
32c52999 | 114 | gdb_test "thread apply 1 record goto 3" "$loop_line" |
cbb55fa7 MM |
115 | gdb_test "thread apply 2 record goto 4" "$loop_line" |
116 | gdb_test "thread apply 1 info record" \ | |
32c52999 | 117 | ".*Replay in progress\. At instruction 3\." "thread 1 at insn 3" |
cbb55fa7 | 118 | gdb_test "thread apply 2 info record" \ |
1a1c0afc | 119 | ".*Replay in progress\. At instruction 4\." "thread 2 at insn 4" |
cbb55fa7 MM |
120 | |
121 | gdb_test "thread apply all record goto 5" "$loop_line" | |
122 | gdb_test "thread apply 1 info record" \ | |
1a1c0afc | 123 | ".*Replay in progress\. At instruction 5\." "thread 1 at insn 5" |
cbb55fa7 | 124 | gdb_test "thread apply 2 info record" \ |
1a1c0afc | 125 | ".*Replay in progress\. At instruction 5\." "thread 2 at insn 5" |
cbb55fa7 MM |
126 | } |
127 | ||
128 | with_test_prefix "step" { | |
129 | with_test_prefix "thread 1" { | |
130 | gdb_test "thread apply 1 stepi 2" "$loop_line" | |
131 | gdb_test "thread apply 1 info record" \ | |
132 | ".*Replay in progress\. At instruction 7\." | |
133 | gdb_test "thread apply 2 info record" \ | |
134 | ".*Replay in progress\. At instruction 5\." | |
135 | } | |
136 | ||
137 | with_test_prefix "thread 2" { | |
138 | gdb_test "thread apply 2 stepi 3" "$loop_line" | |
139 | gdb_test "thread apply 1 info record" \ | |
140 | ".*Replay in progress\. At instruction 7\." | |
141 | gdb_test "thread apply 2 info record" \ | |
142 | ".*Replay in progress\. At instruction 8\." | |
143 | } | |
144 | ||
145 | with_test_prefix "all" { | |
146 | gdb_cont_to all "stepi 4" "$loop_line" 2 | |
147 | gdb_test "thread apply 1 info record" \ | |
148 | ".*Replay in progress\. At instruction 11\." | |
149 | gdb_test "thread apply 2 info record" \ | |
150 | ".*Replay in progress\. At instruction 12\." | |
151 | } | |
152 | } | |
153 | ||
154 | with_test_prefix "reverse-step" { | |
155 | with_test_prefix "thread 1" { | |
156 | gdb_test "thread apply 1 reverse-stepi 2" "$loop_line" | |
157 | gdb_test "thread apply 1 info record" \ | |
158 | ".*Replay in progress\. At instruction 9\." | |
159 | gdb_test "thread apply 2 info record" \ | |
160 | ".*Replay in progress\. At instruction 12\." | |
161 | } | |
162 | ||
163 | with_test_prefix "thread 2" { | |
164 | gdb_test "thread apply 2 reverse-stepi 3" "$loop_line" | |
165 | gdb_test "thread apply 1 info record" \ | |
166 | ".*Replay in progress\. At instruction 9\." | |
167 | gdb_test "thread apply 2 info record" \ | |
168 | ".*Replay in progress\. At instruction 9\." | |
169 | } | |
170 | ||
171 | with_test_prefix "all" { | |
172 | gdb_cont_to all "reverse-stepi 4" "$loop_line" 2 | |
173 | gdb_test "thread apply 1 info record" \ | |
174 | ".*Replay in progress\. At instruction 5\." | |
175 | gdb_test "thread apply 2 info record" \ | |
176 | ".*Replay in progress\. At instruction 5\." | |
177 | } | |
178 | } | |
179 | ||
180 | with_test_prefix "continue" { | |
181 | with_test_prefix "thread 1" { | |
1a1c0afc MM |
182 | with_test_prefix "continue" { |
183 | gdb_cont_to_no_history 1 "continue" 1 | |
184 | gdb_test "thread apply 1 info record" \ | |
185 | ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" | |
186 | gdb_test "thread apply 2 info record" \ | |
187 | ".*Replay in progress\. At instruction 5\." | |
188 | } | |
189 | with_test_prefix "reverse-continue" { | |
190 | gdb_cont_to_no_history 1 "reverse-continue" 1 | |
191 | gdb_test "thread apply 1 info record" \ | |
192 | ".*Replay in progress\. At instruction 1\." | |
193 | gdb_test "thread apply 2 info record" \ | |
194 | ".*Replay in progress\. At instruction 5\." | |
195 | } | |
cbb55fa7 MM |
196 | } |
197 | ||
198 | with_test_prefix "thread 2" { | |
1a1c0afc MM |
199 | with_test_prefix "continue" { |
200 | gdb_cont_to_no_history 2 "continue" 1 | |
201 | gdb_test "thread apply 1 info record" \ | |
202 | ".*Replay in progress\. At instruction 1\." | |
203 | gdb_test "thread apply 2 info record" \ | |
204 | ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" | |
205 | } | |
206 | with_test_prefix "reverse-continue" { | |
207 | gdb_cont_to_no_history 2 "reverse-continue" 1 | |
208 | gdb_test "thread apply 1 info record" \ | |
209 | ".*Replay in progress\. At instruction 1\." | |
210 | gdb_test "thread apply 2 info record" \ | |
211 | ".*Replay in progress\. At instruction 1\." | |
212 | } | |
cbb55fa7 MM |
213 | } |
214 | } | |
215 | ||
216 | # a thread may only resume if no thread is still replaying | |
217 | with_test_prefix "no progress" { | |
218 | with_test_prefix "thread 1" { | |
219 | gdb_test "thread apply 1 record goto end" ".*" | |
220 | gdb_test "thread apply 2 record goto begin" ".*" | |
221 | ||
222 | gdb_cont_to_no_history 1 "continue" 1 | |
223 | gdb_cont_to_no_history 1 "step" 1 | |
224 | gdb_test "thread apply 1 info record" \ | |
225 | ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" | |
226 | gdb_test "thread apply 2 info record" \ | |
227 | ".*Replay in progress\. At instruction 1\." | |
228 | } | |
229 | ||
230 | with_test_prefix "thread 2" { | |
231 | gdb_test "thread apply 1 record goto begin" ".*" | |
232 | gdb_test "thread apply 2 record goto end" ".*" | |
233 | ||
234 | gdb_cont_to_no_history 2 "continue" 1 | |
235 | gdb_cont_to_no_history 2 "step" 1 | |
236 | gdb_test "thread apply 1 info record" \ | |
237 | ".*Replay in progress\. At instruction 1\." | |
238 | gdb_test "thread apply 2 info record" \ | |
239 | ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" | |
240 | } | |
241 | ||
242 | with_test_prefix "all" { | |
243 | gdb_test "thread apply all record goto begin" ".*" | |
244 | ||
245 | gdb_cont_to_no_history all "continue" 2 | |
246 | gdb_test "thread apply 1 info record" \ | |
247 | ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" | |
248 | gdb_test "thread apply 2 info record" \ | |
249 | ".*Recorded \[0-9\]+ instructions \[^\\\r\\\n\]*" | |
250 | } | |
251 | } | |
252 | ||
253 | # now that both threads stopped replaying we may resume recording | |
254 | with_test_prefix "cont to end" { | |
255 | gdb_breakpoint $bp_3 | |
256 | gdb_cont_to_bp_line "$srcfile:$bp_3" all 1 | |
257 | } |