]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/c-style-enum-in-composite.rs
Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into sync_cg_clif-2023-02-09
[rust.git] / tests / debuginfo / c-style-enum-in-composite.rs
1 // min-lldb-version: 310
2
3 // compile-flags:-g
4
5 // === GDB TESTS ===================================================================================
6
7 // gdb-command:run
8
9 // gdb-command:print tuple_interior_padding
10 // gdbg-check:$1 = {__0 = 0, __1 = OneHundred}
11 // gdbr-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred)
12
13 // gdb-command:print tuple_padding_at_end
14 // gdbg-check:$2 = {__0 = {__0 = 1, __1 = OneThousand}, __1 = 2}
15 // gdbr-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2)
16
17 // gdb-command:print tuple_different_enums
18 // gdbg-check:$3 = {__0 = OneThousand, __1 = MountainView, __2 = OneMillion, __3 = Vienna}
19 // gdbr-check:$3 = (c_style_enum_in_composite::AnEnum::OneThousand, c_style_enum_in_composite::AnotherEnum::MountainView, c_style_enum_in_composite::AnEnum::OneMillion, c_style_enum_in_composite::AnotherEnum::Vienna)
20
21 // gdb-command:print padded_struct
22 // gdbg-check:$4 = {a = 3, b = OneMillion, c = 4, d = Toronto, e = 5}
23 // gdbr-check:$4 = c_style_enum_in_composite::PaddedStruct {a: 3, b: c_style_enum_in_composite::AnEnum::OneMillion, c: 4, d: c_style_enum_in_composite::AnotherEnum::Toronto, e: 5}
24
25 // gdb-command:print packed_struct
26 // gdbg-check:$5 = {a = 6, b = OneHundred, c = 7, d = Vienna, e = 8}
27 // gdbr-check:$5 = c_style_enum_in_composite::PackedStruct {a: 6, b: c_style_enum_in_composite::AnEnum::OneHundred, c: 7, d: c_style_enum_in_composite::AnotherEnum::Vienna, e: 8}
28
29 // gdb-command:print non_padded_struct
30 // gdbg-check:$6 = {a = OneMillion, b = MountainView, c = OneThousand, d = Toronto}
31 // gdbr-check:$6 = c_style_enum_in_composite::NonPaddedStruct {a: c_style_enum_in_composite::AnEnum::OneMillion, b: c_style_enum_in_composite::AnotherEnum::MountainView, c: c_style_enum_in_composite::AnEnum::OneThousand, d: c_style_enum_in_composite::AnotherEnum::Toronto}
32
33 // gdb-command:print struct_with_drop
34 // gdbg-check:$7 = {__0 = {a = OneHundred, b = Vienna}, __1 = 9}
35 // gdbr-check:$7 = (c_style_enum_in_composite::StructWithDrop {a: c_style_enum_in_composite::AnEnum::OneHundred, b: c_style_enum_in_composite::AnotherEnum::Vienna}, 9)
36
37 // === LLDB TESTS ==================================================================================
38
39 // lldb-command:run
40
41 // lldb-command:print tuple_interior_padding
42 // lldbg-check:[...]$0 = { 0 = 0 1 = OneHundred }
43 // lldbr-check:((i16, c_style_enum_in_composite::AnEnum)) tuple_interior_padding = { 0 = 0 1 = OneHundred }
44
45 // lldb-command:print tuple_padding_at_end
46 // lldbg-check:[...]$1 = { 0 = { 0 = 1 1 = OneThousand } 1 = 2 }
47 // lldbr-check:(((u64, c_style_enum_in_composite::AnEnum), u64)) tuple_padding_at_end = { 0 = { 0 = 1 1 = OneThousand } 1 = 2 }
48
49 // lldb-command:print tuple_different_enums
50 // lldbg-check:[...]$2 = { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna }
51 // lldbr-check:((c_style_enum_in_composite::AnEnum, c_style_enum_in_composite::AnotherEnum, c_style_enum_in_composite::AnEnum, c_style_enum_in_composite::AnotherEnum)) tuple_different_enums = { 0 = c_style_enum_in_composite::AnEnum::OneThousand 1 = c_style_enum_in_composite::AnotherEnum::MountainView 2 = c_style_enum_in_composite::AnEnum::OneMillion 3 = c_style_enum_in_composite::AnotherEnum::Vienna }
52
53 // lldb-command:print padded_struct
54 // lldbg-check:[...]$3 = { a = 3 b = OneMillion c = 4 d = Toronto e = 5 }
55 // lldbr-check:(c_style_enum_in_composite::PaddedStruct) padded_struct = { a = 3 b = c_style_enum_in_composite::AnEnum::OneMillion c = 4 d = Toronto e = 5 }
56
57 // lldb-command:print packed_struct
58 // lldbg-check:[...]$4 = { a = 6 b = OneHundred c = 7 d = Vienna e = 8 }
59 // lldbr-check:(c_style_enum_in_composite::PackedStruct) packed_struct = { a = 6 b = c_style_enum_in_composite::AnEnum::OneHundred c = 7 d = Vienna e = 8 }
60
61 // lldb-command:print non_padded_struct
62 // lldbg-check:[...]$5 = { a = OneMillion b = MountainView c = OneThousand d = Toronto }
63 // lldbr-check:(c_style_enum_in_composite::NonPaddedStruct) non_padded_struct = { a = c_style_enum_in_composite::AnEnum::OneMillion, b = c_style_enum_in_composite::AnotherEnum::MountainView, c = c_style_enum_in_composite::AnEnum::OneThousand, d = c_style_enum_in_composite::AnotherEnum::Toronto }
64
65 // lldb-command:print struct_with_drop
66 // lldbg-check:[...]$6 = { 0 = { a = OneHundred b = Vienna } 1 = 9 }
67 // lldbr-check:((c_style_enum_in_composite::StructWithDrop, i64)) struct_with_drop = { 0 = { a = c_style_enum_in_composite::AnEnum::OneHundred b = c_style_enum_in_composite::AnotherEnum::Vienna } 1 = 9 }
68
69 #![allow(unused_variables)]
70 #![feature(omit_gdb_pretty_printer_section)]
71 #![omit_gdb_pretty_printer_section]
72
73 use self::AnEnum::{OneHundred, OneThousand, OneMillion};
74 use self::AnotherEnum::{MountainView, Toronto, Vienna};
75
76 enum AnEnum {
77     OneHundred = 100,
78     OneThousand = 1000,
79     OneMillion = 1000000
80 }
81
82 enum AnotherEnum {
83     MountainView,
84     Toronto,
85     Vienna
86 }
87
88 struct PaddedStruct {
89     a: i16,
90     b: AnEnum,
91     c: i16,
92     d: AnotherEnum,
93     e: i16
94 }
95
96 #[repr(packed)]
97 struct PackedStruct {
98     a: i16,
99     b: AnEnum,
100     c: i16,
101     d: AnotherEnum,
102     e: i16
103 }
104
105 struct NonPaddedStruct {
106     a: AnEnum,
107     b: AnotherEnum,
108     c: AnEnum,
109     d: AnotherEnum
110 }
111
112 struct StructWithDrop {
113     a: AnEnum,
114     b: AnotherEnum
115 }
116
117 impl Drop for StructWithDrop {
118     fn drop(&mut self) {()}
119 }
120
121 fn main() {
122
123     let tuple_interior_padding = (0_i16, OneHundred);
124     // It will depend on the machine architecture if any padding is actually involved here
125     let tuple_padding_at_end = ((1_u64, OneThousand), 2_u64);
126     let tuple_different_enums = (OneThousand, MountainView, OneMillion, Vienna);
127
128     let padded_struct = PaddedStruct {
129         a: 3,
130         b: OneMillion,
131         c: 4,
132         d: Toronto,
133         e: 5
134     };
135
136     let packed_struct = PackedStruct {
137         a: 6,
138         b: OneHundred,
139         c: 7,
140         d: Vienna,
141         e: 8
142     };
143
144     let non_padded_struct = NonPaddedStruct {
145         a: OneMillion,
146         b: MountainView,
147         c: OneThousand,
148         d: Toronto
149     };
150
151     let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
152
153     zzz(); // #break
154 }
155
156 fn zzz() { () }