Exemple #1
0
        private void EmitDebugVariable(FunctionCompilerContext functionContext, Instruction start, ValueRef generatedScope, StackValue variable, DW_TAG dwarfType, string variableName, int argIndex = 0)
        {
            var sequencePoint = start.SequencePoint;
            var debugType     = CreateDebugType(functionContext, 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,
                                                                        LLVM.GetInsertBlock(builder));

            LLVM.SetInstDebugLocation(builder, debugVariableDeclare);
        }
        private void EmitDebugVariable(FunctionCompilerContext functionContext, SequencePoint sequencePoint, ValueRef 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,
                                                                        LLVM.GetInsertBlock(builder));

            LLVM.SetInstDebugLocation(builder, debugVariableDeclare);
        }
Exemple #3
0
        private void EmitDebugVariable(FunctionCompilerContext functionContext, Instruction start, ValueRef generatedScope, StackValue variable, DW_TAG dwarfType, string variableName, int argIndex = 0)
        {
            var sequencePoint = start.SequencePoint;
            var debugType = CreateDebugType(functionContext, 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,
                LLVM.GetInsertBlock(builder));
            LLVM.SetInstDebugLocation(builder, debugVariableDeclare);
        }
        protected void processDebugInfoEntry(ref int ix, List <int> abbreviationSectionTable)
        {
            // get abbreviation code number from the debug_info section
            uint abbreviationCode = getLEB128(ref ix, debugInfoSect);

            if (abbreviationCode == 0)
            {
                return;
            }
            int abix = -1;

            if (abbreviationCode < abbreviationSectionTable.Count)
            {
                abix = abbreviationSectionTable[(int)abbreviationCode];
            }
            if (abix < 0)
            {
                Debug.WriteLine(String.Format(
                                    "could not locate abbreviation code {0}", abbreviationCode));
                ix += 1000;          // action to force termination of caller's loop
                return;
            }
            DW_TAG tag         = (DW_TAG)debugAbbrevSect[abix++]; // do not delete
            bool   hasChildren = (debugAbbrevSect[abix++]) != 0;  // do not delete

            while (debugAbbrevSect[abix] != 0)
            {
                DW_AT   attribute = (DW_AT)debugAbbrevSect[abix++];
                DW_FORM f         = (DW_FORM)debugAbbrevSect[abix++];
                int     len;
                string  s;
                uint    dummy;
                for ( ; ;)
                {
                    switch (f)
                    {
                    case DW_FORM.addr:
                        ix += 4;
                        break;

                    case DW_FORM.block:
                        len = (int)getLEB128(ref ix, debugInfoSect);
                        ix += len;
                        break;

                    case DW_FORM.block1:
                        len = (int)(debugInfoSect[ix++] & 0xff);
                        ix += len;
                        break;

                    case DW_FORM.block2:
                        len = (int)getInt16(debugInfoSect, ix);
                        ix += len + 2;
                        break;

                    case DW_FORM.block4:
                        len = (int)getInt32(debugInfoSect, ix);
                        ix += len + 4;
                        break;

                    case DW_FORM.data1:
                    case DW_FORM.ref1:
                    case DW_FORM.flag:
                        ix += 1;
                        break;

                    case DW_FORM.data2:
                    case DW_FORM.ref2:
                        ix += 2;
                        break;

                    case DW_FORM.data4:
                    case DW_FORM.ref4:
                        ix += 4;
                        break;

                    case DW_FORM.data8:
                    case DW_FORM.ref8:
                        ix += 8;
                        break;

                    case DW_FORM.dwstring:
                        s = getString(ref ix, debugInfoSect);
                        if (attribute == DW_AT.comp_dir)
                        {
                            CompilationDirectory = s;
                        }
                        if (attribute == DW_AT.name)
                        {
                            SourceFileName = s;
                        }
                        if (trace > 1)
                        {
                            Debug.WriteLine(String.Format(
                                                " -- Attribute {0} = {1}", attribute.ToString(), s));
                        }
                        break;

                    case DW_FORM.sdata:
                    case DW_FORM.udata:
                    case DW_FORM.ref_udata:
                        dummy = getLEB128(ref ix, debugInfoSect);                        // do not delete
                        break;

                    case DW_FORM.strp:
                        // skip over offset into .debug_str section
                        ix += 4;
                        break;

                    case DW_FORM.ref_addr:
                        ix += 4;
                        break;

                    case DW_FORM.indirect:
                        f = (DW_FORM)getLEB128(ref ix, debugInfoSect);
                        continue;

                    default:
                        Debug.WriteLine(String.Format(
                                            "unimplemented DW_FORM tag (value 0x{0:X})", f));
                        return;
                    }
                    break;
                }
            }
        }
        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);
        }