Inheritance: DebugInformation
Example #1
0
        static bool AddScope(Collection<ScopeDebugInformation> scopes, ScopeDebugInformation scope)
        {
            foreach (var sub_scope in scopes) {
                if (sub_scope.HasScopes && AddScope (sub_scope.Scopes, scope))
                    return true;

                if (scope.Start.Offset >= sub_scope.Start.Offset && scope.End.Offset <= sub_scope.End.Offset) {
                    sub_scope.Scopes.Add (scope);
                    return true;
                }
            }

            return false;
        }
Example #2
0
        private void ReadScope(ScopeDebugInformation scope)
        {
            InstructionOffset instructionOffset = scope.Start;
            Instruction       instruction       = GetInstruction(instructionOffset.Offset);

            if (instruction != null)
            {
                scope.Start = new InstructionOffset(instruction);
            }
            instructionOffset = scope.End;
            Instruction       instruction2 = GetInstruction(instructionOffset.Offset);
            InstructionOffset end;

            if (instruction2 == null)
            {
                instructionOffset = default(InstructionOffset);
                end = instructionOffset;
            }
            else
            {
                end = new InstructionOffset(instruction2);
            }
            scope.End = end;
            if (!scope.variables.IsNullOrEmpty())
            {
                for (int i = 0; i < scope.variables.Count; i++)
                {
                    VariableDebugInformation variableDebugInformation = scope.variables[i];
                    VariableDefinition       variable = GetVariable(variableDebugInformation.Index);
                    if (variable != null)
                    {
                        variableDebugInformation.index = new VariableIndex(variable);
                    }
                }
            }
            if (!scope.scopes.IsNullOrEmpty())
            {
                ReadScopes(scope.scopes);
            }
        }
Example #3
0
        void ReadScope(ScopeDebugInformation scope)
        {
            scope.Start = new InstructionOffset(GetInstruction(scope.Start.Offset));

            var end_instruction = GetInstruction(scope.End.Offset);

            scope.End = end_instruction == null
                                ? new InstructionOffset()
                                : new InstructionOffset(end_instruction);

            if (!scope.variables.IsNullOrEmpty())
            {
                for (int i = 0; i < scope.variables.Count; i++)
                {
                    var variable = scope.variables [i];
                    variable.index = new VariableIndex(GetVariable(variable.Index));
                }
            }

            if (!scope.scopes.IsNullOrEmpty())
            {
                ReadScopes(scope.scopes);
            }
        }
Example #4
0
        void ReadScope(ScopeDebugInformation scope)
        {
            var start_instruction = GetInstruction (scope.Start.Offset);
            if (start_instruction != null)
                scope.Start = new InstructionOffset (start_instruction);

            var end_instruction = GetInstruction (scope.End.Offset);
            if (end_instruction != null)
                scope.End = new InstructionOffset (end_instruction);

            if (!scope.variables.IsNullOrEmpty ()) {
                for (int i = 0; i < scope.variables.Count; i++) {
                    var variable_info = scope.variables [i];
                    var variable = GetVariable (variable_info.Index);
                    if (variable != null)
                        variable_info.index = new VariableIndex (variable);
                }
            }

            if (!scope.scopes.IsNullOrEmpty ())
                ReadScopes (scope.scopes);
        }
Example #5
0
        static ScopeDebugInformation ReadScopeAndLocals(PdbScope scope, MethodDebugInformation info)
        {
            var parent = new ScopeDebugInformation ();
            parent.Start = new InstructionOffset ((int) scope.offset);
            parent.End = new InstructionOffset ((int) (scope.offset + scope.length));

            if (!scope.slots.IsNullOrEmpty()) {
                parent.variables = new Collection<VariableDebugInformation> (scope.slots.Length);

                foreach (PdbSlot slot in scope.slots) {
                    if (slot.flags == 1) // parameter names
                        continue;

                    var index = (int) slot.slot;
                    var variable = new VariableDebugInformation (index, slot.name);
                    if (slot.flags == 4)
                        variable.IsDebuggerHidden = true;
                    parent.variables.Add (variable);
                }
            }

            if (!scope.constants.IsNullOrEmpty ()) {
                parent.constants = new Collection<ConstantDebugInformation> (scope.constants.Length);

                foreach (var constant in scope.constants) {
                    parent.constants.Add (new ConstantDebugInformation (
                        constant.name,
                        (TypeReference) info.method.Module.LookupToken ((int) constant.token),
                        constant.value));
                }
            }

            parent.scopes = ReadScopeAndLocals (scope.scopes, info);

            return parent;
        }
