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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [bitfields.exp] - Blame information for rev 833

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 1992, 1994, 1995, 1997, 2007, 2008, 2009, 2010
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Fred Fish. (fnf@cygnus.com)
18
 
19
if $tracelevel then {
20
        strace $tracelevel
21
}
22
 
23
set prms_id 0
24
set bug_id 0
25
 
26
set testfile "bitfields"
27
set srcfile ${testfile}.c
28
set binfile ${objdir}/${subdir}/${testfile}
29
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
30
    untested bitfields.exp
31
    return -1
32
}
33
 
34
#
35
# Test bitfield locating and uniqueness.
36
# For each member, set that member to 1 and verify that the member (and only
37
# that member) is 1, then reset it back to 0.
38
#
39
 
40
proc bitfield_uniqueness {} {
41
    global decimal
42
    global hex
43
    global gdb_prompt
44
    global srcfile
45
 
46
    if { ! [runto break1] } {
47
        gdb_suppress_tests;
48
    }
49
 
50
    if [gdb_test "print flags" ".*uc = 1 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*"] {
51
        gdb_suppress_tests;
52
    }
53
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #1"] {
54
        gdb_suppress_tests;
55
    }
56
    # Note that we check for s1 as either 1 or -1, so that failure to
57
    # treat it correctly as a signed 1bit field (values 0 or -1) while
58
    # printing its value does not cause a spurious failure.  We do the
59
    # signedness preservation test later.
60
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = (1|-1), u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s1)"] {
61
        gdb_suppress_tests;
62
    }
63
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #2"] {
64
        gdb_suppress_tests;
65
    }
66
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 1, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u1)"] {
67
        gdb_suppress_tests;
68
    }
69
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #3"] {
70
        gdb_suppress_tests;
71
    }
72
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 1, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s2)"] {
73
        gdb_suppress_tests;
74
    }
75
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #4"] {
76
        gdb_suppress_tests;
77
    }
78
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 1, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u2)"] {
79
        gdb_suppress_tests;
80
    }
81
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #5"] {
82
        gdb_suppress_tests;
83
    }
84
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 1, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s3)"] {
85
        gdb_suppress_tests;
86
    }
87
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #6"] {
88
        gdb_suppress_tests;
89
    }
90
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 1, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u3)"] {
91
        gdb_suppress_tests
92
    }
93
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #7"] {
94
        gdb_suppress_tests
95
    }
96
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 1, u9 = 0, sc = 0.*" "bitfield uniqueness (s9)"] {
97
        gdb_suppress_tests
98
    }
99
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #8"] {
100
        gdb_suppress_tests
101
    }
102
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 1, sc = 0.*" "bitfield uniqueness (u9)"] {
103
        gdb_suppress_tests
104
    }
105
    if [gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #9"] {
106
        gdb_suppress_tests
107
    }
108
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1.*" "bitfield uniqueness (sc)"] {
109
        gdb_suppress_tests
110
    }
111
    # Hmmmm?
112
    gdb_stop_suppressing_tests;
113
}
114
 
115
 
116
#
117
# Test bitfield containment.
118
# Fill alternating fields with all 1's and verify that none of the bits
119
# "bleed over" to the other fields.
120
#
121
 
122
proc bitfield_containment {} {
123
    global decimal
124
    global hex
125
    global gdb_prompt
126
    global srcfile
127
 
128
    delete_breakpoints
129
 
130
    if { ![runto break2] } {
131
        gdb_suppress_tests
132
    }
133
 
134
    if [gdb_test "print/x flags" "= {uc = 0xff, s1 = 0x0, u1 = 0x1, s2 = 0x0, u2 = 0x3, s3 = 0x0, u3 = 0x7, s9 = 0x0, u9 = 0x1ff, sc = 0x0}" "bitfield containment #1"] {
135
        gdb_suppress_tests
136
    }
137
 
138
    if [gdb_test "cont" "Break.*break2 \\(\\) at .*$srcfile:$decimal.*" "continuing to break2"] {
139
        gdb_suppress_tests
140
    }
141
 
142
    # If program is compiled with Sun CC, then these print out as their
143
    # actual sizes; if compiled with gcc, they print out as 0xffffffff
144
    # (which strikes me as bogus, but accept it at least for now).
145
    if [gdb_test "print/x flags" "= {uc = 0x0, s1 = 0x(1|f*), u1 = 0x0, s2 = 0x(3|f*), u2 = 0x0, s3 = 0x(7|f*), u3 = 0x0, s9 = 0x(1ff|f*), u9 = 0x0, sc = 0xff}" "bitfield containment #2"] {
146
        gdb_suppress_tests
147
    }
148
    gdb_stop_suppressing_tests;
149
}
150
 
151
# Test unsigned bitfields for unsignedness and range.
152
# Fill the unsigned fields with the maximum positive value and verify that
153
# the values are printed correctly.
154
 
