Ejemplo n.º 1
0
        public override IEnumerable <SymbolStoreKey> GetKeys(KeyTypeFlags flags)
        {
            if (!IsValid() || (flags & KeyTypeFlags.IdentityKey) == 0)
            {
                yield break;
            }

            Debug.Assert(_perfmapFile.Header is not null);

            PerfMapFile.PerfMapHeader header = _perfmapFile.Header;

            if (header.Version > PerfMapFile.MaxKnownPerfMapVersion)
            {
                Tracer.Warning("Trying to get key for PerfMap {0} with version {1}, higher than max known version {2}.",
                               _file.FileName, header.Version, PerfMapFile.MaxKnownPerfMapVersion);
            }

            yield return(PerfMapFileKeyGenerator.GetKey(_file.FileName, header.Signature, header.Version));
        }
Ejemplo n.º 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.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"));
                    }
                }
            }
        }