private void EmitDebugVariable(FunctionCompilerContext functionContext, SequencePoint sequencePoint, DIDescriptor generatedScope, StackValue variable, DW_TAG dwarfType, string variableName, int argIndex = 0) { var debugType = CreateDebugType(variable.Type); // Process fields and other dependent debug types ProcessMissingDebugTypes(); // Read it again in case it was mutated debugType = CreateDebugType(variable.Type); // TODO: Detect where variable is actually declared (first use of local?) var debugLocalVariable = LLVM.DIBuilderCreateLocalVariable(debugBuilder, (uint)dwarfType, generatedScope, variableName, functionContext.DebugFile, sequencePoint != null ? (uint)sequencePoint.StartLine : 0, debugType, true, 0, (uint)argIndex); var debugVariableDeclare = LLVM.DIBuilderInsertDeclareAtEnd(debugBuilder, variable.Value, debugLocalVariable, debugEmptyExpression, LLVM.GetInsertBlock(builder)); LLVM.SetInstDebugLocation(builder, debugVariableDeclare); }
private void InitializeDebug() { debugBuilder = LLVM.DIBuilderCreate(module); debugEmptyExpression = LLVM.DIBuilderCreateExpression(debugBuilder, new long[0]); }