2014-02-07 13:08:32 -06:00
|
|
|
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
2013-06-21 05:09:30 -05:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-02-07 13:08:32 -06:00
|
|
|
// ignore-android: FIXME(#10381)
|
2013-12-13 17:45:08 -06:00
|
|
|
|
2014-02-06 21:57:09 -06:00
|
|
|
// compile-flags:-g
|
2013-09-06 09:00:08 -05:00
|
|
|
// debugger:rbreak zzz
|
2013-06-21 05:09:30 -05:00
|
|
|
// debugger:run
|
|
|
|
// debugger:finish
|
|
|
|
// debugger:print simple
|
|
|
|
// check:$1 = {x = 10, y = 20}
|
|
|
|
|
|
|
|
// debugger:print noDestructor
|
|
|
|
// check:$2 = {a = {x = 10, y = 20}, guard = -1}
|
|
|
|
|
|
|
|
// debugger:print withDestructor
|
|
|
|
// check:$3 = {a = {x = 10, y = 20}, guard = -1}
|
|
|
|
|
2013-07-01 05:11:29 -05:00
|
|
|
// debugger:print nested
|
|
|
|
// check:$4 = {a = {a = {x = 7890, y = 9870}}}
|
|
|
|
|
2014-04-14 10:30:31 -05:00
|
|
|
#![allow(unused_variable)]
|
2013-08-17 10:37:42 -05:00
|
|
|
|
2013-06-21 05:09:30 -05:00
|
|
|
struct NoDestructor {
|
2013-07-16 05:17:55 -05:00
|
|
|
x: i32,
|
|
|
|
y: i64
|
2013-06-21 05:09:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct WithDestructor {
|
2013-07-16 05:17:55 -05:00
|
|
|
x: i32,
|
|
|
|
y: i64
|
2013-06-21 05:09:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for WithDestructor {
|
2013-09-16 20:18:07 -05:00
|
|
|
fn drop(&mut self) {}
|
2013-06-21 05:09:30 -05:00
|
|
|
}
|
|
|
|
|
2013-06-26 15:17:45 -05:00
|
|
|
struct NoDestructorGuarded {
|
2013-06-21 05:09:30 -05:00
|
|
|
a: NoDestructor,
|
|
|
|
guard: i64
|
|
|
|
}
|
|
|
|
|
2013-06-26 15:17:45 -05:00
|
|
|
struct WithDestructorGuarded {
|
2013-06-21 05:09:30 -05:00
|
|
|
a: WithDestructor,
|
|
|
|
guard: i64
|
|
|
|
}
|
|
|
|
|
2013-07-01 05:11:29 -05:00
|
|
|
struct NestedInner {
|
|
|
|
a: WithDestructor
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for NestedInner {
|
2013-09-16 20:18:07 -05:00
|
|
|
fn drop(&mut self) {}
|
2013-07-01 05:11:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct NestedOuter {
|
|
|
|
a: NestedInner
|
|
|
|
}
|
|
|
|
|
2013-06-21 05:09:30 -05:00
|
|
|
|
|
|
|
// The compiler adds a 'destructed' boolean field to structs implementing Drop. This field is used
|
2013-06-27 12:27:06 -05:00
|
|
|
// at runtime to prevent drop() to be executed more than once (see middle::trans::adt).
|
2013-06-21 05:09:30 -05: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 12:27:06 -05:00
|
|
|
// able to read its value correctly (dots are padding bytes, D is the boolean destructor flag):
|
|
|
|
//
|
2013-07-20 03:47:24 -05:00
|
|
|
// 64 bit
|
|
|
|
//
|
2013-06-27 12:27:06 -05: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 03:47:24 -05: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 05:09:30 -05:00
|
|
|
let withDestructor = WithDestructorGuarded {
|
|
|
|
a: WithDestructor { x: 10, y: 20 },
|
|
|
|
guard: -1
|
|
|
|
};
|
|
|
|
|
2013-07-20 03:47:24 -05:00
|
|
|
// expected layout (64 bit) = xxxx....yyyyyyyyD.......D...
|
|
|
|
// <--WithDestructor------>
|
|
|
|
// <-------NestedInner-------->
|
|
|
|
// <-------NestedOuter-------->
|
2013-07-01 05:11:29 -05:00
|
|
|
let nested = NestedOuter { a: NestedInner { a: WithDestructor { x: 7890, y: 9870 } } };
|
|
|
|
|
2013-06-21 05:09:30 -05:00
|
|
|
zzz();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn zzz() {()}
|