]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | // ignore-android: FIXME(#10381) | |
13 | // min-lldb-version: 310 | |
14 | ||
15 | // compile-flags:-g | |
16 | ||
17 | // === GDB TESTS =================================================================================== | |
18 | ||
19 | // gdb-command:run | |
20 | ||
21 | // gdb-command:print packed | |
22 | // gdb-check:$1 = {x = 123, y = 234, z = 345} | |
23 | ||
24 | // gdb-command:print packedInPacked | |
25 | // gdb-check:$2 = {a = 1111, b = {x = 2222, y = 3333, z = 4444}, c = 5555, d = {x = 6666, y = 7777, z = 8888}} | |
26 | ||
27 | // gdb-command:print packedInUnpacked | |
28 | // gdb-check:$3 = {a = -1111, b = {x = -2222, y = -3333, z = -4444}, c = -5555, d = {x = -6666, y = -7777, z = -8888}} | |
29 | ||
30 | // gdb-command:print unpackedInPacked | |
31 | // gdb-check:$4 = {a = 987, b = {x = 876, y = 765, z = 654, w = 543}, c = {x = 432, y = 321, z = 210, w = 109}, d = -98} | |
32 | ||
33 | // gdb-command:print sizeof(packed) | |
34 | // gdb-check:$5 = 14 | |
35 | ||
36 | // gdb-command:print sizeof(packedInPacked) | |
37 | // gdb-check:$6 = 40 | |
38 | ||
39 | ||
40 | // === LLDB TESTS ================================================================================== | |
41 | ||
42 | // lldb-command:run | |
43 | ||
44 | // lldb-command:print packed | |
45 | // lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 } | |
46 | ||
47 | // lldb-command:print packedInPacked | |
48 | // lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } } | |
49 | ||
50 | // lldb-command:print packedInUnpacked | |
51 | // lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } } | |
52 | ||
53 | // lldb-command:print unpackedInPacked | |
54 | // lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, d: -98 } | |
55 | ||
56 | // lldb-command:print sizeof(packed) | |
57 | // lldb-check:[...]$4 = 14 | |
58 | ||
59 | // lldb-command:print sizeof(packedInPacked) | |
60 | // lldb-check:[...]$5 = 40 | |
61 | ||
62 | #![allow(unused_variables)] | |
63 | #![omit_gdb_pretty_printer_section] | |
64 | ||
65 | #[repr(packed)] | |
66 | struct Packed { | |
67 | x: i16, | |
68 | y: i32, | |
69 | z: i64 | |
70 | } | |
71 | ||
72 | #[repr(packed)] | |
73 | struct PackedInPacked { | |
74 | a: i32, | |
75 | b: Packed, | |
76 | c: i64, | |
77 | d: Packed | |
78 | } | |
79 | ||
80 | // layout (64 bit): aaaa bbbb bbbb bbbb bb.. .... cccc cccc dddd dddd dddd dd.. | |
81 | struct PackedInUnpacked { | |
82 | a: i32, | |
83 | b: Packed, | |
84 | c: i64, | |
85 | d: Packed | |
86 | } | |
87 | ||
88 | // layout (64 bit): xx.. yyyy zz.. .... wwww wwww | |
89 | struct Unpacked { | |
90 | x: i16, | |
91 | y: i32, | |
92 | z: i16, | |
93 | w: i64 | |
94 | } | |
95 | ||
96 | // layout (64 bit): aabb bbbb bbbb bbbb bbbb bbbb bbcc cccc cccc cccc cccc cccc ccdd dddd dd | |
97 | #[repr(packed)] | |
98 | struct UnpackedInPacked { | |
99 | a: i16, | |
100 | b: Unpacked, | |
101 | c: Unpacked, | |
102 | d: i64 | |
103 | } | |
104 | ||
105 | fn main() { | |
106 | let packed = Packed { x: 123, y: 234, z: 345 }; | |
107 | ||
108 | let packedInPacked = PackedInPacked { | |
109 | a: 1111, | |
110 | b: Packed { x: 2222, y: 3333, z: 4444 }, | |
111 | c: 5555, | |
112 | d: Packed { x: 6666, y: 7777, z: 8888 } | |
113 | }; | |
114 | ||
115 | let packedInUnpacked = PackedInUnpacked { | |
116 | a: -1111, | |
117 | b: Packed { x: -2222, y: -3333, z: -4444 }, | |
118 | c: -5555, | |
119 | d: Packed { x: -6666, y: -7777, z: -8888 } | |
120 | }; | |
121 | ||
122 | let unpackedInPacked = UnpackedInPacked { | |
123 | a: 987, | |
124 | b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, | |
125 | c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, | |
126 | d: -98 | |
127 | }; | |
128 | ||
129 | zzz(); // #break | |
130 | } | |
131 | ||
132 | fn zzz() {()} |