Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b81ea865
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b81ea865
编写于
8月 23, 2013
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debuginfo: Support for variables captured in closures and closure type descriptions.
上级
67555d9b
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
559 addition
and
192 deletion
+559
-192
src/librustc/lib/llvm.rs
src/librustc/lib/llvm.rs
+19
-0
src/librustc/middle/moves.rs
src/librustc/middle/moves.rs
+1
-1
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+4
-24
src/librustc/middle/trans/closure.rs
src/librustc/middle/trans/closure.rs
+6
-0
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/common.rs
+1
-1
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/debuginfo.rs
+313
-162
src/libsyntax/ast_map.rs
src/libsyntax/ast_map.rs
+4
-4
src/rustllvm/RustWrapper.cpp
src/rustllvm/RustWrapper.cpp
+36
-0
src/test/debug-info/var-captured-in-managed-closure.rs
src/test/debug-info/var-captured-in-managed-closure.rs
+58
-0
src/test/debug-info/var-captured-in-sendable-closure.rs
src/test/debug-info/var-captured-in-sendable-closure.rs
+56
-0
src/test/debug-info/var-captured-in-stack-closure.rs
src/test/debug-info/var-captured-in-stack-closure.rs
+61
-0
未找到文件。
src/librustc/lib/llvm.rs
浏览文件 @
b81ea865
...
...
@@ -2084,6 +2084,25 @@ pub fn LLVMDIBuilderCreateTemplateTypeParameter(Builder: DIBuilderRef,
ColumnNo
:
c_uint
)
->
ValueRef
;
#[fast_ffi]
pub
fn
LLVMDIBuilderCreateOpDeref
(
IntType
:
TypeRef
)
->
ValueRef
;
#[fast_ffi]
pub
fn
LLVMDIBuilderCreateOpPlus
(
IntType
:
TypeRef
)
->
ValueRef
;
#[fast_ffi]
pub
fn
LLVMDIBuilderCreateComplexVariable
(
Builder
:
DIBuilderRef
,
Tag
:
c_uint
,
Scope
:
ValueRef
,
Name
:
*
c_char
,
File
:
ValueRef
,
LineNo
:
c_uint
,
Ty
:
ValueRef
,
AddrOps
:
*
ValueRef
,
AddrOpsCount
:
c_uint
,
ArgNo
:
c_uint
)
->
ValueRef
;
pub
fn
LLVMInitializeX86TargetInfo
();
pub
fn
LLVMInitializeX86Target
();
pub
fn
LLVMInitializeX86TargetMC
();
...
...
src/librustc/middle/moves.rs
浏览文件 @
b81ea865
...
...
@@ -143,7 +143,7 @@ struct Foo { a: int, b: ~int }
use
syntax
::
visit
::
Visitor
;
use
syntax
::
codemap
::
Span
;
#[deriving(Encodable,
Decodable)]
#[deriving(E
q,
E
ncodable,
Decodable)]
pub
enum
CaptureMode
{
CapCopy
,
// Copy the value into the closure.
CapMove
,
// Move the value into the closure.
...
...
src/librustc/middle/trans/base.rs
浏览文件 @
b81ea865
...
...
@@ -131,20 +131,6 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
_
InsnCtxt
{
_
x
:
()
}
}
fn
fcx_has_nonzero_span
(
fcx
:
&
FunctionContext
)
->
bool
{
match
fcx
.span
{
None
=>
false
,
Some
(
span
)
=>
*
span
.lo
!=
0
||
*
span
.hi
!=
0
}
}
fn
span_is_empty
(
opt_span
:
&
Option
<
Span
>
)
->
bool
{
match
*
opt_span
{
None
=>
true
,
Some
(
span
)
=>
*
span
.lo
==
0
&&
*
span
.hi
==
0
}
}
struct
StatRecorder
<
'self
>
{
ccx
:
@
mut
CrateContext
,
name
:
&
'self
str
,
...
...
@@ -1132,8 +1118,7 @@ pub fn trans_stmt(cx: @mut Block, s: &ast::Stmt) -> @mut Block {
match
d
.node
{
ast
::
DeclLocal
(
ref
local
)
=>
{
bcx
=
init_local
(
bcx
,
*
local
);
if
cx
.sess
()
.opts.extra_debuginfo
&&
fcx_has_nonzero_span
(
bcx
.fcx
)
{
if
cx
.sess
()
.opts.extra_debuginfo
{
debuginfo
::
create_local_var_metadata
(
bcx
,
*
local
);
}
}
...
...
@@ -1633,12 +1618,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
}
};
let
uses_outptr
=
type_of
::
return_uses_outptr
(
ccx
.tcx
,
substd_output_type
);
let
debug_context
=
if
id
!=
-
1
&&
ccx
.sess.opts.debuginfo
&&
!
span_is_empty
(
&
sp
)
{
Some
(
debuginfo
::
create_function_debug_context
(
ccx
,
id
,
param_substs
,
llfndecl
))
}
else
{
None
};
let
debug_context
=
debuginfo
::
create_function_debug_context
(
ccx
,
id
,
param_substs
,
llfndecl
);
let
fcx
=
@
mut
FunctionContext
{
llfn
:
llfndecl
,
...
...
@@ -1784,7 +1764,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
fcx
.llself
=
Some
(
ValSelfData
{
v
:
self_val
,
..
slf
});
add_clean
(
bcx
,
self_val
,
slf
.t
);
if
fcx
.ccx.sess.opts.extra_debuginfo
&&
fcx_has_nonzero_span
(
fcx
)
{
if
fcx
.ccx.sess.opts.extra_debuginfo
{
debuginfo
::
create_self_argument_metadata
(
bcx
,
slf
.t
,
self_val
);
}
}
...
...
@@ -1811,7 +1791,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
};
bcx
=
_
match
::
store_arg
(
bcx
,
args
[
arg_n
]
.pat
,
llarg
);
if
fcx
.ccx.sess.opts.extra_debuginfo
&&
fcx_has_nonzero_span
(
fcx
)
{
if
fcx
.ccx.sess.opts.extra_debuginfo
{
debuginfo
::
create_argument_metadata
(
bcx
,
&
args
[
arg_n
]);
}
}
...
...
src/librustc/middle/trans/closure.rs
浏览文件 @
b81ea865
...
...
@@ -17,6 +17,7 @@
use
middle
::
trans
::
build
::
*
;
use
middle
::
trans
::
common
::
*
;
use
middle
::
trans
::
datum
::{
Datum
,
INIT
};
use
middle
::
trans
::
debuginfo
;
use
middle
::
trans
::
expr
;
use
middle
::
trans
::
glue
;
use
middle
::
trans
::
type_of
::
*
;
...
...
@@ -317,6 +318,11 @@ pub fn load_environment(fcx: @mut FunctionContext,
}
let
def_id
=
ast_util
::
def_id_of_def
(
cap_var
.def
);
fcx
.llupvars
.insert
(
def_id
.node
,
upvarptr
);
if
fcx
.ccx.sess.opts.extra_debuginfo
{
debuginfo
::
create_captured_var_metadata
(
bcx
,
def_id
.node
,
upvarptr
,
cap_var
.span
);
}
i
+=
1u
;
}
}
...
...
src/librustc/middle/trans/common.rs
浏览文件 @
b81ea865
...
...
@@ -228,7 +228,7 @@ pub struct FunctionContext {
ccx
:
@
mut
CrateContext
,
// Used and maintained by the debuginfo module.
debug_context
:
Option
<~
debuginfo
::
FunctionDebugContext
>
debug_context
:
debuginfo
::
FunctionDebugContext
,
}
impl
FunctionContext
{
...
...
src/librustc/middle/trans/debuginfo.rs
浏览文件 @
b81ea865
此差异已折叠。
点击以展开。
src/libsyntax/ast_map.rs
浏览文件 @
b81ea865
...
...
@@ -73,7 +73,7 @@ pub enum ast_node {
node_variant
(
variant
,
@
item
,
@
path
),
node_expr
(
@
Expr
),
node_stmt
(
@
Stmt
),
node_arg
,
node_arg
(
@
pat
)
,
node_local
(
Ident
),
node_block
(
Block
),
node_struct_ctor
(
@
struct_def
,
@
item
,
@
path
),
...
...
@@ -171,7 +171,7 @@ fn map_fn(&mut self,
sp
:
codemap
::
Span
,
id
:
NodeId
)
{
for
a
in
decl
.inputs
.iter
()
{
self
.map
.insert
(
a
.id
,
node_arg
);
self
.map
.insert
(
a
.id
,
node_arg
(
a
.pat
)
);
}
visit
::
walk_fn
(
self
,
fk
,
decl
,
body
,
sp
,
id
,
());
}
...
...
@@ -487,8 +487,8 @@ pub fn node_id_to_str(map: map, id: NodeId, itr: @ident_interner) -> ~str {
fmt!
(
"stmt %s (id=%?)"
,
pprust
::
stmt_to_str
(
stmt
,
itr
),
id
)
}
Some
(
&
node_arg
)
=>
{
fmt!
(
"arg
(id=%?)"
,
id
)
Some
(
&
node_arg
(
pat
)
)
=>
{
fmt!
(
"arg
%s (id=%?)"
,
pprust
::
pat_to_str
(
pat
,
itr
)
,
id
)
}
Some
(
&
node_local
(
ident
))
=>
{
fmt!
(
"local (id=%?, name=%s)"
,
id
,
itr
.get
(
ident
.name
))
...
...
src/rustllvm/RustWrapper.cpp
浏览文件 @
b81ea865
...
...
@@ -724,3 +724,39 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter(
LineNo
,
ColumnNo
));
}
extern
"C"
LLVMValueRef
LLVMDIBuilderCreateOpDeref
(
LLVMTypeRef
IntTy
)
{
return
LLVMConstInt
(
IntTy
,
DIBuilder
::
OpDeref
,
true
);
}
extern
"C"
LLVMValueRef
LLVMDIBuilderCreateOpPlus
(
LLVMTypeRef
IntTy
)
{
return
LLVMConstInt
(
IntTy
,
DIBuilder
::
OpPlus
,
true
);
}
extern
"C"
LLVMValueRef
LLVMDIBuilderCreateComplexVariable
(
DIBuilderRef
Builder
,
unsigned
Tag
,
LLVMValueRef
Scope
,
const
char
*
Name
,
LLVMValueRef
File
,
unsigned
LineNo
,
LLVMValueRef
Ty
,
LLVMValueRef
*
AddrOps
,
unsigned
AddrOpsCount
,
unsigned
ArgNo
)
{
llvm
::
ArrayRef
<
llvm
::
Value
*>
addr_ops
((
llvm
::
Value
**
)
AddrOps
,
AddrOpsCount
);
return
wrap
(
Builder
->
createComplexVariable
(
Tag
,
unwrapDI
<
DIDescriptor
>
(
Scope
),
Name
,
unwrapDI
<
DIFile
>
(
File
),
LineNo
,
unwrapDI
<
DIType
>
(
Ty
),
addr_ops
,
ArgNo
));
}
src/test/debug-info/var-captured-in-managed-closure.rs
0 → 100644
浏览文件 @
b81ea865
// 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.
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print constant
// check:$1 = 1
// debugger:print a_struct
// check:$2 = {a = -2, b = 3.5, c = 4}
// debugger:print *owned
// check:$3 = 5
// debugger:print managed->val
// check:$4 = 6
#[allow(unused_variable)]
;
struct
Struct
{
a
:
int
,
b
:
float
,
c
:
uint
}
fn
main
()
{
let
constant
=
1
;
let
a_struct
=
Struct
{
a
:
-
2
,
b
:
3.5
,
c
:
4
};
let
owned
=
~
5
;
let
managed
=
@
6
;
let
closure
:
@
fn
()
=
||
{
zzz
();
do_something
(
&
constant
,
&
a_struct
.a
,
owned
,
managed
);
};
closure
();
}
fn
do_something
(
_
:
&
int
,
_
:
&
int
,
_
:
&
int
,
_
:
&
int
)
{
}
fn
zzz
()
{()}
src/test/debug-info/var-captured-in-sendable-closure.rs
0 → 100644
浏览文件 @
b81ea865
// 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.
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print constant
// check:$1 = 1
// debugger:print a_struct
// check:$2 = {a = -2, b = 3.5, c = 4}
// debugger:print *owned
// check:$3 = 5
#[allow(unused_variable)]
;
struct
Struct
{
a
:
int
,
b
:
float
,
c
:
uint
}
fn
main
()
{
let
constant
=
1
;
let
a_struct
=
Struct
{
a
:
-
2
,
b
:
3.5
,
c
:
4
};
let
owned
=
~
5
;
let
closure
:
~
fn
()
=
||
{
zzz
();
do_something
(
&
constant
,
&
a_struct
.a
,
owned
);
};
closure
();
}
fn
do_something
(
_
:
&
int
,
_
:
&
int
,
_
:
&
int
)
{
}
fn
zzz
()
{()}
src/test/debug-info/var-captured-in-stack-closure.rs
0 → 100644
浏览文件 @
b81ea865
// 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.
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
// compile-flags:-Z extra-debug-info
// debugger:break zzz
// debugger:run
// debugger:finish
// debugger:print variable
// check:$1 = 1
// debugger:print constant
// check:$2 = 2
// debugger:print a_struct
// check:$3 = {a = -3, b = 4.5, c = 5}
// debugger:print *struct_ref
// check:$4 = {a = -3, b = 4.5, c = 5}
// debugger:print *owned
// check:$5 = 6
// debugger:print managed->val
// check:$6 = 7
#[allow(unused_variable)]
;
struct
Struct
{
a
:
int
,
b
:
float
,
c
:
uint
}
fn
main
()
{
let
mut
variable
=
1
;
let
constant
=
2
;
let
a_struct
=
Struct
{
a
:
-
3
,
b
:
4.5
,
c
:
5
};
let
struct_ref
=
&
a_struct
;
let
owned
=
~
6
;
let
managed
=
@
7
;
let
closure
=
||
{
zzz
();
variable
=
constant
+
a_struct
.a
+
struct_ref
.a
+
*
owned
+
*
managed
;
};
closure
();
}
fn
zzz
()
{()}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录