OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.trace/] [report.exp] - Blame information for rev 252

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.