1 // ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
3 // min-lldb-version: 310
7 // === GDB TESTS ===================================================================================
11 // gdb-command:print some
12 // gdbg-check:$1 = {RUST$ENCODED$ENUM$0$None = {__0 = 0x12345678}}
13 // gdbr-check:$1 = core::option::Option<&u32>::Some(0x12345678)
15 // gdb-command:print none
16 // gdbg-check:$2 = {RUST$ENCODED$ENUM$0$None = {__0 = 0x0}}
17 // gdbr-check:$2 = core::option::Option<&u32>::None
19 // gdb-command:print full
20 // gdbg-check:$3 = {RUST$ENCODED$ENUM$1$Empty = {__0 = 454545, __1 = 0x87654321, __2 = 9988}}
21 // gdbr-check:$3 = option_like_enum::MoreFields::Full(454545, 0x87654321, 9988)
23 // gdbg-command:print empty_gdb->discr
24 // gdbr-command:print empty_gdb.discr
25 // gdb-check:$4 = (isize *) 0x0
27 // gdb-command:print droid
28 // gdbg-check:$5 = {RUST$ENCODED$ENUM$2$Void = {id = 675675, range = 10000001, internals = 0x43218765}}
29 // gdbr-check:$5 = option_like_enum::NamedFields::Droid{id: 675675, range: 10000001, internals: 0x43218765}
31 // gdbg-command:print void_droid_gdb->internals
32 // gdbr-command:print void_droid_gdb.internals
33 // gdb-check:$6 = (isize *) 0x0
35 // gdb-command:print nested_non_zero_yep
36 // gdbg-check:$7 = {RUST$ENCODED$ENUM$1$2$Nope = {__0 = 10.5, __1 = {a = 10, b = 20, c = [...]}}}
37 // gdbr-check:$7 = option_like_enum::NestedNonZero::Yep(10.5, option_like_enum::NestedNonZeroField {a: 10, b: 20, c: 0x[...] "x[...]"})
39 // gdb-command:print nested_non_zero_nope
40 // gdbg-check:$8 = {RUST$ENCODED$ENUM$1$2$Nope = {__0 = [...], __1 = {a = [...], b = [...], c = 0x0}}}
41 // gdbr-check:$8 = option_like_enum::NestedNonZero::Nope
43 // gdb-command:continue
46 // === LLDB TESTS ==================================================================================
50 // lldb-command:print some
51 // lldb-check:[...]$0 = Some(&0x12345678)
53 // lldb-command:print none
54 // lldb-check:[...]$1 = None
56 // lldb-command:print full
57 // lldb-check:[...]$2 = Full(454545, &0x87654321, 9988)
59 // lldb-command:print empty
60 // lldb-check:[...]$3 = Empty
62 // lldb-command:print droid
63 // lldb-check:[...]$4 = Droid { id: 675675, range: 10000001, internals: &0x43218765 }
65 // lldb-command:print void_droid
66 // lldb-check:[...]$5 = Void
68 // lldb-command:print some_str
69 // lldb-check:[...]$6 = Some("abc")
71 // lldb-command:print none_str
72 // lldb-check:[...]$7 = None
74 // lldb-command:print nested_non_zero_yep
75 // lldb-check:[...]$8 = Yep(10.5, NestedNonZeroField { a: 10, b: 20, c: &[...] })
77 // lldb-command:print nested_non_zero_nope
78 // lldb-check:[...]$9 = Nope
81 #![feature(omit_gdb_pretty_printer_section)]
82 #![omit_gdb_pretty_printer_section]
84 // If a struct has exactly two variants, one of them is empty, and the other one
85 // contains a non-nullable pointer, then this value is used as the discriminator.
86 // The test cases in this file make sure that something readable is generated for
87 // this kind of types.
88 // If the non-empty variant contains a single non-nullable pointer than the whole
89 // item is represented as just a pointer and not wrapped in a struct.
90 // Unfortunately (for these test cases) the content of the non-discriminant fields
91 // in the null-case is not defined. So we just read the discriminator field in
92 // this case (by casting the value to a memory-equivalent struct).
95 Full(u32, &'a isize, i16),
99 struct MoreFieldsRepr<'a> {
105 enum NamedFields<'a> {
106 Droid { id: i32, range: i64, internals: &'a isize },
110 struct NamedFieldsRepr<'a> {
116 struct NestedNonZeroField<'a> {
122 enum NestedNonZero<'a> {
123 Yep(f64, NestedNonZeroField<'a>),
129 let some_str: Option<&'static str> = Some("abc");
130 let none_str: Option<&'static str> = None;
132 let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678_usize) });
133 let none: Option<&u32> = None;
135 let full = MoreFields::Full(454545, unsafe { std::mem::transmute(0x87654321_usize) }, 9988);
137 let empty = MoreFields::Empty;
138 let empty_gdb: &MoreFieldsRepr = unsafe { std::mem::transmute(&MoreFields::Empty) };
140 let droid = NamedFields::Droid {
143 internals: unsafe { std::mem::transmute(0x43218765_usize) }
146 let void_droid = NamedFields::Void;
147 let void_droid_gdb: &NamedFieldsRepr = unsafe { std::mem::transmute(&NamedFields::Void) };
150 let nested_non_zero_yep = NestedNonZero::Yep(
158 let nested_non_zero_nope = NestedNonZero::Nope;