LLVM: add compile unit to debug info

This commit also adds a bunch of bindings for debug info.
This commit is contained in:
Andrew Kelley
2022-03-07 15:43:20 -07:00
parent 95fc41b2b4
commit c6160fa3a5
4 changed files with 362 additions and 8 deletions

View File

@@ -184,6 +184,9 @@ pub const Value = opaque {
pub const setFunctionCallConv = LLVMSetFunctionCallConv;
extern fn LLVMSetFunctionCallConv(Fn: *const Value, CC: CallConv) void;
pub const fnSetSubprogram = ZigLLVMFnSetSubprogram;
extern fn ZigLLVMFnSetSubprogram(f: *const Value, subprogram: *DISubprogram) void;
pub const setValueName = LLVMSetValueName;
extern fn LLVMSetValueName(Val: *const Value, Name: [*:0]const u8) void;
@@ -354,6 +357,18 @@ pub const Module = opaque {
Name: [*:0]const u8,
NameLen: usize,
) ?*const Value;
pub const setTarget = LLVMSetTarget;
extern fn LLVMSetTarget(M: *const Module, Triple: [*:0]const u8) void;
pub const addModuleDebugInfoFlag = ZigLLVMAddModuleDebugInfoFlag;
extern fn ZigLLVMAddModuleDebugInfoFlag(module: *const Module) void;
pub const addModuleCodeViewFlag = ZigLLVMAddModuleCodeViewFlag;
extern fn ZigLLVMAddModuleCodeViewFlag(module: *const Module) void;
pub const createDIBuilder = ZigLLVMCreateDIBuilder;
extern fn ZigLLVMCreateDIBuilder(module: *const Module, allow_unresolved: bool) *DIBuilder;
};
pub const lookupIntrinsicID = LLVMLookupIntrinsicID;
@@ -1203,7 +1218,7 @@ pub const WriteImportLibrary = ZigLLVMWriteImportLibrary;
extern fn ZigLLVMWriteImportLibrary(
def_path: [*:0]const u8,
arch: ArchType,
output_lib_path: [*c]const u8,
output_lib_path: [*:0]const u8,
kill_at: bool,
) bool;
@@ -1400,3 +1415,286 @@ pub const address_space = struct {
pub const constant_buffer_15: c_uint = 23;
};
};
pub const DIEnumerator = opaque {};
pub const DILocalVariable = opaque {};
pub const DIGlobalVariable = opaque {};
pub const DILocation = opaque {};
pub const DIType = opaque {
pub const toScope = ZigLLVMTypeToScope;
extern fn ZigLLVMTypeToScope(ty: *DIType) *DIScope;
};
pub const DIFile = opaque {
pub const toScope = ZigLLVMFileToScope;
extern fn ZigLLVMFileToScope(difile: *DIFile) *DIScope;
};
pub const DILexicalBlock = opaque {
pub const toScope = ZigLLVMLexicalBlockToScope;
extern fn ZigLLVMLexicalBlockToScope(lexical_block: *DILexicalBlock) *DIScope;
};
pub const DICompileUnit = opaque {
pub const toScope = ZigLLVMCompileUnitToScope;
extern fn ZigLLVMCompileUnitToScope(compile_unit: *DICompileUnit) *DIScope;
};
pub const DISubprogram = opaque {
pub const toScope = ZigLLVMSubprogramToScope;
extern fn ZigLLVMSubprogramToScope(subprogram: *DISubprogram) *DIScope;
};
pub const getDebugLoc = ZigLLVMGetDebugLoc;
extern fn ZigLLVMGetDebugLoc(line: c_uint, col: c_uint, scope: *DIScope) *DILocation;
pub const DIBuilder = opaque {
pub const dispose = ZigLLVMDisposeDIBuilder;
extern fn ZigLLVMDisposeDIBuilder(dib: *DIBuilder) void;
pub const finalize = ZigLLVMDIBuilderFinalize;
extern fn ZigLLVMDIBuilderFinalize(dib: *DIBuilder) void;
pub const createPointerType = ZigLLVMCreateDebugPointerType;
extern fn ZigLLVMCreateDebugPointerType(
dib: *DIBuilder,
pointee_type: *DIType,
size_in_bits: u64,
align_in_bits: u64,
name: [*:0]const u8,
) *DIType;
pub const createBasicType = ZigLLVMCreateDebugBasicType;
extern fn ZigLLVMCreateDebugBasicType(
dib: *DIBuilder,
name: [*:0]const u8,
size_in_bits: u64,
encoding: c_uint,
) *DIType;
pub const createArrayType = ZigLLVMCreateDebugArrayType;
extern fn ZigLLVMCreateDebugArrayType(
dib: *DIBuilder,
size_in_bits: u64,
align_in_bits: u64,
elem_type: *DIType,
elem_count: c_int,
) *DIType;
pub const createEnumerator = ZigLLVMCreateDebugEnumerator;
extern fn ZigLLVMCreateDebugEnumerator(
dib: *DIBuilder,
name: [*:0]const u8,
val: i64,
) *DIEnumerator;
pub const createEnumerationType = ZigLLVMCreateDebugEnumerationType;
extern fn ZigLLVMCreateDebugEnumerationType(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
file: *DIFile,
line_number: c_uint,
size_in_bits: u64,
align_in_bits: u64,
enumerator_array: [*]const *DIEnumerator,
enumerator_array_len: c_int,
underlying_type: *DIType,
unique_id: [*:0]const u8,
) *DIType;
pub const createStructType = ZigLLVMCreateDebugStructType;
extern fn ZigLLVMCreateDebugStructType(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
file: *DIFile,
line_number: c_uint,
size_in_bits: u64,
align_in_bits: u64,
flags: c_uint,
derived_from: *DIType,
types_array: [*]const *DIType,
types_array_len: c_int,
run_time_lang: c_uint,
vtable_holder: *DIType,
unique_id: [*:0]const u8,
) *DIType;
pub const createUnionType = ZigLLVMCreateDebugUnionType;
extern fn ZigLLVMCreateDebugUnionType(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
file: *DIFile,
line_number: c_uint,
size_in_bits: u64,
align_in_bits: u64,
flags: c_uint,
types_array: [*]const *DIType,
types_array_len: c_int,
run_time_lang: c_uint,
unique_id: [*:0]const u8,
) *DIType;
pub const createMemberType = ZigLLVMCreateDebugMemberType;
extern fn ZigLLVMCreateDebugMemberType(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
file: *DIFile,
line: c_uint,
size_in_bits: u64,
align_in_bits: u64,
offset_in_bits: u64,
flags: c_uint,
ty: *DIType,
) *DIType;
pub const createReplaceableCompositeType = ZigLLVMCreateReplaceableCompositeType;
extern fn ZigLLVMCreateReplaceableCompositeType(
dib: *DIBuilder,
tag: c_uint,
name: [*:0]const u8,
scope: *DIScope,
file: *DIFile,
line: c_uint,
) *DIType;
pub const createForwardDeclType = ZigLLVMCreateDebugForwardDeclType;
extern fn ZigLLVMCreateDebugForwardDeclType(
dib: *DIBuilder,
tag: c_uint,
name: [*:0]const u8,
scope: *DIScope,
file: *DIFile,
line: c_uint,
) *DIType;
pub const replaceTemporary = ZigLLVMReplaceTemporary;
extern fn ZigLLVMReplaceTemporary(dib: *DIBuilder, ty: *DIType, replacement: *DIType) void;
pub const replaceDebugArrays = ZigLLVMReplaceDebugArrays;
extern fn ZigLLVMReplaceDebugArrays(
dib: *DIBuilder,
ty: *DIType,
types_array: [*]const *DIType,
types_array_len: c_int,
) void;
pub const createSubroutineType = ZigLLVMCreateSubroutineType;
extern fn ZigLLVMCreateSubroutineType(
dib: *DIBuilder,
types_array: [*]const *DIType,
types_array_len: c_int,
flags: c_uint,
) *DIType;
pub const createAutoVariable = ZigLLVMCreateAutoVariable;
extern fn ZigLLVMCreateAutoVariable(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
file: *DIFile,
line_no: c_uint,
ty: *DIType,
always_preserve: bool,
flags: c_uint,
) *DILocalVariable;
pub const createGlobalVariable = ZigLLVMCreateGlobalVariable;
extern fn ZigLLVMCreateGlobalVariable(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
linkage_name: [*:0]const u8,
file: *DIFile,
line_no: c_uint,
di_type: *DIType,
is_local_to_unit: bool,
) *DIGlobalVariable;
pub const createParameterVariable = ZigLLVMCreateParameterVariable;
extern fn ZigLLVMCreateParameterVariable(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
file: *DIFile,
line_no: c_uint,
ty: *DIType,
always_preserve: bool,
flags: c_uint,
arg_no: c_uint,
) *DILocalVariable;
pub const createLexicalBlock = ZigLLVMCreateLexicalBlock;
extern fn ZigLLVMCreateLexicalBlock(
dib: *DIBuilder,
scope: *DIScope,
file: *DIFile,
line: c_uint,
col: c_uint,
) *DILexicalBlock;
pub const createCompileUnit = ZigLLVMCreateCompileUnit;
extern fn ZigLLVMCreateCompileUnit(
dib: *DIBuilder,
lang: c_uint,
difile: *DIFile,
producer: [*:0]const u8,
is_optimized: bool,
flags: [*:0]const u8,
runtime_version: c_uint,
split_name: [*:0]const u8,
dwo_id: u64,
emit_debug_info: bool,
) *DICompileUnit;
pub const createFile = ZigLLVMCreateFile;
extern fn ZigLLVMCreateFile(
dib: *DIBuilder,
filename: [*:0]const u8,
directory: [*:0]const u8,
) *DIFile;
pub const createFunction = ZigLLVMCreateFunction;
extern fn ZigLLVMCreateFunction(
dib: *DIBuilder,
scope: *DIScope,
name: [*:0]const u8,
linkage_name: [*:0]const u8,
file: *DIFile,
lineno: c_uint,
fn_di_type: *DIType,
is_local_to_unit: bool,
is_definition: bool,
scope_line: c_uint,
flags: c_uint,
is_optimized: bool,
decl_subprogram: *DISubprogram,
) *DISubprogram;
pub const createVectorType = ZigLLVMDIBuilderCreateVectorType;
extern fn ZigLLVMDIBuilderCreateVectorType(
dib: *DIBuilder,
SizeInBits: u64,
AlignInBits: u32,
Ty: *DIType,
elem_count: u32,
) *DIType;
pub const insertDeclareAtEnd = ZigLLVMInsertDeclareAtEnd;
extern fn ZigLLVMInsertDeclareAtEnd(
dib: *DIBuilder,
storage: *const Value,
var_info: *DILocalVariable,
debug_loc: *DILocation,
basic_block_ref: *const BasicBlock,
) *const Value;
pub const insertDeclare = ZigLLVMInsertDeclare;
extern fn ZigLLVMInsertDeclare(
dib: *DIBuilder,
storage: *const Value,
var_info: *DILocalVariable,
debug_loc: *DILocation,
insert_before_instr: *const Value,
) *const Value;
};