2018-01-03 18:24:25 +00:00
|
|
|
// ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
|
|
|
|
|
2014-10-09 14:31:03 +00:00
|
|
|
// min-lldb-version: 310
|
2013-11-04 06:53:01 +00:00
|
|
|
|
2014-02-07 03:57:09 +00:00
|
|
|
// compile-flags:-g
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === GDB TESTS ===================================================================================
|
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:run
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print some
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$1 = {RUST$ENCODED$ENUM$0$None = {__0 = 0x12345678}}
|
|
|
|
// gdbr-check:$1 = core::option::Option<&u32>::Some(0x12345678)
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print none
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$2 = {RUST$ENCODED$ENUM$0$None = {__0 = 0x0}}
|
|
|
|
// gdbr-check:$2 = core::option::Option<&u32>::None
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print full
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$3 = {RUST$ENCODED$ENUM$1$Empty = {__0 = 454545, __1 = 0x87654321, __2 = 9988}}
|
|
|
|
// gdbr-check:$3 = option_like_enum::MoreFields::Full(454545, 0x87654321, 9988)
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-command:print empty_gdb->discr
|
|
|
|
// gdbr-command:print empty_gdb.discr
|
2014-12-06 02:12:25 +00:00
|
|
|
// gdb-check:$4 = (isize *) 0x0
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print droid
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$5 = {RUST$ENCODED$ENUM$2$Void = {id = 675675, range = 10000001, internals = 0x43218765}}
|
|
|
|
// gdbr-check:$5 = option_like_enum::NamedFields::Droid{id: 675675, range: 10000001, internals: 0x43218765}
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-command:print void_droid_gdb->internals
|
|
|
|
// gdbr-command:print void_droid_gdb.internals
|
2014-12-06 02:12:25 +00:00
|
|
|
// gdb-check:$6 = (isize *) 0x0
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
// gdb-command:print nested_non_zero_yep
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$7 = {RUST$ENCODED$ENUM$1$2$Nope = {__0 = 10.5, __1 = {a = 10, b = 20, c = [...]}}}
|
|
|
|
// gdbr-check:$7 = option_like_enum::NestedNonZero::Yep(10.5, option_like_enum::NestedNonZeroField {a: 10, b: 20, c: 0x[...] "x[...]"})
|
2015-01-08 13:55:13 +00:00
|
|
|
|
|
|
|
// gdb-command:print nested_non_zero_nope
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$8 = {RUST$ENCODED$ENUM$1$2$Nope = {__0 = [...], __1 = {a = [...], b = [...], c = 0x0}}}
|
|
|
|
// gdbr-check:$8 = option_like_enum::NestedNonZero::Nope
|
2015-01-08 13:55:13 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:continue
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
|
|
|
|
// lldb-command:run
|
|
|
|
|
|
|
|
// lldb-command:print some
|
|
|
|
// lldb-check:[...]$0 = Some(&0x12345678)
|
|
|
|
|
|
|
|
// lldb-command:print none
|
|
|
|
// lldb-check:[...]$1 = None
|
|
|
|
|
|
|
|
// lldb-command:print full
|
|
|
|
// lldb-check:[...]$2 = Full(454545, &0x87654321, 9988)
|
|
|
|
|
|
|
|
// lldb-command:print empty
|
|
|
|
// lldb-check:[...]$3 = Empty
|
|
|
|
|
|
|
|
// lldb-command:print droid
|
|
|
|
// lldb-check:[...]$4 = Droid { id: 675675, range: 10000001, internals: &0x43218765 }
|
|
|
|
|
|
|
|
// lldb-command:print void_droid
|
|
|
|
// lldb-check:[...]$5 = Void
|
|
|
|
|
2014-12-02 22:33:52 +00:00
|
|
|
// lldb-command:print some_str
|
2015-05-09 14:48:36 +00:00
|
|
|
// lldb-check:[...]$6 = Some("abc")
|
2014-12-02 22:33:52 +00:00
|
|
|
|
|
|
|
// lldb-command:print none_str
|
|
|
|
// lldb-check:[...]$7 = None
|
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
// lldb-command:print nested_non_zero_yep
|
|
|
|
// lldb-check:[...]$8 = Yep(10.5, NestedNonZeroField { a: 10, b: 20, c: &[...] })
|
|
|
|
|
|
|
|
// lldb-command:print nested_non_zero_nope
|
|
|
|
// lldb-check:[...]$9 = Nope
|
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2015-09-19 20:33:47 +00:00
|
|
|
#![feature(omit_gdb_pretty_printer_section)]
|
2014-12-03 22:48:18 +00:00
|
|
|
#![omit_gdb_pretty_printer_section]
|
|
|
|
|
2013-07-15 13:48:57 +00:00
|
|
|
// If a struct has exactly two variants, one of them is empty, and the other one
|
|
|
|
// contains a non-nullable pointer, then this value is used as the discriminator.
|
|
|
|
// The test cases in this file make sure that something readable is generated for
|
|
|
|
// this kind of types.
|
2014-05-18 07:04:50 +00:00
|
|
|
// If the non-empty variant contains a single non-nullable pointer than the whole
|
|
|
|
// item is represented as just a pointer and not wrapped in a struct.
|
2013-08-08 12:14:52 +00:00
|
|
|
// Unfortunately (for these test cases) the content of the non-discriminant fields
|
|
|
|
// in the null-case is not defined. So we just read the discriminator field in
|
|
|
|
// this case (by casting the value to a memory-equivalent struct).
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
enum MoreFields<'a> {
|
2014-12-06 02:12:25 +00:00
|
|
|
Full(u32, &'a isize, i16),
|
2013-07-15 13:48:57 +00:00
|
|
|
Empty
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
struct MoreFieldsRepr<'a> {
|
2013-08-08 12:14:52 +00:00
|
|
|
a: u32,
|
2014-12-06 02:12:25 +00:00
|
|
|
discr: &'a isize,
|
2013-08-08 12:14:52 +00:00
|
|
|
b: i16
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
enum NamedFields<'a> {
|
2014-12-06 02:12:25 +00:00
|
|
|
Droid { id: i32, range: i64, internals: &'a isize },
|
2013-07-15 13:48:57 +00:00
|
|
|
Void
|
|
|
|
}
|
|
|
|
|
2013-12-10 07:16:18 +00:00
|
|
|
struct NamedFieldsRepr<'a> {
|
2013-08-08 12:14:52 +00:00
|
|
|
id: i32,
|
|
|
|
range: i64,
|
2014-12-06 02:12:25 +00:00
|
|
|
internals: &'a isize
|
2013-08-08 12:14:52 +00:00
|
|
|
}
|
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
struct NestedNonZeroField<'a> {
|
|
|
|
a: u16,
|
|
|
|
b: u32,
|
|
|
|
c: &'a char,
|
|
|
|
}
|
|
|
|
|
|
|
|
enum NestedNonZero<'a> {
|
|
|
|
Yep(f64, NestedNonZeroField<'a>),
|
|
|
|
Nope
|
|
|
|
}
|
|
|
|
|
2013-07-15 13:48:57 +00:00
|
|
|
fn main() {
|
|
|
|
|
2014-12-02 22:33:52 +00:00
|
|
|
let some_str: Option<&'static str> = Some("abc");
|
|
|
|
let none_str: Option<&'static str> = None;
|
|
|
|
|
2015-02-18 14:05:34 +00:00
|
|
|
let some: Option<&u32> = Some(unsafe { std::mem::transmute(0x12345678_usize) });
|
2013-07-16 10:17:55 +00:00
|
|
|
let none: Option<&u32> = None;
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2015-02-18 14:05:34 +00:00
|
|
|
let full = MoreFields::Full(454545, unsafe { std::mem::transmute(0x87654321_usize) }, 9988);
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-11-06 08:05:53 +00:00
|
|
|
let empty = MoreFields::Empty;
|
|
|
|
let empty_gdb: &MoreFieldsRepr = unsafe { std::mem::transmute(&MoreFields::Empty) };
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-11-06 08:05:53 +00:00
|
|
|
let droid = NamedFields::Droid {
|
2013-08-08 12:14:52 +00:00
|
|
|
id: 675675,
|
|
|
|
range: 10000001,
|
2015-02-18 14:05:34 +00:00
|
|
|
internals: unsafe { std::mem::transmute(0x43218765_usize) }
|
2013-08-08 12:14:52 +00:00
|
|
|
};
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2014-11-06 08:05:53 +00:00
|
|
|
let void_droid = NamedFields::Void;
|
|
|
|
let void_droid_gdb: &NamedFieldsRepr = unsafe { std::mem::transmute(&NamedFields::Void) };
|
2013-07-15 13:48:57 +00:00
|
|
|
|
2015-01-08 13:55:13 +00:00
|
|
|
let x = 'x';
|
|
|
|
let nested_non_zero_yep = NestedNonZero::Yep(
|
|
|
|
10.5,
|
|
|
|
NestedNonZeroField {
|
|
|
|
a: 10,
|
|
|
|
b: 20,
|
|
|
|
c: &x
|
|
|
|
});
|
|
|
|
|
|
|
|
let nested_non_zero_nope = NestedNonZero::Nope;
|
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
zzz(); // #break
|
2013-07-15 13:48:57 +00:00
|
|
|
}
|
|
|
|
|
2013-08-08 12:14:52 +00:00
|
|
|
fn zzz() {()}
|