]> git.proxmox.com Git - rustc.git/blob - src/test/debuginfo/packed-struct-with-destructor.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / debuginfo / packed-struct-with-destructor.rs
1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-tidy-linelength
12 // min-lldb-version: 310
13
14 // compile-flags:-g
15
16 // === GDB TESTS ===================================================================================
17
18 // gdb-command:run
19
20 // gdb-command:print packed
21 // gdbg-check:$1 = {x = 123, y = 234, z = 345}
22 // gdbr-check:$1 = packed_struct_with_destructor::Packed {x: 123, y: 234, z: 345}
23
24 // gdb-command:print packedInPacked
25 // gdbg-check:$2 = {a = 1111, b = {x = 2222, y = 3333, z = 4444}, c = 5555, d = {x = 6666, y = 7777, z = 8888}}
26 // gdbr-check:$2 = packed_struct_with_destructor::PackedInPacked {a: 1111, b: packed_struct_with_destructor::Packed {x: 2222, y: 3333, z: 4444}, c: 5555, d: packed_struct_with_destructor::Packed {x: 6666, y: 7777, z: 8888}}
27
28 // gdb-command:print packedInUnpacked
29 // gdbg-check:$3 = {a = -1111, b = {x = -2222, y = -3333, z = -4444}, c = -5555, d = {x = -6666, y = -7777, z = -8888}}
30 // gdbr-check:$3 = packed_struct_with_destructor::PackedInUnpacked {a: -1111, b: packed_struct_with_destructor::Packed {x: -2222, y: -3333, z: -4444}, c: -5555, d: packed_struct_with_destructor::Packed {x: -6666, y: -7777, z: -8888}}
31
32 // gdb-command:print unpackedInPacked
33 // gdbg-check:$4 = {a = 987, b = {x = 876, y = 765, z = 654}, c = {x = 543, y = 432, z = 321}, d = 210}
34 // gdbr-check:$4 = packed_struct_with_destructor::UnpackedInPacked {a: 987, b: packed_struct_with_destructor::Unpacked {x: 876, y: 765, z: 654}, c: packed_struct_with_destructor::Unpacked {x: 543, y: 432, z: 321}, d: 210}
35
36
37 // gdb-command:print packedInPackedWithDrop
38 // gdbg-check:$5 = {a = 11, b = {x = 22, y = 33, z = 44}, c = 55, d = {x = 66, y = 77, z = 88}}
39 // gdbr-check:$5 = packed_struct_with_destructor::PackedInPackedWithDrop {a: 11, b: packed_struct_with_destructor::Packed {x: 22, y: 33, z: 44}, c: 55, d: packed_struct_with_destructor::Packed {x: 66, y: 77, z: 88}}
40
41 // gdb-command:print packedInUnpackedWithDrop
42 // gdbg-check:$6 = {a = -11, b = {x = -22, y = -33, z = -44}, c = -55, d = {x = -66, y = -77, z = -88}}
43 // gdbr-check:$6 = packed_struct_with_destructor::PackedInUnpackedWithDrop {a: -11, b: packed_struct_with_destructor::Packed {x: -22, y: -33, z: -44}, c: -55, d: packed_struct_with_destructor::Packed {x: -66, y: -77, z: -88}}
44
45 // gdb-command:print unpackedInPackedWithDrop
46 // gdbg-check:$7 = {a = 98, b = {x = 87, y = 76, z = 65}, c = {x = 54, y = 43, z = 32}, d = 21}
47 // gdbr-check:$7 = packed_struct_with_destructor::UnpackedInPackedWithDrop {a: 98, b: packed_struct_with_destructor::Unpacked {x: 87, y: 76, z: 65}, c: packed_struct_with_destructor::Unpacked {x: 54, y: 43, z: 32}, d: 21}
48
49 // gdb-command:print deeplyNested
50 // gdbg-check:$8 = {a = {a = 1, b = {x = 2, y = 3, z = 4}, c = 5, d = {x = 6, y = 7, z = 8}}, b = {a = 9, b = {x = 10, y = 11, z = 12}, c = {x = 13, y = 14, z = 15}, d = 16}, c = {a = 17, b = {x = 18, y = 19, z = 20}, c = 21, d = {x = 22, y = 23, z = 24}}, d = {a = 25, b = {x = 26, y = 27, z = 28}, c = 29, d = {x = 30, y = 31, z = 32}}, e = {a = 33, b = {x = 34, y = 35, z = 36}, c = {x = 37, y = 38, z = 39}, d = 40}, f = {a = 41, b = {x = 42, y = 43, z = 44}, c = 45, d = {x = 46, y = 47, z = 48}}}
51 // gdbr-check:$8 = packed_struct_with_destructor::DeeplyNested {a: packed_struct_with_destructor::PackedInPacked {a: 1, b: packed_struct_with_destructor::Packed {x: 2, y: 3, z: 4}, c: 5, d: packed_struct_with_destructor::Packed {x: 6, y: 7, z: 8}}, b: packed_struct_with_destructor::UnpackedInPackedWithDrop {a: 9, b: packed_struct_with_destructor::Unpacked {x: 10, y: 11, z: 12}, c: packed_struct_with_destructor::Unpacked {x: 13, y: 14, z: 15}, d: 16}, c: packed_struct_with_destructor::PackedInUnpacked {a: 17, b: packed_struct_with_destructor::Packed {x: 18, y: 19, z: 20}, c: 21, d: packed_struct_with_destructor::Packed {x: 22, y: 23, z: 24}}, d: packed_struct_with_destructor::PackedInUnpackedWithDrop {a: 25, b: packed_struct_with_destructor::Packed {x: 26, y: 27, z: 28}, c: 29, d: packed_struct_with_destructor::Packed {x: 30, y: 31, z: 32}}, e: packed_struct_with_destructor::UnpackedInPacked {a: 33, b: packed_struct_with_destructor::Unpacked {x: 34, y: 35, z: 36}, c: packed_struct_with_destructor::Unpacked {x: 37, y: 38, z: 39}, d: 40}, f: packed_struct_with_destructor::PackedInPackedWithDrop {a: 41, b: packed_struct_with_destructor::Packed {x: 42, y: 43, z: 44}, c: 45, d: packed_struct_with_destructor::Packed {x: 46, y: 47, z: 48}}}
52
53
54 // === LLDB TESTS ==================================================================================
55
56 // lldb-command:run
57
58 // lldb-command:print packed
59 // lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 }
60
61 // lldb-command:print packedInPacked
62 // lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } }
63
64 // lldb-command:print packedInUnpacked
65 // lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } }
66
67 // lldb-command:print unpackedInPacked
68 // lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654 }, c: Unpacked { x: 543, y: 432, z: 321 }, d: 210 }
69
70 // lldb-command:print packedInPackedWithDrop
71 // lldb-check:[...]$4 = PackedInPackedWithDrop { a: 11, b: Packed { x: 22, y: 33, z: 44 }, c: 55, d: Packed { x: 66, y: 77, z: 88 } }
72
73 // lldb-command:print packedInUnpackedWithDrop
74 // lldb-check:[...]$5 = PackedInUnpackedWithDrop { a: -11, b: Packed { x: -22, y: -33, z: -44 }, c: -55, d: Packed { x: -66, y: -77, z: -88 } }
75
76 // lldb-command:print unpackedInPackedWithDrop
77 // lldb-check:[...]$6 = UnpackedInPackedWithDrop { a: 98, b: Unpacked { x: 87, y: 76, z: 65 }, c: Unpacked { x: 54, y: 43, z: 32 }, d: 21 }
78
79 // lldb-command:print deeplyNested
80 // lldb-check:[...]$7 = DeeplyNested { a: PackedInPacked { a: 1, b: Packed { x: 2, y: 3, z: 4 }, c: 5, d: Packed { x: 6, y: 7, z: 8 } }, b: UnpackedInPackedWithDrop { a: 9, b: Unpacked { x: 10, y: 11, z: 12 }, c: Unpacked { x: 13, y: 14, z: 15 }, d: 16 }, c: PackedInUnpacked { a: 17, b: Packed { x: 18, y: 19, z: 20 }, c: 21, d: Packed { x: 22, y: 23, z: 24 } }, d: PackedInUnpackedWithDrop { a: 25, b: Packed { x: 26, y: 27, z: 28 }, c: 29, d: Packed { x: 30, y: 31, z: 32 } }, e: UnpackedInPacked { a: 33, b: Unpacked { x: 34, y: 35, z: 36 }, c: Unpacked { x: 37, y: 38, z: 39 }, d: 40 }, f: PackedInPackedWithDrop { a: 41, b: Packed { x: 42, y: 43, z: 44 }, c: 45, d: Packed { x: 46, y: 47, z: 48 } } }
81
82
83 #![allow(unused_variables)]
84 #![feature(omit_gdb_pretty_printer_section)]
85 #![omit_gdb_pretty_printer_section]
86
87 #[repr(packed)]
88 struct Packed {
89 x: i16,
90 y: i32,
91 z: i64
92 }
93
94 impl Drop for Packed {
95 fn drop(&mut self) {}
96 }
97
98 #[repr(packed)]
99 struct PackedInPacked {
100 a: i32,
101 b: Packed,
102 c: i64,
103 d: Packed
104 }
105
106 struct PackedInUnpacked {
107 a: i32,
108 b: Packed,
109 c: i64,
110 d: Packed
111 }
112
113 struct Unpacked {
114 x: i64,
115 y: i32,
116 z: i16
117 }
118
119 impl Drop for Unpacked {
120 fn drop(&mut self) {}
121 }
122
123 #[repr(packed)]
124 struct UnpackedInPacked {
125 a: i16,
126 b: Unpacked,
127 c: Unpacked,
128 d: i64
129 }
130
131 #[repr(packed)]
132 struct PackedInPackedWithDrop {
133 a: i32,
134 b: Packed,
135 c: i64,
136 d: Packed
137 }
138
139 impl Drop for PackedInPackedWithDrop {
140 fn drop(&mut self) {}
141 }
142
143 struct PackedInUnpackedWithDrop {
144 a: i32,
145 b: Packed,
146 c: i64,
147 d: Packed
148 }
149
150 impl Drop for PackedInUnpackedWithDrop {
151 fn drop(&mut self) {}
152 }
153
154 #[repr(packed)]
155 struct UnpackedInPackedWithDrop {
156 a: i16,
157 b: Unpacked,
158 c: Unpacked,
159 d: i64
160 }
161
162 impl Drop for UnpackedInPackedWithDrop {
163 fn drop(&mut self) {}
164 }
165
166 struct DeeplyNested {
167 a: PackedInPacked,
168 b: UnpackedInPackedWithDrop,
169 c: PackedInUnpacked,
170 d: PackedInUnpackedWithDrop,
171 e: UnpackedInPacked,
172 f: PackedInPackedWithDrop
173 }
174
175 fn main() {
176 let packed = Packed { x: 123, y: 234, z: 345 };
177
178 let packedInPacked = PackedInPacked {
179 a: 1111,
180 b: Packed { x: 2222, y: 3333, z: 4444 },
181 c: 5555,
182 d: Packed { x: 6666, y: 7777, z: 8888 }
183 };
184
185 let packedInUnpacked = PackedInUnpacked {
186 a: -1111,
187 b: Packed { x: -2222, y: -3333, z: -4444 },
188 c: -5555,
189 d: Packed { x: -6666, y: -7777, z: -8888 }
190 };
191
192 let unpackedInPacked = UnpackedInPacked {
193 a: 987,
194 b: Unpacked { x: 876, y: 765, z: 654 },
195 c: Unpacked { x: 543, y: 432, z: 321 },
196 d: 210
197 };
198
199 let packedInPackedWithDrop = PackedInPackedWithDrop {
200 a: 11,
201 b: Packed { x: 22, y: 33, z: 44 },
202 c: 55,
203 d: Packed { x: 66, y: 77, z: 88 }
204 };
205
206 let packedInUnpackedWithDrop = PackedInUnpackedWithDrop {
207 a: -11,
208 b: Packed { x: -22, y: -33, z: -44 },
209 c: -55,
210 d: Packed { x: -66, y: -77, z: -88 }
211 };
212
213 let unpackedInPackedWithDrop = UnpackedInPackedWithDrop {
214 a: 98,
215 b: Unpacked { x: 87, y: 76, z: 65 },
216 c: Unpacked { x: 54, y: 43, z: 32 },
217 d: 21
218 };
219
220 let deeplyNested = DeeplyNested {
221 a: PackedInPacked {
222 a: 1,
223 b: Packed { x: 2, y: 3, z: 4 },
224 c: 5,
225 d: Packed { x: 6, y: 7, z: 8 }
226 },
227 b: UnpackedInPackedWithDrop {
228 a: 9,
229 b: Unpacked { x: 10, y: 11, z: 12 },
230 c: Unpacked { x: 13, y: 14, z: 15 },
231 d: 16
232 },
233 c: PackedInUnpacked {
234 a: 17,
235 b: Packed { x: 18, y: 19, z: 20 },
236 c: 21,
237 d: Packed { x: 22, y: 23, z: 24 }
238 },
239 d: PackedInUnpackedWithDrop {
240 a: 25,
241 b: Packed { x: 26, y: 27, z: 28 },
242 c: 29,
243 d: Packed { x: 30, y: 31, z: 32 }
244 },
245 e: UnpackedInPacked {
246 a: 33,
247 b: Unpacked { x: 34, y: 35, z: 36 },
248 c: Unpacked { x: 37, y: 38, z: 39 },
249 d: 40
250 },
251 f: PackedInPackedWithDrop {
252 a: 41,
253 b: Packed { x: 42, y: 43, z: 44 },
254 c: 45,
255 d: Packed { x: 46, y: 47, z: 48 }
256 }
257 };
258
259 zzz(); // #break
260 }
261
262 fn zzz() {()}