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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gdb-6.8/] [pre-binutils-2.20.1-sync/] [gdb/] [testsuite/] [gdb.trace/] [backtrace.exp] - Blame information for rev 291

Go to most recent revision | 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 backtrace.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 backtrace.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
#
77
# test backtraces in trace frames
78
#
79
 
80
set testline1 0
81
set testline2 0
82
set testline3 0
83
set testline4 0
84
set testline5 0
85
set testline6 0
86
 
87
set arg1 1
88
set arg2 2
89
set arg3 3
90
set arg4 4
91
set arg5 5
92
set arg6 6
93
 
94
set baseline [gdb_find_recursion_test_baseline $srcfile];
95
if { $baseline == -1 } {
96
    fail "Could not find gdb_recursion_test function"
97
    return;
98
}
99
 
100
send_gdb "list $baseline, +12\n"
101
gdb_expect {
102
    -re "\[\r\n\](\[0-9\]+).*gdbtestline 1 " {
103
        set testline1 $expect_out(1,string)
104
        exp_continue
105
    }
106
    -re "\[\r\n\](\[0-9\]+).*gdbtestline 2 " {
107
        set testline2 $expect_out(1,string)
108
        exp_continue
109
    }
110
    -re "\[\r\n\](\[0-9\]+).*gdbtestline 3 " {
111
        set testline3 $expect_out(1,string)
112
        exp_continue
113
    }
114
    -re "\[\r\n\](\[0-9\]+).*gdbtestline 4 " {
115
        set testline4 $expect_out(1,string)
116
        exp_continue
117
    }
118
    -re "\[\r\n\](\[0-9\]+).*gdbtestline 5 " {
119
        set testline5 $expect_out(1,string)
120
        exp_continue
121
    }
122
    -re "\[\r\n\](\[0-9\]+).*gdbtestline 6 " {
123
        set testline6 $expect_out(1,string)
124
        exp_continue
125
    }
126
    -re ".*$gdb_prompt $" {
127
        if { ($testline1 == 0) || ($testline2 == 0) || ($testline3 == 0) || ($testline4 == 0) || ($testline5 == 0) || ($testline6 == 0) } {
128
            untested backtrace.exp
129
            return -1
130
all tests in this module will fail."
131
        }
132
    }
133
    default {
134
            untested backtrace.exp
135
            return -1
136
all tests in this module will fail."
137
    }
138
}
139
 
140
#
141
# Setup backtrace experiment.  This will involve:
142
#   1) a tracepoint where nothing is collected
143
#   2) a tracepoint where only regs are collected
144
#   3) a tracepoint where regs, locals and args are collected
145
#   4) a tracepoint where regs plus some amount of stack are collected.
146
#
147
 
148
gdb_delete_tracepoints
149
set tdp2 [gdb_gettpnum $testline2]
150
set tdp3 [gdb_gettpnum $testline3]
151
set tdp4 [gdb_gettpnum $testline4]
152
set tdp5 [gdb_gettpnum $testline5]
153
set tdp6 [gdb_gettpnum $testline6]
154
if {    $tdp2 <= 0 || $tdp3 <= 0 || \
155
        $tdp4 <= 0 || $tdp5 <= 0 || $tdp6 <= 0 } then {
156
    fail "setting tracepoints failed"
157
    return;
158
}
159
 
160
#gdb_trace_setactions "setup TP to collect FP" \
161
#       "$tdp2" \
162
#       "collect \$fp" ""
163
#
164
 
165
gdb_trace_setactions "8.6: setup TP to collect regs" \
166
        "$tdp3" \
167
        "collect \$regs" "^$"
168
 
169
gdb_trace_setactions "8.6: setup TP to collect regs, args, and locals" \
170
        "$tdp4" \
171
        "collect \$regs, \$args, \$locs" "^$"
172
 
173
gdb_trace_setactions "8.6: setup TP to collect stack mem cast expr" \
174
        "$tdp6" \
