1 // ignore-tidy-linelength
3 // min-lldb-version: 310
7 // === GDB TESTS ===================================================================================
10 // gdb-command:print simple
11 // gdbg-check:$1 = {x = 10, y = 20}
12 // gdbr-check:$1 = struct_with_destructor::WithDestructor {x: 10, y: 20}
14 // gdb-command:print noDestructor
15 // gdbg-check:$2 = {a = {x = 10, y = 20}, guard = -1}
16 // gdbr-check:$2 = struct_with_destructor::NoDestructorGuarded {a: struct_with_destructor::NoDestructor {x: 10, y: 20}, guard: -1}
18 // gdb-command:print withDestructor
19 // gdbg-check:$3 = {a = {x = 10, y = 20}, guard = -1}
20 // gdbr-check:$3 = struct_with_destructor::WithDestructorGuarded {a: struct_with_destructor::WithDestructor {x: 10, y: 20}, guard: -1}
22 // gdb-command:print nested
23 // gdbg-check:$4 = {a = {a = {x = 7890, y = 9870}}}
24 // gdbr-check:$4 = struct_with_destructor::NestedOuter {a: struct_with_destructor::NestedInner {a: struct_with_destructor::WithDestructor {x: 7890, y: 9870}}}
27 // === LLDB TESTS ==================================================================================
30 // lldb-command:print simple
31 // lldbg-check:[...]$0 = { x = 10 y = 20 }
32 // lldbr-check:(struct_with_destructor::WithDestructor) simple = { x = 10 y = 20 }
34 // lldb-command:print noDestructor
35 // lldbg-check:[...]$1 = { a = { x = 10 y = 20 } guard = -1 }
36 // lldbr-check:(struct_with_destructor::NoDestructorGuarded) noDestructor = { a = { x = 10 y = 20 } guard = -1 }
38 // lldb-command:print withDestructor
39 // lldbg-check:[...]$2 = { a = { x = 10 y = 20 } guard = -1 }
40 // lldbr-check:(struct_with_destructor::WithDestructorGuarded) withDestructor = { a = { x = 10 y = 20 } guard = -1 }
42 // lldb-command:print nested
43 // lldbg-check:[...]$3 = { a = { a = { x = 7890 y = 9870 } } }
44 // lldbr-check:(struct_with_destructor::NestedOuter) nested = { a = { a = { x = 7890 y = 9870 } } }
46 #![allow(unused_variables)]
47 #![feature(omit_gdb_pretty_printer_section)]
48 #![omit_gdb_pretty_printer_section]
55 struct WithDestructor {
60 impl Drop for WithDestructor {
64 struct NoDestructorGuarded {
69 struct WithDestructorGuarded {
78 impl Drop for NestedInner {
87 // The compiler adds a 'destructed' boolean field to structs implementing Drop. This field is used
88 // at runtime to prevent drop() to be executed more than once.
89 // This field must be incorporated by the debug info generation. Otherwise the debugger assumes a
90 // wrong size/layout for the struct.
93 let simple = WithDestructor { x: 10, y: 20 };
95 let noDestructor = NoDestructorGuarded {
96 a: NoDestructor { x: 10, y: 20 },
100 // If the destructor flag field is not incorporated into the debug info for 'WithDestructor'
101 // then the debugger will have an invalid offset for the field 'guard' and thus should not be
102 // able to read its value correctly (dots are padding bytes, D is the boolean destructor flag):
106 // NoDestructorGuarded = 0000....00000000FFFFFFFF
107 // <--------------><------>
108 // NoDestructor guard
111 // withDestructorGuarded = 0000....00000000D.......FFFFFFFF
112 // <--------------><------> // How debug info says it is
113 // WithDestructor guard
115 // <----------------------><------> // How it actually is
116 // WithDestructor guard
120 // NoDestructorGuarded = 000000000000FFFFFFFF
121 // <----------><------>
122 // NoDestructor guard
125 // withDestructorGuarded = 000000000000D...FFFFFFFF
126 // <----------><------> // How debug info says it is
127 // WithDestructor guard
129 // <--------------><------> // How it actually is
130 // WithDestructor guard
132 let withDestructor = WithDestructorGuarded {
133 a: WithDestructor { x: 10, y: 20 },
137 // expected layout (64 bit) = xxxx....yyyyyyyyD.......D...
138 // <--WithDestructor------>
139 // <-------NestedInner-------->
140 // <-------NestedOuter-------->
141 let nested = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } };