public SymbolMethodImpl(PortablePdbReader reader, int token, SymbolScope rootScope, SymbolSequencePoint[] sequencePoints, int kickoffMethod)
 {
     this.reader         = reader;
     this.token          = token;
     this.rootScope      = rootScope;
     this.sequencePoints = sequencePoints;
     this.kickoffMethod  = kickoffMethod;
 }
Ejemplo n.º 2
0
 public SymbolScopeImpl(PortablePdbReader owner, SymbolScopeImpl parent, int startOffset, int endOffset, PdbCustomDebugInfo[] customDebugInfos)
 {
     this.owner            = owner;
     method                = null;
     this.parent           = parent;
     this.startOffset      = startOffset;
     this.endOffset        = endOffset;
     childrenList          = new List <SymbolScope>();
     localsList            = new List <SymbolVariable>();
     this.customDebugInfos = customDebugInfos;
 }
        public static SymbolReader TryCreate(PdbReaderContext pdbContext, DataReaderFactory pdbStream, bool isEmbeddedPortablePdb)
        {
            bool disposePdbStream = true;

            try {
                if (!pdbContext.HasDebugInfo)
                {
                    return(null);
                }
                if (pdbStream is null)
                {
                    return(null);
                }
                if (pdbStream.Length < 4)
                {
                    return(null);
                }
                if (pdbStream.CreateReader().ReadUInt32() != 0x424A5342)
                {
                    return(null);
                }

                var debugDir = pdbContext.CodeViewDebugDirectory;
                if (debugDir is null)
                {
                    return(null);
                }
                // Don't check that debugDir.MinorVersion == PortablePdbConstants.PortableCodeViewVersionMagic
                // and debugDir.MajorVersion == PortablePdbConstants.FormatVersion since it could be a converted
                // WindowsPDB file: https://github.com/dotnet/corefx/blob/master/src/System.Reflection.Metadata/specs/PE-COFF.md#codeview-debug-directory-entry-type-2
                if (!pdbContext.TryGetCodeViewData(out var pdbGuid, out uint age))
                {
                    return(null);
                }

                var reader = new PortablePdbReader(pdbStream, isEmbeddedPortablePdb ? PdbFileKind.EmbeddedPortablePDB : PdbFileKind.PortablePDB);
                if (!reader.MatchesModule(pdbGuid, debugDir.TimeDateStamp, age))
                {
                    return(null);
                }
                disposePdbStream = false;
                return(reader);
            }
            catch (IOException) {
            }
            finally {
                if (disposePdbStream)
                {
                    pdbStream?.Dispose();
                }
            }
            return(null);
        }