Do not set prms_id/bug_id anymore.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tfind.exp
1 # Copyright 1998, 2002, 2005, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 # This file was written by Michael Snyder (msnyder@cygnus.com)
18
19 load_lib "trace-support.exp";
20
21 if $tracelevel then {
22 strace $tracelevel
23 }
24
25
26 gdb_exit
27 gdb_start
28
29 set testfile "actions"
30 set srcfile ${testfile}.c
31 set binfile $objdir/$subdir/tfind
32
33 if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" \
34 executable {debug nowarnings}] != "" } {
35 untested tfind.exp
36 return -1
37 }
38 gdb_load $binfile
39 gdb_test "tstop" "" ""
40 gdb_test "tfind none" "" ""
41 runto_main
42 gdb_reinitialize_dir $srcdir/$subdir
43
44 # We generously give ourselves one "pass" if we successfully
45 # detect that this test cannot be run on this target!
46 if { ![gdb_target_supports_trace] } then {
47 pass "Current target does not support trace"
48 return 1;
49
50 }
51
52 # If testing on a remote host, download the source file.
53 # remote_download host $srcdir/$subdir/$srcfile
54
55 # define relative source line numbers:
56 # all subsequent line numbers are relative to this first one (baseline)
57 set baseline [gdb_find_recursion_test_baseline $srcfile];
58 if { $baseline == -1 } then {
59 fail "Could not find gdb_recursion_test function"
60 return;
61 }
62
63 set testline1 [expr $baseline + 1]
64 set testline2 [expr $baseline + 5]
65 set testline3 [expr $baseline + 6]
66 set testline4 [expr $baseline + 7]
67 set testline5 [expr $baseline + 8]
68
69 #
70 # test tfind command
71 #
72
73 gdb_delete_tracepoints
74 set tdp1 [gdb_gettpnum "\*gdb_recursion_test"]
75 set tdp2 [gdb_gettpnum $testline2]
76 set tdp3 [gdb_gettpnum $testline3]
77 set tdp4 [gdb_gettpnum $testline4]
78 set tdp5 [gdb_gettpnum $testline5]
79 if { $tdp1 <= 0 || $tdp2 <= 0 || $tdp3 <= 0 || \
80 $tdp4 <= 0 || $tdp5 <= 0 } then {
81 fail "setting tracepoints"
82 return;
83 }
84
85 # 6.1 test tstart command
86 send_gdb "tstart\n"
87 gdb_expect {
88 -re "Trace can only be run on remote targets.*$gdb_prompt $" {
89 fail "6.1: tstart (not connected to remote?)"
90 return;
91 }
92 -re "Target does not support this command.*$gdb_prompt $" {
93 fail "6.1: tstart (connected to wrong target?)"
94 return;
95 }
96 -re "Target returns error code.*$gdb_prompt $" {
97 fail "6.1: tstart (connected to wrong target?)"
98 return;
99 }
100 -re "$gdb_prompt $" {
101 pass "6.1: tstart"
102 }
103 default {
104 fail "6.1: tstart (default)"
105 return;
106 }
107 }
108
109 # test tstatus (when trace on)
110 gdb_test "tstatus" "\[Tt\]race is running.*" "test tstatus on"
111
112 # 6.2 test help tstart
113 gdb_test "help tstart" "Start trace data collection." "6.2: help tstart"
114
115 gdb_test "break end" "" ""
116 gdb_test "continue" \
117 "Continuing.*Breakpoint $decimal, end.*" \
118 "run trace experiment"
119
120 # 7.1 test tstop command
121 send_gdb "tstop\n"
122 gdb_expect {
123 -re "Trace can only be run on remote targets.*$gdb_prompt $" {
124 fail "7.1: tstop (not connected to remote?)"
125 return;
126 }
127 -re "Target does not support this command.*$gdb_prompt $" {
128 fail "7.1: tstop (connected to wrong target?)"
129 return;
130 }
131 -re "Target returns error code.*$gdb_prompt $" {
132 fail "7.1: tstop (connected to wrong target?)"
133 return;
134 }
135 -re "$gdb_prompt $" {
136 pass "7.1: tstop"
137 }
138 default {
139 fail "7.1: tstop (default)"
140 return;
141 }
142 }
143
144 # 7.2 test help tstop
145 gdb_test "help tstop" "Stop trace data collection." "7.2: help tstop"
146
147 # test tstatus (when trace off)
148 gdb_test "tstatus" "Trace stopped by a tstop command.*" \
149 "test tstatus off after tstop"
150
151 ## record starting PC
152 set save_pc [gdb_readexpr "(unsigned long) \$pc"];
153 if { $save_pc == -1 } then {
154 fail "could not read PC"
155 return;
156 }
157
158 # 8.7 tfind start
159 ## check $trace_frame == 0
160 gdb_tfind_test "8.7: tfind start command" "start" "0";
161 ## check $pc != startPC
162 gdb_test "printf \"x \%d x\\n\", \$pc != $save_pc" \
163 "x 1 x" \
164 "8.7b: tfind start"
165
166 # 8.8 tfind none
167 ## check $trace_frame == -1
168 gdb_tfind_test "8.8: tfind none" "none" "-1";
169 ## check $pc == startPC
170 gdb_test "printf \"x \%d x\\n\", \$pc == $save_pc" \
171 "x 1 x" \
172 "8.8b: tfind none (restores non-trace PC)"
173
174 # 8.9 tfind end
175 ## check $trace_frame == -1
176 gdb_tfind_test "8.9: tfind end, selects no frame" "end" "-1";
177 ## check $pc == startPC
178 gdb_test "printf \"x \%d x\\n\", \$pc == $save_pc" \
179 "x 1 x" \
180 "8.9b: tfind end (restores non-tracing PC)"
181
182 # 8.1 tfind n
183 ## check $trace_frame == n
184 gdb_tfind_test "8.1: tfind 1" "1" "1"
185 ## check $trace_line corresponds to tracepoint for frame n
186 gdb_test "print \$trace_line" "$testline2" "8.1b: tfind 1 (correct line)"
187
188 # 8.28 tfind invalid n (big number)
189 ## check "not found" error
190 ## check $trace_frame != n
191 gdb_test "tfind 32767" \
192 "failed to find.*" \
193 "8.28: tfind <n> command rejects invalid frame number"
194
195 gdb_test "printf \"x \%d x\\n\", \$trace_frame == 32767" \
196 "x 0 x" \
197 "8.28: tfind <n> rejected bad input (32767)"
198
199 # 8.31 tfind negative n
200 ## check error
201 gdb_test "tfind -3" "invalid input.*" "8.31: tfind <n> rejects negative input"
202 ## check $trace_frame != -n
203 gdb_test "printf \"x \%d x\\n\", \$trace_frame == -3" "x 0 x" \
204 "8.31: tfind <n> rejected negative input (-3)"
205
206 # 8.10 tfind <no arg>
207 ## check $trace_frame += 1
208
209 gdb_tfind_test "8.10: tfind start" "start" "0";
210 gdb_test "print \$trace_line" "$baseline" \
211 "8.10: tfind 0 (correct line $baseline)"
212 gdb_tfind_test "8.10: tfind noargument 1" "" "1";
213 gdb_test "print \$trace_line" "$testline2" \
214 "8.10: tfind 1 (correct line $testline2)"
215 gdb_tfind_test "8.10: tfind noargument 2" "" "2";
216 gdb_test "print \$trace_line" "$testline3" \
217 "8.10: tfind 2 (correct line $testline3)"
218 gdb_tfind_test "8.10: tfind noargument 3" "" "3";
219 gdb_test "print \$trace_line" "$testline4" \
220 "8.10: tfind 3 (correct line $testline4)"
221
222 gdb_tfind_test "8.11: tfind 3" "3" "3";
223 gdb_test "print \$trace_line" "$testline4" \
224 "8.11: tfind 3 (correct line $testline4)"
225 gdb_tfind_test "8.11: tfind backward 2" "-" "2";
226 gdb_test "print \$trace_line" "$testline3" \
227 "8.11: tfind 2 (correct line $testline3)"
228 gdb_tfind_test "8.11: tfind backward 1" "-" "1";
229 gdb_test "print \$trace_line" "$testline2" \
230 "8.11: tfind 1 (correct line $testline2)"
231 gdb_tfind_test "8.11: tfind backward 0" "-" "0";
232 gdb_test "print \$trace_line" "$baseline" \
233 "8.11: tfind 0 (correct line $baseline)"
234
235 gdb_tfind_test "8.12: tfind none" "none" "-1";
236 gdb_tfind_test "8.12: tfind tracepoint <n>" "tracepoint $tdp2" \
237 "\$tracepoint" "$tdp2";
238 gdb_test "print \$trace_line" "$testline2" \
239 "8.12: tfind tracepoint <n> (line $testline2)"
240
241 gdb_tfind_test "8.25: tfind none" "none" "-1";
242 gdb_test "tfind tracepoint 0" "failed to find.*" \
243 "8.25: tfind tracepoint rejects zero"
244 gdb_test "tfind tracepoint 32767" "failed to find.*" \
245 "8.25: tfind tracepoint rejects nonexistant tracepoint (32767)"
246 gdb_test "tfind tracepoint -1" "failed to find.*" \
247 "8.25: tfind tracepoint rejects nonexistant tracepoint (-1)"
248
249 # 8.37 tfind tracepoint n where n no longer exists (but used to)
250 gdb_test "delete trace $tdp2" "" ""
251 gdb_tfind_test "8.37: tfind none" "none" "-1";
252 gdb_tfind_test "8.37: tfind deleted tracepoint" \
253 "tracepoint $tdp2" \
254 "\$tracepoint" "$tdp2";
255 gdb_test "print \$trace_line" "$testline2" \
256 "8.37: tfind deleted tracepoint (line $testline2)"
257
258 # 8.13 tfind tracepoint <no arg>
259 ## check $tracepoint same before and after, $trace_frame changed
260
261 gdb_tfind_test "8.13: tfind none" "none" "-1";
262 gdb_tfind_test "8.13: tracepoint $tdp1" "tracepoint $tdp1" \
263 "\$tracepoint" "$tdp1";
264 gdb_test "print \$trace_line" "$baseline" \
265 "8.13: tfind tracepoint $tdp1 (line $baseline)"
266 gdb_test "set \$save_frame = \$trace_frame" "" ""
267 gdb_tfind_test "8.13: tracepoint <no arg>" "tracepoint" \
268 "\$tracepoint" "$tdp1";
269 gdb_test "printf \"x \%d x\\n\", \$trace_frame == \$save_frame" \
270 "x 0 x" \
271 "8.13: tracepoint <no arg>, tracepoint number unchanged"
272
273 # 1.12 set tracepoint in prologue
274 #
275 # tdp1 was set at *gdb_recursion_test (ie. the hard address of the
276 # function, before the prologue). Test to see that it succeeded.
277 # Current pc should be equal to the address of the function.
278
279 gdb_test "printf \"x \%d x\\n\", \$pc == gdb_recursion_test" \
280 "x 1 x" \
281 "1.12: set tracepoint in prologue"
282
283 # 8.14 tfind pc x
284 ## check pc == x, $trace_frame != -1
285 gdb_tfind_test "8.14: tfind 3" "3" "3"
286 gdb_test "print \$trace_line" "$testline4" \
287 "8.14: tfind 3 (line $testline4)"
288
289 gdb_test "set \$test_pc = \$pc" "" ""
290 gdb_tfind_test "8.14: tfind none" "none" "-1"
291 gdb_tfind_test "8.14: tfind pc" "pc \$test_pc" "\$trace_frame != -1" "1";
292 gdb_test "print \$trace_line" "$testline4" \
293 "8.14: tfind pc x (line $testline4)"
294 gdb_test "printf \"x \%d x\\n\", \$pc == \$test_pc" \
295 "x 1 x" \
296 "8.14: tfind pc x"
297
298 # 8.15 tfind pc <no arg>
299 ## check pc same before and after, $trace_frame changed
300 gdb_tfind_test "8.15: tfind 3" "3" "3"
301 gdb_test "print \$trace_line" "$testline4" \
302 "8.15: tfind 3 (line $testline4)"
303 gdb_test "set \$test_pc = \$pc" "" ""
304 gdb_tfind_test "8.15: tfind pc" "pc" "\$pc == \$test_pc" "1"
305 gdb_test "print \$trace_line" "$testline4" \
306 "8.15: tfind pc (line $testline4)"
307 gdb_test "printf \"x \%d x\\n\", \$trace_frame != 3" "x 1 x" \
308 "8.15: trace frame didn't change"
309
310 # 8.26 tfind pc invalid x
311 ## check error, pc != x (trace_frame unchanged?)
312 gdb_tfind_test "8.26: tfind start" "start" "0"
313 gdb_test "tfind pc 0" "failed to find.*" "8.26: tfind pc zero"
314 gdb_test "tfind pc -1" "failed to find.*" "8.26: tfind pc -1"
315
316 # 8.16 tfind line n
317 ## check #trace_frame != -1, $trace_line == n
318 gdb_tfind_test "8.16: tfind none" "none" "-1"
319 gdb_tfind_test "8.16: tfind line $testline3" \
320 "line $testline3" \
321 "\$trace_line == $testline3" "1"
322
323 # 8.17 tfind line <no arg> (# 8.19, 8.20)
324 ## check $trace_line changed, no error, pc changed, frame changed, tdp changed
325 gdb_tfind_test "8.17: tfind none" "none" "-1"
326 gdb_tfind_test "8.17: tfind line $testline3" "line $testline3" "\$trace_line == $testline3" "1"
327 gdb_tfind_test "8.17: tfind line <no arg>" "line" "\$trace_line != $testline3" "1"
328
329 # 8.36 tfind and disassembly
330 gdb_tfind_test "8.36: tfind start" "start" "0"
331 set timeout 60
332 send_gdb "disassemble gdb_c_test\n"
333 # look for disassembly of function label
334 gdb_expect {
335 -re "<(\.\[0-9\]+|)>:.*End of assembler dump.*$gdb_prompt $" { pass "8.36: trace disassembly" }
336 -re ".*$gdb_prompt $" { fail "8.36: trace disassembly" }
337 timeout { fail "8.36: trace disassembly (timeout)" }
338 }
339
340 gdb_test "tfind line 0" \
341 "out of range.*|failed to find.*" \
342 "8.18: tfind line 0";
343 gdb_test "tfind line 32767" \
344 "out of range.*|failed to find.*" \
345 "8.27: tfind line 32767";
346 gdb_test "tfind line NoSuChFiLe.c:$baseline" \
347 "No source file named.*" \
348 "8.27: tfind line in bad source file";
349
350 # 8.32 tfind invalid subcommand (tfind foo)
351 ## check error
352 gdb_test "tfind NoSuChOpTiOn 21" \
353 "No symbol.*|\[Ww\]arning.*|\[Ee\]rror.*" \
354 "8.32: tfind with bad subcommand"
355
356 # 8.38 test help tfind
357 gdb_test "help tfind" "Select a trace frame.*" \
358 "8.38: help tfind"
359 gdb_test "help tfind pc" "Select a trace frame by PC.*" \
360 "8.38: help tfind PC"
361 gdb_test "help tfind end" "Synonym for 'none'.*" \
362 "8.38: help tfind end"
363 gdb_test "help tfind none" "De-select any trace frame.*" \
364 "8.38: help tfind none"
365 gdb_test "help tfind line" "Select a trace frame by source line.*" \
366 "8.38: help tfind line"
367 gdb_test "help tfind start" "Select the first trace frame.*" \
368 "8.38: help tfind start"
369 gdb_test "help tfind range" "Select a trace frame whose PC is in.*" \
370 "8.38: help tfind range"
371 gdb_test "help tfind trace" "Select a trace frame by tracepoint number.*" \
372 "8.38: help tfind tracepoint"
373
374 # Finished!
375 gdb_tfind_test "8.17: tfind none" "none" "-1"
This page took 0.037956 seconds and 5 git commands to generate.