Use DIBuilder in debuginfo
This commit is contained in:
parent
5f0e494d9d
commit
868f9a88d6
6 changed files with 832 additions and 708 deletions
|
|
@ -224,13 +224,51 @@ pub type SectionIteratorRef = *SectionIterator_opaque;
|
|||
pub enum Pass_opaque {}
|
||||
pub type PassRef = *Pass_opaque;
|
||||
|
||||
pub mod debuginfo {
|
||||
use core::prelude::*;
|
||||
use super::{ValueRef};
|
||||
|
||||
pub enum DIBuilder_opaque {}
|
||||
pub type DIBuilderRef = *DIBuilder_opaque;
|
||||
|
||||
pub type DIDescriptor = ValueRef;
|
||||
pub type DIScope = DIDescriptor;
|
||||
pub type DILocation = DIDescriptor;
|
||||
pub type DIFile = DIScope;
|
||||
pub type DILexicalBlock = DIScope;
|
||||
pub type DISubprogram = DIScope;
|
||||
pub type DIType = DIDescriptor;
|
||||
pub type DIBasicType = DIType;
|
||||
pub type DIDerivedType = DIType;
|
||||
pub type DICompositeType = DIDerivedType;
|
||||
pub type DIVariable = DIDescriptor;
|
||||
pub type DIArray = DIDescriptor;
|
||||
pub type DISubrange = DIDescriptor;
|
||||
|
||||
pub enum DIDescriptorFlags {
|
||||
FlagPrivate = 1 << 0,
|
||||
FlagProtected = 1 << 1,
|
||||
FlagFwdDecl = 1 << 2,
|
||||
FlagAppleBlock = 1 << 3,
|
||||
FlagBlockByrefStruct = 1 << 4,
|
||||
FlagVirtual = 1 << 5,
|
||||
FlagArtificial = 1 << 6,
|
||||
FlagExplicit = 1 << 7,
|
||||
FlagPrototyped = 1 << 8,
|
||||
FlagObjcClassComplete = 1 << 9,
|
||||
FlagObjectPointer = 1 << 10,
|
||||
FlagVector = 1 << 11,
|
||||
FlagStaticMember = 1 << 12
|
||||
}
|
||||
}
|
||||
|
||||
pub mod llvm {
|
||||
use super::{AtomicBinOp, AtomicOrdering, BasicBlockRef, ExecutionEngineRef};
|
||||
use super::{Bool, BuilderRef, ContextRef, MemoryBufferRef, ModuleRef};
|
||||
use super::{ObjectFileRef, Opcode, PassManagerRef, PassManagerBuilderRef};
|
||||
use super::{SectionIteratorRef, TargetDataRef, TypeKind, TypeRef, UseRef};
|
||||
use super::{ValueRef,PassRef};
|
||||
|
||||
use super::{ValueRef, PassRef};
|
||||
use super::debuginfo::*;
|
||||
use core::libc::{c_char, c_int, c_longlong, c_ushort, c_uint, c_ulonglong};
|
||||
|
||||
#[link_args = "-Lrustllvm -lrustllvm"]
|
||||
|
|
@ -1885,6 +1923,149 @@ pub mod llvm {
|
|||
AlignStack: Bool, Dialect: c_uint)
|
||||
-> ValueRef;
|
||||
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_new(M: ModuleRef) -> DIBuilderRef;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_delete(Builder: DIBuilderRef);
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_finalize(Builder: DIBuilderRef);
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createCompileUnit(
|
||||
Builder: DIBuilderRef,
|
||||
Lang: c_uint,
|
||||
File: *c_char,
|
||||
Dir: *c_char,
|
||||
Producer: *c_char,
|
||||
isOptimized: bool,
|
||||
Flags: *c_char,
|
||||
RuntimeVer: c_uint,
|
||||
SplitName: *c_char);
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createFile(
|
||||
Builder: DIBuilderRef,
|
||||
Filename: *c_char,
|
||||
Directory: *c_char) -> DIFile;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createSubroutineType(
|
||||
Builder: DIBuilderRef,
|
||||
File: DIFile,
|
||||
ParameterTypes: DIArray) -> DICompositeType;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createFunction(
|
||||
Builder: DIBuilderRef,
|
||||
Scope: DIDescriptor,
|
||||
Name: *c_char,
|
||||
LinkageName: *c_char,
|
||||
File: DIFile,
|
||||
LineNo: c_uint,
|
||||
Ty: DIType,
|
||||
isLocalToUnit: bool,
|
||||
isDefinition: bool,
|
||||
ScopeLine: c_uint,
|
||||
Flags: c_uint,
|
||||
isOptimized: bool,
|
||||
Fn: ValueRef,
|
||||
TParam: ValueRef,
|
||||
Decl: ValueRef) -> DISubprogram;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createBasicType(
|
||||
Builder: DIBuilderRef,
|
||||
Name: *c_char,
|
||||
SizeInBits: c_ulonglong,
|
||||
AlignInBits: c_ulonglong,
|
||||
Encoding: c_uint) -> DIBasicType;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createPointerType(
|
||||
Builder: DIBuilderRef,
|
||||
PointeeTy: DIType,
|
||||
SizeInBits: c_ulonglong,
|
||||
AlignInBits: c_ulonglong,
|
||||
Name: *c_char) -> DIDerivedType;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createStructType(
|
||||
Builder: DIBuilderRef,
|
||||
Scope: DIDescriptor,
|
||||
Name: *c_char,
|
||||
File: DIFile,
|
||||
LineNumber: c_uint,
|
||||
SizeInBits: c_ulonglong,
|
||||
AlignInBits: c_ulonglong,
|
||||
Flags: c_uint,
|
||||
DerivedFrom: DIType,
|
||||
Elements: DIArray,
|
||||
RunTimeLang: c_uint,
|
||||
VTableHolder: ValueRef) -> DICompositeType;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createMemberType(
|
||||
Builder: DIBuilderRef,
|
||||
Scope: DIDescriptor,
|
||||
Name: *c_char,
|
||||
File: DIFile,
|
||||
LineNo: c_uint,
|
||||
SizeInBits: c_ulonglong,
|
||||
AlignInBits: c_ulonglong,
|
||||
OffsetInBits: c_ulonglong,
|
||||
Flags: c_uint,
|
||||
Ty: DIType) -> DIDerivedType;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createLexicalBlock(
|
||||
Builder: DIBuilderRef,
|
||||
Scope: DIDescriptor,
|
||||
File: DIFile,
|
||||
Line: c_uint,
|
||||
Col: c_uint) -> DILexicalBlock;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createLocalVariable(
|
||||
Builder: DIBuilderRef,
|
||||
Tag: c_uint,
|
||||
Scope: DIDescriptor,
|
||||
Name: *c_char,
|
||||
File: DIFile,
|
||||
LineNo: c_uint,
|
||||
Ty: DIType,
|
||||
AlwaysPreserve: bool,
|
||||
Flags: c_uint,
|
||||
ArgNo: c_uint) -> DIVariable;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_createVectorType(
|
||||
Builder: DIBuilderRef,
|
||||
Size: c_ulonglong,
|
||||
AlignInBits: c_ulonglong,
|
||||
Ty: DIType,
|
||||
Subscripts: DIArray) -> DIType;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_getOrCreateSubrange(
|
||||
Builder: DIBuilderRef,
|
||||
Lo: c_longlong,
|
||||
Count: c_longlong) -> DISubrange;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_getOrCreateArray(
|
||||
Builder: DIBuilderRef,
|
||||
Ptr: *DIDescriptor,
|
||||
Count: c_uint) -> DIArray;
|
||||
|
||||
#[fast_ffi]
|
||||
pub unsafe fn DIBuilder_insertDeclare(
|
||||
Builder: DIBuilderRef,
|
||||
Val: ValueRef,
|
||||
VarInfo: DIVariable,
|
||||
InsertBefore: *c_void) -> *c_void;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3074,6 +3074,7 @@ pub fn trans_crate(sess: session::Session,
|
|||
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
||||
let llmod_id = link_meta.name.to_owned() + ".rc";
|
||||
|
||||
Some(debuginfo::mk_ctxt(llmod, copy llmod_id))
|
||||
// FIXME(#6511): get LLVM building with --enable-threads so this
|
||||
// function can be called
|
||||
// if !llvm::LLVMRustStartMultithreading() {
|
||||
|
|
@ -3102,7 +3103,10 @@ pub fn trans_crate(sess: session::Session,
|
|||
fill_crate_map(ccx, ccx.crate_map);
|
||||
glue::emit_tydescs(ccx);
|
||||
write_abi_version(ccx);
|
||||
|
||||
if ccx.sess.opts.debuginfo {
|
||||
debuginfo::finalize(ccx);
|
||||
}
|
||||
|
||||
// Translate the metadata.
|
||||
write_metadata(ccx, crate);
|
||||
if ccx.sess.trans_stats() {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -560,3 +560,204 @@ extern "C" bool LLVMRustStartMultithreading() {
|
|||
assert(lock.release());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
typedef DIBuilder* DIBuilderRef;
|
||||
|
||||
template<typename DIT>
|
||||
DIT unwrapDI(LLVMValueRef ref) { return DIT(ref ? unwrap<MDNode>(ref) : NULL); }
|
||||
|
||||
extern "C" DIBuilderRef DIBuilder_new(LLVMModuleRef M) {
|
||||
return new DIBuilder(*unwrap(M));
|
||||
}
|
||||
|
||||
extern "C" void DIBuilder_delete(DIBuilderRef Builder) {
|
||||
delete Builder;
|
||||
}
|
||||
|
||||
extern "C" void DIBuilder_finalize(DIBuilderRef Builder) {
|
||||
Builder->finalize();
|
||||
}
|
||||
|
||||
extern "C" void DIBuilder_createCompileUnit(
|
||||
DIBuilderRef Builder,
|
||||
unsigned Lang,
|
||||
const char* File,
|
||||
const char* Dir,
|
||||
const char* Producer,
|
||||
bool isOptimized,
|
||||
const char* Flags,
|
||||
unsigned RuntimeVer,
|
||||
const char* SplitName) {
|
||||
Builder->createCompileUnit(Lang, File, Dir, Producer, isOptimized,
|
||||
Flags, RuntimeVer, SplitName);
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createFile(
|
||||
DIBuilderRef Builder,
|
||||
const char* Filename,
|
||||
const char* Directory) {
|
||||
return wrap(Builder->createFile(Filename, Directory));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createSubroutineType(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef File,
|
||||
LLVMValueRef ParameterTypes) {
|
||||
return wrap(Builder->createSubroutineType(
|
||||
unwrapDI<DIFile>(File),
|
||||
unwrapDI<DIArray>(ParameterTypes)));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createFunction(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef Scope,
|
||||
const char* Name,
|
||||
const char* LinkageName,
|
||||
LLVMValueRef File,
|
||||
unsigned LineNo,
|
||||
LLVMValueRef Ty,
|
||||
bool isLocalToUnit,
|
||||
bool isDefinition,
|
||||
unsigned ScopeLine,
|
||||
unsigned Flags,
|
||||
bool isOptimized,
|
||||
LLVMValueRef Fn,
|
||||
LLVMValueRef TParam,
|
||||
LLVMValueRef Decl) {
|
||||
return wrap(Builder->createFunction(
|
||||
unwrapDI<DIScope>(Scope), Name, LinkageName,
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
unwrapDI<DIType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
|
||||
Flags, isOptimized,
|
||||
unwrap<Function>(Fn),
|
||||
unwrapDI<MDNode*>(TParam),
|
||||
unwrapDI<MDNode*>(Decl)));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createBasicType(
|
||||
DIBuilderRef Builder,
|
||||
const char* Name,
|
||||
uint64_t SizeInBits,
|
||||
uint64_t AlignInBits,
|
||||
unsigned Encoding) {
|
||||
return wrap(Builder->createBasicType(
|
||||
Name, SizeInBits,
|
||||
AlignInBits, Encoding));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createPointerType(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef PointeeTy,
|
||||
uint64_t SizeInBits,
|
||||
uint64_t AlignInBits,
|
||||
const char* Name) {
|
||||
return wrap(Builder->createPointerType(
|
||||
unwrapDI<DIType>(PointeeTy), SizeInBits, AlignInBits, Name));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createStructType(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef Scope,
|
||||
const char* Name,
|
||||
LLVMValueRef File,
|
||||
unsigned LineNumber,
|
||||
uint64_t SizeInBits,
|
||||
uint64_t AlignInBits,
|
||||
unsigned Flags,
|
||||
LLVMValueRef DerivedFrom,
|
||||
LLVMValueRef Elements,
|
||||
unsigned RunTimeLang,
|
||||
LLVMValueRef VTableHolder) {
|
||||
return wrap(Builder->createStructType(
|
||||
unwrapDI<DIDescriptor>(Scope), Name,
|
||||
unwrapDI<DIFile>(File), LineNumber,
|
||||
SizeInBits, AlignInBits, Flags,
|
||||
unwrapDI<DIType>(DerivedFrom),
|
||||
unwrapDI<DIArray>(Elements), RunTimeLang,
|
||||
unwrapDI<MDNode*>(VTableHolder)));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createMemberType(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef Scope,
|
||||
const char* Name,
|
||||
LLVMValueRef File,
|
||||
unsigned LineNo,
|
||||
uint64_t SizeInBits,
|
||||
uint64_t AlignInBits,
|
||||
uint64_t OffsetInBits,
|
||||
unsigned Flags,
|
||||
LLVMValueRef Ty) {
|
||||
return wrap(Builder->createMemberType(
|
||||
unwrapDI<DIDescriptor>(Scope), Name,
|
||||
unwrapDI<DIFile>(File), LineNo,
|
||||
SizeInBits, AlignInBits, OffsetInBits, Flags,
|
||||
unwrapDI<DIType>(Ty)));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createLexicalBlock(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef Scope,
|
||||
LLVMValueRef File,
|
||||
unsigned Line,
|
||||
unsigned Col) {
|
||||
return wrap(Builder->createLexicalBlock(
|
||||
unwrapDI<DIDescriptor>(Scope),
|
||||
unwrapDI<DIFile>(File), Line, Col));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createLocalVariable(
|
||||
DIBuilderRef Builder,
|
||||
unsigned Tag,
|
||||
LLVMValueRef Scope,
|
||||
const char* Name,
|
||||
LLVMValueRef File,
|
||||
unsigned LineNo,
|
||||
LLVMValueRef Ty,
|
||||
bool AlwaysPreserve,
|
||||
unsigned Flags,
|
||||
unsigned ArgNo) {
|
||||
return wrap(Builder->createLocalVariable(Tag,
|
||||
unwrapDI<DIDescriptor>(Scope), Name,
|
||||
unwrapDI<DIFile>(File),
|
||||
LineNo,
|
||||
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_createVectorType(
|
||||
DIBuilderRef Builder,
|
||||
uint64_t Size,
|
||||
uint64_t AlignInBits,
|
||||
LLVMValueRef Ty,
|
||||
LLVMValueRef Subscripts) {
|
||||
return wrap(Builder->createVectorType(Size, AlignInBits,
|
||||
unwrapDI<DIType>(Ty),
|
||||
unwrapDI<DIArray>(Subscripts)));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_getOrCreateSubrange(
|
||||
DIBuilderRef Builder,
|
||||
int64_t Lo,
|
||||
int64_t Count) {
|
||||
return wrap(Builder->getOrCreateSubrange(Lo, Count));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_getOrCreateArray(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef* Ptr,
|
||||
unsigned Count) {
|
||||
return wrap(Builder->getOrCreateArray(
|
||||
ArrayRef<Value*>(reinterpret_cast<Value**>(Ptr), Count)));
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef DIBuilder_insertDeclare(
|
||||
DIBuilderRef Builder,
|
||||
LLVMValueRef Val,
|
||||
LLVMValueRef VarInfo,
|
||||
LLVMValueRef InsertBefore) {
|
||||
return wrap(Builder->insertDeclare(
|
||||
unwrap(Val),
|
||||
unwrapDI<DIVariable>(VarInfo),
|
||||
unwrap<Instruction>(InsertBefore)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -588,3 +588,20 @@ LLVMInlineAsm
|
|||
LLVMInitializePasses
|
||||
LLVMAddPass
|
||||
LLVMCreatePass
|
||||
DIBuilder_new
|
||||
DIBuilder_delete
|
||||
DIBuilder_finalize
|
||||
DIBuilder_createCompileUnit
|
||||
DIBuilder_createLocalVariable
|
||||
DIBuilder_createFunction
|
||||
DIBuilder_createFile
|
||||
DIBuilder_createLexicalBlock
|
||||
DIBuilder_createBasicType
|
||||
DIBuilder_createPointerType
|
||||
DIBuilder_createMemberType
|
||||
DIBuilder_createStructType
|
||||
DIBuilder_getOrCreateSubrange
|
||||
DIBuilder_createVectorType
|
||||
DIBuilder_createSubroutineType
|
||||
DIBuilder_getOrCreateArray
|
||||
DIBuilder_insertDeclare
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@
|
|||
#include "llvm/Transforms/IPO.h"
|
||||
#include "llvm/Transforms/Instrumentation.h"
|
||||
#include "llvm/Transforms/Vectorize.h"
|
||||
#include "llvm/DebugInfo.h"
|
||||
#include "llvm/DIBuilder.h"
|
||||
#include "llvm-c/Core.h"
|
||||
#include "llvm-c/BitReader.h"
|
||||
#include "llvm-c/ExecutionEngine.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue