示例#1
0
        public override IEnumerable <SymbolStoreKey> GetKeys(KeyTypeFlags flags)
        {
            if ((flags & KeyTypeFlags.IdentityKey) != 0)
            {
                SymbolStoreKey key = null;

                try
                {
                    _file.Stream.Position = 0;
                    using (MetadataReaderProvider provider = MetadataReaderProvider.FromPortablePdbStream(_file.Stream, MetadataStreamOptions.LeaveOpen))
                    {
                        MetadataReader reader = provider.GetMetadataReader();
                        var            blob   = new BlobContentId(reader.DebugMetadataHeader.Id);
                        if ((flags & KeyTypeFlags.ForceWindowsPdbs) == 0)
                        {
                            key = GetKey(_file.FileName, blob.Guid);
                        }
                        else
                        {
                            // Force the Windows PDB index
                            key = PDBFileKeyGenerator.GetKey(_file.FileName, blob.Guid, 1);
                        }
                    }
                }
                catch (BadImageFormatException ex)
                {
                    Tracer.Warning("PortablePDBFileKeyGenerator {0}", ex.Message);
                }

                if (key != null)
                {
                    yield return(key);
                }
            }
        }
示例#2
0
 public override IEnumerable <SymbolStoreKey> GetKeys(KeyTypeFlags flags)
 {
     if (IsValid())
     {
         if ((flags & KeyTypeFlags.IdentityKey) != 0)
         {
             yield return(GetKey(_path, _peFile.Timestamp, _peFile.SizeOfImage));
         }
         if ((flags & KeyTypeFlags.SymbolKey) != 0)
         {
             foreach (PEPdbRecord pdb in _peFile.Pdbs)
             {
                 if (((flags & KeyTypeFlags.ForceWindowsPdbs) == 0) && pdb.IsPortablePDB)
                 {
                     yield return(PortablePDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature));
                 }
                 else
                 {
                     yield return(PDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature, pdb.Age));
                 }
             }
         }
         if ((flags & KeyTypeFlags.ClrKeys) != 0)
         {
             if (Path.GetFileName(_path) == CoreClrFileName)
             {
                 string coreclrId = string.Format("{0:x}{1:x}", _peFile.Timestamp, _peFile.SizeOfImage);
                 foreach (string specialFileName in GetSpecialFiles())
                 {
                     yield return(BuildKey(specialFileName, coreclrId));
                 }
             }
         }
     }
 }
示例#3
0
        public override IEnumerable <SymbolStoreKey> GetKeys(KeyTypeFlags flags)
        {
            if (IsValid())
            {
                if ((flags & KeyTypeFlags.IdentityKey) != 0)
                {
                    yield return(GetKey(_path, _peFile.Timestamp, _peFile.SizeOfImage));
                }
                if ((flags & KeyTypeFlags.SymbolKey) != 0)
                {
                    PEPdbRecord[] pdbs = new PEPdbRecord[0];

                    try
                    {
                        pdbs = _peFile.Pdbs.ToArray();
                    }
                    catch (InvalidVirtualAddressException ex)
                    {
                        Tracer.Error("Reading PDB records for {0}: {1}", _path, ex.Message);
                    }

                    foreach (PEPdbRecord pdb in pdbs)
                    {
                        if (((flags & KeyTypeFlags.ForceWindowsPdbs) == 0) && pdb.IsPortablePDB)
                        {
                            yield return(PortablePDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature, _peFile.PdbChecksums));
                        }
                        else
                        {
                            yield return(PDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature, pdb.Age, _peFile.PdbChecksums));
                        }
                    }
                }
                if ((flags & KeyTypeFlags.ClrKeys) != 0)
                {
                    if (GetFileName(_path) == CoreClrFileName)
                    {
                        string coreclrId = string.Format("{0:x}{1:x}", _peFile.Timestamp, _peFile.SizeOfImage);
                        foreach (string specialFileName in GetSpecialFiles())
                        {
                            yield return(BuildKey(specialFileName, coreclrId));
                        }
                    }
                }
                if ((flags & KeyTypeFlags.HostKeys) != 0)
                {
                    if ((_peFile.FileHeader.Characteristics & (ushort)ImageFile.Dll) == 0 && !_peFile.IsILImage)
                    {
                        string id = string.Format("{0:x}{1:x}", _peFile.Timestamp, _peFile.SizeOfImage);

                        // The host program as itself (usually dotnet.exe)
                        yield return(BuildKey(_path, id));

                        // apphost.exe downloaded as the host program name
                        yield return(BuildKey(_path, prefix: null, id, "apphost.exe"));
                    }
                }
            }
        }
