Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PdbSource"/> class.
 /// </summary>
 /// <param name="pdbFile">Portable PDB file reader.</param>
 /// <param name="handle">Our metadata reader handle.</param>
 internal PdbSource(PdbFile pdbFile, DocumentHandle handle)
 {
     PdbFile       = pdbFile;
     documentCache = SimpleCache.CreateStruct(() => PdbFile.Reader.GetDocument(handle));
     hashCache     = SimpleCache.CreateStruct(() => PdbFile.Reader.GetBlobBytes(Document.Hash));
     nameCache     = SimpleCache.CreateStruct(() => PdbFile.Reader.GetString(Document.Name));
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PdbFile"/> class.
        /// </summary>
        /// <param name="file">File loaded into memory for faster parsing.</param>
        public unsafe EmbeddedPdbFile(MemoryLoadedFile file)
        {
            PEReader peReader         = new PEReader(file.BasePointer, (int)file.Length);
            var      debugEntries     = peReader.ReadDebugDirectory();
            var      embeddedPdbEntry = debugEntries.FirstOrDefault(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb);

            if (embeddedPdbEntry.DataSize == 0)
            {
                throw new Exception("PDB wasn't embedded");
            }
            embeddedPdbReaderProvider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdbEntry);
            PdbFile   = new PdbFile(embeddedPdbReaderProvider.GetMetadataReader());
            this.file = file;
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PdbFunction"/> class.
        /// </summary>
        /// <param name="pdbFile">Portable PDB file reader.</param>
        /// <param name="handle">Our metadata reader handle.</param>
        internal PdbFunction(PdbFile pdbFile, MethodDebugInformationHandle handle)
        {
            PdbFile = pdbFile;
            methodDebugInformationCache = SimpleCache.CreateStruct(() => pdbFile.Reader.GetMethodDebugInformation(handle));
            localScopesCache            = SimpleCache.CreateStruct(() =>
            {
                var localScopes         = pdbFile.Reader.GetLocalScopes(handle);
                IPdbLocalScope[] scopes = new IPdbLocalScope[localScopes.Count];
                int i = 0;

                foreach (var l in localScopes)
                {
                    scopes[i++] = new PdbLocalScope(this, l);
                }
                return(scopes);
            });
            sequencePointsCache = SimpleCache.CreateStruct(() =>
            {
                var sequencePoints = MethodDebugInformation.GetSequencePoints();

                return(sequencePoints.Select(sp => new PdbSequencePoint(this, sp)).OfType <IPdbSequencePoint>().ToArray());
            });
            Token = System.Reflection.Metadata.Ecma335.MetadataTokens.GetToken(handle.ToDefinitionHandle());
        }