コード例 #1
0
        public static SymbolReader TryCreate(PdbReaderContext pdbContext, DataReaderFactory pdbStream, bool isEmbeddedPortablePdb)
        {
            bool disposePdbStream = true;

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

                var debugDir = pdbContext.CodeViewDebugDirectory;
                if (debugDir == null)
                {
                    return(null);
                }
                if (debugDir.MinorVersion != DDW.PortablePdbConstants.PortableCodeViewVersionMagic)
                {
                    return(null);
                }
                bool validFormatVersion = debugDir.MajorVersion == DDW.PortablePdbConstants.FormatVersion;
                Debug.Assert(validFormatVersion, $"New Portable PDB version: 0x{debugDir.MajorVersion:X4}");
                if (!validFormatVersion)
                {
                    return(null);
                }
                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);
        }
コード例 #2
0
 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;
 }
コード例 #3
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;
 }
コード例 #4
0
        public static SymbolReader TryCreate(PdbReaderContext pdbContext, DataReaderFactory pdbStream, bool isEmbeddedPortablePdb)
        {
            bool disposePdbStream = true;

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

                var debugDir = pdbContext.CodeViewDebugDirectory;
                if (debugDir == 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);
        }