1 # Copyright 1998, 2007 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 2 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, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 if [istarget "m68k-*-elf"] then {
21 pass "Test not supported on this target"
25 load_lib "trace-support.exp"
35 set srcfile ${testfile}.c
36 set binfile $objdir/$subdir/$testfile
38 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
39 executable {debug nowarnings}] != "" } {
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.
55 proc gdb_tracepoint_limit_test { } {
59 # Make sure we're in a sane starting state.
60 gdb_test "tstop" "" ""
61 gdb_test "tfind none" "" ""
62 gdb_delete_tracepoints
64 # Set three tracepoints
65 gdb_test "trace foo" \
66 "Tracepoint \[0-9\]+ at .*" \
67 "tracepoint limit test: set first tracepoint"
69 gdb_test "trace bar" \
70 "Tracepoint \[0-9\]+ at .*" \
71 "tracepoint limit test: set second tracepoint"
73 gdb_test "trace baz" \
74 "Tracepoint \[0-9\]+ at .*" \
75 "tracepoint limit test: set third tracepoint"
77 # Set secret artificial tracepoint limit to four
78 gdb_test "maint packet QTLimit:tp:4" \
80 "tracepoint limit test: set limit to four"
82 # Now sending three tracepoints should succeed.
85 -re "$cr$gdb_prompt" {
86 pass "tracepoint limit test: send fewer than limit"
89 fail "tracepoint limit test: send fewer than limit"
93 # Set secret artificial tracepoint limit to three
94 gdb_test "maint packet QTLimit:tp:3" \
96 "tracepoint limit test: set limit to three"
98 # Now sending three tracepoints should still succeed.
101 -re "$cr$gdb_prompt" {
102 pass "tracepoint limit test: send equal to limit"
105 fail "tracepoint limit test: send equal to limit"
109 # Set secret artificial tracepoint limit to two
110 gdb_test "maint packet QTLimit:tp:2" \
112 "tracepoint limit test: set limit to two"
114 # Now sending three tracepoints should fail.
117 "tracepoint limit test: send more than limit"
120 gdb_test "tstop" "" ""
121 gdb_test "maint packet QTLimit:tp:FFFFFFFF" "" ""
124 proc gdb_memrange_limit_test { } {
128 # Make sure we're in a sane starting state.
129 gdb_test "tstop" "" ""
130 gdb_test "tfind none" "" ""
131 gdb_delete_tracepoints
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"
138 gdb_trace_setactions "memrange limit test: set first actions" \
142 gdb_test "trace bar" \
143 "Tracepoint \[0-9\]+ at .*" \
144 "memrange limit test: set second tracepoint"
146 gdb_trace_setactions "memrange limit test: set second actions" \
150 gdb_test "trace baz" \
151 "Tracepoint \[0-9\]+ at .*" \
152 "memrange limit test: set third tracepoint"
154 gdb_trace_setactions "memrange limit test: set third actions" \
158 # Set secret artificial memrange limit to four
159 gdb_test "maint packet QTLimit:memrange:4" \
161 "memrange limit test: set limit to four"
163 # Now sending three memranges should still succeed.
166 -re "$cr$gdb_prompt" {
167 pass "memrange limit test: send fewer than limit"
170 fail "memrange limit test: send fewer than limit"
174 # Set secret artificial memrange limit to three
175 gdb_test "maint packet QTLimit:memrange:3" \
177 "memrange limit test: set limit to three"
179 # Now sending three memranges should still succeed.
182 -re "$cr$gdb_prompt" {
183 pass "memrange limit test: send equal to limit"
186 fail "memrange limit test: send equal to limit"
190 # Set secret artificial memrange limit to two
191 gdb_test "maint packet QTLimit:memrange:2" \
193 "memrange limit test: set limit to two"
195 # Now sending three memranges should fail.
198 "memrange limit test: send more than limit"
201 gdb_test "tstop" "" ""
202 gdb_test "maint packet QTLimit:memrange:FFFFFFFF" "" ""
206 proc gdb_bytecode_limit_test { } {
210 # Make sure we're in a sane starting state.
211 gdb_test "tstop" "" ""
212 gdb_test "tfind none" "" ""
213 gdb_delete_tracepoints
215 # Set three tracepoints
216 gdb_test "trace foo" \
217 "Tracepoint \[0-9\]+ at .*" \
218 "bytecode limit test: set first tracepoint"
220 gdb_trace_setactions "bytecode limit test: set first actions" \
224 gdb_test "trace bar" \
225 "Tracepoint \[0-9\]+ at .*" \
226 "bytecode limit test: set second tracepoint"
228 gdb_trace_setactions "bytecode limit test: set second actions" \
232 gdb_test "trace baz" \
233 "Tracepoint \[0-9\]+ at .*" \
234 "bytecode limit test: set third tracepoint"
236 gdb_trace_setactions "bytecode limit test: set third actions" \
240 # Set secret artificial bytecode limit to a large number
241 gdb_test "maint packet QTLimit:bytecode:400" \
243 "bytecode limit test: set limit to large"
245 # Now sending three bytecodes should still succeed.
248 -re "$cr$gdb_prompt" {
249 pass "bytecode limit test: send fewer than limit"
252 fail "bytecode limit test: send fewer than limit"
256 # Set secret artificial bytecode limit to a small number
257 gdb_test "maint packet QTLimit:bytecode:40" \
259 "bytecode limit test: set limit to small"
261 # Now sending three bytecodes should fail.
264 "bytecode limit test: send more than limit"
268 gdb_test "tstop" "" ""
269 gdb_test "maint packet QTLimit:bytecode:FFFFFFFF" "" ""
272 proc gdb_trace_limits_tests { } {
275 # We generously give ourselves one "pass" if we successfully
276 # detect that this test cannot be run on this target!
278 if { ![gdb_target_supports_trace] } then {
279 pass "Current target does not supporst trace"
283 if [gdb_test "maint packet QTLimit:tp:ffffffff" \
284 "received: .OK." ""] then {
285 pass "This test cannot be run on this target"
289 if [gdb_test "maint packet QTLimit:memrange:ffffffff" \
290 "received: .OK." ""] then {
291 pass "This test cannot be run on this target"
295 if [gdb_test "maint packet QTLimit:bytecode:ffffffff" \
296 "received: .OK." ""] then {
297 pass "This test cannot be run on this target"
301 gdb_tracepoint_limit_test
302 gdb_memrange_limit_test
303 gdb_bytecode_limit_test
306 # Start with a fresh gdb.
310 gdb_reinitialize_dir $srcdir/$subdir
313 if [target_info exists gdb_stub] {
316 # Body of test encased in a proc so we can return prematurely.
317 gdb_trace_limits_tests