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