]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/limits.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / limits.exp
1 # Copyright 1998, 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 if [istarget "m68k-*-elf"] then {
21 pass "Test not supported on this target"
22 return;
23 }
24
25 load_lib "trace-support.exp"
26
27 if $tracelevel then {
28 strace $tracelevel
29 }
30
31 set prms_id 0
32 set bug_id 0
33
34 set testfile "limits"
35 set srcfile ${testfile}.c
36 set binfile $objdir/$subdir/$testfile
37
38 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
39 executable {debug nowarnings}] != "" } {
40 untested limits.exp
41 return -1
42 }
43
44 # Tests:
45 # 1) Meet and exceed artificial limit on number of tracepoints
46 # 2) Meet and exceed artificial limit on number of memranges
47 # 3) Meet and exceed artificial limit on bytes of bytecode data
48 # [NOTE: number four is moved out into its own separate test module.]
49 # 4) Meet and exceed artificial limit on bytes of trace buffer storage
50 # (circular and non-circular modes). However note that a more
51 # thorough test of the circular mode can be made separately.
52
53 set cr "\[\r\n\]+"
54
55 proc gdb_tracepoint_limit_test { } {
56 global gdb_prompt
57 global cr
58
59 # Make sure we're in a sane starting state.
60 gdb_test "tstop" "" ""
61 gdb_test "tfind none" "" ""
62 gdb_delete_tracepoints
63
64 # Set three tracepoints
65 gdb_test "trace foo" \
66 "Tracepoint \[0-9\]+ at .*" \
67 "tracepoint limit test: set first tracepoint"
68
69 gdb_test "trace bar" \
70 "Tracepoint \[0-9\]+ at .*" \
71 "tracepoint limit test: set second tracepoint"
72
73 gdb_test "trace baz" \
74 "Tracepoint \[0-9\]+ at .*" \
75 "tracepoint limit test: set third tracepoint"
76
77 # Set secret artificial tracepoint limit to four
78 gdb_test "maint packet QTLimit:tp:4" \
79 "received: .OK." \
80 "tracepoint limit test: set limit to four"
81
82 # Now sending three tracepoints should succeed.
83 send_gdb "tstart\n"
84 gdb_expect {
85 -re "$cr$gdb_prompt" {
86 pass "tracepoint limit test: send fewer than limit"
87 }
88 default {
89 fail "tracepoint limit test: send fewer than limit"
90 }
91 }
92
93 # Set secret artificial tracepoint limit to three
94 gdb_test "maint packet QTLimit:tp:3" \
95 "received: .OK." \
96 "tracepoint limit test: set limit to three"
97
98 # Now sending three tracepoints should still succeed.
99 send_gdb "tstart\n"
100 gdb_expect {
101 -re "$cr$gdb_prompt" {
102 pass "tracepoint limit test: send equal to limit"
103 }
104 default {
105 fail "tracepoint limit test: send equal to limit"
106 }
107 }
108
109 # Set secret artificial tracepoint limit to two
110 gdb_test "maint packet QTLimit:tp:2" \
111 "received: .OK." \
112 "tracepoint limit test: set limit to two"
113
114 # Now sending three tracepoints should fail.
115 gdb_test "tstart" \
116 ".*\[Ee\]rror.*" \
117 "tracepoint limit test: send more than limit"
118
119 # Clean up:
120 gdb_test "tstop" "" ""
121 gdb_test "maint packet QTLimit:tp:FFFFFFFF" "" ""
122 }
123
124 proc gdb_memrange_limit_test { } {
125 global gdb_prompt
126 global cr
127
128 # Make sure we're in a sane starting state.
129 gdb_test "tstop" "" ""
130 gdb_test "tfind none" "" ""
131 gdb_delete_tracepoints
132
133 # Set three tracepoints, and make 'em collect memranges
134 gdb_test "trace foo" \
135 "Tracepoint \[0-9\]+ at .*" \
136 "memrange limit test: set first tracepoint"
137
138 gdb_trace_setactions "memrange limit test: set first actions" \
139 "" \
140 "collect \$arg" "^$"
141
142 gdb_test "trace bar" \
143 "Tracepoint \[0-9\]+ at .*" \
144 "memrange limit test: set second tracepoint"
145
146 gdb_trace_setactions "memrange limit test: set second actions" \
147 "" \
148 "collect \$arg" "^$"
149
150 gdb_test "trace baz" \
151 "Tracepoint \[0-9\]+ at .*" \
152 "memrange limit test: set third tracepoint"
153
154 gdb_trace_setactions "memrange limit test: set third actions" \
155 "" \
156 "collect \$arg" "^$"
157
158 # Set secret artificial memrange limit to four
159 gdb_test "maint packet QTLimit:memrange:4" \
160 "received: .OK." \
161 "memrange limit test: set limit to four"
162
163 # Now sending three memranges should still succeed.
164 send_gdb "tstart\n"
165 gdb_expect {
166 -re "$cr$gdb_prompt" {
167 pass "memrange limit test: send fewer than limit"
168 }
169 default {
170 fail "memrange limit test: send fewer than limit"
171 }
172 }
173
174 # Set secret artificial memrange limit to three
175 gdb_test "maint packet QTLimit:memrange:3" \
176 "received: .OK." \
177 "memrange limit test: set limit to three"
178
179 # Now sending three memranges should still succeed.
180 send_gdb "tstart\n"
181 gdb_expect {
182 -re "$cr$gdb_prompt" {
183 pass "memrange limit test: send equal to limit"
184 }
185 default {
186 fail "memrange limit test: send equal to limit"
187 }
188 }
189
190 # Set secret artificial memrange limit to two
191 gdb_test "maint packet QTLimit:memrange:2" \
192 "received: .OK." \
193 "memrange limit test: set limit to two"
194
195 # Now sending three memranges should fail.
196 gdb_test "tstart" \
197 ".*\[Ee\]rror.*" \
198 "memrange limit test: send more than limit"
199
200 # Clean up:
201 gdb_test "tstop" "" ""
202 gdb_test "maint packet QTLimit:memrange:FFFFFFFF" "" ""
203 }
204
205
206 proc gdb_bytecode_limit_test { } {
207 global gdb_prompt
208 global cr
209
210 # Make sure we're in a sane starting state.
211 gdb_test "tstop" "" ""
212 gdb_test "tfind none" "" ""
213 gdb_delete_tracepoints
214
215 # Set three tracepoints
216 gdb_test "trace foo" \
217 "Tracepoint \[0-9\]+ at .*" \
218 "bytecode limit test: set first tracepoint"
219
220 gdb_trace_setactions "bytecode limit test: set first actions" \
221 "" \
222 "collect x + n" "^$"
223
224 gdb_test "trace bar" \
225 "Tracepoint \[0-9\]+ at .*" \
226 "bytecode limit test: set second tracepoint"
227
228 gdb_trace_setactions "bytecode limit test: set second actions" \
229 "" \
230 "collect y + n" "^$"
231
232 gdb_test "trace baz" \
233 "Tracepoint \[0-9\]+ at .*" \
234 "bytecode limit test: set third tracepoint"
235
236 gdb_trace_setactions "bytecode limit test: set third actions" \
237 "" \
238 "collect z + n" "^$"
239
240 # Set secret artificial bytecode limit to a large number
241 gdb_test "maint packet QTLimit:bytecode:400" \
242 "received: .OK." \
243 "bytecode limit test: set limit to large"
244
245 # Now sending three bytecodes should still succeed.
246 send_gdb "tstart\n"
247 gdb_expect {
248 -re "$cr$gdb_prompt" {
249 pass "bytecode limit test: send fewer than limit"
250 }
251 default {
252 fail "bytecode limit test: send fewer than limit"
253 }
254 }
255
256 # Set secret artificial bytecode limit to a small number
257 gdb_test "maint packet QTLimit:bytecode:40" \
258 "received: .OK." \
259 "bytecode limit test: set limit to small"
260
261 # Now sending three bytecodes should fail.
262 gdb_test "tstart" \
263 ".*\[Ee\]rror.*" \
264 "bytecode limit test: send more than limit"
265
266
267 # Clean up:
268 gdb_test "tstop" "" ""
269 gdb_test "maint packet QTLimit:bytecode:FFFFFFFF" "" ""
270 }
271
272 proc gdb_trace_limits_tests { } {
273 global gdb_prompt
274
275 # We generously give ourselves one "pass" if we successfully
276 # detect that this test cannot be run on this target!
277
278 if { ![gdb_target_supports_trace] } then {
279 pass "Current target does not supporst trace"
280 return 1;
281 }
282
283 if [gdb_test "maint packet QTLimit:tp:ffffffff" \
284 "received: .OK." ""] then {
285 pass "This test cannot be run on this target"
286 return 1;
287 }
288
289 if [gdb_test "maint packet QTLimit:memrange:ffffffff" \
290 "received: .OK." ""] then {
291 pass "This test cannot be run on this target"
292 return 1;
293 }
294
295 if [gdb_test "maint packet QTLimit:bytecode:ffffffff" \
296 "received: .OK." ""] then {
297 pass "This test cannot be run on this target"
298 return;
299 }
300
301 gdb_tracepoint_limit_test
302 gdb_memrange_limit_test
303 gdb_bytecode_limit_test
304 }
305
306 # Start with a fresh gdb.
307
308 gdb_exit
309 gdb_start
310 gdb_reinitialize_dir $srcdir/$subdir
311 gdb_load $binfile
312
313 if [target_info exists gdb_stub] {
314 gdb_step_for_stub;
315 }
316 # Body of test encased in a proc so we can return prematurely.
317 gdb_trace_limits_tests