Skip to content

Commit 7af2e6e

Browse files
debuginfo: Fixed unique pointers to data containing managed pointers.
1 parent e0108a4 commit 7af2e6e

File tree

2 files changed

+67
-9
lines changed

2 files changed

+67
-9
lines changed

src/librustc/middle/trans/debuginfo.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,15 +1137,7 @@ fn get_or_create_type_metadata(cx: &mut CrateContext,
11371137
create_enum_metadata(cx, t, def_id, substs, span)
11381138
},
11391139
ty::ty_box(ref mt) => {
1140-
let content_llvm_type = type_of::type_of(cx, mt.ty);
1141-
let content_type_metadata = get_or_create_type_metadata(cx, mt.ty, span);
1142-
1143-
let box_metadata = create_boxed_type_metadata(cx,
1144-
content_llvm_type,
1145-
content_type_metadata,
1146-
span);
1147-
1148-
create_pointer_type_metadata(cx, t, box_metadata)
1140+
create_pointer_to_box_metadata(cx, t, mt.ty)
11491141
},
11501142
ty::ty_evec(ref mt, ref vstore) => {
11511143
match *vstore {
@@ -1162,6 +1154,9 @@ fn get_or_create_type_metadata(cx: &mut CrateContext,
11621154
}
11631155
}
11641156
},
1157+
ty::ty_uniq(ref mt) if ty::type_contents(cx.tcx, mt.ty).contains_managed() => {
1158+
create_pointer_to_box_metadata(cx, t, mt.ty)
1159+
},
11651160
ty::ty_uniq(ref mt) |
11661161
ty::ty_ptr(ref mt) |
11671162
ty::ty_rptr(_, ref mt) => {
@@ -1193,6 +1188,24 @@ fn get_or_create_type_metadata(cx: &mut CrateContext,
11931188

11941189
dbg_cx(cx).created_types.insert(type_id, type_metadata);
11951190
return type_metadata;
1191+
1192+
1193+
fn create_pointer_to_box_metadata(cx: &mut CrateContext,
1194+
pointer_type: ty::t,
1195+
type_in_box: ty::t)
1196+
-> DIType {
1197+
let content_llvm_type = type_of::type_of(cx, type_in_box);
1198+
let content_type_metadata = get_or_create_type_metadata(cx,
1199+
type_in_box,
1200+
codemap::dummy_sp());
1201+
1202+
let box_metadata = create_boxed_type_metadata(cx,
1203+
content_llvm_type,
1204+
content_type_metadata,
1205+
codemap::dummy_sp());
1206+
1207+
create_pointer_type_metadata(cx, pointer_type, box_metadata)
1208+
}
11961209
}
11971210

11981211
fn set_debug_location(cx: @mut CrateContext, scope: DIScope, line: uint, col: uint) {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright 2013 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.
4+
//
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.
10+
11+
// compile-flags:-Z extra-debug-info
12+
// debugger:set print pretty off
13+
// debugger:break zzz
14+
// debugger:run
15+
// debugger:finish
16+
17+
// debugger:print *ordinary_unique
18+
// check:$1 = {-1, -2}
19+
20+
// debugger:print managed_within_unique.val->x
21+
// check:$2 = -3
22+
23+
// debugger:print managed_within_unique.val->y->val
24+
// check:$3 = -4
25+
26+
struct ContainsManaged
27+
{
28+
x: int,
29+
y: @int
30+
}
31+
32+
fn main() {
33+
34+
let ordinary_unique = ~(-1, -2);
35+
36+
37+
// This is a special case: Normally values allocated in the exchange heap are not boxed, unless,
38+
// however, if they contain managed pointers.
39+
// This test case verifies that both cases are handled correctly.
40+
let managed_within_unique = ~ContainsManaged { x: -3, y: @-4 };
41+
42+
zzz();
43+
}
44+
45+
fn zzz() {()}

0 commit comments

Comments
 (0)