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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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