Example #6
0
        void DefineScope(ScopeDebugInformation scope, MethodDebugInformation info)
        {
            var start_offset = scope.Start.Offset;
            var end_offset = scope.End.IsEndOfMethod
                ? info.code_size
                : scope.End.Offset;

            writer.OpenScope (start_offset);

            var sym_token = new SymbolToken (info.local_var_token.ToInt32 ());

            if (!scope.variables.IsNullOrEmpty ()) {
                for (int i = 0; i < scope.variables.Count; i++) {
                    var variable = scope.variables [i];
                    CreateLocalVariable (variable, sym_token, start_offset, end_offset);
                }
            }

            if (!scope.scopes.IsNullOrEmpty ()) {
                for (int i = 0; i < scope.scopes.Count; i++)
                    DefineScope (scope.scopes [i], info);
            }

            writer.CloseScope (end_offset);
        }
Example #7
0
        static void ReadLocalVariables(MethodEntry entry, ScopeDebugInformation [] scopes)
        {
            var locals = entry.GetLocals ();

            foreach (var local in locals) {
                var variable = new VariableDebugInformation (local.Index, local.Name);

                var index = local.BlockIndex;
                if (index < 0 || index >= scopes.Length)
                    continue;

                var scope = scopes [index];
                if (scope == null)
                    continue;

                scope.Variables.Add (variable);
            }
        }
Example #8
0
        static ScopeDebugInformation[] ReadScopes(MethodEntry entry, MethodDebugInformation info)
        {
            var blocks = entry.GetCodeBlocks ();
            var scopes = new ScopeDebugInformation [blocks.Length + 1];

            info.scope = scopes [0] = new ScopeDebugInformation {
                Start = new InstructionOffset (0),
                End = new InstructionOffset (info.code_size),
            };

            foreach (var block in blocks) {
                if (block.BlockType != CodeBlockEntry.Type.Lexical && block.BlockType != CodeBlockEntry.Type.CompilerGenerated)
                    continue;

                var scope = new ScopeDebugInformation ();
                scope.Start = new InstructionOffset (block.StartOffset);
                scope.End = new InstructionOffset (block.EndOffset);

                scopes [block.Index + 1] = scope;

                if (!AddScope (info.scope.Scopes, scope))
                    info.scope.Scopes.Add (scope);
            }

            return scopes;
        }
Example #9
0
        void WriteScopeVariables(ScopeDebugInformation scope)
        {
            if (!scope.HasVariables)
                return;

            foreach (var variable in scope.variables)
                if (!string.IsNullOrEmpty (variable.Name))
                    writer.DefineLocalVariable (variable.Index, variable.Name);
        }
Example #10
0
        void WriteScope(ScopeDebugInformation scope, MethodDebugInformation info)
        {
            writer.OpenScope (scope.Start.Offset);

            WriteScopeVariables (scope);

            if (scope.HasScopes)
                WriteScopes (scope.Scopes, info);

            writer.CloseScope (scope.End.IsEndOfMethod ? info.code_size : scope.End.Offset);
        }
Example #11
0
        void WriteRootScope(ScopeDebugInformation scope, MethodDebugInformation info)
        {
            WriteScopeVariables (scope);

            if (scope.HasScopes)
                WriteScopes (scope.Scopes, info);
        }