]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/report.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / report.exp
1 # Copyright 1998, 2007 Free Software Foundation, Inc.
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 # This file was written by Michael Snyder (msnyder@cygnus.com)
21
22 load_lib "trace-support.exp";
23
24 if $tracelevel then {
25 strace $tracelevel
26 }
27
28 set prms_id 0
29 set bug_id 0
30
31 gdb_exit
32 gdb_start
33
34 if [istarget "m68k-*-elf"] then {
35 load_lib "emc-support.exp";
36 set srcfile gdb_c_test.c
37 set binfile [board_info target d490_binfile];
38 gdb_test "set remotetimeout 6" "" ""
39 set timeout 500
40 gdb_target_monitor $binfile
41 # Give a TSTOP and ignore errors, to make sure any previous trace is off
42 gdb_test "tstop" "" ""
43 gdb_test "tfind none" "" ""
44 send_gdb "compare-sections CS\n"
45 gdb_expect {
46 -re "MIS-MATCHED.*$gdb_prompt $" {
47 untested report.exp
48 return -1
49 all tests in this module will fail.";
50 }
51 -re ".*$gdb_prompt $" { }
52 }
53 } else {
54 set testfile "actions"
55 set srcfile ${testfile}.c
56 set binfile $objdir/$subdir/$testfile
57 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
58 executable {debug nowarnings}] != "" } {
59 untested report.exp
60 return -1
61 }
62 gdb_load $binfile
63 gdb_test "tstop" "" ""
64 gdb_test "tfind none" "" ""
65 runto_main
66 }
67 gdb_reinitialize_dir $srcdir/$subdir
68
69 # We generously give ourselves one "pass" if we successfully
70 # detect that this test cannot be run on this target!
71 if { ![gdb_target_supports_trace] } then {
72 pass "Current target does not supporst trace"
73 return 1;
74
75 }
76
77 set cr "\[\r\n\]+"
78
79 # If testing on a remote host, download the source file.
80 # remote_download host $srcdir/$subdir/$srcfile
81
82 #
83 # test general reporting of trace experiment results
84 #
85
86 set testline1 0
87 set testline2 0
88 set testline3 0
89 set testline4 0
90 set testline5 0
91 set testline6 0
92
93 set arg1 1
94 set arg2 2
95 set arg3 3
96 set arg4 4
97 set arg5 5
98 set arg6 6
99
100 set gdb_recursion_test_baseline [gdb_find_recursion_test_baseline $srcfile];
101 if { $gdb_recursion_test_baseline == -1 } {
102 fail "Could not find gdb_recursion_test function"
103 return;
104 }
105
106 send_gdb "list $gdb_recursion_test_baseline, +12\n"
107 gdb_expect {
108 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 1 " {
109 set testline1 $expect_out(1,string)
110 exp_continue
111 }
112 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 2 " {
113 set testline2 $expect_out(1,string)
114 exp_continue
115 }
116 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 3 " {
117 set testline3 $expect_out(1,string)
118 exp_continue
119 }
120 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 4 " {
121 set testline4 $expect_out(1,string)
122 exp_continue
123 }
124 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 5 " {
125 set testline5 $expect_out(1,string)
126 exp_continue
127 }
128 -re "\[\r\n\](\[0-9\]+)\[^\r\n\]+gdbtestline 6 " {
129 set testline6 $expect_out(1,string)
130 exp_continue
131 }
132 -re ".*$gdb_prompt $" {
133 if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
134 untested report.exp
135 return -1
136 all tests in this module will fail."
137 }
138 }
139 default {
140 untested report.exp
141 return -1
142 all tests in this module will fail."
143 }
144 }
145
146 #
147 # Setup trace experiment. This will involve:
148 # 1) a tracepoint where nothing is collected
149 # 2) a tracepoint where only regs are collected
150 # 3) a tracepoint where only args are collected
151 # 4) a tracepoint where only locals are collected
152 # 5) a tracepoint where some amount of stack memory is collected.
153 # 6) a tracepoint where some expressions are collected.
154 #
155
156 gdb_delete_tracepoints
157 set tdp1 [gdb_gettpnum $testline1]
158 set tdp2 [gdb_gettpnum $testline2]
159 set tdp3 [gdb_gettpnum $testline3]
160 set tdp4 [gdb_gettpnum $testline4]
161 set tdp5 [gdb_gettpnum $testline5]
162 set tdp6 [gdb_gettpnum $testline6]
163
164 if { $tdp1 <= 0 || $tdp2 <= 0 || $tdp3 <= 0 || \
165 $tdp4 <= 0 || $tdp5 <= 0 || $tdp6 <= 0 } then {
166 fail "setting tracepoints failed"
167 return;
168 }
169
170 gdb_trace_setactions "9.x: setup TP to collect regs" \
171 "$tdp2" \
172 "collect \$regs" "^$"
173
174
175 gdb_trace_setactions "9.x: setup TP to collect args" \
176 "$tdp3" \
177 "collect \$args" "^$"
178
179 gdb_trace_setactions "9.x: setup TP to collect locals" \
180 "$tdp4" \
181 "collect \$locs" "^$"
182
183 gdb_trace_setactions "9.x: setup TP to collect stack memory" \
184 "$tdp5" \
185 "collect \$fp, \*\(void \*\*\) \$sp @ 64" "^$"
186
187 gdb_trace_setactions "9.x: setup TP to collect expressions" \
188 "$tdp6" \
189 "collect gdb_char_test, gdb_short_test, gdb_long_test" "^$"
190
191 gdb_test "tstart" "" ""
192
193 if [istarget "m68k-*-elf"] then {
194 gdb_emclaptop_command "85,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6"
195 sleep 5
196
197 } else {
198 gdb_test "break end" "" ""
199 gdb_test "continue" \
200 "Continuing.*Breakpoint $decimal, end.*" \
201 "run trace experiment"
202 }
203
204 gdb_test "tstop" "" ""
205
206 #
207 # 9.1 test the tdump command
208 #
209
210 set timeout 60
211
212 gdb_tfind_test "9.1: init: make sure not debugging any trace frame" "none" "-1"
213
214 gdb_tfind_test "9.1: find frame for TP $tdp1" "tracepoint $tdp1" \
215 "\$tracepoint" "$tdp1"
216
217 # Nothing was collected at tdp1, so this tdump should be empty.
218 gdb_test "tdump" \
219 "Data collected at tracepoint $tdp1, trace frame $decimal:" \
220 "9.1: tdump, nothing collected"
221
222 gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \
223 "\$tracepoint" "$tdp2"
224
225 # regs were collected at tdp2.
226 # How to match for the output of "info registers" on an unknown architecture?
227 # For now, assume that every architecture has a register called "pc".
228 gdb_test "tdump" \
229 "\[\r\n\]pc .*" \
230 "9.1: tdump, regs collected"
231
232 gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \
233 "\$tracepoint" "$tdp3"
234
235 # args were collected at tdp3
236 gdb_test "tdump" \
237 "depth = 3.*q1 = 2.*q2 = 2.*q3 = 3.*q4 = 4.*q5 = 5.*q6 = 6" \
238 "9.1: tdump, args collected"
239
240 gdb_tfind_test "9.1: find frame for TP $tdp4" "tracepoint $tdp4" \
241 "\$tracepoint" "$tdp4"
242
243 # locals were collected at tdp4
244 gdb_test "tdump" \
245 "q = 1" \
246 "9.1: tdump, locals collected"
247
248 gdb_tfind_test "9.1: find frame for TP $tdp5" "tracepoint $tdp5" \
249 "\$tracepoint" "$tdp5"
250
251 # stack was collected at tdp5, plus the frame pointer
252 gdb_test "tdump" \
253 ".fp = .*sp @ 64 = .*" \
254 "9.1: tdump, memrange collected"
255
256 gdb_tfind_test "9.1: find frame for TP $tdp6" "tracepoint $tdp6" \
257 "\$tracepoint" "$tdp6"
258
259 # globals were collected at tdp6
260 gdb_test "tdump" \
261 "gdb_char_test = 1.*gdb_short_test = 2.*gdb_long_test = 3" \
262 "9.1: tdump, global variables collected"
263
264 # 9.2 test tdump with arguments
265 # [no go, tdump doesn't have any arguments]
266
267 # 9.3 help tdump
268
269 gdb_test "help tdump" "Print everything collected at the current.*" \
270 "9.3: help tdump"
271
272 set linecount1 0
273 set linecount2 0
274 set linecount3 0
275 set linecount4 0
276 set linecount5 0
277 set linecount6 0
278
279 gdb_tfind_test "11.x, 12.1: find start frame" "start" "0"
280
281 #
282 # 11.x test built-in trace variables $trace_frame, $trace_line etc.
283 #
284
285 gdb_test "printf \"x %d x\\n\", \$trace_frame" "x 0 x" \
286 "11.1: test \$trace_frame"
287
288 gdb_test "printf \"x %d x\\n\", \$tracepoint" "x $tdp1 x" \
289 "11.2: test \$tracepoint"
290
291 gdb_test "printf \"x %d x\\n\", \$trace_line" "x $testline1 x" \
292 "11.3: test \$trace_line"
293
294 send_gdb "print \$trace_file\n"
295 gdb_expect {
296 -re "\\$\[0-9\]+ = \"$srcfile\"\[\r\n\]+$gdb_prompt $" {
297 pass "11.4: test \$trace_file"
298 }
299 -re "\\$\[0-9\]+ = \"$srcdir/$subdir/$srcfile\"\[\r\n\]+$gdb_prompt $" {
300 pass "11.4: test \$trace_file"
301 }
302 -re "$gdb_prompt $" {
303 fail "11.4: test \$trace_file"
304 }
305 timeout {
306 fail "11.4: test \$trace_file (timeout)"
307 }
308 }
309
310 #gdb_test "print \$trace_file" "\"$srcdir/$subdir/$srcfile\"" \
311 # "11.4: test \$trace_file"
312
313 #
314 # 12.x test report generation using arbitrary GDB commands, loops etc.
315 #
316
317 send_gdb "while \$trace_frame != -1\n output \$trace_file\n printf \", line \%d \(tracepoint #\%d\)\\n\", \$trace_line, \$tracepoint\n tfind\n end\n"
318 gdb_expect {
319 -re " line $testline1 .tracepoint .$tdp1" {
320 set linecount1 [expr $linecount1 + 1]
321 exp_continue
322 }
323 -re " line $testline2 .tracepoint .$tdp2" {
324 set linecount2 [expr $linecount2 + 1]
325 exp_continue
326 }
327 -re " line $testline3 .tracepoint .$tdp3" {
328 set linecount3 [expr $linecount3 + 1]
329 exp_continue
330 }
331 -re " line $testline4 .tracepoint .$tdp4" {
332 set linecount4 [expr $linecount4 + 1]
333 exp_continue
334 }
335 -re " line $testline5 .tracepoint .$tdp5" {
336 set linecount5 [expr $linecount5 + 1]
337 exp_continue
338 }
339 -re " line $testline6 .tracepoint .$tdp6" {
340 set linecount6 [expr $linecount6 + 1]
341 exp_continue
342 }
343 -re ".*$gdb_prompt $" {
344 if { ($linecount1 < 4) || ($linecount2 < 4) || ($linecount3 < 4) || ($linecount4 < 4) || ($linecount5 < 4) || ($linecount6 < 4) } {
345 fail "12.1: trace report #1"
346 } else {
347 pass "12.1: trace report #1"
348 }
349 }
350 timeout {
351 fail "12.1: trace report #1 (timeout)"
352 }
353 }
354
355 gdb_tfind_test "12.2: find first TDP #2 frame" "tracepoint $tdp2" \
356 "\$tracepoint" "$tdp2"
357
358 set linecount2 0
359
360 send_gdb "while \$trace_frame != -1\n printf \"tracepoint #\%d, FP 0x\%08x, SP 0x\%08x, PC 0x%08x\\n\", \$tracepoint, \$fp, \$sp, \$pc\n tfind tracepoint\n end\n"
361 gdb_expect {
362 -re "tracepoint #$tdp2, FP $hex, SP $hex, PC $hex" {
363 set linecount2 [expr $linecount2 + 1]
364 exp_continue
365 }
366 -re ".*$gdb_prompt $" {
367 if { ($linecount2 < 4) } {
368 fail "12.2: trace report #2"
369 } else {
370 pass "12.2: trace report #2"
371 }
372 }
373 timeout {
374 fail "12.2: trace report #2 (timeout)"
375 }
376 }
377
378 gdb_tfind_test "12.3: find first TDP #3 frame" "tracepoint $tdp3" \
379 "\$tracepoint" "$tdp3"
380
381 set linecount3 0
382
383 send_gdb "while \$trace_frame != -1\n printf \"TDP #\%d, frame \%d: depth = \%d, q1 = \%d\\n\", \$tracepoint, \$trace_frame, depth, q1\n tfind tracepoint\n end\n"
384 gdb_expect {
385 -re "TDP #$tdp3, frame $decimal: depth = $decimal, q1 = $decimal" {
386 set linecount3 [expr $linecount3 + 1]
387 exp_continue
388 }
389 -re ".*$gdb_prompt $" {
390 if { ($linecount3 < 4) } {
391 fail "12.3: trace report #3"
392 } else {
393 pass "12.3: trace report #3"
394 }
395 }
396 timeout {
397 fail "12.3: trace report #3 (timeout)"
398 }
399 }
400
401 gdb_tfind_test "12.4: find first TDP #6 frame" "tracepoint $tdp6" \
402 "\$tracepoint" "$tdp6"
403
404 set linecount6 0
405
406 send_gdb "while \$trace_frame != -1\n printf \"TDP #\%d, frame %d: char_test = \%d, long_test = \%d\\n\", \$tracepoint, \$trace_frame, gdb_char_test, gdb_long_test\n tfind tracepoint\n end\n"
407 gdb_expect {
408 -re "TDP #$tdp6, frame $decimal: char_test = $arg1, long_test = $arg3" {
409 set linecount6 [expr $linecount6 + 1]
410 exp_continue
411 }
412 -re ".*$gdb_prompt $" {
413 if { ($linecount6 < 4) } {
414 fail "12.4: trace report #4"
415 } else {
416 pass "12.4: trace report #4"
417 }
418 }
419 timeout {
420 fail "12.4: trace report #4 (timeout)"
421 }
422 }
423
424 # Finished!
425 gdb_tfind_test "finished: make sure not debugging any trace frame" "none" "-1"