Skip to content

Commit 5e040e9

Browse files
debuginfo: Support for by-value arguments (still excluding some cases of self arguments)
1 parent ba101d2 commit 5e040e9

File tree

4 files changed

+99
-5
lines changed

4 files changed

+99
-5
lines changed

src/librustc/lib/llvm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,12 @@ pub mod llvm {
21022102
ArgNo: c_uint)
21032103
-> ValueRef;
21042104

2105+
#[fast_ffi]
2106+
pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef;
2107+
2108+
#[fast_ffi]
2109+
pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef;
2110+
21052111
pub fn LLVMInitializeX86TargetInfo();
21062112
pub fn LLVMInitializeX86Target();
21072113
pub fn LLVMInitializeX86TargetMC();

src/librustc/middle/trans/debuginfo.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,18 @@ pub fn create_self_argument_metadata(bcx: @mut Block,
333333
argument_index
334334
};
335335

336+
let variable_access = if unsafe { llvm::LLVMIsAAllocaInst(llptr) } != ptr::null() {
337+
DirectVariable
338+
} else {
339+
IndirectVariable
340+
};
341+
336342
declare_local(bcx,
337343
llptr,
338344
special_idents::self_,
339345
type_of_self,
340346
scope_metadata,
341-
DirectVariable,
347+
variable_access,
342348
ArgumentVariable(argument_index),
343349
span);
344350
}
@@ -371,6 +377,12 @@ pub fn create_argument_metadata(bcx: @mut Block,
371377
}
372378
};
373379

380+
let variable_access = if unsafe { llvm::LLVMIsAAllocaInst(llptr) } != ptr::null() {
381+
DirectVariable
382+
} else {
383+
IndirectVariable
384+
};
385+
374386
let argument_type = node_id_type(bcx, node_id);
375387
let argument_ident = ast_util::path_to_ident(path_ref);
376388

@@ -386,7 +398,7 @@ pub fn create_argument_metadata(bcx: @mut Block,
386398
argument_ident,
387399
argument_type,
388400
scope_metadata,
389-
DirectVariable,
401+
variable_access,
390402
ArgumentVariable(argument_index),
391403
span);
392404
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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:break zzz
13+
// debugger:run
14+
15+
// debugger:finish
16+
// debugger:print self
17+
// check:$1 = 1111
18+
// debugger:continue
19+
20+
// debugger:finish
21+
// debugger:print self
22+
// check:$2 = {x = 2222, y = 3333}
23+
// debugger:continue
24+
25+
// debugger:finish
26+
// debugger:print self
27+
// check:$3 = {4444.5, 5555, 6666, 7777.5}
28+
// debugger:continue
29+
30+
// debugger:finish
31+
// debugger:print self->val
32+
// check:$4 = 8888
33+
// debugger:continue
34+
35+
trait Trait {
36+
fn method(self) -> Self;
37+
}
38+
39+
impl Trait for int {
40+
fn method(self) -> int {
41+
zzz();
42+
self
43+
}
44+
}
45+
46+
struct Struct {
47+
x: uint,
48+
y: uint,
49+
}
50+
51+
impl Trait for Struct {
52+
fn method(self) -> Struct {
53+
zzz();
54+
self
55+
}
56+
}
57+
58+
impl Trait for (float, int, int, float) {
59+
fn method(self) -> (float, int, int, float) {
60+
zzz();
61+
self
62+
}
63+
}
64+
65+
impl Trait for @int {
66+
fn method(self) -> @int {
67+
zzz();
68+
self
69+
}
70+
}
71+
72+
fn main() {
73+
let _ = (1111 as int).method();
74+
let _ = Struct { x: 2222, y: 3333 }.method();
75+
let _ = (4444.5, 5555, 6666, 7777.5).method();
76+
let _ = (@8888).method();
77+
}
78+
79+
fn zzz() {()}

src/test/debug-info/by-value-struct-argument.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Does not work yet, see issue #8512
12-
// xfail-test
13-
1411
// compile-flags:-Z extra-debug-info
1512
// debugger:break zzz
1613
// debugger:run

0 commit comments

Comments
 (0)