示例#4
0
 public override IEnumerable <SymbolStoreKey> GetKeys(KeyTypeFlags flags)
 {
     if (IsValid())
     {
         if ((flags & KeyTypeFlags.IdentityKey) != 0)
         {
             yield return(GetKey(_path, _peFile.Timestamp, _peFile.SizeOfImage));
         }
         if ((flags & KeyTypeFlags.SymbolKey) != 0)
         {
             IEnumerable <PEPdbRecord> pdbs = new PEPdbRecord[0];
             try
             {
                 pdbs = _peFile.Pdbs.ToArray();
             }
             catch (InvalidVirtualAddressException ex)
             {
                 Tracer.Error("Reading PDB records for {0}: {1}", _path, ex.Message);
             }
             foreach (PEPdbRecord pdb in pdbs)
             {
                 if (((flags & KeyTypeFlags.ForceWindowsPdbs) == 0) && pdb.IsPortablePDB)
                 {
                     yield return(PortablePDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature));
                 }
                 else
                 {
                     yield return(PDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature, pdb.Age));
                 }
             }
         }
         if ((flags & KeyTypeFlags.ClrKeys) != 0)
         {
             if (GetFileName(_path) == CoreClrFileName)
             {
                 string coreclrId = string.Format("{0:x}{1:x}", _peFile.Timestamp, _peFile.SizeOfImage);
                 foreach (string specialFileName in GetSpecialFiles())
                 {
                     yield return(BuildKey(specialFileName, coreclrId));
                 }
             }
         }
     }
 }
示例#5
0
        public override IEnumerable <SymbolStoreKey> GetKeys(KeyTypeFlags flags)
        {
            if (IsValid())
            {
                if ((flags & KeyTypeFlags.IdentityKey) != 0)
                {
                    yield return(GetKey(_path, _peFile.Timestamp, _peFile.SizeOfImage));
                }
                if ((flags & KeyTypeFlags.RuntimeKeys) != 0 && GetFileName(_path) == CoreClrFileName)
                {
                    yield return(GetKey(_path, _peFile.Timestamp, _peFile.SizeOfImage));
                }
                if ((flags & KeyTypeFlags.SymbolKey) != 0)
                {
                    PEPdbRecord[] pdbs = new PEPdbRecord[0];
                    try
                    {
                        pdbs = _peFile.Pdbs.ToArray();
                    }
                    catch (InvalidVirtualAddressException ex)
                    {
                        Tracer.Error("Reading PDB records for {0}: {1}", _path, ex.Message);
                    }

                    foreach (PEPdbRecord pdb in pdbs)
                    {
                        if (((flags & KeyTypeFlags.ForceWindowsPdbs) == 0) && pdb.IsPortablePDB)
                        {
                            yield return(PortablePDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature, _peFile.PdbChecksums));
                        }
                        else
                        {
                            yield return(PDBFileKeyGenerator.GetKey(pdb.Path, pdb.Signature, pdb.Age, _peFile.PdbChecksums));
                        }
                    }
                }

                if ((flags & KeyTypeFlags.PerfMapKeys) != 0)
                {
                    foreach (PEPerfMapRecord perfmapRecord in _peFile.PerfMapsV1)
                    {
                        if (perfmapRecord.Version > FileFormats.PerfMap.PerfMapFile.MaxKnownPerfMapVersion)
                        {
                            Tracer.Warning("Trying to get key for PerfmapFile {0} associated with PE {1} with version {2}, higher than max known version {3}",
                                           perfmapRecord.Path, _path, perfmapRecord.Version, FileFormats.PerfMap.PerfMapFile.MaxKnownPerfMapVersion);
                        }
                        yield return(PerfMapFileKeyGenerator.GetKey(perfmapRecord.Path, perfmapRecord.Signature, perfmapRecord.Version));
                    }
                }

                if ((flags & (KeyTypeFlags.ClrKeys | KeyTypeFlags.DacDbiKeys)) != 0)
                {
                    if (GetFileName(_path) == CoreClrFileName)
                    {
                        string coreclrId = string.Format("{0:X8}{1:x}", _peFile.Timestamp, _peFile.SizeOfImage);
                        foreach (string specialFileName in GetSpecialFiles(flags))
                        {
                            yield return(BuildKey(specialFileName, coreclrId));
                        }
                    }
                }
                if ((flags & KeyTypeFlags.HostKeys) != 0)
                {
                    if ((_peFile.FileHeader.Characteristics & (ushort)ImageFile.Dll) == 0 && !_peFile.IsILImage)
                    {
                        string id = string.Format("{0:X8}{1:x}", _peFile.Timestamp, _peFile.SizeOfImage);

                        // The host program as itself (usually dotnet.exe)
                        yield return(BuildKey(_path, id));

                        // apphost.exe downloaded as the host program name
                        yield return(BuildKey(_path, prefix: null, id, "apphost.exe"));
                    }
                }
            }
        }