Inheritance: DebugInformation
Example #1
0
        public void Write(MethodDebugInformation info)
        {
            var method_token = info.method.MetadataToken;
            var sym_token = new SymbolToken (method_token.ToInt32 ());

            writer.OpenMethod (sym_token);

            if (!info.sequence_points.IsNullOrEmpty ())
                DefineSequencePoints (info.sequence_points);

            if (info.scope != null)
                DefineScope (info.scope, info);

            writer.CloseMethod ();
        }
Example #2
0
        public MethodDebugInformation Read(MethodDefinition method)
        {
            var method_token = method.MetadataToken;
            var entry = symbol_file.GetMethodByToken (method_token.ToInt32	());
            if (entry == null)
                return null;

            var info = new MethodDebugInformation (method);

            var scopes = ReadScopes (entry, info);
            ReadLineNumbers (entry, info);
            ReadLocalVariables (entry, scopes);

            return info;
        }
Example #3
0
        public void Write(MethodDebugInformation info)
        {
            var method = new SourceMethod (info.method);

            var sequence_points = info.SequencePoints;
            int count = sequence_points.Count;
            if (count == 0)
                return;

            var offsets = new int [count];
            var start_rows = new int [count];
            var end_rows = new int [count];
            var start_cols = new int [count];
            var end_cols = new int [count];

            SourceFile file;
            Populate (sequence_points, offsets, start_rows, end_rows, start_cols, end_cols, out file);

            var builder = writer.OpenMethod (file.CompilationUnit, 0, method);

            for (int i = 0; i < count; i++) {
                builder.MarkSequencePoint (
                    offsets [i],
                    file.CompilationUnit.SourceFile,
                    start_rows [i],
                    start_cols [i],
                    end_rows [i],
                    end_cols [i],
                    false);
            }

            if (info.scope != null)
                WriteRootScope (info.scope, info);

            writer.CloseMethod ();
        }
Example #4
0
        public void Write(MethodDebugInformation info)
        {
            CheckMethodDebugInformationTable();

            pdb_metadata.AddMethodDebugInformation(info);
        }
Example #5
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 #6
0
        void ReadSequencePoints(PdbFunction function, MethodDebugInformation info)
        {
            if (function.lines == null)
                return;

            info.sequence_points = new Collection<SequencePoint> ();

            foreach (PdbLines lines in function.lines)
                ReadLines (lines, info);
        }
Example #7
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 #8
0
        static void ReadLine(PdbLine line, Document document, MethodDebugInformation info)
        {
            var sequence_point = new SequencePoint ((int) line.offset, document);
            sequence_point.StartLine = (int) line.lineBegin;
            sequence_point.StartColumn = (int) line.colBegin;
            sequence_point.EndLine = (int) line.lineEnd;
            sequence_point.EndColumn = (int) line.colEnd;

            info.sequence_points.Add (sequence_point);
        }
Example #9
0
        void ReadLineNumbers(MethodEntry entry, MethodDebugInformation info)
        {
            var table = entry.GetLineNumberTable ();

            info.sequence_points = new Collection<SequencePoint> (table.LineNumbers.Length);

            for (var i = 0; i < table.LineNumbers.Length; i++) {
                var line = table.LineNumbers [i];
                if (i > 0 && table.LineNumbers [i - 1].Offset == line.Offset)
                    continue;

                info.sequence_points.Add (LineToSequencePoint (line));
            }
        }
Example #10
0
 void ReadStateMachineKickOffMethod(MethodDebugInformation method_info)
 {
     method_info.kickoff_method = debug_reader.ReadStateMachineKickoffMethod (method_info.method);
 }
Example #11
0
 void ReadSequencePoints(MethodDebugInformation method_info)
 {
     method_info.sequence_points = debug_reader.ReadSequencePoints (method_info.method);
 }
Example #12
0
 void ReadScope(MethodDebugInformation method_info)
 {
     method_info.scope = debug_reader.ReadScope (method_info.method);
 }
Example #13
0
 void ReadCustomDebugInformations(MethodDebugInformation info)
 {
     info.method.custom_infos = debug_reader.GetCustomDebugInformation (info.method);
 }
Example #14
0
 void WriteScopes(Collection<ScopeDebugInformation> scopes, MethodDebugInformation info)
 {
     for (int i = 0; i < scopes.Count; i++)
         WriteScope (scopes [i], info);
 }
Example #15
0
 public void Write(MethodDebugInformation info)
 {
     writer.Write(info);
 }
Example #16
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 #17
0
        public void Write(MethodDebugInformation info)
        {
            CheckMethodDebugInformationTable ();

            pdb_metadata.AddMethodDebugInformation (info);
        }
Example #18
0
 public MethodDebugInformation Read(MethodDefinition method)
 {
     var info = new MethodDebugInformation (method);
     ReadSequencePoints (info);
     ReadScope (info);
     ReadStateMachineKickOffMethod (info);
     ReadCustomDebugInformations (info);
     return info;
 }
Example #19
0
 void ReadSequencePoints(MethodDebugInformation method_info)
 {
     method_info.sequence_points = debug_reader.ReadSequencePoints(method_info.method);
 }
Example #20
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 #21
0
 void ReadScope(MethodDebugInformation method_info)
 {
     method_info.scope = debug_reader.ReadScope(method_info.method);
 }
Example #22
0
        static Collection<ScopeDebugInformation> ReadScopeAndLocals(PdbScope [] scopes, MethodDebugInformation info)
        {
            var symbols = new Collection<ScopeDebugInformation> (scopes.Length);

            foreach (PdbScope scope in scopes)
                if (scope != null)
                    symbols.Add (ReadScopeAndLocals (scope, info));

            return symbols;
        }
Example #23
0
 void ReadStateMachineKickOffMethod(MethodDebugInformation method_info)
 {
     method_info.kickoff_method = debug_reader.ReadStateMachineKickoffMethod(method_info.method);
 }
Example #24
0
        void ReadLines(PdbLines lines, MethodDebugInformation info)
        {
            var document = GetDocument (lines.file);

            foreach (var line in lines.lines)
                ReadLine (line, document, info);
        }
Example #25
0
 void ReadCustomDebugInformations(MethodDebugInformation info)
 {
     info.method.custom_infos = debug_reader.GetCustomDebugInformation(info.method);
 }
Example #26
0
        public MethodDebugInformation Read(MethodDefinition method)
        {
            var method_token = method.MetadataToken;

            PdbFunction function;
            if (!functions.TryGetValue (method_token.ToUInt32 (), out function))
                return null;

            var symbol = new MethodDebugInformation (method);

            ReadSequencePoints (function, symbol);

            if (!function.scopes.IsNullOrEmpty())
                symbol.scope = ReadScopeAndLocals (function.scopes [0], symbol);

            if (function.scopes.Length > 1) {
                for (int i = 1; i < function.scopes.Length; i++) {
                    var s = ReadScopeAndLocals (function.scopes [i], symbol);
                    if (!AddScope (symbol.scope.Scopes, s))
                        symbol.scope.Scopes.Add (s);
                }
            }

            return symbol;
        }
Example #27
0
        void WriteRootScope(ScopeDebugInformation scope, MethodDebugInformation info)
        {
            WriteScopeVariables (scope);

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