debuginfo: Fixed unique pointers to data containing managed pointers.

This commit is contained in:
Michael Woerister 2013-07-15 12:14:49 +02:00
parent e0108a47ab
commit 7af2e6ee45
2 changed files with 67 additions and 9 deletions

View file

@ -1137,15 +1137,7 @@ fn get_or_create_type_metadata(cx: &mut CrateContext,
create_enum_metadata(cx, t, def_id, substs, span)
},
ty::ty_box(ref mt) => {
let content_llvm_type = type_of::type_of(cx, mt.ty);
let content_type_metadata = get_or_create_type_metadata(cx, mt.ty, span);
let box_metadata = create_boxed_type_metadata(cx,
content_llvm_type,
content_type_metadata,
span);
create_pointer_type_metadata(cx, t, box_metadata)
create_pointer_to_box_metadata(cx, t, mt.ty)
},
ty::ty_evec(ref mt, ref vstore) => {
match *vstore {
@ -1162,6 +1154,9 @@ fn get_or_create_type_metadata(cx: &mut CrateContext,
}
}
},
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).contains_managed() => {
create_pointer_to_box_metadata(cx, t, mt.ty)
},
ty::ty_uniq(ref mt) |
ty::ty_ptr(ref mt) |
ty::ty_rptr(_, ref mt) => {
@ -1193,6 +1188,24 @@ fn get_or_create_type_metadata(cx: &mut CrateContext,
dbg_cx(cx).created_types.insert(type_id, type_metadata);
return type_metadata;
fn create_pointer_to_box_metadata(cx: &mut CrateContext,
pointer_type: ty::t,
type_in_box: ty::t)
-> DIType {
let content_llvm_type = type_of::type_of(cx, type_in_box);
let content_type_metadata = get_or_create_type_metadata(cx,
type_in_box,
codemap::dummy_sp());
let box_metadata = create_boxed_type_metadata(cx,
content_llvm_type,
content_type_metadata,
codemap::dummy_sp());
create_pointer_type_metadata(cx, pointer_type, box_metadata)
}
}
fn set_debug_location(cx: @mut CrateContext, scope: DIScope, line: uint, col: uint) {

View file

@ -0,0 +1,45 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// 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.
// compile-flags:-Z extra-debug-info
// debugger:set print pretty off
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print *ordinary_unique
// check:$1 = {-1, -2}
// debugger:print managed_within_unique.val->x
// check:$2 = -3
// debugger:print managed_within_unique.val->y->val
// check:$3 = -4
struct ContainsManaged
{
x: int,
y: @int
}
fn main() {
let ordinary_unique = ~(-1, -2);
// This is a special case: Normally values allocated in the exchange heap are not boxed, unless,
// however, if they contain managed pointers.
// This test case verifies that both cases are handled correctly.
let managed_within_unique = ~ContainsManaged { x: -3, y: @-4 };
zzz();
}
fn zzz() {()}