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