175
        "collect \$fp, \(\*\(void \*\*\) \(\$sp\)\) @ 64" "^$"
176
 
177
gdb_test "tstart" "" ""
178
 
179
if [istarget "m68k-*-elf"] then {
180
    gdb_emclaptop_command "85,$arg1,$arg2,$arg3,$arg4,$arg5,$arg6"
181
    sleep 5
182
} else {
183
    gdb_test "break end" "" ""
184
    gdb_test "continue" \
185
            "Continuing.*Breakpoint $decimal, end.*" \
186
            "run trace experiment"
187
}
188
 
189
gdb_test "tstop" "" ""
190
 
191
proc gdb_backtrace_tdp_1 { msg } {
192
    global gdb_prompt
193
 
194
    # We are in a trace frame at which we didn't collect anything
195
    # except $PC.  Therefore we expect to be able to identify stack
196
    # frame #0, but that's about all.  In particular we do not expect
197
    # to be able to display the function's arguments or locals, and we
198
    # do not expect to be able to identify the caller of this function.
199
 
200
    send_gdb "backtrace\n"
201
    gdb_expect {
202
        -re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
203
            pass "$msg"
204
        }
205
        -re ".*$gdb_prompt $" {
206
            fail "$msg"
207
        }
208
        timeout { fail "$msg (timeout)" }
209
    }
210
}
211
 
212
proc gdb_backtrace_tdp_2 { msg } {
213
    global gdb_prompt
214
 
215
    # We are in a trace frame at which we collected only the registers
216
    # Therefore we expect to be able to identify stack frame #0, but
217
    # we don't expect to be able to display its args unles they are
218
    # passed in registers (which isn't the case for m68k), and we
219
    # don't expect to be able to identify the caller's stack frame.
220
 
221
    send_gdb "backtrace\n"
222
    gdb_expect {
223
        -re "#0\[\t \]+gdb_recursion_test.*depth=.*$gdb_prompt $" {
224
            pass "$msg"
225
        }
226
        -re ".*$gdb_prompt $" {
227
            fail "$msg"
228
        }
229
        timeout { fail "$msg (timeout)" }
230
    }
231
}
232
 
233
proc gdb_backtrace_tdp_3 { msg } {
234
    global gdb_prompt
235
 
236
    # We are in a trace frame at which we collected all registers, all
237
    # arguments and all locals.  This means that the display of
238
    # stack frame #0 should be complete (including argument values).
239
 
240
    send_gdb "backtrace\n"
241
    gdb_expect {
242
        -re "#0\[\t \]+gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
243
            pass "$msg"
244
        }
245
        -re "#0\[\t \]+gdb_recursion_test.*depth=Cannot access.*$gdb_prompt $" {
246
            fail "$msg (failed to collect arguments)"
247
        }
248
        -re ".*$gdb_prompt $" {
249
            fail "$msg"
250
        }
251
        timeout { fail "$msg (timeout)" }
252
    }
253
}
254
 
255
proc gdb_backtrace_tdp_4 { msg depth } {
256
    global gdb_prompt
257
 
258
    # We are in a trace frame at which we collected all registers,
259
    # plus a sizeable hunk of stack memory.  This should enable us to
260
    # display at least several stack frames worth of backtrace.  We'll
261
    # assume that if we can't display at least "depth" levels (with
262
    # args), it counts as an error.
263
 
264
    send_gdb "backtrace\n"
265
    gdb_expect {
266
        -re "#$depth\[\t \].*gdb_recursion_test.*depth=\[0-9\]+.*q1=\[0-9\]+.*q2=\[0-9\]+.*q3=\[0-9\]+.*q4=\[0-9\]+.*q5=\[0-9\]+.*q6=\[0-9\]+.*$gdb_prompt $" {
267
            pass "$msg"
268
        }
269
        -re "#$depth\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
270
            fail "$msg (args missing from #$depth stack frame)"
271
        }
272
        -re "#\[0-9\]+\[\t \].*gdb_recursion_test.*depth=.*$gdb_prompt $" {
273
            fail "$msg (fewer than $depth stack frames found)"
274
        }
275
        -re ".*$gdb_prompt $" {
276
            fail "$msg"
277
        }
278
        timeout { fail "$msg (timeout)" }
279
    }
