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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.trace/] [backtrace.exp] - Blame information for rev 842

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

powered by: WebSVN 2.1.0

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