From 30375ccb303807223dac67a74a0a0f6a3c37263f Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 28 Aug 2013 17:47:31 +0200 Subject: [PATCH] debuginfo: Support for by-value arguments (still excluding some cases of self arguments) --- src/librustc/lib/llvm.rs | 6 ++ src/librustc/middle/trans/debuginfo.rs | 16 +++- .../by-value-self-argument-in-trait-impl.rs | 79 +++++++++++++++++++ .../debug-info/by-value-struct-argument.rs | 3 - 4 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 src/test/debug-info/by-value-self-argument-in-trait-impl.rs diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 7903e6f02fa..9e81ee5e64c 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -2103,6 +2103,12 @@ pub fn LLVMDIBuilderCreateComplexVariable(Builder: DIBuilderRef, ArgNo: c_uint) -> ValueRef; + #[fast_ffi] + pub fn LLVMIsAArgument(value_ref: ValueRef) -> ValueRef; + + #[fast_ffi] + pub fn LLVMIsAAllocaInst(value_ref: ValueRef) -> ValueRef; + pub fn LLVMInitializeX86TargetInfo(); pub fn LLVMInitializeX86Target(); pub fn LLVMInitializeX86TargetMC(); diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 049dee6bfea..70eb54313ca 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -333,12 +333,18 @@ pub fn create_self_argument_metadata(bcx: @mut Block, argument_index }; + let variable_access = if unsafe { llvm::LLVMIsAAllocaInst(llptr) } != ptr::null() { + DirectVariable + } else { + IndirectVariable + }; + declare_local(bcx, llptr, special_idents::self_, type_of_self, scope_metadata, - DirectVariable, + variable_access, ArgumentVariable(argument_index), span); } @@ -371,6 +377,12 @@ pub fn create_argument_metadata(bcx: @mut Block, } }; + let variable_access = if unsafe { llvm::LLVMIsAAllocaInst(llptr) } != ptr::null() { + DirectVariable + } else { + IndirectVariable + }; + let argument_type = node_id_type(bcx, node_id); let argument_ident = ast_util::path_to_ident(path_ref); @@ -386,7 +398,7 @@ pub fn create_argument_metadata(bcx: @mut Block, argument_ident, argument_type, scope_metadata, - DirectVariable, + variable_access, ArgumentVariable(argument_index), span); } diff --git a/src/test/debug-info/by-value-self-argument-in-trait-impl.rs b/src/test/debug-info/by-value-self-argument-in-trait-impl.rs new file mode 100644 index 00000000000..6e381c74a33 --- /dev/null +++ b/src/test/debug-info/by-value-self-argument-in-trait-impl.rs @@ -0,0 +1,79 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags:-Z extra-debug-info +// debugger:break zzz +// debugger:run + +// debugger:finish +// debugger:print self +// check:$1 = 1111 +// debugger:continue + +// debugger:finish +// debugger:print self +// check:$2 = {x = 2222, y = 3333} +// debugger:continue + +// debugger:finish +// debugger:print self +// check:$3 = {4444.5, 5555, 6666, 7777.5} +// debugger:continue + +// debugger:finish +// debugger:print self->val +// check:$4 = 8888 +// debugger:continue + +trait Trait { + fn method(self) -> Self; +} + +impl Trait for int { + fn method(self) -> int { + zzz(); + self + } +} + +struct Struct { + x: uint, + y: uint, +} + +impl Trait for Struct { + fn method(self) -> Struct { + zzz(); + self + } +} + +impl Trait for (float, int, int, float) { + fn method(self) -> (float, int, int, float) { + zzz(); + self + } +} + +impl Trait for @int { + fn method(self) -> @int { + zzz(); + self + } +} + +fn main() { + let _ = (1111 as int).method(); + let _ = Struct { x: 2222, y: 3333 }.method(); + let _ = (4444.5, 5555, 6666, 7777.5).method(); + let _ = (@8888).method(); +} + +fn zzz() {()} diff --git a/src/test/debug-info/by-value-struct-argument.rs b/src/test/debug-info/by-value-struct-argument.rs index 052b3c6994a..73bd805a6f4 100644 --- a/src/test/debug-info/by-value-struct-argument.rs +++ b/src/test/debug-info/by-value-struct-argument.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Does not work yet, see issue #8512 -// xfail-test - // compile-flags:-Z extra-debug-info // debugger:break zzz // debugger:run -- GitLab