OLD | NEW |
1 # Copyright 1992, 1994-1995, 1997, 2004, 2007-2012 Free Software | 1 # Copyright 1992-2013 Free Software Foundation, Inc. |
2 # Foundation, Inc. | |
3 | 2 |
4 # This program is free software; you can redistribute it and/or modify | 3 # 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 | 4 # 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
7 # (at your option) any later version. | 6 # (at your option) any later version. |
8 # | 7 # |
9 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
13 # | 12 # |
14 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 15 |
17 # This file was adapted from bitfields.exp by Paul Hilfinger | 16 # This file was adapted from bitfields.exp by Paul Hilfinger |
18 # (Hilfinger@gnat.com) | 17 # (Hilfinger@gnat.com) |
19 | 18 |
20 # | 19 # |
21 # Tests for bit-fields that do not fit in type (unsigned) int, but do fit | 20 # Tests for bit-fields that do not fit in type (unsigned) int, but do fit |
22 # in type (unsigned) long long. We perform essentially the same tests as | 21 # in type (unsigned) long long. We perform essentially the same tests as |
23 # in bitfields.c, which considers only bit-fields that are <= 9 bits long. | 22 # in bitfields.c, which considers only bit-fields that are <= 9 bits long. |
24 # | 23 # |
25 | 24 |
26 | 25 |
27 set testfile "bitfields2" | 26 standard_testfile .c |
28 set srcfile ${testfile}.c | 27 |
29 set binfile ${objdir}/${subdir}/${testfile} | |
30 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug}] != "" } { | 28 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
ug}] != "" } { |
31 untested bitfields2.exp | 29 untested bitfields2.exp |
32 return -1 | 30 return -1 |
33 } | 31 } |
34 | 32 |
35 set has_signed_bitfields 1 | 33 set has_signed_bitfields 1 |
36 | 34 |
37 # | 35 # |
38 # Continue to expected breakpoint at FUNCTION. Append TAG to make pass/fail | 36 # Continue to expected breakpoint at FUNCTION. Append TAG to make pass/fail |
39 # messages (to make them unique). Suppress tests on failure. | 37 # messages (to make them unique). Suppress tests on failure. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 70 |
73 proc bitfield_uniqueness {} { | 71 proc bitfield_uniqueness {} { |
74 global decimal | 72 global decimal |
75 global hex | 73 global hex |
76 global gdb_prompt | 74 global gdb_prompt |
77 global srcfile | 75 global srcfile |
78 | 76 |
79 start_test break1 | 77 start_test break1 |
80 | 78 |
81 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 0, s1 = 1, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.s1 = 1"] { | 79 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 0, s1 = 1, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.s1 = 1"] { |
82 » gdb_suppress_tests; | 80 » gdb_suppress_tests |
83 } | 81 } |
84 continue_test break1 "#1" | 82 continue_test break1 "#1" |
85 if [gdb_test "print flags" ".*u1 = 1, u2 = 0, u3 = 0, s1 = 0, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.u1 = 1"] { | 83 if [gdb_test "print flags" ".*u1 = 1, u2 = 0, u3 = 0, s1 = 0, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.u1 = 1"] { |
86 » gdb_suppress_tests; | 84 » gdb_suppress_tests |
87 } | 85 } |
88 continue_test break1 "#2" | 86 continue_test break1 "#2" |
89 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 0, s1 = 0, s2 = 1, s3 = 0
.*" "bitfield uniqueness; flags.s2 = 1"] { | 87 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 0, s1 = 0, s2 = 1, s3 = 0
.*" "bitfield uniqueness; flags.s2 = 1"] { |
90 » gdb_suppress_tests; | 88 » gdb_suppress_tests |
91 } | 89 } |
92 continue_test break1 "#3" | 90 continue_test break1 "#3" |
93 if [gdb_test "print flags" ".*u1 = 0, u2 = 1, u3 = 0, s1 = 0, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.u2 = 1"] { | 91 if [gdb_test "print flags" ".*u1 = 0, u2 = 1, u3 = 0, s1 = 0, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.u2 = 1"] { |
94 » gdb_suppress_tests; | 92 » gdb_suppress_tests |
95 } | 93 } |
96 continue_test break1 "#4" | 94 continue_test break1 "#4" |
97 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 0, s1 = 0, s2 = 0, s3 = 1
.*" "bitfield uniqueness; flags.s3 = 1"] { | 95 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 0, s1 = 0, s2 = 0, s3 = 1
.*" "bitfield uniqueness; flags.s3 = 1"] { |
98 » gdb_suppress_tests; | 96 » gdb_suppress_tests |
99 } | 97 } |
100 continue_test break1 "#5" | 98 continue_test break1 "#5" |
101 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 1, s1 = 0, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.u3 = 1"] { | 99 if [gdb_test "print flags" ".*u1 = 0, u2 = 0, u3 = 1, s1 = 0, s2 = 0, s3 = 0
.*" "bitfield uniqueness; flags.u3 = 1"] { |
102 gdb_suppress_tests | 100 gdb_suppress_tests |
103 } | 101 } |
104 gdb_stop_suppressing_tests; | 102 gdb_stop_suppressing_tests |
105 } | 103 } |
106 | 104 |
107 | 105 |
108 # | 106 # |
109 # Test bitfield containment. | 107 # Test bitfield containment. |
110 # Fill alternating fields with all 1's and verify that none of the bits | 108 # Fill alternating fields with all 1's and verify that none of the bits |
111 # "bleed over" to the other fields. | 109 # "bleed over" to the other fields. |
112 # | 110 # |
113 | 111 |
114 proc bitfield_containment {} { | 112 proc bitfield_containment {} { |
115 global decimal | 113 global decimal |
116 global hex | 114 global hex |
117 global gdb_prompt | 115 global gdb_prompt |
118 global srcfile | 116 global srcfile |
119 | 117 |
120 start_test break2 | 118 start_test break2 |
121 | 119 |
122 # If program is compiled with Sun CC, signed fields print out as their | 120 # If program is compiled with Sun CC, signed fields print out as their |
123 # actual sizes; if compiled with gcc, they print out as 0xffffffff. | 121 # actual sizes; if compiled with gcc, they print out as 0xffffffff. |
124 if [gdb_test "print/x flags" "= {u1 = 0x7fff, u2 = 0x0, u3 = 0xffff, s1 = 0x
0, s2 = 0x(1ffffffff|f*), s3 = 0x0}" "bitfield containment; flags.u1, flags.u3,
and flags.s3 to all 1s"] { | 122 if [gdb_test "print/x flags" "= {u1 = 0x7fff, u2 = 0x0, u3 = 0xffff, s1 = 0x
0, s2 = 0x(1ffffffff|f*), s3 = 0x0}" "bitfield containment; flags.u1, flags.u3,
and flags.s3 to all 1s"] { |
125 gdb_suppress_tests | 123 gdb_suppress_tests |
126 } | 124 } |
127 | 125 |
128 continue_test break2 "#1" | 126 continue_test break2 "#1" |
129 | 127 |
130 if [gdb_test "print/x flags" "= {u1 = 0x0, u2 = 0x1ffffffff, u3 = 0x0, s1 =
0x(7fff|f*), s2 = 0x0, s3 = 0xf*}" "bitfield containment; flags.u2, flags.s1, fl
ags.s2 to all 1s"] { | 128 if [gdb_test "print/x flags" "= {u1 = 0x0, u2 = 0x1ffffffff, u3 = 0x0, s1 =
0x(7fff|f*), s2 = 0x0, s3 = 0xf*}" "bitfield containment; flags.u2, flags.s1, fl
ags.s2 to all 1s"] { |
131 gdb_suppress_tests | 129 gdb_suppress_tests |
132 } | 130 } |
133 gdb_stop_suppressing_tests; | 131 gdb_stop_suppressing_tests |
134 } | 132 } |
135 | 133 |
136 # Test unsigned bitfields for unsignedness and range. | 134 # Test unsigned bitfields for unsignedness and range. |
137 # Fill the unsigned fields with the maximum positive value and verify that | 135 # Fill the unsigned fields with the maximum positive value and verify that |
138 # the values are printed correctly. | 136 # the values are printed correctly. |
139 | 137 |
140 proc bitfield_unsignedness {} { | 138 proc bitfield_unsignedness {} { |
141 global decimal | 139 global decimal |
142 global hex | 140 global hex |
143 global gdb_prompt | 141 global gdb_prompt |
144 global srcfile | 142 global srcfile |
145 | 143 |
146 start_test break3 | 144 start_test break3 |
147 | 145 |
148 if [gdb_test "print flags" ".*u1 = 32767, u2 = 8589934591, u3 = 65535, s1 =
0, s2 = 0, s3 = 0.*" "maximum unsigned bitfield values"] { | 146 if [gdb_test "print flags" ".*u1 = 32767, u2 = 8589934591, u3 = 65535, s1 =
0, s2 = 0, s3 = 0.*" "maximum unsigned bitfield values"] { |
149 gdb_suppress_tests | 147 gdb_suppress_tests |
150 } | 148 } |
151 gdb_stop_suppressing_tests; | 149 gdb_stop_suppressing_tests |
152 } | 150 } |
153 | 151 |
154 # | 152 # |
155 # Test signed bitfields for signedness and range. | 153 # Test signed bitfields for signedness and range. |
156 # Fill the signed fields with the maximum positive value, then the maximally | 154 # Fill the signed fields with the maximum positive value, then the maximally |
157 # negative value, then -1, and verify in each case that the values are | 155 # negative value, then -1, and verify in each case that the values are |
158 # printed correctly. | 156 # printed correctly. |
159 # | 157 # |
160 | 158 |
161 proc bitfield_signedness {} { | 159 proc bitfield_signedness {} { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 202 |
205 set test "signed bitfields containing -1" | 203 set test "signed bitfields containing -1" |
206 if $has_signed_bitfields then { | 204 if $has_signed_bitfields then { |
207 if [gdb_test "print flags" "u1 = 0, u2 = 0, u3 = 0, s1 = -1, s2 = -1, s3
= -1.*" $test ] { | 205 if [gdb_test "print flags" "u1 = 0, u2 = 0, u3 = 0, s1 = -1, s2 = -1, s3
= -1.*" $test ] { |
208 gdb_suppress_tests | 206 gdb_suppress_tests |
209 } | 207 } |
210 } else { | 208 } else { |
211 unsupported $test | 209 unsupported $test |
212 } | 210 } |
213 | 211 |
214 gdb_stop_suppressing_tests; | 212 gdb_stop_suppressing_tests |
215 } | 213 } |
216 | 214 |
217 | 215 |
218 # Test setting of long long bit fields from within GDB. | 216 # Test setting of long long bit fields from within GDB. |
219 | 217 |
220 proc bitfield_set {} { | 218 proc bitfield_set {} { |
221 global decimal | 219 global decimal |
222 global hex | 220 global hex |
223 global gdb_prompt | 221 global gdb_prompt |
224 global srcfile | 222 global srcfile |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 | 268 |
271 set test "long long bitfield values after set negative" | 269 set test "long long bitfield values after set negative" |
272 if $has_signed_bitfields then { | 270 if $has_signed_bitfields then { |
273 if [gdb_test "print flags" "u1 = 0, u2 = 4294967296, u3 = 0, s1 = 0, s2
= -1, s3 = 0.*" $test] { | 271 if [gdb_test "print flags" "u1 = 0, u2 = 4294967296, u3 = 0, s1 = 0, s2
= -1, s3 = 0.*" $test] { |
274 gdb_suppress_tests | 272 gdb_suppress_tests |
275 } | 273 } |
276 } else { | 274 } else { |
277 unsupported $test | 275 unsupported $test |
278 } | 276 } |
279 | 277 |
280 gdb_stop_suppressing_tests; | 278 gdb_stop_suppressing_tests |
281 } | 279 } |
282 | 280 |
283 gdb_start | 281 clean_restart ${binfile} |
284 gdb_reinitialize_dir $srcdir/$subdir | |
285 gdb_load ${binfile} | |
286 | 282 |
287 gdb_test_no_output "set print sevenbit-strings" | 283 gdb_test_no_output "set print sevenbit-strings" |
288 runto_main | 284 runto_main |
289 | 285 |
290 bitfield_uniqueness | 286 bitfield_uniqueness |
291 bitfield_containment | 287 bitfield_containment |
292 bitfield_unsignedness | 288 bitfield_unsignedness |
293 bitfield_signedness | 289 bitfield_signedness |
294 bitfield_set | 290 bitfield_set |
295 | 291 |
OLD | NEW |