1 // min-lldb-version: 310
5 // === GDB TESTS ===================================================================================
8 // gdb-command:print simple
9 // gdbg-check:$1 = {x = 10, y = 20}
10 // gdbr-check:$1 = struct_with_destructor::WithDestructor {x: 10, y: 20}
12 // gdb-command:print noDestructor
13 // gdbg-check:$2 = {a = {x = 10, y = 20}, guard = -1}
14 // gdbr-check:$2 = struct_with_destructor::NoDestructorGuarded {a: struct_with_destructor::NoDestructor {x: 10, y: 20}, guard: -1}
16 // gdb-command:print withDestructor
17 // gdbg-check:$3 = {a = {x = 10, y = 20}, guard = -1}
18 // gdbr-check:$3 = struct_with_destructor::WithDestructorGuarded {a: struct_with_destructor::WithDestructor {x: 10, y: 20}, guard: -1}
20 // gdb-command:print nested
21 // gdbg-check:$4 = {a = {a = {x = 7890, y = 9870}}}
22 // gdbr-check:$4 = struct_with_destructor::NestedOuter {a: struct_with_destructor::NestedInner {a: struct_with_destructor::WithDestructor {x: 7890, y: 9870}}}
25 // === LLDB TESTS ==================================================================================
28 // lldb-command:print simple
29 // lldbg-check:[...]$0 = { x = 10 y = 20 }
30 // lldbr-check:(struct_with_destructor::WithDestructor) simple = { x = 10 y = 20 }
32 // lldb-command:print noDestructor
33 // lldbg-check:[...]$1 = { a = { x = 10 y = 20 } guard = -1 }
34 // lldbr-check:(struct_with_destructor::NoDestructorGuarded) noDestructor = { a = { x = 10 y = 20 } guard = -1 }
36 // lldb-command:print withDestructor
37 // lldbg-check:[...]$2 = { a = { x = 10 y = 20 } guard = -1 }
38 // lldbr-check:(struct_with_destructor::WithDestructorGuarded) withDestructor = { a = { x = 10 y = 20 } guard = -1 }
40 // lldb-command:print nested
41 // lldbg-check:[...]$3 = { a = { a = { x = 7890 y = 9870 } } }
42 // lldbr-check:(struct_with_destructor::NestedOuter) nested = { a = { a = { x = 7890 y = 9870 } } }
44 #![allow(unused_variables)]
45 #![feature(omit_gdb_pretty_printer_section)]
46 #![omit_gdb_pretty_printer_section]
53 struct WithDestructor {
58 impl Drop for WithDestructor {
62 struct NoDestructorGuarded {
67 struct WithDestructorGuarded {
76 impl Drop for NestedInner {
85 // The compiler adds a 'destructed' boolean field to structs implementing Drop. This field is used
86 // at runtime to prevent drop() to be executed more than once.
87 // This field must be incorporated by the debug info generation. Otherwise the debugger assumes a
88 // wrong size/layout for the struct.
91 let simple = WithDestructor { x: 10, y: 20 };
93 let noDestructor = NoDestructorGuarded {
94 a: NoDestructor { x: 10, y: 20 },
98 // If the destructor flag field is not incorporated into the debug info for 'WithDestructor'
99 // then the debugger will have an invalid offset for the field 'guard' and thus should not be
100 // able to read its value correctly (dots are padding bytes, D is the boolean destructor flag):
104 // NoDestructorGuarded = 0000....00000000FFFFFFFF
105 // <--------------><------>
106 // NoDestructor guard
109 // withDestructorGuarded = 0000....00000000D.......FFFFFFFF
110 // <--------------><------> // How debug info says it is
111 // WithDestructor guard
113 // <----------------------><------> // How it actually is
114 // WithDestructor guard
118 // NoDestructorGuarded = 000000000000FFFFFFFF
119 // <----------><------>
120 // NoDestructor guard
123 // withDestructorGuarded = 000000000000D...FFFFFFFF
124 // <----------><------> // How debug info says it is
125 // WithDestructor guard
127 // <--------------><------> // How it actually is
128 // WithDestructor guard
130 let withDestructor = WithDestructorGuarded {
131 a: WithDestructor { x: 10, y: 20 },
135 // expected layout (64 bit) = xxxx....yyyyyyyyD.......D...
136 // <--WithDestructor------>
137 // <-------NestedInner-------->
138 // <-------NestedOuter-------->
139 let nested = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } };