1 // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // ignore-android: FIXME(#10381)
12 // min-lldb-version: 310
16 // === GDB TESTS ===================================================================================
19 // gdb-command:print simple
20 // gdb-check:$1 = {x = 10, y = 20}
22 // gdb-command:print noDestructor
23 // gdb-check:$2 = {a = {x = 10, y = 20}, guard = -1}
25 // gdb-command:print withDestructor
26 // gdb-check:$3 = {a = {x = 10, y = 20}, guard = -1}
28 // gdb-command:print nested
29 // gdb-check:$4 = {a = {a = {x = 7890, y = 9870}}}
32 // === LLDB TESTS ==================================================================================
35 // lldb-command:print simple
36 // lldb-check:[...]$0 = WithDestructor { x: 10, y: 20 }
38 // lldb-command:print noDestructor
39 // lldb-check:[...]$1 = NoDestructorGuarded { a: NoDestructor { x: 10, y: 20 }, guard: -1 }
41 // lldb-command:print withDestructor
42 // lldb-check:[...]$2 = WithDestructorGuarded { a: WithDestructor { x: 10, y: 20 }, guard: -1 }
44 // lldb-command:print nested
45 // lldb-check:[...]$3 = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } }
47 #![allow(unused_variables)]
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 (see middle::trans::adt).
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 } } };