Generate better debuginfo for directly tagged enums
This commit is contained in:
parent
1e13a9bb33
commit
f353cbf1a1
@ -1574,7 +1574,7 @@ fn create_member_descriptions(&self, cx: &CodegenCx<'ll, 'tcx>) -> Vec<MemberDes
|
||||
|
||||
MemberDescription {
|
||||
name: if fallback {
|
||||
String::new()
|
||||
format!("Variant{}", i.as_u32())
|
||||
} else {
|
||||
variant_info.variant_name()
|
||||
},
|
||||
@ -1886,8 +1886,9 @@ fn describe_enum_variant(
|
||||
// We have the layout of an enum variant, we need the layout of the outer enum
|
||||
let enum_layout = cx.layout_of(layout.ty);
|
||||
let offset = enum_layout.fields.offset(tag_field.as_usize());
|
||||
let tag_name = if cx.tcx.sess.target.is_like_msvc { "variant$" } else { "RUST$ENUM$DISR" };
|
||||
let args =
|
||||
("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, tag_field.as_usize()).ty);
|
||||
(tag_name.to_owned(), enum_layout.field(cx, tag_field.as_usize()).ty);
|
||||
(Some(offset), Some(args))
|
||||
}
|
||||
_ => (None, None),
|
||||
@ -2062,7 +2063,7 @@ fn prepare_enum_metadata(
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
None,
|
||||
enum_name.as_ptr().cast(),
|
||||
enum_name.len(),
|
||||
file_metadata,
|
||||
@ -2437,7 +2438,7 @@ fn create_union_stub(
|
||||
|
||||
llvm::LLVMRustDIBuilderCreateUnionType(
|
||||
DIB(cx),
|
||||
containing_scope,
|
||||
Some(containing_scope),
|
||||
union_type_name.as_ptr().cast(),
|
||||
union_type_name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
|
@ -2038,7 +2038,7 @@ pub fn LLVMRustDIBuilderCreateEnumerationType(
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateUnionType(
|
||||
Builder: &DIBuilder<'a>,
|
||||
Scope: &'a DIScope,
|
||||
Scope: Option<&'a DIScope>,
|
||||
Name: *const c_char,
|
||||
NameLen: size_t,
|
||||
File: &'a DIFile,
|
||||
|
@ -45,8 +45,16 @@ pub fn push_debuginfo_type_name<'tcx>(
|
||||
ty::Float(float_ty) => output.push_str(float_ty.name_str()),
|
||||
ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
|
||||
ty::Adt(def, substs) => {
|
||||
if def.is_enum() && cpp_like_names {
|
||||
output.push_str("_enum<");
|
||||
}
|
||||
|
||||
push_item_name(tcx, def.did, qualified, output);
|
||||
push_type_params(tcx, substs, output, visited);
|
||||
|
||||
if def.is_enum() && cpp_like_names {
|
||||
output.push('>');
|
||||
}
|
||||
}
|
||||
ty::Tuple(component_types) => {
|
||||
if cpp_like_names {
|
||||
|
@ -149,4 +149,42 @@
|
||||
<Synthetic Name="[...]"><DisplayString>...</DisplayString></Synthetic>
|
||||
</Expand>
|
||||
</Type>
|
||||
<Type Name="_enum<*>">
|
||||
<Intrinsic Name="tag" Expression="Variant0.variant$" />
|
||||
<DisplayString Condition="tag() == 0">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 1" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 2" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 3" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 4" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 5" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 6" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 7" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 8" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 9" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 10" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 11" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 12" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 13" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 14" Optional="true">{tag(),en}</DisplayString>
|
||||
<DisplayString Condition="tag() == 15" Optional="true">{tag(),en}</DisplayString>
|
||||
|
||||
<Expand>
|
||||
<ExpandedItem Condition="tag() == 0">Variant0</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 1" Optional="true">Variant1</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 2" Optional="true">Variant2</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 3" Optional="true">Variant3</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 4" Optional="true">Variant4</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 5" Optional="true">Variant5</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 6" Optional="true">Variant6</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 7" Optional="true">Variant7</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 8" Optional="true">Variant8</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 9" Optional="true">Variant9</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 10" Optional="true">Variant10</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 11" Optional="true">Variant11</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 12" Optional="true">Variant12</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 13" Optional="true">Variant13</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 14" Optional="true">Variant14</ExpandedItem>
|
||||
<ExpandedItem Condition="tag() == 15" Optional="true">Variant15</ExpandedItem>
|
||||
</Expand>
|
||||
</Type>
|
||||
</AutoVisualizer>
|
||||
|
@ -14,14 +14,6 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="core::option::Option<*>">
|
||||
<DisplayString Condition="RUST$ENUM$DISR == 0x0">None</DisplayString>
|
||||
<DisplayString Condition="RUST$ENUM$DISR == 0x1">Some({__0})</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[value]" ExcludeView="simple" Condition="RUST$ENUM$DISR == 1">__0</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="core::option::Option<*>" Priority="MediumLow">
|
||||
<DisplayString Condition="*(void**)this == nullptr">None</DisplayString>
|
||||
<DisplayString>Some({($T1 *)this})</DisplayString>
|
||||
@ -30,15 +22,6 @@
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="core::result::Result<*>">
|
||||
<DisplayString Condition="RUST$ENUM$DISR == 0x0">Ok({__0})</DisplayString>
|
||||
<DisplayString Condition="RUST$ENUM$DISR == 0x1">Err({(*($T2*) &__0)})</DisplayString>
|
||||
<Expand>
|
||||
<Item Name="[value]" Condition="RUST$ENUM$DISR == 0x0">__0</Item>
|
||||
<Item Name="[value]" Condition="RUST$ENUM$DISR == 0x1">(*($T2*) &__0)</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="core::ptr::non_null::NonNull<*>">
|
||||
<DisplayString>{(void*) pointer}</DisplayString>
|
||||
<Expand>
|
||||
|
Loading…
Reference in New Issue
Block a user