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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.trace/] [circ.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
load_lib "trace-support.exp"
17
 
18
if $tracelevel then {
19
        strace $tracelevel
20
}
21
 
22
set prms_id 0
23
set bug_id 0
24
 
25
set testfile "circ"
26
set srcfile ${testfile}.c
27
set binfile $objdir/$subdir/$testfile
28
 
29
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
30
        executable {debug nowarnings}] != "" } {
31
    untested circ.exp
32
    return -1
33
}
34
 
35
# Tests:
36
# 1) Set up a trace experiment that will collect approximately 10 frames,
37
#    requiring more than 512 but less than 1024 bytes of cache buffer.
38
#    (most targets should have at least 1024 bytes of cache buffer!)
39
#    Run and confirm that it collects all 10 frames.
40
# 2) Artificially limit the trace buffer to 512 bytes, and rerun the
41
#    experiment.  Confirm that the first several frames are collected,
42
#    but that the last several are not.
43
# 3) Set trace buffer to circular mode, still with the artificial limit
44
#    of 512 bytes, and rerun the experiment.  Confirm that the last
45
#    several frames are collected, but the first several are not.
46
#
47
 
48
# return 0 for success, 1 for failure
49
proc run_trace_experiment { pass } {
50
    gdb_run_cmd
51
 
52
    if [gdb_test "tstart" \
53
            "\[\r\n\]*" \
54
            "start trace experiment, pass $pass"] then { return 1; }
55
    if [gdb_test "continue" \
56
            "Continuing.*Breakpoint \[0-9\]+, end.*" \
57
            "run to end, pass $pass"] then { return 1; }
58
    if [gdb_test "tstop" \
59
            "\[\r\n\]*" \
60
            "stop trace experiment, pass $pass"] then { return 1; }
61
    return 0;
62
}
63
 
64
# return 0 for success, 1 for failure
65
proc set_a_tracepoint { func } {
66
    if [gdb_test "trace $func" \
67
            "Tracepoint \[0-9\]+ at .*" \
68
            "set tracepoint at $func"] then {
69
        return 1;
70
    }
71
    if [gdb_trace_setactions "set actions for $func" \
72
            "" \
73
            "collect testload" "^$"] then {
74
        return 1;
75
    }
76
    return 0;
77
}
78
 
79
# return 0 for success, 1 for failure
80
proc setup_tracepoints { } {
81
    gdb_delete_tracepoints
82
    if [set_a_tracepoint func0] then { return 1; }
83
    if [set_a_tracepoint func1] then { return 1; }
84
    if [set_a_tracepoint func2] then { return 1; }
85
    if [set_a_tracepoint func3] then { return 1; }
86
    if [set_a_tracepoint func4] then { return 1; }
87
    if [set_a_tracepoint func5] then { return 1; }
88
    if [set_a_tracepoint func6] then { return 1; }
89
    if [set_a_tracepoint func7] then { return 1; }
90
    if [set_a_tracepoint func8] then { return 1; }
91
    if [set_a_tracepoint func9] then { return 1; }
92
    return 0;
93
}
94
 
95
# return 0 for success, 1 for failure
96
proc trace_buffer_normal { } {
97
    if [gdb_test "maint packet QTBuffer:size:ffffffff" \
98
            "received: .OK." ""] then {
99
        pass "This test cannot be run on this target"
100
        return 1;
101
    }
102
    if [gdb_test "maint packet QTBuffer:circular:0" \
103
            "received: .OK." ""] then {
104
        pass "This test cannot be run on this target"
105
        return 1;
106
    }
107
    return 0;
108
}
109
 
110
# return 0 for success, 1 for failure
111
proc gdb_trace_circular_tests { } {
112
 
113
    # We generously give ourselves one "pass" if we successfully
114
    # detect that this test cannot be run on this target!
115
    if { ![gdb_target_supports_trace] } then {
116
        pass "Current target does not support trace"
117
        return 1;
118
    }
119
 
120
    if [trace_buffer_normal] then { return 1; }
121
 
122
    gdb_test "break begin" "" ""
123
    gdb_test "break end"   "" ""
124
    gdb_test "tstop"       "" ""
125
    gdb_test "tfind none"  "" ""
126
 
127
    if [setup_tracepoints] then { return 1; }
128
 
129
    # First, run the trace experiment with default attributes:
130
    # Make sure it behaves as expected.
131
    if [run_trace_experiment 1] then { return 1; }
132
    if [gdb_test "tfind start" \
133
            "#0  func0 .*" \
134
            "find frame zero, pass 1"] then { return 1; }
135
 
136
    if [gdb_test "tfind 9" \
137
            "#0  func9 .*" \
138
            "find frame nine, pass 1"] then { return 1; }
139
 
140
    if [gdb_test "tfind none" \
141
            "#0  end .*" \
142
            "quit trace debugging, pass 1"] then { return 1; }
143
 
144
    # Then, shrink the trace buffer so that it will not hold
145
    # all ten trace frames.  Verify that frame zero is still
146
    # collected, but frame nine is not.
147
    if [gdb_test "maint packet QTBuffer:size:200" \
148
            "received: .OK." "shrink the target trace buffer"] then {
149
        return 1;
150
    }
151
    if [run_trace_experiment 2] then { return 1; }
152
    if [gdb_test "tfind start" \
153
            "#0  func0 .*" \
154
            "find frame zero, pass 2"] then { return 1; }
155
 
156
    if [gdb_test "tfind 9" \
157
            ".* failed to find .*" \
158
            "fail to find frame nine, pass 2"] then { return 1; }
159
 
160
    if [gdb_test "tfind none" \
161
            "#0  end .*" \
162
            "quit trace debugging, pass 2"] then { return 1; }
163
 
164
    # Finally, make the buffer circular.  Now when it runs out of
165
    # space, it should wrap around and overwrite the earliest frames.
166
    # This means that:
167
    #   1) frame zero will be overwritten and therefore unavailable
168
    #   2) the earliest frame in the buffer will be other-than-zero
169
    #   3) frame nine will be available (unlike on pass 2).
170
    if [gdb_test "maint packet QTBuffer:circular:1" \
171
            "received: .OK." "make the target trace buffer circular"] then {
172
        return 1;
173
    }
174
    if [run_trace_experiment 3] then { return 1; }
175
    if [gdb_test "tfind start" \
176
            "#0  func\[1-9\] .*" \
177
            "first frame is NOT frame zero, pass 3"] then { return 1; }
178
 
179
    if [gdb_test "tfind 9" \
180
            "#0  func9 .*" \
181
            "find frame nine, pass 3"] then { return 1; }
182
 
183
    if [gdb_test "tfind none" \
184
            "#0  end .*" \
185
            "quit trace debugging, pass 3"] then { return 1; }
186
 
187
    return 0;
188
}
189
 
190
# Start with a fresh gdb.
191
 
192
gdb_exit
193
gdb_start
194
gdb_reinitialize_dir $srcdir/$subdir
195
gdb_load $binfile
196
 
197
if [target_info exists gdb_stub] {
198
    gdb_step_for_stub;
199
}
200
# Body of test encased in a proc so we can return prematurely.
201
if { ![gdb_trace_circular_tests] } then {
202
    # Set trace buffer attributes back to normal
203
    trace_buffer_normal;
204
}
205
 
206
# Finished!
207
gdb_test "tfind none" "" ""

powered by: WebSVN 2.1.0

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