2014-10-09 14:31:03 +00:00
|
|
|
// min-lldb-version: 310
|
2013-12-13 23:45:08 +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
|
|
|
|
// gdb-command:print simple
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$1 = {x = 10, y = 20}
|
|
|
|
// gdbr-check:$1 = struct_with_destructor::WithDestructor {x: 10, y: 20}
|
2013-06-21 10:09:30 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print noDestructor
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$2 = {a = {x = 10, y = 20}, guard = -1}
|
|
|
|
// gdbr-check:$2 = struct_with_destructor::NoDestructorGuarded {a: struct_with_destructor::NoDestructor {x: 10, y: 20}, guard: -1}
|
2013-06-21 10:09:30 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print withDestructor
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$3 = {a = {x = 10, y = 20}, guard = -1}
|
|
|
|
// gdbr-check:$3 = struct_with_destructor::WithDestructorGuarded {a: struct_with_destructor::WithDestructor {x: 10, y: 20}, guard: -1}
|
2013-06-21 10:09:30 +00:00
|
|
|
|
2014-04-24 09:35:48 +00:00
|
|
|
// gdb-command:print nested
|
2016-10-25 21:32:04 +00:00
|
|
|
// gdbg-check:$4 = {a = {a = {x = 7890, y = 9870}}}
|
|
|
|
// gdbr-check:$4 = struct_with_destructor::NestedOuter {a: struct_with_destructor::NestedInner {a: struct_with_destructor::WithDestructor {x: 7890, y: 9870}}}
|
2013-07-01 10:11:29 +00:00
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
|
|
|
|
// lldb-command:run
|
|
|
|
// lldb-command:print simple
|
2019-05-14 12:50:58 +00:00
|
|
|
// lldbg-check:[...]$0 = { x = 10 y = 20 }
|
|
|
|
// lldbr-check:(struct_with_destructor::WithDestructor) simple = { x = 10 y = 20 }
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// lldb-command:print noDestructor
|
2019-05-14 12:50:58 +00:00
|
|
|
// lldbg-check:[...]$1 = { a = { x = 10 y = 20 } guard = -1 }
|
|
|
|
// lldbr-check:(struct_with_destructor::NoDestructorGuarded) noDestructor = { a = { x = 10 y = 20 } guard = -1 }
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// lldb-command:print withDestructor
|
2019-05-14 12:50:58 +00:00
|
|
|
// lldbg-check:[...]$2 = { a = { x = 10 y = 20 } guard = -1 }
|
|
|
|
// lldbr-check:(struct_with_destructor::WithDestructorGuarded) withDestructor = { a = { x = 10 y = 20 } guard = -1 }
|
2014-07-09 12:46:09 +00:00
|
|
|
|
|
|
|
// lldb-command:print nested
|
2019-05-14 12:50:58 +00:00
|
|
|
// lldbg-check:[...]$3 = { a = { a = { x = 7890 y = 9870 } } }
|
|
|
|
// lldbr-check:(struct_with_destructor::NestedOuter) nested = { a = { a = { x = 7890 y = 9870 } } }
|
2014-07-09 12:46:09 +00:00
|
|
|
|
2014-10-27 22:37:07 +00:00
|
|
|
#![allow(unused_variables)]
|
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-08-17 15:37:42 +00:00
|
|
|
|
2013-06-21 10:09:30 +00:00
|
|
|
struct NoDestructor {
|
2013-07-16 10:17:55 +00:00
|
|
|
x: i32,
|
|
|
|
y: i64
|
2013-06-21 10:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct WithDestructor {
|
2013-07-16 10:17:55 +00:00
|
|
|
x: i32,
|
|
|
|
y: i64
|
2013-06-21 10:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for WithDestructor {
|
2013-09-17 01:18:07 +00:00
|
|
|
fn drop(&mut self) {}
|
2013-06-21 10:09:30 +00:00
|
|
|
}
|
|
|
|
|
2013-06-26 20:17:45 +00:00
|
|
|
struct NoDestructorGuarded {
|
2013-06-21 10:09:30 +00:00
|
|
|
a: NoDestructor,
|
|
|
|
guard: i64
|
|
|
|
}
|
|
|
|
|
2013-06-26 20:17:45 +00:00
|
|
|
struct WithDestructorGuarded {
|
2013-06-21 10:09:30 +00:00
|
|
|
a: WithDestructor,
|
|
|
|
guard: i64
|
|
|
|
}
|
|
|
|
|
2013-07-01 10:11:29 +00:00
|
|
|
struct NestedInner {
|
|
|
|
a: WithDestructor
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for NestedInner {
|
2013-09-17 01:18:07 +00:00
|
|
|
fn drop(&mut self) {}
|
2013-07-01 10:11:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct NestedOuter {
|
|
|
|
a: NestedInner
|
|
|
|
}
|
|
|
|
|
2013-06-21 10:09:30 +00:00
|
|
|
|
|
|
|
// The compiler adds a 'destructed' boolean field to structs implementing Drop. This field is used
|
2018-05-08 13:10:16 +00:00
|
|
|
// at runtime to prevent drop() to be executed more than once.
|
2013-06-21 10:09:30 +00:00
|
|
|
// This field must be incorporated by the debug info generation. Otherwise the debugger assumes a
|
|
|
|
// wrong size/layout for the struct.
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
let simple = WithDestructor { x: 10, y: 20 };
|
|
|
|
|
|
|
|
let noDestructor = NoDestructorGuarded {
|
|
|
|
a: NoDestructor { x: 10, y: 20 },
|
|
|
|
guard: -1
|
|
|
|
};
|
|
|
|
|
|
|
|
// If the destructor flag field is not incorporated into the debug info for 'WithDestructor'
|
|
|
|
// then the debugger will have an invalid offset for the field 'guard' and thus should not be
|
2013-06-27 17:27:06 +00:00
|
|
|
// able to read its value correctly (dots are padding bytes, D is the boolean destructor flag):
|
|
|
|
//
|
2013-07-20 08:47:24 +00:00
|
|
|
// 64 bit
|
|
|
|
//
|
2013-06-27 17:27:06 +00:00
|
|
|
// NoDestructorGuarded = 0000....00000000FFFFFFFF
|
|
|
|
// <--------------><------>
|
|
|
|
// NoDestructor guard
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// withDestructorGuarded = 0000....00000000D.......FFFFFFFF
|
|
|
|
// <--------------><------> // How debug info says it is
|
|
|
|
// WithDestructor guard
|
|
|
|
//
|
|
|
|
// <----------------------><------> // How it actually is
|
|
|
|
// WithDestructor guard
|
|
|
|
//
|
2013-07-20 08:47:24 +00:00
|
|
|
// 32 bit
|
|
|
|
//
|
|
|
|
// NoDestructorGuarded = 000000000000FFFFFFFF
|
|
|
|
// <----------><------>
|
|
|
|
// NoDestructor guard
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// withDestructorGuarded = 000000000000D...FFFFFFFF
|
|
|
|
// <----------><------> // How debug info says it is
|
|
|
|
// WithDestructor guard
|
|
|
|
//
|
|
|
|
// <--------------><------> // How it actually is
|
|
|
|
// WithDestructor guard
|
|
|
|
//
|
2013-06-21 10:09:30 +00:00
|
|
|
let withDestructor = WithDestructorGuarded {
|
|
|
|
a: WithDestructor { x: 10, y: 20 },
|
|
|
|
guard: -1
|
|
|
|
};
|
|
|
|
|
2013-07-20 08:47:24 +00:00
|
|
|
// expected layout (64 bit) = xxxx....yyyyyyyyD.......D...
|
|
|
|
// <--WithDestructor------>
|
|
|
|
// <-------NestedInner-------->
|
|
|
|
// <-------NestedOuter-------->
|
2013-07-01 10:11:29 +00:00
|
|
|
let nested = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } };
|
|
|
|
|
2014-07-09 12:46:09 +00:00
|
|
|
zzz(); // #break
|
2013-06-21 10:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn zzz() {()}
|