Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7464a29a
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,发现更多精彩内容 >>
提交
7464a29a
编写于
12月 05, 2014
作者:
C
Corey Richardson
浏览文件
操作
浏览文件
下载
差异文件
rollup merge of #19474: luqmana/fl
Fixes #19339.
上级
6f173cdb
89d09953
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
9 deletion
+37
-9
src/etc/gdb_rust_pretty_printing.py
src/etc/gdb_rust_pretty_printing.py
+11
-5
src/etc/lldb_rust_formatters.py
src/etc/lldb_rust_formatters.py
+7
-2
src/test/debuginfo/gdb-pretty-struct-and-enums.rs
src/test/debuginfo/gdb-pretty-struct-and-enums.rs
+10
-2
src/test/debuginfo/option-like-enum.rs
src/test/debuginfo/option-like-enum.rs
+9
-0
未找到文件。
src/etc/gdb_rust_pretty_printing.py
浏览文件 @
7464a29a
...
...
@@ -54,13 +54,14 @@ def rust_pretty_printer_lookup_function(val):
return
RustStructPrinter
(
val
,
false
)
if
enum_member_count
==
1
:
if
enum_members
[
0
].
name
==
None
:
first_variant_name
=
enum_members
[
0
].
name
if
first_variant_name
==
None
:
# This is a singleton enum
return
rust_pretty_printer_lookup_function
(
val
[
enum_members
[
0
]])
else
:
assert
enum_members
[
0
].
name
.
startswith
(
"RUST$ENCODED$ENUM$"
)
assert
first_variant_
name
.
startswith
(
"RUST$ENCODED$ENUM$"
)
# This is a space-optimized enum
last_separator_index
=
enum_members
[
0
].
name
.
rfind
(
"$"
)
last_separator_index
=
first_variant_
name
.
rfind
(
"$"
)
second_last_separator_index
=
first_variant_name
.
rfind
(
"$"
,
0
,
last_separator_index
)
disr_field_index
=
first_variant_name
[
second_last_separator_index
+
1
:
last_separator_index
]
...
...
@@ -68,7 +69,12 @@ def rust_pretty_printer_lookup_function(val):
sole_variant_val
=
val
[
enum_members
[
0
]]
disr_field
=
get_field_at_index
(
sole_variant_val
,
disr_field_index
)
discriminant
=
int
(
sole_variant_val
[
disr_field
])
discriminant
=
sole_variant_val
[
disr_field
]
# If the discriminant field is a fat pointer we have to consider the
# first word as the true discriminant
if
discriminant
.
type
.
code
==
gdb
.
TYPE_CODE_STRUCT
:
discriminant
=
discriminant
[
get_field_at_index
(
discriminant
,
0
)]
if
discriminant
==
0
:
null_variant_name
=
first_variant_name
[
last_separator_index
+
1
:]
...
...
@@ -173,7 +179,7 @@ class RustCStyleEnumPrinter:
class
IdentityPrinter
:
def
__init__
(
self
,
string
):
self
.
string
self
.
string
=
string
def
to_string
(
self
):
return
self
.
string
...
...
src/etc/lldb_rust_formatters.py
浏览文件 @
7464a29a
...
...
@@ -138,9 +138,14 @@ def print_enum_val(val, internal_dict):
return
"<invalid enum encoding: %s>"
%
first_variant_name
# Read the discriminant
disr_val
=
val
.
GetChildAtIndex
(
0
).
GetChildAtIndex
(
disr_field_index
)
.
GetValueAsUnsigned
()
disr_val
=
val
.
GetChildAtIndex
(
0
).
GetChildAtIndex
(
disr_field_index
)
if
disr_val
==
0
:
# If the discriminant field is a fat pointer we have to consider the
# first word as the true discriminant
if
disr_val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
:
disr_val
=
disr_val
.
GetChildAtIndex
(
0
)
if
disr_val
.
GetValueAsUnsigned
()
==
0
:
# Null case: Print the name of the null-variant
null_variant_name
=
first_variant_name
[
last_separator_index
+
1
:]
return
null_variant_name
...
...
src/test/debuginfo/gdb-pretty-struct-and-enums.rs
浏览文件 @
7464a29a
...
...
@@ -58,11 +58,17 @@
// gdb-command: print none
// gdb-check:$12 = None
// gdb-command: print some_fat
// gdb-check:$13 = Some = {"abc"}
// gdb-command: print none_fat
// gdb-check:$14 = None
// gdb-command: print nested_variant1
// gdb-check:$1
3
= NestedVariant1 = {NestedStruct = {regular_struct = RegularStruct = {the_first_field = 111, the_second_field = 112.5, the_third_field = true, the_fourth_field = "NestedStructString1"}, tuple_struct = TupleStruct = {113.5, 114}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar2, mixed_enum = MixedEnumTupleVar = {115, 116, false}}}
// gdb-check:$1
5
= NestedVariant1 = {NestedStruct = {regular_struct = RegularStruct = {the_first_field = 111, the_second_field = 112.5, the_third_field = true, the_fourth_field = "NestedStructString1"}, tuple_struct = TupleStruct = {113.5, 114}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar2, mixed_enum = MixedEnumTupleVar = {115, 116, false}}}
// gdb-command: print nested_variant2
// gdb-check:$1
4
= NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}}
// gdb-check:$1
6
= NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}}
use
self
::
CStyleEnum
::{
CStyleEnumVar1
,
CStyleEnumVar2
,
CStyleEnumVar3
};
use
self
::
MixedEnum
::{
MixedEnumCStyleVar
,
MixedEnumTupleVar
,
MixedEnumStructVar
};
...
...
@@ -129,6 +135,8 @@ fn main() {
let
some
=
Some
(
110u
);
let
none
:
Option
<
int
>
=
None
;
let
some_fat
=
Some
(
"abc"
);
let
none_fat
:
Option
<&
'static
str
>
=
None
;
let
nested_variant1
=
NestedVariant1
(
NestedStruct
{
...
...
src/test/debuginfo/option-like-enum.rs
浏览文件 @
7464a29a
...
...
@@ -61,6 +61,12 @@
// lldb-command:print void_droid
// lldb-check:[...]$5 = Void
// lldb-command:print some_str
// lldb-check:[...]$6 = Some(&str { data_ptr: [...], length: 3 })
// lldb-command:print none_str
// lldb-check:[...]$7 = None
// If a struct has exactly two variants, one of them is empty, and the other one
// contains a non-nullable pointer, then this value is used as the discriminator.
...
...
@@ -96,6 +102,9 @@ struct NamedFieldsRepr<'a> {
fn
main
()
{
let
some_str
:
Option
<&
'static
str
>
=
Some
(
"abc"
);
let
none_str
:
Option
<&
'static
str
>
=
None
;
let
some
:
Option
<&
u32
>
=
Some
(
unsafe
{
std
::
mem
::
transmute
(
0x12345678u
)
});
let
none
:
Option
<&
u32
>
=
None
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录