1 # Copyright 1998, 2007, 2008, 2009 Free Software Foundation, Inc.
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 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 if [istarget "m68k-*-elf"] then {
17 pass "Test not supported on this target"
21 load_lib "trace-support.exp"
31 set srcfile ${testfile}.c
32 set binfile $objdir/$subdir/$testfile
34 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
35 executable {debug nowarnings}] != "" } {
41 # 1) Meet and exceed artificial limit on number of tracepoints
42 # 2) Meet and exceed artificial limit on number of memranges
43 # 3) Meet and exceed artificial limit on bytes of bytecode data
44 # [NOTE: number four is moved out into its own separate test module.]
45 # 4) Meet and exceed artificial limit on bytes of trace buffer storage
46 # (circular and non-circular modes). However note that a more
47 # thorough test of the circular mode can be made separately.
51 proc gdb_tracepoint_limit_test { } {
55 # Make sure we're in a sane starting state.
56 gdb_test "tstop" "" ""
57 gdb_test "tfind none" "" ""
58 gdb_delete_tracepoints
60 # Set three tracepoints
61 gdb_test "trace foo" \
62 "Tracepoint \[0-9\]+ at .*" \
63 "tracepoint limit test: set first tracepoint"
65 gdb_test "trace bar" \
66 "Tracepoint \[0-9\]+ at .*" \
67 "tracepoint limit test: set second tracepoint"
69 gdb_test "trace baz" \
70 "Tracepoint \[0-9\]+ at .*" \
71 "tracepoint limit test: set third tracepoint"
73 # Set secret artificial tracepoint limit to four
74 gdb_test "maint packet QTLimit:tp:4" \
76 "tracepoint limit test: set limit to four"
78 # Now sending three tracepoints should succeed.
81 -re "$cr$gdb_prompt" {
82 pass "tracepoint limit test: send fewer than limit"
85 fail "tracepoint limit test: send fewer than limit"
89 # Set secret artificial tracepoint limit to three
90 gdb_test "maint packet QTLimit:tp:3" \
92 "tracepoint limit test: set limit to three"
94 # Now sending three tracepoints should still succeed.
97 -re "$cr$gdb_prompt" {
98 pass "tracepoint limit test: send equal to limit"
101 fail "tracepoint limit test: send equal to limit"
105 # Set secret artificial tracepoint limit to two
106 gdb_test "maint packet QTLimit:tp:2" \
108 "tracepoint limit test: set limit to two"
110 # Now sending three tracepoints should fail.
113 "tracepoint limit test: send more than limit"
116 gdb_test "tstop" "" ""
117 gdb_test "maint packet QTLimit:tp:FFFFFFFF" "" ""
120 proc gdb_memrange_limit_test { } {
124 # Make sure we're in a sane starting state.
125 gdb_test "tstop" "" ""
126 gdb_test "tfind none" "" ""
127 gdb_delete_tracepoints
129 # Set three tracepoints, and make 'em collect memranges
130 gdb_test "trace foo" \
131 "Tracepoint \[0-9\]+ at .*" \
132 "memrange limit test: set first tracepoint"
134 gdb_trace_setactions "memrange limit test: set first actions" \
138 gdb_test "trace bar" \
139 "Tracepoint \[0-9\]+ at .*" \
140 "memrange limit test: set second tracepoint"
142 gdb_trace_setactions "memrange limit test: set second actions" \
146 gdb_test "trace baz" \
147 "Tracepoint \[0-9\]+ at .*" \
148 "memrange limit test: set third tracepoint"
150 gdb_trace_setactions "memrange limit test: set third actions" \
154 # Set secret artificial memrange limit to four
155 gdb_test "maint packet QTLimit:memrange:4" \
157 "memrange limit test: set limit to four"
159 # Now sending three memranges should still succeed.
162 -re "$cr$gdb_prompt" {
163 pass "memrange limit test: send fewer than limit"
166 fail "memrange limit test: send fewer than limit"
170 # Set secret artificial memrange limit to three
171 gdb_test "maint packet QTLimit:memrange:3" \
173 "memrange limit test: set limit to three"
175 # Now sending three memranges should still succeed.
178 -re "$cr$gdb_prompt" {
179 pass "memrange limit test: send equal to limit"
182 fail "memrange limit test: send equal to limit"
186 # Set secret artificial memrange limit to two
187 gdb_test "maint packet QTLimit:memrange:2" \
189 "memrange limit test: set limit to two"
191 # Now sending three memranges should fail.
194 "memrange limit test: send more than limit"
197 gdb_test "tstop" "" ""
198 gdb_test "maint packet QTLimit:memrange:FFFFFFFF" "" ""
202 proc gdb_bytecode_limit_test { } {
206 # Make sure we're in a sane starting state.
207 gdb_test "tstop" "" ""
208 gdb_test "tfind none" "" ""
209 gdb_delete_tracepoints
211 # Set three tracepoints
212 gdb_test "trace foo" \
213 "Tracepoint \[0-9\]+ at .*" \
214 "bytecode limit test: set first tracepoint"
216 gdb_trace_setactions "bytecode limit test: set first actions" \
220 gdb_test "trace bar" \
221 "Tracepoint \[0-9\]+ at .*" \
222 "bytecode limit test: set second tracepoint"
224 gdb_trace_setactions "bytecode limit test: set second actions" \
228 gdb_test "trace baz" \
229 "Tracepoint \[0-9\]+ at .*" \
230 "bytecode limit test: set third tracepoint"
232 gdb_trace_setactions "bytecode limit test: set third actions" \
236 # Set secret artificial bytecode limit to a large number
237 gdb_test "maint packet QTLimit:bytecode:400" \
239 "bytecode limit test: set limit to large"
241 # Now sending three bytecodes should still succeed.
244 -re "$cr$gdb_prompt" {
245 pass "bytecode limit test: send fewer than limit"
248 fail "bytecode limit test: send fewer than limit"
252 # Set secret artificial bytecode limit to a small number
253 gdb_test "maint packet QTLimit:bytecode:40" \
255 "bytecode limit test: set limit to small"
257 # Now sending three bytecodes should fail.
260 "bytecode limit test: send more than limit"
264 gdb_test "tstop" "" ""
265 gdb_test "maint packet QTLimit:bytecode:FFFFFFFF" "" ""
268 proc gdb_trace_limits_tests { } {
271 # We generously give ourselves one "pass" if we successfully
272 # detect that this test cannot be run on this target!
274 if { ![gdb_target_supports_trace] } then {
275 pass "Current target does not support trace"
279 if [gdb_test "maint packet QTLimit:tp:ffffffff" \
280 "received: .OK." ""] then {
281 pass "This test cannot be run on this target"
285 if [gdb_test "maint packet QTLimit:memrange:ffffffff" \
286 "received: .OK." ""] then {
287 pass "This test cannot be run on this target"
291 if [gdb_test "maint packet QTLimit:bytecode:ffffffff" \
292 "received: .OK." ""] then {
293 pass "This test cannot be run on this target"
297 gdb_tracepoint_limit_test
298 gdb_memrange_limit_test
299 gdb_bytecode_limit_test
302 # Start with a fresh gdb.
306 gdb_reinitialize_dir $srcdir/$subdir
309 if [target_info exists gdb_stub] {
312 # Body of test encased in a proc so we can return prematurely.
313 gdb_trace_limits_tests