mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 09:53:26 +00:00
Set the DICompileUnit emissionKind
This commit is contained in:
parent
75d0bceb0a
commit
cff0750090
@ -13,7 +13,7 @@ use value::Value;
|
||||
|
||||
use llvm;
|
||||
use llvm::debuginfo::{DIArray, DIType, DIFile, DIScope, DIDescriptor,
|
||||
DICompositeType, DILexicalBlock, DIFlags};
|
||||
DICompositeType, DILexicalBlock, DIFlags, DebugEmissionKind};
|
||||
use llvm_util;
|
||||
|
||||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
@ -846,6 +846,7 @@ pub fn compile_unit_metadata(tcx: TyCtxt,
|
||||
let producer = CString::new(producer).unwrap();
|
||||
let flags = "\0";
|
||||
let split_name = "\0";
|
||||
let kind = DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo);
|
||||
|
||||
unsafe {
|
||||
let file_metadata = llvm::LLVMRustDIBuilderCreateFile(
|
||||
@ -859,7 +860,8 @@ pub fn compile_unit_metadata(tcx: TyCtxt,
|
||||
tcx.sess.opts.optimize != config::OptLevel::No,
|
||||
flags.as_ptr() as *const _,
|
||||
0,
|
||||
split_name.as_ptr() as *const _);
|
||||
split_name.as_ptr() as *const _,
|
||||
kind);
|
||||
|
||||
if tcx.sess.opts.debugging_opts.profile {
|
||||
let cu_desc_metadata = llvm::LLVMRustMetadataAsValue(debug_context.llcontext,
|
||||
|
@ -2,7 +2,7 @@ use super::debuginfo::{
|
||||
DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
|
||||
DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
|
||||
DIGlobalVariableExpression, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
|
||||
DINameSpace, DIFlags, DISPFlags,
|
||||
DINameSpace, DIFlags, DISPFlags, DebugEmissionKind,
|
||||
};
|
||||
|
||||
use libc::{c_uint, c_int, size_t, c_char};
|
||||
@ -605,6 +605,26 @@ pub mod debuginfo {
|
||||
const SPFlagOptimized = (1 << 4);
|
||||
}
|
||||
}
|
||||
|
||||
/// LLVMRustDebugEmissionKind
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub enum DebugEmissionKind {
|
||||
NoDebug,
|
||||
FullDebug,
|
||||
LineTablesOnly,
|
||||
}
|
||||
|
||||
impl DebugEmissionKind {
|
||||
pub fn from_generic(kind: rustc::session::config::DebugInfo) -> Self {
|
||||
use rustc::session::config::DebugInfo;
|
||||
match kind {
|
||||
DebugInfo::None => DebugEmissionKind::NoDebug,
|
||||
DebugInfo::Limited => DebugEmissionKind::LineTablesOnly,
|
||||
DebugInfo::Full => DebugEmissionKind::FullDebug,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern { pub type ModuleBuffer; }
|
||||
@ -1381,7 +1401,8 @@ extern "C" {
|
||||
isOptimized: bool,
|
||||
Flags: *const c_char,
|
||||
RuntimeVer: c_uint,
|
||||
SplitName: *const c_char)
|
||||
SplitName: *const c_char,
|
||||
kind: DebugEmissionKind)
|
||||
-> &'a DIDescriptor;
|
||||
|
||||
pub fn LLVMRustDIBuilderCreateFile(Builder: &DIBuilder<'a>,
|
||||
|
@ -576,6 +576,25 @@ static DISubprogram::DISPFlags fromRust(LLVMRustDISPFlags SPFlags) {
|
||||
}
|
||||
#endif
|
||||
|
||||
enum class LLVMRustDebugEmissionKind {
|
||||
NoDebug,
|
||||
FullDebug,
|
||||
LineTablesOnly,
|
||||
};
|
||||
|
||||
static DICompileUnit::DebugEmissionKind fromRust(LLVMRustDebugEmissionKind Kind) {
|
||||
switch (Kind) {
|
||||
case LLVMRustDebugEmissionKind::NoDebug:
|
||||
return DICompileUnit::DebugEmissionKind::NoDebug;
|
||||
case LLVMRustDebugEmissionKind::FullDebug:
|
||||
return DICompileUnit::DebugEmissionKind::FullDebug;
|
||||
case LLVMRustDebugEmissionKind::LineTablesOnly:
|
||||
return DICompileUnit::DebugEmissionKind::LineTablesOnly;
|
||||
default:
|
||||
report_fatal_error("bad DebugEmissionKind.");
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" uint32_t LLVMRustDebugMetadataVersion() {
|
||||
return DEBUG_METADATA_VERSION;
|
||||
}
|
||||
@ -616,11 +635,13 @@ extern "C" void LLVMRustDIBuilderFinalize(LLVMRustDIBuilderRef Builder) {
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
|
||||
LLVMRustDIBuilderRef Builder, unsigned Lang, LLVMMetadataRef FileRef,
|
||||
const char *Producer, bool isOptimized, const char *Flags,
|
||||
unsigned RuntimeVer, const char *SplitName) {
|
||||
unsigned RuntimeVer, const char *SplitName,
|
||||
LLVMRustDebugEmissionKind Kind) {
|
||||
auto *File = unwrapDI<DIFile>(FileRef);
|
||||
|
||||
return wrap(Builder->createCompileUnit(Lang, File, Producer, isOptimized,
|
||||
Flags, RuntimeVer, SplitName));
|
||||
Flags, RuntimeVer, SplitName,
|
||||
fromRust(Kind)));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
|
Loading…
Reference in New Issue
Block a user