1 # Copyright
1998 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
}] != "" } {
40 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
44 #
1) Set up a
trace experiment that will collect approximately
10 frames
,
45 # requiring more than
512 but less than
1024 bytes of
cache buffer.
46 #
(most targets should have at least
1024 bytes of
cache buffer
!)
47 # Run and confirm that it collects all
10 frames.
48 #
2) Artificially
limit the
trace buffer to
512 bytes
, and rerun the
49 # experiment. Confirm that the first several frames are collected
,
50 # but that the last several are not.
51 #
3) Set trace buffer to circular
mode, still with the artificial
limit
52 # of
512 bytes
, and rerun the experiment. Confirm that the last
53 # several frames are collected
, but the first several are not.
56 #
return 0 for success
, 1 for failure
57 proc run_trace_experiment
{ pass
} {
60 if [gdb_test
"tstart" \
62 "start trace experiment, pass $pass"] then { return 1; }
63 if [gdb_test
"continue" \
64 "Continuing.*Breakpoint \[0-9\]+, end.*" \
65 "run to end, pass $pass"] then { return 1; }
66 if [gdb_test
"tstop" \
68 "stop trace experiment, pass $pass"] then { return 1; }
72 #
return 0 for success
, 1 for failure
73 proc set_a_tracepoint
{ func
} {
74 if [gdb_test
"trace $func" \
75 "Tracepoint \[0-9\]+ at .*" \
76 "set tracepoint at $func"] then {
79 if [gdb_trace_setactions
"set actions for $func" \
81 "collect testload" "^$"] then {
87 #
return 0 for success
, 1 for failure
88 proc setup_tracepoints
{ } {
89 gdb_delete_tracepoints
90 if [set_a_tracepoint func0
] then { return 1; }
91 if [set_a_tracepoint func1
] then { return 1; }
92 if [set_a_tracepoint func2
] then { return 1; }
93 if [set_a_tracepoint func3
] then { return 1; }
94 if [set_a_tracepoint func4
] then { return 1; }
95 if [set_a_tracepoint func5
] then { return 1; }
96 if [set_a_tracepoint func6
] then { return 1; }
97 if [set_a_tracepoint func7
] then { return 1; }
98 if [set_a_tracepoint func8
] then { return 1; }
99 if [set_a_tracepoint func9
] then { return 1; }
103 #
return 0 for success
, 1 for failure
104 proc trace_buffer_normal
{ } {
105 if [gdb_test
"maint packet QTBuffer:size:ffffffff" \
106 "received: .OK." ""] then {
107 pass
"This test cannot be run on this target"
110 if [gdb_test
"maint packet QTBuffer:circular:0" \
111 "received: .OK." ""] then {
112 pass
"This test cannot be run on this target"
118 #
return 0 for success
, 1 for failure
119 proc gdb_trace_circular_tests
{ } {
121 # We generously give ourselves one
"pass" if we successfully
122 # detect that this test cannot be run
on this target
!
123 if { ![gdb_target_supports_trace
] } then {
124 pass
"Current target does not supporst trace"
128 if [trace_buffer_normal
] then { return 1; }
130 gdb_test
"break begin" "" ""
131 gdb_test
"break end" "" ""
132 gdb_test
"tstop" "" ""
133 gdb_test
"tfind none" "" ""
135 if [setup_tracepoints
] then { return 1; }
137 # First
, run the
trace experiment with default attributes
:
138 # Make sure it behaves as expected.
139 if [run_trace_experiment
1] then { return 1; }
140 if [gdb_test
"tfind start" \
142 "find frame zero, pass 1"] then { return 1; }
144 if [gdb_test
"tfind 9" \
146 "find frame nine, pass 1"] then { return 1; }
148 if [gdb_test
"tfind none" \
150 "quit trace debugging, pass 1"] then { return 1; }
152 #
Then, shrink the
trace buffer so that it will not hold
153 # all ten
trace frames. Verify that frame zero is still
154 # collected
, but frame nine is not.
155 if [gdb_test
"maint packet QTBuffer:size:200" \
156 "received: .OK." "shrink the target trace buffer"] then {
159 if [run_trace_experiment
2] then { return 1; }
160 if [gdb_test
"tfind start" \
162 "find frame zero, pass 2"] then { return 1; }
164 if [gdb_test
"tfind 9" \
165 ".* failed to find .*" \
166 "fail to find frame nine, pass 2"] then { return 1; }
168 if [gdb_test
"tfind none" \
170 "quit trace debugging, pass 2"] then { return 1; }
172 # Finally
, make the buffer circular. Now when it runs out of
173 # space
, it should wrap around and overwrite the earliest frames.
175 #
1) frame zero will be overwritten and therefore unavailable
176 #
2) the earliest frame in the buffer will be other
-than
-zero
177 #
3) frame nine will be available
(unlike
on pass
2).
178 if [gdb_test
"maint packet QTBuffer:circular:1" \
179 "received: .OK." "make the target trace buffer circular"] then {
182 if [run_trace_experiment
3] then { return 1; }
183 if [gdb_test
"tfind start" \
184 "#0 func\[1-9\] .*" \
185 "first frame is NOT frame zero, pass 3"] then { return 1; }
187 if [gdb_test
"tfind 9" \
189 "find frame nine, pass 3"] then { return 1; }
191 if [gdb_test
"tfind none" \
193 "quit trace debugging, pass 3"] then { return 1; }
198 # Start with a fresh gdb.
202 gdb_reinitialize_dir $srcdir
/$subdir
205 if [target_info
exists gdb_stub
] {
208 # Body of test encased in a proc so we can
return prematurely.
209 if { ![gdb_trace_circular_tests
] } then {
210 #
Set trace buffer attributes
back to
normal
215 gdb_test
"tfind none" "" ""