280
}
281
 
282
#
283
# begin backtrace test
284
#
285
 
286
set timeout 60
287
 
288
gdb_tfind_test "init: make sure not debugging any trace frame" "none" "-1"
289
 
290
gdb_tfind_test "8.6: find start frame" "start" "0"
291
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
292
        "TDP $tdp2:" ""
293
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 1, collect nothing"
294
 
295
gdb_tfind_test "8.6: find frame 1"     "1" "1"
296
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
297
        "TDP $tdp3:" ""
298
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 1, collect regs"
299
 
300
gdb_tfind_test "8.6: find frame 2"     "2" "2"
301
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
302
        "TDP $tdp4:" ""
303
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 1, collect args and locals"
304
 
305
 
306
gdb_tfind_test "8.6: find frame 4"     "4" "4"
307
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
308
        "TDP $tdp6:" ""
309
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
310
 
311
gdb_tfind_test "8.6: find frame 5"     "5" "5"
312
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
313
        "TDP $tdp2:" ""
314
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 2, collect nothing"
315
 
316
gdb_tfind_test "8.6: find frame 6"     "6" "6"
317
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
318
        "TDP $tdp3:" ""
319
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 2, collect regs"
320
 
321
gdb_tfind_test "8.6: find frame 7"     "7" "7"
322
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
323
        "TDP $tdp4:" ""
324
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 2, collect args and locals"
325
 
326
 
327
gdb_tfind_test "8.6: find frame 9"     "9" "9"
328
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
329
        "TDP $tdp6:" ""
330
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
331
 
332
gdb_tfind_test "8.6: find frame 10"    "10" "10"
333
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
334
        "TDP $tdp2:" ""
335
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 3, collect nothing"
336
 
337
gdb_tfind_test "8.6: find frame 11"    "11" "11"
338
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
339
        "TDP $tdp3:" ""
340
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 3, collect regs"
341
 
342
gdb_tfind_test "8.6: find frame 12"    "12" "12"
343
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
344
        "TDP $tdp4:" ""
345
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 3, collect args and locals"
346
 
347
 
348
gdb_tfind_test "8.6: find frame 14"    "14" "14"
349
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
350
        "TDP $tdp6:" ""
351
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
352
 
353
gdb_tfind_test "8.6: find frame 15"    "15" "15"
354
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
355
        "TDP $tdp2:" ""
356
gdb_backtrace_tdp_1 "8.6: Backtrace, depth == 4, collect nothing"
357
 
358
gdb_tfind_test "8.6: find frame 16"    "16" "16"
359
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
360
        "TDP $tdp3:" ""
361
gdb_backtrace_tdp_2 "8.6: Backtrace, depth == 4, collect regs"
362
 
363
gdb_tfind_test "8.6: find frame 17"    "17" "17"
364
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
365
        "TDP $tdp4:" ""
366
gdb_backtrace_tdp_3 "8.6: Backtrace, depth == 4, collect args and locals"
367
 
368
 
369
gdb_tfind_test "8.6: find frame 19"    "19" "19"
370
gdb_test "printf \"TDP \%d:\\n\", \$tracepoint" \
371
        "TDP $tdp6:" ""
372
gdb_backtrace_tdp_4 "8.6: Backtrace, depth == 1, collect stack mem expr" "0"
373
 
374
gdb_test "printf \"x \%d x\\n\", depth == 3" \
375
        "x 0 x" \
376
        "1.13: trace in recursion: depth not equal to 3"
377
 
378
# Finished!
379
gdb_test "tfind none" "" ""

powered by: WebSVN 2.1.0

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