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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.base/] [bitfields.exp] - Blame information for rev 330

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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