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-6.8/] [gdb/] [testsuite/] [gdb.trace/] [report.exp] - Blame information for rev 157

Details | Compare with Previous | View Log

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