blob: 642879cf3b672ac9ecc73b32271373f6d6068101 [file] [log] [blame]
Chris Wailesc25c0452024-05-02 11:11:34 -07001//@ compile-flags:-g
Inna Palantff3f07a2019-07-11 16:15:26 -07002
3// === GDB TESTS ===================================================================================
4
5// gdb-command:run
6
7// gdb-command:print tuple_interior_padding
Chris Wailesbcfff4e2024-10-17 11:23:36 -07008// gdb-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred)
Inna Palantff3f07a2019-07-11 16:15:26 -07009
10// gdb-command:print tuple_padding_at_end
Chris Wailesbcfff4e2024-10-17 11:23:36 -070011// gdb-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2)
Inna Palantff3f07a2019-07-11 16:15:26 -070012
13// gdb-command:print tuple_different_enums
Chris Wailesbcfff4e2024-10-17 11:23:36 -070014// gdb-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)
Inna Palantff3f07a2019-07-11 16:15:26 -070015
16// gdb-command:print padded_struct
Chris Wailesbcfff4e2024-10-17 11:23:36 -070017// gdb-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}
Inna Palantff3f07a2019-07-11 16:15:26 -070018
19// gdb-command:print packed_struct
Chris Wailesbcfff4e2024-10-17 11:23:36 -070020// gdb-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}
Inna Palantff3f07a2019-07-11 16:15:26 -070021
22// gdb-command:print non_padded_struct
Chris Wailesbcfff4e2024-10-17 11:23:36 -070023// gdb-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}
Inna Palantff3f07a2019-07-11 16:15:26 -070024
25// gdb-command:print struct_with_drop
Chris Wailesbcfff4e2024-10-17 11:23:36 -070026// gdb-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)
Inna Palantff3f07a2019-07-11 16:15:26 -070027
28// === LLDB TESTS ==================================================================================
29
30// lldb-command:run
31
Chris Wailes09b8e4e2024-06-13 15:43:20 -070032// lldb-command:v tuple_interior_padding
Chris Wailesbcfff4e2024-10-17 11:23:36 -070033// lldb-check:[...] { 0 = 0 1 = OneHundred }
Inna Palantff3f07a2019-07-11 16:15:26 -070034
Chris Wailes09b8e4e2024-06-13 15:43:20 -070035// lldb-command:v tuple_padding_at_end
Chris Wailesbcfff4e2024-10-17 11:23:36 -070036// lldb-check:[...] { 0 = { 0 = 1 1 = OneThousand } 1 = 2 }
Jeff Vander Stoep983137f2020-09-16 14:50:30 +020037
Chris Wailes09b8e4e2024-06-13 15:43:20 -070038// lldb-command:v tuple_different_enums
Chris Wailesbcfff4e2024-10-17 11:23:36 -070039// lldb-check:[...] { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna }
Inna Palantff3f07a2019-07-11 16:15:26 -070040
Chris Wailes09b8e4e2024-06-13 15:43:20 -070041// lldb-command:v padded_struct
Chris Wailesbcfff4e2024-10-17 11:23:36 -070042// lldb-check:[...] { a = 3 b = OneMillion c = 4 d = Toronto e = 5 }
Inna Palantff3f07a2019-07-11 16:15:26 -070043
Chris Wailes09b8e4e2024-06-13 15:43:20 -070044// lldb-command:v packed_struct
Chris Wailesbcfff4e2024-10-17 11:23:36 -070045// lldb-check:[...] { a = 6 b = OneHundred c = 7 d = Vienna e = 8 }
Inna Palantff3f07a2019-07-11 16:15:26 -070046
Chris Wailes09b8e4e2024-06-13 15:43:20 -070047// lldb-command:v non_padded_struct
Chris Wailesbcfff4e2024-10-17 11:23:36 -070048// lldb-check:[...] { a = OneMillion b = MountainView c = OneThousand d = Toronto }
Inna Palantff3f07a2019-07-11 16:15:26 -070049
Chris Wailes09b8e4e2024-06-13 15:43:20 -070050// lldb-command:v struct_with_drop
Chris Wailesbcfff4e2024-10-17 11:23:36 -070051// lldb-check:[...] { 0 = { a = OneHundred b = Vienna } 1 = 9 }
Inna Palantff3f07a2019-07-11 16:15:26 -070052
53#![allow(unused_variables)]
54#![feature(omit_gdb_pretty_printer_section)]
55#![omit_gdb_pretty_printer_section]
56
57use self::AnEnum::{OneHundred, OneThousand, OneMillion};
58use self::AnotherEnum::{MountainView, Toronto, Vienna};
59
60enum AnEnum {
61 OneHundred = 100,
62 OneThousand = 1000,
63 OneMillion = 1000000
64}
65
66enum AnotherEnum {
67 MountainView,
68 Toronto,
69 Vienna
70}
71
72struct PaddedStruct {
73 a: i16,
74 b: AnEnum,
75 c: i16,
76 d: AnotherEnum,
77 e: i16
78}
79
80#[repr(packed)]
81struct PackedStruct {
82 a: i16,
83 b: AnEnum,
84 c: i16,
85 d: AnotherEnum,
86 e: i16
87}
88
89struct NonPaddedStruct {
90 a: AnEnum,
91 b: AnotherEnum,
92 c: AnEnum,
93 d: AnotherEnum
94}
95
96struct StructWithDrop {
97 a: AnEnum,
98 b: AnotherEnum
99}
100
101impl Drop for StructWithDrop {
102 fn drop(&mut self) {()}
103}
104
105fn main() {
106
107 let tuple_interior_padding = (0_i16, OneHundred);
108 // It will depend on the machine architecture if any padding is actually involved here
109 let tuple_padding_at_end = ((1_u64, OneThousand), 2_u64);
110 let tuple_different_enums = (OneThousand, MountainView, OneMillion, Vienna);
111
112 let padded_struct = PaddedStruct {
113 a: 3,
114 b: OneMillion,
115 c: 4,
116 d: Toronto,
117 e: 5
118 };
119
120 let packed_struct = PackedStruct {
121 a: 6,
122 b: OneHundred,
123 c: 7,
124 d: Vienna,
125 e: 8
126 };
127
128 let non_padded_struct = NonPaddedStruct {
129 a: OneMillion,
130 b: MountainView,
131 c: OneThousand,
132 d: Toronto
133 };
134
135 let struct_with_drop = (StructWithDrop { a: OneHundred, b: Vienna }, 9_i64);
136
137 zzz(); // #break
138}
139
140fn zzz() { () }