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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
|
# Copyright 1998 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 2 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
if [istarget "m68k-*-elf"] then {
pass "Test not supported on this target"
return;
}
load_lib "trace-support.exp"
if $tracelevel then {
strace $tracelevel
}
set prms_id 0
set bug_id 0
set testfile "limits"
set srcfile ${testfile}.c
set binfile $objdir/$subdir/$testfile
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
executable {debug additional_flags=-w}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
# Tests:
# 1) Meet and exceed artificial limit on number of tracepoints
# 2) Meet and exceed artificial limit on number of memranges
# 3) Meet and exceed artificial limit on bytes of bytecode data
# [NOTE: number four is moved out into its own separate test module.]
# 4) Meet and exceed artificial limit on bytes of trace buffer storage
# (circular and non-circular modes). However note that a more
# thorough test of the circular mode can be made separately.
set cr "\[\r\n\]+"
proc gdb_tracepoint_limit_test { } {
global gdb_prompt
global cr
# Make sure we're in a sane starting state.
gdb_test "tstop" "" ""
gdb_test "tfind none" "" ""
gdb_delete_tracepoints
# Set three tracepoints
gdb_test "trace foo" \
"Tracepoint \[0-9\]+ at .*" \
"tracepoint limit test: set first tracepoint"
gdb_test "trace bar" \
"Tracepoint \[0-9\]+ at .*" \
"tracepoint limit test: set second tracepoint"
gdb_test "trace baz" \
"Tracepoint \[0-9\]+ at .*" \
"tracepoint limit test: set third tracepoint"
# Set secret artificial tracepoint limit to four
gdb_test "maint packet QTLimit:tp:4" \
"received: .OK." \
"tracepoint limit test: set limit to four"
# Now sending three tracepoints should succeed.
send_gdb "tstart\n"
gdb_expect {
-re "$cr$gdb_prompt" {
pass "tracepoint limit test: send fewer than limit"
}
default {
fail "tracepoint limit test: send fewer than limit"
}
}
# Set secret artificial tracepoint limit to three
gdb_test "maint packet QTLimit:tp:3" \
"received: .OK." \
"tracepoint limit test: set limit to three"
# Now sending three tracepoints should still succeed.
send_gdb "tstart\n"
gdb_expect {
-re "$cr$gdb_prompt" {
pass "tracepoint limit test: send equal to limit"
}
default {
fail "tracepoint limit test: send equal to limit"
}
}
# Set secret artificial tracepoint limit to two
gdb_test "maint packet QTLimit:tp:2" \
"received: .OK." \
"tracepoint limit test: set limit to two"
# Now sending three tracepoints should fail.
gdb_test "tstart" \
".*\[Ee\]rror.*" \
"tracepoint limit test: send more than limit"
# Clean up:
gdb_test "tstop" "" ""
gdb_test "maint packet QTLimit:tp:FFFFFFFF" "" ""
}
proc gdb_memrange_limit_test { } {
global gdb_prompt
global cr
# Make sure we're in a sane starting state.
gdb_test "tstop" "" ""
gdb_test "tfind none" "" ""
gdb_delete_tracepoints
# Set three tracepoints, and make 'em collect memranges
gdb_test "trace foo" \
"Tracepoint \[0-9\]+ at .*" \
"memrange limit test: set first tracepoint"
gdb_trace_setactions "memrange limit test: set first actions" \
"" \
"collect \$arg" "^$"
gdb_test "trace bar" \
"Tracepoint \[0-9\]+ at .*" \
"memrange limit test: set second tracepoint"
gdb_trace_setactions "memrange limit test: set second actions" \
"" \
"collect \$arg" "^$"
gdb_test "trace baz" \
"Tracepoint \[0-9\]+ at .*" \
"memrange limit test: set third tracepoint"
gdb_trace_setactions "memrange limit test: set third actions" \
"" \
"collect \$arg" "^$"
# Set secret artificial memrange limit to four
gdb_test "maint packet QTLimit:memrange:4" \
"received: .OK." \
"memrange limit test: set limit to four"
# Now sending three memranges should still succeed.
send_gdb "tstart\n"
gdb_expect {
-re "$cr$gdb_prompt" {
pass "memrange limit test: send fewer than limit"
}
default {
fail "memrange limit test: send fewer than limit"
}
}
# Set secret artificial memrange limit to three
gdb_test "maint packet QTLimit:memrange:3" \
"received: .OK." \
"memrange limit test: set limit to three"
# Now sending three memranges should still succeed.
send_gdb "tstart\n"
gdb_expect {
-re "$cr$gdb_prompt" {
pass "memrange limit test: send equal to limit"
}
default {
fail "memrange limit test: send equal to limit"
}
}
# Set secret artificial memrange limit to two
gdb_test "maint packet QTLimit:memrange:2" \
"received: .OK." \
"memrange limit test: set limit to two"
# Now sending three memranges should fail.
gdb_test "tstart" \
".*\[Ee\]rror.*" \
"memrange limit test: send more than limit"
# Clean up:
gdb_test "tstop" "" ""
gdb_test "maint packet QTLimit:memrange:FFFFFFFF" "" ""
}
proc gdb_bytecode_limit_test { } {
global gdb_prompt
global cr
# Make sure we're in a sane starting state.
gdb_test "tstop" "" ""
gdb_test "tfind none" "" ""
gdb_delete_tracepoints
# Set three tracepoints
gdb_test "trace foo" \
"Tracepoint \[0-9\]+ at .*" \
"bytecode limit test: set first tracepoint"
gdb_trace_setactions "bytecode limit test: set first actions" \
"" \
"collect x + n" "^$"
gdb_test "trace bar" \
"Tracepoint \[0-9\]+ at .*" \
"bytecode limit test: set second tracepoint"
gdb_trace_setactions "bytecode limit test: set second actions" \
"" \
"collect y + n" "^$"
gdb_test "trace baz" \
"Tracepoint \[0-9\]+ at .*" \
"bytecode limit test: set third tracepoint"
gdb_trace_setactions "bytecode limit test: set third actions" \
"" \
"collect z + n" "^$"
# Set secret artificial bytecode limit to a large number
gdb_test "maint packet QTLimit:bytecode:400" \
"received: .OK." \
"bytecode limit test: set limit to large"
# Now sending three bytecodes should still succeed.
send_gdb "tstart\n"
gdb_expect {
-re "$cr$gdb_prompt" {
pass "bytecode limit test: send fewer than limit"
}
default {
fail "bytecode limit test: send fewer than limit"
}
}
# Set secret artificial bytecode limit to a small number
gdb_test "maint packet QTLimit:bytecode:40" \
"received: .OK." \
"bytecode limit test: set limit to small"
# Now sending three bytecodes should fail.
gdb_test "tstart" \
".*\[Ee\]rror.*" \
"bytecode limit test: send more than limit"
# Clean up:
gdb_test "tstop" "" ""
gdb_test "maint packet QTLimit:bytecode:FFFFFFFF" "" ""
}
proc gdb_trace_limits_tests { } {
global gdb_prompt
# We generously give ourselves one "pass" if we successfully
# detect that this test cannot be run on this target!
if { ![gdb_target_supports_trace] } then {
pass "Current target does not supporst trace"
return 1;
}
if [gdb_test "maint packet QTLimit:tp:ffffffff" \
"received: .OK." ""] then {
pass "This test cannot be run on this target"
return 1;
}
if [gdb_test "maint packet QTLimit:memrange:ffffffff" \
"received: .OK." ""] then {
pass "This test cannot be run on this target"
return 1;
}
if [gdb_test "maint packet QTLimit:bytecode:ffffffff" \
"received: .OK." ""] then {
pass "This test cannot be run on this target"
return;
}
gdb_tracepoint_limit_test
gdb_memrange_limit_test
gdb_bytecode_limit_test
}
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $binfile
if [target_info exists gdb_stub] {
gdb_step_for_stub;
}
# Body of test encased in a proc so we can return prematurely.
gdb_trace_limits_tests
|