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