]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/simple-struct.rs
Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morse
[rust.git] / src / test / debuginfo / simple-struct.rs
1 // ignore-tidy-linelength
2
3 // min-lldb-version: 310
4 // ignore-gdb // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
5
6 // compile-flags:-g
7
8 // === GDB TESTS ===================================================================================
9
10 // gdbg-command:print 'simple_struct::NO_PADDING_16'
11 // gdbr-command:print simple_struct::NO_PADDING_16
12 // gdbg-check:$1 = {x = 1000, y = -1001}
13 // gdbr-check:$1 = simple_struct::NoPadding16 {x: 1000, y: -1001}
14
15 // gdbg-command:print 'simple_struct::NO_PADDING_32'
16 // gdbr-command:print simple_struct::NO_PADDING_32
17 // gdbg-check:$2 = {x = 1, y = 2, z = 3}
18 // gdbr-check:$2 = simple_struct::NoPadding32 {x: 1, y: 2, z: 3}
19
20 // gdbg-command:print 'simple_struct::NO_PADDING_64'
21 // gdbr-command:print simple_struct::NO_PADDING_64
22 // gdbg-check:$3 = {x = 4, y = 5, z = 6}
23 // gdbr-check:$3 = simple_struct::NoPadding64 {x: 4, y: 5, z: 6}
24
25 // gdbg-command:print 'simple_struct::NO_PADDING_163264'
26 // gdbr-command:print simple_struct::NO_PADDING_163264
27 // gdbg-check:$4 = {a = 7, b = 8, c = 9, d = 10}
28 // gdbr-check:$4 = simple_struct::NoPadding163264 {a: 7, b: 8, c: 9, d: 10}
29
30 // gdbg-command:print 'simple_struct::INTERNAL_PADDING'
31 // gdbr-command:print simple_struct::INTERNAL_PADDING
32 // gdbg-check:$5 = {x = 11, y = 12}
33 // gdbr-check:$5 = simple_struct::InternalPadding {x: 11, y: 12}
34
35 // gdbg-command:print 'simple_struct::PADDING_AT_END'
36 // gdbr-command:print simple_struct::PADDING_AT_END
37 // gdbg-check:$6 = {x = 13, y = 14}
38 // gdbr-check:$6 = simple_struct::PaddingAtEnd {x: 13, y: 14}
39
40 // gdb-command:run
41
42 // gdb-command:print no_padding16
43 // gdbg-check:$7 = {x = 10000, y = -10001}
44 // gdbr-check:$7 = simple_struct::NoPadding16 {x: 10000, y: -10001}
45
46 // gdb-command:print no_padding32
47 // gdbg-check:$8 = {x = -10002, y = -10003.5, z = 10004}
48 // gdbr-check:$8 = simple_struct::NoPadding32 {x: -10002, y: -10003.5, z: 10004}
49
50 // gdb-command:print no_padding64
51 // gdbg-check:$9 = {x = -10005.5, y = 10006, z = 10007}
52 // gdbr-check:$9 = simple_struct::NoPadding64 {x: -10005.5, y: 10006, z: 10007}
53
54 // gdb-command:print no_padding163264
55 // gdbg-check:$10 = {a = -10008, b = 10009, c = 10010, d = 10011}
56 // gdbr-check:$10 = simple_struct::NoPadding163264 {a: -10008, b: 10009, c: 10010, d: 10011}
57
58 // gdb-command:print internal_padding
59 // gdbg-check:$11 = {x = 10012, y = -10013}
60 // gdbr-check:$11 = simple_struct::InternalPadding {x: 10012, y: -10013}
61
62 // gdb-command:print padding_at_end
63 // gdbg-check:$12 = {x = -10014, y = 10015}
64 // gdbr-check:$12 = simple_struct::PaddingAtEnd {x: -10014, y: 10015}
65
66 // gdbg-command:print 'simple_struct::NO_PADDING_16'
67 // gdbr-command:print simple_struct::NO_PADDING_16
68 // gdbg-check:$13 = {x = 100, y = -101}
69 // gdbr-check:$13 = simple_struct::NoPadding16 {x: 100, y: -101}
70
71 // gdbg-command:print 'simple_struct::NO_PADDING_32'
72 // gdbr-command:print simple_struct::NO_PADDING_32
73 // gdbg-check:$14 = {x = -15, y = -16, z = 17}
74 // gdbr-check:$14 = simple_struct::NoPadding32 {x: -15, y: -16, z: 17}
75
76 // gdbg-command:print 'simple_struct::NO_PADDING_64'
77 // gdbr-command:print simple_struct::NO_PADDING_64
78 // gdbg-check:$15 = {x = -18, y = 19, z = 20}
79 // gdbr-check:$15 = simple_struct::NoPadding64 {x: -18, y: 19, z: 20}
80
81 // gdbg-command:print 'simple_struct::NO_PADDING_163264'
82 // gdbr-command:print simple_struct::NO_PADDING_163264
83 // gdbg-check:$16 = {a = -21, b = 22, c = 23, d = 24}
84 // gdbr-check:$16 = simple_struct::NoPadding163264 {a: -21, b: 22, c: 23, d: 24}
85
86 // gdbg-command:print 'simple_struct::INTERNAL_PADDING'
87 // gdbr-command:print simple_struct::INTERNAL_PADDING
88 // gdbg-check:$17 = {x = 25, y = -26}
89 // gdbr-check:$17 = simple_struct::InternalPadding {x: 25, y: -26}
90
91 // gdbg-command:print 'simple_struct::PADDING_AT_END'
92 // gdbr-command:print simple_struct::PADDING_AT_END
93 // gdbg-check:$18 = {x = -27, y = 28}
94 // gdbr-check:$18 = simple_struct::PaddingAtEnd {x: -27, y: 28}
95
96 // gdb-command:continue
97
98 // === LLDB TESTS ==================================================================================
99
100 // lldb-command:run
101
102 // lldb-command:print no_padding16
103 // lldbg-check:[...]$0 = { x = 10000 y = -10001 }
104 // lldbr-check:(simple_struct::NoPadding16) no_padding16 = { x = 10000 y = -10001 }
105
106 // lldb-command:print no_padding32
107 // lldbg-check:[...]$1 = { x = -10002 y = -10003.5 z = 10004 }
108 // lldbr-check:(simple_struct::NoPadding32) no_padding32 = { x = -10002 y = -10003.5 z = 10004 }
109
110 // lldb-command:print no_padding64
111 // lldbg-check:[...]$2 = { x = -10005.5 y = 10006 z = 10007 }
112 // lldbr-check:(simple_struct::NoPadding64) no_padding64 = { x = -10005.5 y = 10006 z = 10007 }
113
114 // lldb-command:print no_padding163264
115 // lldbg-check:[...]$3 = { a = -10008 b = 10009 c = 10010 d = 10011 }
116 // lldbr-check:(simple_struct::NoPadding163264) no_padding163264 = { a = -10008 b = 10009 c = 10010 d = 10011 }
117
118 // lldb-command:print internal_padding
119 // lldbg-check:[...]$4 = { x = 10012 y = -10013 }
120 // lldbr-check:(simple_struct::InternalPadding) internal_padding = { x = 10012 y = -10013 }
121
122 // lldb-command:print padding_at_end
123 // lldbg-check:[...]$5 = { x = -10014 y = 10015 }
124 // lldbr-check:(simple_struct::PaddingAtEnd) padding_at_end = { x = -10014 y = 10015 }
125
126 #![allow(unused_variables)]
127 #![allow(dead_code)]
128 #![feature(omit_gdb_pretty_printer_section)]
129 #![omit_gdb_pretty_printer_section]
130
131 struct NoPadding16 {
132     x: u16,
133     y: i16
134 }
135
136 struct NoPadding32 {
137     x: i32,
138     y: f32,
139     z: u32
140 }
141
142 struct NoPadding64 {
143     x: f64,
144     y: i64,
145     z: u64
146 }
147
148 struct NoPadding163264 {
149     a: i16,
150     b: u16,
151     c: i32,
152     d: u64
153 }
154
155 struct InternalPadding {
156     x: u16,
157     y: i64
158 }
159
160 struct PaddingAtEnd {
161     x: i64,
162     y: u16
163 }
164
165 static mut NO_PADDING_16: NoPadding16 = NoPadding16 {
166     x: 1000,
167     y: -1001
168 };
169
170 static mut NO_PADDING_32: NoPadding32 = NoPadding32 {
171     x: 1,
172     y: 2.0,
173     z: 3
174 };
175
176 static mut NO_PADDING_64: NoPadding64 = NoPadding64 {
177     x: 4.0,
178     y: 5,
179     z: 6
180 };
181
182 static mut NO_PADDING_163264: NoPadding163264 = NoPadding163264 {
183     a: 7,
184     b: 8,
185     c: 9,
186     d: 10
187 };
188
189 static mut INTERNAL_PADDING: InternalPadding = InternalPadding {
190     x: 11,
191     y: 12
192 };
193
194 static mut PADDING_AT_END: PaddingAtEnd = PaddingAtEnd {
195     x: 13,
196     y: 14
197 };
198
199 fn main() {
200     let no_padding16 = NoPadding16 { x: 10000, y: -10001 };
201     let no_padding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 };
202     let no_padding64 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 };
203     let no_padding163264 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 };
204
205     let internal_padding = InternalPadding { x: 10012, y: -10013 };
206     let padding_at_end = PaddingAtEnd { x: -10014, y: 10015 };
207
208     unsafe {
209         NO_PADDING_16.x = 100;
210         NO_PADDING_16.y = -101;
211
212         NO_PADDING_32.x = -15;
213         NO_PADDING_32.y = -16.0;
214         NO_PADDING_32.z = 17;
215
216         NO_PADDING_64.x = -18.0;
217         NO_PADDING_64.y = 19;
218         NO_PADDING_64.z = 20;
219
220         NO_PADDING_163264.a = -21;
221         NO_PADDING_163264.b = 22;
222         NO_PADDING_163264.c = 23;
223         NO_PADDING_163264.d = 24;
224
225         INTERNAL_PADDING.x = 25;
226         INTERNAL_PADDING.y = -26;
227
228         PADDING_AT_END.x = -27;
229         PADDING_AT_END.y = 28;
230     }
231
232     zzz(); // #break
233 }
234
235 fn zzz() {()}