Пример #1
0
        public MethodInfo(AssemblyInfo assembly, MethodDefinitionHandle methodDefHandle, int token, SourceFile source, TypeInfo type, MetadataReader asmMetadataReader, MetadataReader pdbMetadataReader)
        {
            this.IsAsync           = -1;
            this.Assembly          = assembly;
            this.methodDef         = asmMetadataReader.GetMethodDefinition(methodDefHandle);
            this.DebugInformation  = pdbMetadataReader.GetMethodDebugInformation(methodDefHandle.ToDebugInformationHandle());
            this.source            = source;
            this.Token             = token;
            this.methodDefHandle   = methodDefHandle;
            this.Name              = asmMetadataReader.GetString(methodDef.Name);
            this.pdbMetadataReader = pdbMetadataReader;
            this.IsEnCMethod       = false;
            this.TypeInfo          = type;
            if (!DebugInformation.SequencePointsBlob.IsNil)
            {
                var           sps   = DebugInformation.GetSequencePoints();
                SequencePoint start = sps.First();
                SequencePoint end   = sps.First();

                foreach (SequencePoint sp in sps)
                {
                    if (sp.StartLine < start.StartLine)
                    {
                        start = sp;
                    }
                    else if (sp.StartLine == start.StartLine && sp.StartColumn < start.StartColumn)
                    {
                        start = sp;
                    }

                    if (sp.EndLine > end.EndLine)
                    {
                        end = sp;
                    }
                    else if (sp.EndLine == end.EndLine && sp.EndColumn > end.EndColumn)
                    {
                        end = sp;
                    }
                }

                StartLocation = new SourceLocation(this, start);
                EndLocation   = new SourceLocation(this, end);

                foreach (var cattr in methodDef.GetCustomAttributes())
                {
                    var ctorHandle = asmMetadataReader.GetCustomAttribute(cattr).Constructor;
                    if (ctorHandle.Kind == HandleKind.MemberReference)
                    {
                        var container = asmMetadataReader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent;
                        var name      = asmMetadataReader.GetString(asmMetadataReader.GetTypeReference((TypeReferenceHandle)container).Name);
                        if (name == "DebuggerHiddenAttribute")
                        {
                            this.IsHiddenFromDebugger = true;
                            break;
                        }
                    }
                }
            }
            localScopes = pdbMetadataReader.GetLocalScopes(methodDefHandle);
        }
Пример #2
0
        public override SourceLocation SourceLocationForManagedCode(uint methodMetadataToken, int ilOffset)
        {
            MethodDefinitionHandle       methodDefinitionHandle = (MethodDefinitionHandle)MetadataTokens.Handle((int)methodMetadataToken);
            MethodDebugInformationHandle methodDebugInfoHandle  = methodDefinitionHandle.ToDebugInformationHandle();
            MethodDebugInformation       methodDebugInfo        = _metaData.GetMethodDebugInformation(methodDebugInfoHandle);

            int           methodToken       = MetadataTokens.GetToken(methodDebugInfoHandle.ToDefinitionHandle());
            SequencePoint lastSequencePoint = default(SequencePoint);

            foreach (SequencePoint sequencePoint in methodDebugInfo.GetSequencePoints())
            {
                if (sequencePoint.Offset > ilOffset)
                {
                    if (lastSequencePoint.Document.IsNil)
                    {
                        lastSequencePoint = sequencePoint;
                    }
                    break;
                }
                lastSequencePoint = sequencePoint;
            }
            if (lastSequencePoint.Document.IsNil)
            {
                return(null);
            }
            return(new SourceLocation(GetSourceFile(lastSequencePoint.Document), lastSequencePoint.StartLine));
        }
Пример #3
0
        public MethodInfo(AssemblyInfo assembly, MethodDefinitionHandle methodDefHandle, int token, SourceFile source, TypeInfo type, MetadataReader asmMetadataReader, MetadataReader pdbMetadataReader)
        {
            this.IsAsync           = -1;
            this.Assembly          = assembly;
            this.methodDef         = asmMetadataReader.GetMethodDefinition(methodDefHandle);
            this.DebugInformation  = pdbMetadataReader.GetMethodDebugInformation(methodDefHandle.ToDebugInformationHandle());
            this.source            = source;
            this.Token             = token;
            this.methodDefHandle   = methodDefHandle;
            this.Name              = asmMetadataReader.GetString(methodDef.Name);
            this.pdbMetadataReader = pdbMetadataReader;
            this.IsEnCMethod       = false;
            if (!DebugInformation.SequencePointsBlob.IsNil)
            {
                var           sps   = DebugInformation.GetSequencePoints();
                SequencePoint start = sps.First();
                SequencePoint end   = sps.First();

                foreach (SequencePoint sp in sps)
                {
                    if (sp.StartLine < start.StartLine)
                    {
                        start = sp;
                    }
                    else if (sp.StartLine == start.StartLine && sp.StartColumn < start.StartColumn)
                    {
                        start = sp;
                    }

                    if (sp.EndLine > end.EndLine)
                    {
                        end = sp;
                    }
                    else if (sp.EndLine == end.EndLine && sp.EndColumn > end.EndColumn)
                    {
                        end = sp;
                    }
                }

                StartLocation = new SourceLocation(this, start);
                EndLocation   = new SourceLocation(this, end);
            }
            localScopes = pdbMetadataReader.GetLocalScopes(methodDefHandle);
        }
Пример #4
0
 /// <summary>
 /// Attempt to locate debugging information for a particular method.
 ///
 ///     Returns null on failure, for example if there was no PDB information found for the
 ///     DLL, or if the particular method is compiler generated or doesn't come from source code.
 /// </summary>
 /// <param name="handle">The handle of the method.</param>
 /// <returns>The debugging information, or null if the information could not be located.</returns>
 public PDB.IMethod GetMethodDebugInformation(MethodDefinitionHandle handle)
 {
     return(pdb == null ? null : pdb.GetMethod(handle.ToDebugInformationHandle()));
 }
Пример #5
0
 /// <summary>
 /// Attempt to locate debugging information for a particular method.
 ///
 ///     Returns null on failure, for example if there was no PDB information found for the
 ///     DLL, or if the particular method is compiler generated or doesn't come from source code.
 /// </summary>
 /// <param name="handle">The handle of the method.</param>
 /// <returns>The debugging information, or null if the information could not be located.</returns>
 public PDB.Method? GetMethodDebugInformation(MethodDefinitionHandle handle)
 {
     return(Pdb?.GetMethod(handle.ToDebugInformationHandle()));
 }
 public override StandaloneSignatureHandle GetLocalSignature(MethodDefinitionHandle methodHandle)
 => _pdbReader.GetMethodDebugInformation(methodHandle.ToDebugInformationHandle()).LocalSignature;