示例#1
0
        private static Scope ReadPDBScope(PDBScope scope, MergeBuffer mergeBuffer, [CanBeNull] Scope parent, MethodDef thisMeth)
        {
            Contract.Requires(scope != null);
            Contract.Requires(thisMeth != null);
            Scope thisScope = new Scope(parent, thisMeth);

            if (parent != null)
            {
                mergeBuffer.Add(new OpenScope(thisScope), (uint)scope.StartOffset);
            }

            foreach (PDBVariable var in scope.Variables)
            {
                thisScope.AddLocalBinding(var.Name, var.Address);
            }

            foreach (PDBScope child in scope.Children)
            {
                ReadPDBScope(child, mergeBuffer, thisScope, thisMeth);
            }

            if (parent != null)
            {
                mergeBuffer.Add(new CloseScope(thisScope), (uint)scope.EndOffset);
            }

            return(thisScope);
        }
示例#2
0
        public void ReadPDB()
        {
            PDBReader reader = new PDBReader(this.fileName);

            foreach (ClassDef cDef in GetClasses())
            {
                foreach (MethodDef mDef in cDef.GetMethods())
                {
                    CILInstructions buffer = mDef.GetCodeBuffer();
                    PDBMethod       meth   = reader.GetMethod((int)mDef.Token());

                    if (meth == null)
                    {
                        continue; // no symbols for this method
                    }
                    PDBSequencePoint[] spList = meth.SequencePoints;

                    MergeBuffer mergeBuffer = new MergeBuffer(buffer.GetInstructions());

                    PDBScope outer = meth.Scope;
                    Scope    root  = ReadPDBScope(outer, mergeBuffer, null, mDef);
                    buffer.currentScope = root;
                    bool hasRootScope = mergeBuffer.hasRootScope();

                    if (!hasRootScope)
                    {
                        mergeBuffer.Add(new OpenScope(root), (uint)0);
                    }
                    foreach (PDBSequencePoint sp in spList)
                    {
                        PDBDocument doc = sp.Document;
                        mergeBuffer.Add(
                            new Line((uint)sp.Line, (uint)sp.Column, (uint)sp.EndLine, (uint)sp.EndColumn,
                                     SourceFile.GetSourceFile(doc.URL, doc.Language, doc.LanguageVendor, doc.DocumentType)),
                            (uint)sp.Offset);
                    }
                    if (!hasRootScope)
                    {
                        mergeBuffer.Add(new CloseScope(root), (uint)outer.EndOffset);
                    }

                    buffer.SetInstructions(mergeBuffer.Instructions);
                }
            }
        }
示例#3
0
        private static Scope ReadPDBScope(PDBScope scope, MergeBuffer mergeBuffer, [CanBeNull] Scope parent, MethodDef thisMeth)
        {
            Contract.Requires(scope != null);
            Contract.Requires(thisMeth != null);
            Scope thisScope = new Scope(parent, thisMeth);

            if (parent != null) mergeBuffer.Add(new OpenScope(thisScope), (uint)scope.StartOffset);

            foreach (PDBVariable var in scope.Variables)
                thisScope.AddLocalBinding(var.Name, var.Address);

            foreach (PDBScope child in scope.Children)
                ReadPDBScope(child, mergeBuffer, thisScope, thisMeth);

            if (parent != null) mergeBuffer.Add(new CloseScope(thisScope), (uint)scope.EndOffset);

            return thisScope;
        }
示例#4
0
        public void ReadPDB()
        {
            PDBReader reader = new PDBReader(this.fileName);
            foreach (ClassDef cDef in GetClasses())
                foreach (MethodDef mDef in cDef.GetMethods())
                {
                    CILInstructions buffer = mDef.GetCodeBuffer();
                    PDBMethod meth = reader.GetMethod((int)mDef.Token());

                    if (meth == null)
                        continue; // no symbols for this method

                    PDBSequencePoint[] spList = meth.SequencePoints;

                    MergeBuffer mergeBuffer = new MergeBuffer(buffer.GetInstructions());

                    PDBScope outer = meth.Scope;
                    Scope root = ReadPDBScope(outer, mergeBuffer, null, mDef);
                    buffer.currentScope = root;
                    bool hasRootScope = mergeBuffer.hasRootScope();

                    if (!hasRootScope)
                        mergeBuffer.Add(new OpenScope(root), (uint)0);
                    foreach (PDBSequencePoint sp in spList)
                    {
                        PDBDocument doc = sp.Document;
                        mergeBuffer.Add(
                            new Line((uint)sp.Line, (uint)sp.Column, (uint)sp.EndLine, (uint)sp.EndColumn,
                            SourceFile.GetSourceFile(doc.URL, doc.Language, doc.LanguageVendor, doc.DocumentType)),
                            (uint)sp.Offset);
                    }
                    if (!hasRootScope)
                        mergeBuffer.Add(new CloseScope(root), (uint)outer.EndOffset);

                    buffer.SetInstructions(mergeBuffer.Instructions);
                }
        }