155
proc bitfield_unsignedness {} {
156
    global decimal
157
    global hex
158
    global gdb_prompt
159
    global srcfile
160
 
161
    delete_breakpoints
162
 
163
    if { ![runto break3] } {
164
        gdb_suppress_tests
165
    }
166
 
167
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 1, s2 = 0, u2 = 3, s3 = 0, u3 = 7, s9 = 0, u9 = 511, sc = 0.*" "unsigned bitfield ranges"] {
168
        gdb_suppress_tests
169
    }
170
    gdb_stop_suppressing_tests;
171
}
172
 
173
#
174
# Test signed bitfields for signedness and range.
175
# Fill the signed fields with the maximum positive value, then the maximally
176
# negative value, then -1, and verify in each case that the values are
177
# printed correctly.
178
#
179
 
180
proc bitfield_signedness {} {
181
    global decimal
182
    global hex
183
    global gdb_prompt
184
    global srcfile
185
 
186
    delete_breakpoints
187
 
188
    if { ! [runto break4] } {
189
        gdb_suppress_tests
190
    }
191
 
192
    if [gdb_test "print flags" "= {uc = 0 .*, s1 = 0, u1 = 0, s2 = 1, u2 = 0, s3 = 3, u3 = 0, s9 = 255, u9 = 0, sc = 0 .*}" "signed bitfields, max positive values"] {
193
        gdb_suppress_tests
194
    }
195
 
196
    if [gdb_test "cont" "Break.*break4 \\(\\) at .*$srcfile:$decimal.*" "continuing to break4 #1"] {
197
        gdb_suppress_tests
198
    }
199
 
200
    # Determine if the target has signed bitfields so we can xfail the
201
    # the signed bitfield tests if it doesn't.
202
    send_gdb "print i\n"
203
    gdb_expect {
204
        -re ".* = -256.*$gdb_prompt $" {
205
            pass "determining signed-ness of bitfields"
206
        }
207
        -re ".* = 256.*$gdb_prompt $" {
208
            pass "determining signed-ness of bitfields"
209
            setup_xfail "*-*-*"
210
        }
211
        -re ".*$gdb_prompt $" {
212
            fail "determining signed-ness of bitfields"
213
            gdb_suppress_tests
214
        }
215
        default {
216
            fail "determining signed-ness of bitfields" ;
217
            gdb_suppress_tests;
218
        }
219
    }
220
 
221
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = -1, u1 = 0, s2 = -2, u2 = 0, s3 = -4, u3 = 0, s9 = -256, u9 = 0, sc = 0.*" "signed bitfields, max negative values"] {
222
        gdb_suppress_tests
223
    }
224
 
225
    if [gdb_test "cont" "Break.*break4 \\(\\) at .*$srcfile:$decimal.*" "continuing to break4 #2"] {
226
        gdb_suppress_tests
227
    }
228
 
229
    if [gdb_test "print flags" ".*uc = 0 .*, s1 = -1, u1 = 0, s2 = -1, u2 = 0, s3 = -1, u3 = 0, s9 = -1, u9 = 0, sc = 0.*" "signed bitfields with -1"] {
230
        gdb_suppress_tests
231
    }
232
    # Hmmmm???
233
    gdb_stop_suppressing_tests;
234
}
235
 
236
# Test bitfields at non-zero offsets in a struct.
237
 
238
proc bitfield_at_offset {} {
239
    global decimal
240
    global hex
241
    global gdb_prompt
242
    global srcfile
243
 
244
    gdb_breakpoint break5
245
    if [gdb_test "cont" "Break.*break5 \\(\\) at .*$srcfile:$decimal.*" "continuing to break5"] {
246
        return
247
    }
248
 
249
    set one ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 5, s9 = 0, u9 = 0, sc = 0.*"
250
    set two ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 3, s9 = 0, u9 = 0, sc = 0.*"
251
    gdb_test "print container" "$one$two" "distinct bitfields in container"
252
    gdb_test "print container.one.u3" ".* = 5"
253
    gdb_test "print container.two.u3" ".* = 3"
254
}
255
 
256
gdb_start
257
gdb_reinitialize_dir $srcdir/$subdir
258
gdb_load ${binfile}
259
 
260
send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
261
 
262
bitfield_uniqueness
263
if [istarget "mips-idt-*"] then {
264
    # Restart because IDT/SIM runs out of file descriptors.
265
    gdb_exit
266
    gdb_start
267
    gdb_reinitialize_dir $srcdir/$subdir
268
    gdb_load ${binfile}
269
}
270
bitfield_containment
271
if [istarget "mips-idt-*"] then {
272
    # Restart because IDT/SIM runs out of file descriptors.
273
    gdb_exit
274
    gdb_start
275
    gdb_reinitialize_dir $srcdir/$subdir
276
    gdb_load ${binfile}
277
}
278
bitfield_unsignedness
279
if [istarget "mips-idt-*"] then {
280
    # Restart because IDT/SIM runs out of file descriptors.
281
    gdb_exit
282
    gdb_start
283
    gdb_reinitialize_dir $srcdir/$subdir
284
    gdb_load ${binfile}
285
}
286
bitfield_signedness
287
 
288
bitfield_at_offset

powered by: WebSVN 2.1.0

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