force enum DISCR_*
to const u64
to allow for inspection via LLDB's SBTypeStaticField::GetConstantValue()
This commit is contained in:
parent
bc4266ca96
commit
a1191e30b6
3 changed files with 40 additions and 20 deletions
|
@ -73,6 +73,9 @@ const DW_ATE_unsigned: c_uint = 0x07;
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
const DW_ATE_UTF: c_uint = 0x10;
|
const DW_ATE_UTF: c_uint = 0x10;
|
||||||
|
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
const DW_TAG_const_type: c_uint = 0x26;
|
||||||
|
|
||||||
pub(super) const UNKNOWN_LINE_NUMBER: c_uint = 0;
|
pub(super) const UNKNOWN_LINE_NUMBER: c_uint = 0;
|
||||||
pub(super) const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
|
pub(super) const UNKNOWN_COLUMN_NUMBER: c_uint = 0;
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@ use crate::common::{AsCCharPtr, CodegenCx};
|
||||||
use crate::debuginfo::metadata::enums::DiscrResult;
|
use crate::debuginfo::metadata::enums::DiscrResult;
|
||||||
use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId};
|
use crate::debuginfo::metadata::type_map::{self, Stub, UniqueTypeId};
|
||||||
use crate::debuginfo::metadata::{
|
use crate::debuginfo::metadata::{
|
||||||
DINodeCreationResult, NO_GENERICS, NO_SCOPE_METADATA, SmallVec, UNKNOWN_LINE_NUMBER,
|
DINodeCreationResult, DW_TAG_const_type, NO_GENERICS, NO_SCOPE_METADATA, SmallVec,
|
||||||
build_field_di_node, file_metadata, file_metadata_from_def_id, size_and_align_of, type_di_node,
|
UNKNOWN_LINE_NUMBER, build_field_di_node, file_metadata, file_metadata_from_def_id,
|
||||||
unknown_file_metadata, visibility_di_flags,
|
size_and_align_of, type_di_node, unknown_file_metadata, visibility_di_flags,
|
||||||
};
|
};
|
||||||
use crate::debuginfo::utils::DIB;
|
use crate::debuginfo::utils::DIB;
|
||||||
use crate::llvm::debuginfo::{DIFile, DIFlags, DIType};
|
use crate::llvm::debuginfo::{DIFile, DIFlags, DIType};
|
||||||
|
@ -566,8 +566,25 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
||||||
None,
|
None,
|
||||||
));
|
));
|
||||||
|
|
||||||
let build_assoc_const =
|
let build_assoc_const = |name: &str,
|
||||||
|name: &str, type_di_node: &'ll DIType, value: u64, align: Align| unsafe {
|
type_di_node_: &'ll DIType,
|
||||||
|
value: u64,
|
||||||
|
align: Align| unsafe {
|
||||||
|
// FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
|
||||||
|
// problems inspecting other value types. Since DISCR_* is typically only going to be
|
||||||
|
// directly inspected via the debugger visualizer - which compares it to the `tag` value
|
||||||
|
// (whose type is not modified at all) it shouldn't cause any real problems.
|
||||||
|
let (t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
|
||||||
|
(type_di_node_, align.bits() as u32)
|
||||||
|
} else {
|
||||||
|
let ty_u64 = Ty::new_uint(cx.tcx, ty::UintTy::U64);
|
||||||
|
(type_di_node(cx, ty_u64), Align::EIGHT.bits() as u32)
|
||||||
|
};
|
||||||
|
|
||||||
|
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
|
||||||
|
let field_type =
|
||||||
|
llvm::LLVMRustDIBuilderCreateQualifiedType(DIB(cx), DW_TAG_const_type, t_di);
|
||||||
|
|
||||||
llvm::LLVMRustDIBuilderCreateStaticMemberType(
|
llvm::LLVMRustDIBuilderCreateStaticMemberType(
|
||||||
DIB(cx),
|
DIB(cx),
|
||||||
wrapper_struct_type_di_node,
|
wrapper_struct_type_di_node,
|
||||||
|
@ -575,10 +592,10 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
||||||
name.len(),
|
name.len(),
|
||||||
unknown_file_metadata(cx),
|
unknown_file_metadata(cx),
|
||||||
UNKNOWN_LINE_NUMBER,
|
UNKNOWN_LINE_NUMBER,
|
||||||
type_di_node,
|
field_type,
|
||||||
DIFlags::FlagZero,
|
DIFlags::FlagZero,
|
||||||
Some(cx.const_u64(value)),
|
Some(cx.const_u64(value)),
|
||||||
align.bits() as u32,
|
align,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1143,8 +1143,8 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticMemberType(
|
||||||
extern "C" LLVMMetadataRef
|
extern "C" LLVMMetadataRef
|
||||||
LLVMRustDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
|
LLVMRustDIBuilderCreateQualifiedType(LLVMDIBuilderRef Builder, unsigned Tag,
|
||||||
LLVMMetadataRef Type) {
|
LLVMMetadataRef Type) {
|
||||||
return wrap(unwrap(Builder)->createQualifiedType(Tag,
|
return wrap(
|
||||||
unwrapDI<DIType>(Type)));
|
unwrap(Builder)->createQualifiedType(Tag, unwrapDI<DIType>(Type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" LLVMMetadataRef
|
extern "C" LLVMMetadataRef
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue