OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.trace/] [report.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

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