]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/struct-in-struct.rs
Auto merge of #68528 - ecstatic-morse:maybe-init-variants, r=oli-obk
[rust.git] / src / test / debuginfo / struct-in-struct.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 three_simple_structs
11 // gdbg-check:$1 = {x = {x = 1}, y = {x = 2}, z = {x = 3}}
12 // gdbr-check:$1 = struct_in_struct::ThreeSimpleStructs {x: struct_in_struct::Simple {x: 1}, y: struct_in_struct::Simple {x: 2}, z: struct_in_struct::Simple {x: 3}}
13
14 // gdb-command:print internal_padding_parent
15 // gdbg-check:$2 = {x = {x = 4, y = 5}, y = {x = 6, y = 7}, z = {x = 8, y = 9}}
16 // gdbr-check:$2 = struct_in_struct::InternalPaddingParent {x: struct_in_struct::InternalPadding {x: 4, y: 5}, y: struct_in_struct::InternalPadding {x: 6, y: 7}, z: struct_in_struct::InternalPadding {x: 8, y: 9}}
17
18 // gdb-command:print padding_at_end_parent
19 // gdbg-check:$3 = {x = {x = 10, y = 11}, y = {x = 12, y = 13}, z = {x = 14, y = 15}}
20 // gdbr-check:$3 = struct_in_struct::PaddingAtEndParent {x: struct_in_struct::PaddingAtEnd {x: 10, y: 11}, y: struct_in_struct::PaddingAtEnd {x: 12, y: 13}, z: struct_in_struct::PaddingAtEnd {x: 14, y: 15}}
21
22
23 // === LLDB TESTS ==================================================================================
24
25 // lldb-command:run
26
27 // lldb-command:print three_simple_structs
28 // lldbg-check:[...]$0 = ThreeSimpleStructs { x: Simple { x: 1 }, y: Simple { x: 2 }, z: Simple { x: 3 } }
29 // lldbr-check:(struct_in_struct::ThreeSimpleStructs) three_simple_structs = ThreeSimpleStructs { x: Simple { x: 1 }, y: Simple { x: 2 }, z: Simple { x: 3 } }
30
31 // lldb-command:print internal_padding_parent
32 // lldbg-check:[...]$1 = InternalPaddingParent { x: InternalPadding { x: 4, y: 5 }, y: InternalPadding { x: 6, y: 7 }, z: InternalPadding { x: 8, y: 9 } }
33 // lldbr-check:(struct_in_struct::InternalPaddingParent) internal_padding_parent = InternalPaddingParent { x: InternalPadding { x: 4, y: 5 }, y: InternalPadding { x: 6, y: 7 }, z: InternalPadding { x: 8, y: 9 } }
34
35 // lldb-command:print padding_at_end_parent
36 // lldbg-check:[...]$2 = PaddingAtEndParent { x: PaddingAtEnd { x: 10, y: 11 }, y: PaddingAtEnd { x: 12, y: 13 }, z: PaddingAtEnd { x: 14, y: 15 } }
37 // lldbr-check:(struct_in_struct::PaddingAtEndParent) padding_at_end_parent = PaddingAtEndParent { x: PaddingAtEnd { x: 10, y: 11 }, y: PaddingAtEnd { x: 12, y: 13 }, z: PaddingAtEnd { x: 14, y: 15 } }
38
39 // lldb-command:print mixed
40 // lldbg-check:[...]$3 = Mixed { x: PaddingAtEnd { x: 16, y: 17 }, y: InternalPadding { x: 18, y: 19 }, z: Simple { x: 20 }, w: 21 }
41 // lldbr-check:(struct_in_struct::Mixed) mixed = Mixed { x: PaddingAtEnd { x: 16, y: 17 }, y: InternalPadding { x: 18, y: 19 }, z: Simple { x: 20 }, w: 21 }
42
43 // lldb-command:print bag
44 // lldbg-check:[...]$4 = Bag { x: Simple { x: 22 } }
45 // lldbr-check:(struct_in_struct::Bag) bag = Bag { x: Simple { x: 22 } }
46
47 // lldb-command:print bag_in_bag
48 // lldbg-check:[...]$5 = BagInBag { x: Bag { x: Simple { x: 23 } } }
49 // lldbr-check:(struct_in_struct::BagInBag) bag_in_bag = BagInBag { x: Bag { x: Simple { x: 23 } } }
50
51 // lldb-command:print tjo
52 // lldbg-check:[...]$6 = ThatsJustOverkill { x: BagInBag { x: Bag { x: Simple { x: 24 } } } }
53 // lldbr-check:(struct_in_struct::ThatsJustOverkill) tjo = ThatsJustOverkill { x: BagInBag { x: Bag { x: Simple { x: 24 } } } }
54
55 // lldb-command:print tree
56 // lldbg-check:[...]$7 = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } }
57 // lldbr-check:(struct_in_struct::Tree) tree = Tree { x: Simple { x: 25 }, y: InternalPaddingParent { x: InternalPadding { x: 26, y: 27 }, y: InternalPadding { x: 28, y: 29 }, z: InternalPadding { x: 30, y: 31 } }, z: BagInBag { x: Bag { x: Simple { x: 32 } } } }
58
59 #![allow(unused_variables)]
60 #![feature(omit_gdb_pretty_printer_section)]
61 #![omit_gdb_pretty_printer_section]
62
63 struct Simple {
64     x: i32
65 }
66
67 struct InternalPadding {
68     x: i32,
69     y: i64
70 }
71
72 struct PaddingAtEnd {
73     x: i64,
74     y: i32
75 }
76
77 struct ThreeSimpleStructs {
78     x: Simple,
79     y: Simple,
80     z: Simple
81 }
82
83 struct InternalPaddingParent {
84     x: InternalPadding,
85     y: InternalPadding,
86     z: InternalPadding
87 }
88
89 struct PaddingAtEndParent {
90     x: PaddingAtEnd,
91     y: PaddingAtEnd,
92     z: PaddingAtEnd
93 }
94
95 struct Mixed {
96     x: PaddingAtEnd,
97     y: InternalPadding,
98     z: Simple,
99     w: i16
100 }
101
102 struct Bag {
103     x: Simple
104 }
105
106 struct BagInBag {
107     x: Bag
108 }
109
110 struct ThatsJustOverkill {
111     x: BagInBag
112 }
113
114 struct Tree {
115     x: Simple,
116     y: InternalPaddingParent,
117     z: BagInBag
118 }
119
120 fn main() {
121
122     let three_simple_structs = ThreeSimpleStructs {
123         x: Simple { x: 1 },
124         y: Simple { x: 2 },
125         z: Simple { x: 3 }
126     };
127
128     let internal_padding_parent = InternalPaddingParent {
129         x: InternalPadding { x: 4, y: 5 },
130         y: InternalPadding { x: 6, y: 7 },
131         z: InternalPadding { x: 8, y: 9 }
132     };
133
134     let padding_at_end_parent = PaddingAtEndParent {
135         x: PaddingAtEnd { x: 10, y: 11 },
136         y: PaddingAtEnd { x: 12, y: 13 },
137         z: PaddingAtEnd { x: 14, y: 15 }
138     };
139
140     let mixed = Mixed {
141         x: PaddingAtEnd { x: 16, y: 17 },
142         y: InternalPadding { x: 18, y: 19 },
143         z: Simple { x: 20 },
144         w: 21
145     };
146
147     let bag = Bag { x: Simple { x: 22 } };
148     let bag_in_bag = BagInBag {
149         x: Bag {
150             x: Simple { x: 23 }
151         }
152     };
153
154     let tjo = ThatsJustOverkill {
155         x: BagInBag {
156             x: Bag {
157                 x: Simple { x: 24 }
158             }
159         }
160     };
161
162     let tree = Tree {
163         x: Simple { x: 25 },
164         y: InternalPaddingParent {
165             x: InternalPadding { x: 26, y: 27 },
166             y: InternalPadding { x: 28, y: 29 },
167             z: InternalPadding { x: 30, y: 31 }
168         },
169         z: BagInBag {
170             x: Bag {
171                 x: Simple { x: 32 }
172             }
173         }
174     };
175
176     zzz(); // #break
177 }
178
179 fn zzz() {()}