]>
Commit | Line | Data |
---|---|---|
6aba47ca | 1 | # Copyright 1998, 2007 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 | |
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 "circ" | |
35 | set srcfile ${testfile}.c | |
36 | set binfile $objdir/$subdir/$testfile | |
37 | ||
38 | if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ | |
fc91c6c2 | 39 | executable {debug nowarnings}] != "" } { |
b60f0898 JB |
40 | untested circ.exp |
41 | return -1 | |
c906108c SS |
42 | } |
43 | ||
44 | # Tests: | |
45 | # 1) Set up a trace experiment that will collect approximately 10 frames, | |
46 | # requiring more than 512 but less than 1024 bytes of cache buffer. | |
47 | # (most targets should have at least 1024 bytes of cache buffer!) | |
48 | # Run and confirm that it collects all 10 frames. | |
49 | # 2) Artificially limit the trace buffer to 512 bytes, and rerun the | |
50 | # experiment. Confirm that the first several frames are collected, | |
51 | # but that the last several are not. | |
52 | # 3) Set trace buffer to circular mode, still with the artificial limit | |
53 | # of 512 bytes, and rerun the experiment. Confirm that the last | |
54 | # several frames are collected, but the first several are not. | |
55 | # | |
56 | ||
57 | # return 0 for success, 1 for failure | |
58 | proc run_trace_experiment { pass } { | |
59 | gdb_run_cmd | |
60 | ||
61 | if [gdb_test "tstart" \ | |
62 | "\[\r\n\]*" \ | |
63 | "start trace experiment, pass $pass"] then { return 1; } | |
64 | if [gdb_test "continue" \ | |
65 | "Continuing.*Breakpoint \[0-9\]+, end.*" \ | |
66 | "run to end, pass $pass"] then { return 1; } | |
67 | if [gdb_test "tstop" \ | |
68 | "\[\r\n\]*" \ | |
69 | "stop trace experiment, pass $pass"] then { return 1; } | |
70 | return 0; | |
71 | } | |
72 | ||
73 | # return 0 for success, 1 for failure | |
74 | proc set_a_tracepoint { func } { | |
75 | if [gdb_test "trace $func" \ | |
76 | "Tracepoint \[0-9\]+ at .*" \ | |
77 | "set tracepoint at $func"] then { | |
78 | return 1; | |
79 | } | |
80 | if [gdb_trace_setactions "set actions for $func" \ | |
81 | "" \ | |
82 | "collect testload" "^$"] then { | |
83 | return 1; | |
84 | } | |
85 | return 0; | |
86 | } | |
87 | ||
88 | # return 0 for success, 1 for failure | |
89 | proc setup_tracepoints { } { | |
90 | gdb_delete_tracepoints | |
91 | if [set_a_tracepoint func0] then { return 1; } | |
92 | if [set_a_tracepoint func1] then { return 1; } | |
93 | if [set_a_tracepoint func2] then { return 1; } | |
94 | if [set_a_tracepoint func3] then { return 1; } | |
95 | if [set_a_tracepoint func4] then { return 1; } | |
96 | if [set_a_tracepoint func5] then { return 1; } | |
97 | if [set_a_tracepoint func6] then { return 1; } | |
98 | if [set_a_tracepoint func7] then { return 1; } | |
99 | if [set_a_tracepoint func8] then { return 1; } | |
100 | if [set_a_tracepoint func9] then { return 1; } | |
101 | return 0; | |
102 | } | |
103 | ||
104 | # return 0 for success, 1 for failure | |
105 | proc trace_buffer_normal { } { | |
106 | if [gdb_test "maint packet QTBuffer:size:ffffffff" \ | |
107 | "received: .OK." ""] then { | |
108 | pass "This test cannot be run on this target" | |
109 | return 1; | |
110 | } | |
111 | if [gdb_test "maint packet QTBuffer:circular:0" \ | |
112 | "received: .OK." ""] then { | |
113 | pass "This test cannot be run on this target" | |
114 | return 1; | |
115 | } | |
116 | return 0; | |
117 | } | |
118 | ||
119 | # return 0 for success, 1 for failure | |
120 | proc gdb_trace_circular_tests { } { | |
121 | ||
122 | # We generously give ourselves one "pass" if we successfully | |
123 | # detect that this test cannot be run on this target! | |
124 | if { ![gdb_target_supports_trace] } then { | |
125 | pass "Current target does not supporst trace" | |
126 | return 1; | |
127 | } | |
128 | ||
129 | if [trace_buffer_normal] then { return 1; } | |
130 | ||
131 | gdb_test "break begin" "" "" | |
132 | gdb_test "break end" "" "" | |
133 | gdb_test "tstop" "" "" | |
134 | gdb_test "tfind none" "" "" | |
135 | ||
136 | if [setup_tracepoints] then { return 1; } | |
137 | ||
138 | # First, run the trace experiment with default attributes: | |
139 | # Make sure it behaves as expected. | |
140 | if [run_trace_experiment 1] then { return 1; } | |
141 | if [gdb_test "tfind start" \ | |
142 | "#0 func0 .*" \ | |
143 | "find frame zero, pass 1"] then { return 1; } | |
144 | ||
145 | if [gdb_test "tfind 9" \ | |
146 | "#0 func9 .*" \ | |
147 | "find frame nine, pass 1"] then { return 1; } | |
148 | ||
149 | if [gdb_test "tfind none" \ | |
150 | "#0 end .*" \ | |
151 | "quit trace debugging, pass 1"] then { return 1; } | |
152 | ||
153 | # Then, shrink the trace buffer so that it will not hold | |
154 | # all ten trace frames. Verify that frame zero is still | |
155 | # collected, but frame nine is not. | |
156 | if [gdb_test "maint packet QTBuffer:size:200" \ | |
157 | "received: .OK." "shrink the target trace buffer"] then { | |
158 | return 1; | |
159 | } | |
160 | if [run_trace_experiment 2] then { return 1; } | |
161 | if [gdb_test "tfind start" \ | |
162 | "#0 func0 .*" \ | |
163 | "find frame zero, pass 2"] then { return 1; } | |
164 | ||
165 | if [gdb_test "tfind 9" \ | |
166 | ".* failed to find .*" \ | |
167 | "fail to find frame nine, pass 2"] then { return 1; } | |
168 | ||
169 | if [gdb_test "tfind none" \ | |
170 | "#0 end .*" \ | |
171 | "quit trace debugging, pass 2"] then { return 1; } | |
172 | ||
173 | # Finally, make the buffer circular. Now when it runs out of | |
174 | # space, it should wrap around and overwrite the earliest frames. | |
175 | # This means that: | |
176 | # 1) frame zero will be overwritten and therefore unavailable | |
177 | # 2) the earliest frame in the buffer will be other-than-zero | |
178 | # 3) frame nine will be available (unlike on pass 2). | |
179 | if [gdb_test "maint packet QTBuffer:circular:1" \ | |
180 | "received: .OK." "make the target trace buffer circular"] then { | |
181 | return 1; | |
182 | } | |
183 | if [run_trace_experiment 3] then { return 1; } | |
184 | if [gdb_test "tfind start" \ | |
185 | "#0 func\[1-9\] .*" \ | |
186 | "first frame is NOT frame zero, pass 3"] then { return 1; } | |
187 | ||
188 | if [gdb_test "tfind 9" \ | |
189 | "#0 func9 .*" \ | |
190 | "find frame nine, pass 3"] then { return 1; } | |
191 | ||
192 | if [gdb_test "tfind none" \ | |
193 | "#0 end .*" \ | |
194 | "quit trace debugging, pass 3"] then { return 1; } | |
195 | ||
196 | return 0; | |
197 | } | |
198 | ||
199 | # Start with a fresh gdb. | |
200 | ||
201 | gdb_exit | |
202 | gdb_start | |
203 | gdb_reinitialize_dir $srcdir/$subdir | |
204 | gdb_load $binfile | |
205 | ||
206 | if [target_info exists gdb_stub] { | |
207 | gdb_step_for_stub; | |
208 | } | |
209 | # Body of test encased in a proc so we can return prematurely. | |
210 | if { ![gdb_trace_circular_tests] } then { | |
211 | # Set trace buffer attributes back to normal | |
212 | trace_buffer_normal; | |
213 | } | |
214 | ||
215 | # Finished! | |
216 | gdb_test "tfind none" "" "" |