Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0b633c82
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
0b633c82
编写于
1月 26, 2020
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_codegen_ssa: split declare_local into create_dbg_var and dbg_var_addr.
上级
0d34a877
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
79 addition
and
43 deletion
+79
-43
src/librustc_codegen_llvm/builder.rs
src/librustc_codegen_llvm/builder.rs
+1
-0
src/librustc_codegen_llvm/common.rs
src/librustc_codegen_llvm/common.rs
+1
-0
src/librustc_codegen_llvm/debuginfo/mod.rs
src/librustc_codegen_llvm/debuginfo/mod.rs
+51
-33
src/librustc_codegen_ssa/mir/debuginfo.rs
src/librustc_codegen_ssa/mir/debuginfo.rs
+4
-4
src/librustc_codegen_ssa/traits/backend.rs
src/librustc_codegen_ssa/traits/backend.rs
+3
-0
src/librustc_codegen_ssa/traits/builder.rs
src/librustc_codegen_ssa/traits/builder.rs
+1
-1
src/librustc_codegen_ssa/traits/debuginfo.rs
src/librustc_codegen_ssa/traits/debuginfo.rs
+17
-5
src/librustc_codegen_ssa/traits/mod.rs
src/librustc_codegen_ssa/traits/mod.rs
+1
-0
未找到文件。
src/librustc_codegen_llvm/builder.rs
浏览文件 @
0b633c82
...
...
@@ -57,6 +57,7 @@ impl BackendTypes for Builder<'_, 'll, 'tcx> {
type
Funclet
=
<
CodegenCx
<
'll
,
'tcx
>
as
BackendTypes
>
::
Funclet
;
type
DIScope
=
<
CodegenCx
<
'll
,
'tcx
>
as
BackendTypes
>
::
DIScope
;
type
DIVariable
=
<
CodegenCx
<
'll
,
'tcx
>
as
BackendTypes
>
::
DIVariable
;
}
impl
ty
::
layout
::
HasDataLayout
for
Builder
<
'_
,
'_
,
'_
>
{
...
...
src/librustc_codegen_llvm/common.rs
浏览文件 @
0b633c82
...
...
@@ -91,6 +91,7 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
type
Funclet
=
Funclet
<
'll
>
;
type
DIScope
=
&
'll
llvm
::
debuginfo
::
DIScope
;
type
DIVariable
=
&
'll
llvm
::
debuginfo
::
DIVariable
;
}
impl
CodegenCx
<
'll
,
'tcx
>
{
...
...
src/librustc_codegen_llvm/debuginfo/mod.rs
浏览文件 @
0b633c82
...
...
@@ -11,7 +11,7 @@
use
crate
::
llvm
;
use
crate
::
llvm
::
debuginfo
::{
DIArray
,
DIBuilder
,
DIFile
,
DIFlags
,
DILexicalBlock
,
DISPFlags
,
DIScope
,
DIType
,
DIArray
,
DIBuilder
,
DIFile
,
DIFlags
,
DILexicalBlock
,
DISPFlags
,
DIScope
,
DIType
,
DIVariable
,
};
use
rustc
::
middle
::
codegen_fn_attrs
::
CodegenFnAttrFlags
;
use
rustc
::
ty
::
subst
::{
GenericArgKind
,
SubstsRef
};
...
...
@@ -143,33 +143,23 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
};
}
impl
DebugInfoBuilderMethods
<
'tcx
>
for
Builder
<
'a
,
'll
,
'tcx
>
{
fn
declare_local
(
impl
DebugInfoBuilderMethods
for
Builder
<
'a
,
'll
,
'tcx
>
{
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn
dbg_var_addr
(
&
mut
self
,
dbg_context
:
&
FunctionDebugContext
<&
'll
DIScope
>
,
variable_name
:
ast
::
Name
,
variable_type
:
Ty
<
'tcx
>
,
dbg_var
:
&
'll
DIVariable
,
scope_metadata
:
&
'll
DIScope
,
variable_alloca
:
Self
::
Value
,
direct_offset
:
Size
,
indirect_offsets
:
&
[
Size
],
variable_kind
:
VariableKind
,
span
:
Span
,
)
{
assert
!
(
!
dbg_context
.source_locations_enabled
);
let
cx
=
self
.cx
();
let
file
=
span_start
(
cx
,
span
)
.file
;
let
file_metadata
=
file_metadata
(
cx
,
&
file
.name
,
dbg_context
.defining_crate
);
let
loc
=
span_start
(
cx
,
span
);
let
type_metadata
=
type_metadata
(
cx
,
variable_type
,
span
);
let
(
argument_index
,
dwarf_tag
)
=
match
variable_kind
{
ArgumentVariable
(
index
)
=>
(
index
as
c_uint
,
DW_TAG_arg_variable
),
LocalVariable
=>
(
0
,
DW_TAG_auto_variable
),
};
let
align
=
cx
.align_of
(
variable_type
);
// Convert the direct and indirect offsets to address ops.
let
op_deref
=
||
unsafe
{
llvm
::
LLVMRustDIBuilderCreateOpDeref
()
};
...
...
@@ -188,32 +178,19 @@ fn declare_local(
}
}
let
name
=
SmallCStr
::
new
(
&
variable_name
.as_str
());
let
metadata
=
unsafe
{
llvm
::
LLVMRustDIBuilderCreateVariable
(
DIB
(
cx
),
dwarf_tag
,
scope_metadata
,
name
.as_ptr
(),
file_metadata
,
loc
.line
as
c_uint
,
type_metadata
,
cx
.sess
()
.opts.optimize
!=
config
::
OptLevel
::
No
,
DIFlags
::
FlagZero
,
argument_index
,
align
.bytes
()
as
u32
,
)
};
// FIXME(eddyb) maybe this information could be extracted from `var`,
// to avoid having to pass it down in both places?
source_loc
::
set_debug_location
(
self
,
InternalDebugLocation
::
new
(
scope_metadata
,
loc
.line
,
loc
.col
.to_usize
()),
);
unsafe
{
let
debug_loc
=
llvm
::
LLVMGetCurrentDebugLocation
(
self
.llbuilder
);
// FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
let
instr
=
llvm
::
LLVMRustDIBuilderInsertDeclareAtEnd
(
DIB
(
cx
),
variable_alloca
,
metadata
,
dbg_var
,
addr_ops
.as_ptr
(),
addr_ops
.len
()
as
c_uint
,
debug_loc
,
...
...
@@ -558,4 +535,45 @@ fn extend_scope_to_file(
fn
debuginfo_finalize
(
&
self
)
{
finalize
(
self
)
}
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn
create_dbg_var
(
&
self
,
dbg_context
:
&
FunctionDebugContext
<&
'll
DIScope
>
,
variable_name
:
ast
::
Name
,
variable_type
:
Ty
<
'tcx
>
,
scope_metadata
:
&
'll
DIScope
,
variable_kind
:
VariableKind
,
span
:
Span
,
)
->
&
'll
DIVariable
{
let
file
=
span_start
(
self
,
span
)
.file
;
let
file_metadata
=
file_metadata
(
self
,
&
file
.name
,
dbg_context
.defining_crate
);
let
loc
=
span_start
(
self
,
span
);
let
type_metadata
=
type_metadata
(
self
,
variable_type
,
span
);
let
(
argument_index
,
dwarf_tag
)
=
match
variable_kind
{
ArgumentVariable
(
index
)
=>
(
index
as
c_uint
,
DW_TAG_arg_variable
),
LocalVariable
=>
(
0
,
DW_TAG_auto_variable
),
};
let
align
=
self
.align_of
(
variable_type
);
let
name
=
SmallCStr
::
new
(
&
variable_name
.as_str
());
unsafe
{
llvm
::
LLVMRustDIBuilderCreateVariable
(
DIB
(
self
),
dwarf_tag
,
scope_metadata
,
name
.as_ptr
(),
file_metadata
,
loc
.line
as
c_uint
,
type_metadata
,
self
.sess
()
.opts.optimize
!=
config
::
OptLevel
::
No
,
DIFlags
::
FlagZero
,
argument_index
,
align
.bytes
()
as
u32
,
)
}
}
}
src/librustc_codegen_ssa/mir/debuginfo.rs
浏览文件 @
0b633c82
...
...
@@ -226,15 +226,15 @@ pub fn debug_introduce_local(&self, bx: &mut Bx, local: mir::Local) {
let
(
scope
,
span
)
=
self
.debug_loc
(
var
.source_info
);
if
let
Some
(
scope
)
=
scope
{
bx
.declare_local
(
let
dbg_var
=
bx
.create_dbg_var
(
debug_context
,
var
.name
,
layout
.ty
,
scope
,
kind
,
span
);
bx
.dbg_var_addr
(
debug_context
,
var
.name
,
layout
.ty
,
dbg_var
,
scope
,
base
.llval
,
direct_offset
,
&
indirect_offsets
,
kind
,
span
,
);
}
...
...
src/librustc_codegen_ssa/traits/backend.rs
浏览文件 @
0b633c82
...
...
@@ -21,7 +21,10 @@ pub trait BackendTypes {
type
Type
:
CodegenObject
;
type
Funclet
;
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `Dbg`, `Debug`, `DebugInfo`, `DI` etc.).
type
DIScope
:
Copy
;
type
DIVariable
:
Copy
;
}
pub
trait
Backend
<
'tcx
>
:
...
...
src/librustc_codegen_ssa/traits/builder.rs
浏览文件 @
0b633c82
...
...
@@ -28,7 +28,7 @@ pub enum OverflowOp {
pub
trait
BuilderMethods
<
'a
,
'tcx
>
:
HasCodegen
<
'tcx
>
+
DebugInfoBuilderMethods
<
'tcx
>
+
DebugInfoBuilderMethods
+
ArgAbiMethods
<
'tcx
>
+
AbiBuilderMethods
<
'tcx
>
+
IntrinsicCallMethods
<
'tcx
>
...
...
src/librustc_codegen_ssa/traits/debuginfo.rs
浏览文件 @
0b633c82
...
...
@@ -30,20 +30,32 @@ fn extend_scope_to_file(
defining_crate
:
CrateNum
,
)
->
Self
::
DIScope
;
fn
debuginfo_finalize
(
&
self
);
}
pub
trait
DebugInfoBuilderMethods
<
'tcx
>
:
BackendTypes
{
fn
declare_local
(
&
mut
self
,
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn
create_dbg_var
(
&
self
,
dbg_context
:
&
FunctionDebugContext
<
Self
::
DIScope
>
,
variable_name
:
Name
,
variable_type
:
Ty
<
'tcx
>
,
scope_metadata
:
Self
::
DIScope
,
variable_kind
:
VariableKind
,
span
:
Span
,
)
->
Self
::
DIVariable
;
}
pub
trait
DebugInfoBuilderMethods
:
BackendTypes
{
// FIXME(eddyb) find a common convention for all of the debuginfo-related
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
fn
dbg_var_addr
(
&
mut
self
,
dbg_context
:
&
FunctionDebugContext
<
Self
::
DIScope
>
,
dbg_var
:
Self
::
DIVariable
,
scope_metadata
:
Self
::
DIScope
,
variable_alloca
:
Self
::
Value
,
direct_offset
:
Size
,
// NB: each offset implies a deref (i.e. they're steps in a pointer chain).
indirect_offsets
:
&
[
Size
],
variable_kind
:
VariableKind
,
span
:
Span
,
);
fn
set_source_location
(
...
...
src/librustc_codegen_ssa/traits/mod.rs
浏览文件 @
0b633c82
...
...
@@ -93,5 +93,6 @@ pub trait HasCodegen<'tcx>:
Type
=
Self
::
Type
,
Funclet
=
Self
::
Funclet
,
DIScope
=
Self
::
DIScope
,
DIVariable
=
Self
::
DIVariable
,
>
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录