Chris Wailes | c25c045 | 2024-05-02 11:11:34 -0700 | [diff] [blame] | 1 | //@ compile-flags:-g |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 2 | |
| 3 | // === GDB TESTS =================================================================================== |
| 4 | |
| 5 | // gdb-command:run |
| 6 | |
| 7 | // gdb-command:print tuple_interior_padding |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 8 | // gdb-check:$1 = (0, c_style_enum_in_composite::AnEnum::OneHundred) |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 9 | |
| 10 | // gdb-command:print tuple_padding_at_end |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 11 | // gdb-check:$2 = ((1, c_style_enum_in_composite::AnEnum::OneThousand), 2) |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 12 | |
| 13 | // gdb-command:print tuple_different_enums |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 14 | // 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 Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 15 | |
| 16 | // gdb-command:print padded_struct |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 17 | // 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 Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 18 | |
| 19 | // gdb-command:print packed_struct |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 20 | // 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 Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 21 | |
| 22 | // gdb-command:print non_padded_struct |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 23 | // 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 Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 24 | |
| 25 | // gdb-command:print struct_with_drop |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 26 | // 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 Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 27 | |
| 28 | // === LLDB TESTS ================================================================================== |
| 29 | |
| 30 | // lldb-command:run |
| 31 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 32 | // lldb-command:v tuple_interior_padding |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 33 | // lldb-check:[...] { 0 = 0 1 = OneHundred } |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 34 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 35 | // lldb-command:v tuple_padding_at_end |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 36 | // lldb-check:[...] { 0 = { 0 = 1 1 = OneThousand } 1 = 2 } |
Jeff Vander Stoep | 983137f | 2020-09-16 14:50:30 +0200 | [diff] [blame] | 37 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 38 | // lldb-command:v tuple_different_enums |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 39 | // lldb-check:[...] { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna } |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 40 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 41 | // lldb-command:v padded_struct |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 42 | // lldb-check:[...] { a = 3 b = OneMillion c = 4 d = Toronto e = 5 } |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 43 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 44 | // lldb-command:v packed_struct |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 45 | // lldb-check:[...] { a = 6 b = OneHundred c = 7 d = Vienna e = 8 } |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 46 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 47 | // lldb-command:v non_padded_struct |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 48 | // lldb-check:[...] { a = OneMillion b = MountainView c = OneThousand d = Toronto } |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 49 | |
Chris Wailes | 09b8e4e | 2024-06-13 15:43:20 -0700 | [diff] [blame] | 50 | // lldb-command:v struct_with_drop |
Chris Wailes | bcfff4e | 2024-10-17 11:23:36 -0700 | [diff] [blame] | 51 | // lldb-check:[...] { 0 = { a = OneHundred b = Vienna } 1 = 9 } |
Inna Palant | ff3f07a | 2019-07-11 16:15:26 -0700 | [diff] [blame] | 52 | |
| 53 | #![allow(unused_variables)] |
| 54 | #![feature(omit_gdb_pretty_printer_section)] |
| 55 | #![omit_gdb_pretty_printer_section] |
| 56 | |
| 57 | use self::AnEnum::{OneHundred, OneThousand, OneMillion}; |
| 58 | use self::AnotherEnum::{MountainView, Toronto, Vienna}; |
| 59 | |
| 60 | enum AnEnum { |
| 61 | OneHundred = 100, |
| 62 | OneThousand = 1000, |
| 63 | OneMillion = 1000000 |
| 64 | } |
| 65 | |
| 66 | enum AnotherEnum { |
| 67 | MountainView, |
| 68 | Toronto, |
| 69 | Vienna |
| 70 | } |
| 71 | |
| 72 | struct PaddedStruct { |
| 73 | a: i16, |
| 74 | b: AnEnum, |
| 75 | c: i16, |
| 76 | d: AnotherEnum, |
| 77 | e: i16 |
| 78 | } |
| 79 | |
| 80 | #[repr(packed)] |
| 81 | struct PackedStruct { |
| 82 | a: i16, |
| 83 | b: AnEnum, |
| 84 | c: i16, |
| 85 | d: AnotherEnum, |
| 86 | e: i16 |
| 87 | } |
| 88 | |
| 89 | struct NonPaddedStruct { |
| 90 | a: AnEnum, |
| 91 | b: AnotherEnum, |
| 92 | c: AnEnum, |
| 93 | d: AnotherEnum |
| 94 | } |
| 95 | |
| 96 | struct StructWithDrop { |
| 97 | a: AnEnum, |
| 98 | b: AnotherEnum |
| 99 | } |
| 100 | |
| 101 | impl Drop for StructWithDrop { |
| 102 | fn drop(&mut self) {()} |
| 103 | } |
| 104 | |
| 105 | fn 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 | |
| 140 | fn zzz() { () } |