コード例 #1
0
        private static void DownloadSymbolsForAllFiles(string currentDirectory, string symbolPath)
        {
            IEnumerable <string> dlls = Directory.GetFiles(currentDirectory, "*.dll", SearchOption.AllDirectories);

            dlls = dlls.Concat(Directory.GetFiles(currentDirectory, "*.exe", SearchOption.AllDirectories));

            foreach (var file in dlls)
            {
                if (!PEFile.PEFileReader.IsManagedAssembly(file))
                {
                    continue;
                }

                var pdb = Path.ChangeExtension(file, ".pdb");
                if (!File.Exists(pdb))
                {
                    DownloadSymbols(file, symbolPath);
                }
                else if (!PdbInfo.IsMatch(file, pdb))
                {
                    File.Delete(pdb);
                    DownloadSymbols(file, pdb);
                }
            }
        }
コード例 #2
0
        private static void PrintAssemblyInfo(string dll)
        {
            var debugDirectory = PdbInfo.ReadDebugDirectoryEntries(dll);

            foreach (var debugDirectoryEntry in debugDirectory)
            {
                PrintNameValue("Debug directory entry", debugDirectoryEntry.entry.Type.ToString());
                if (debugDirectoryEntry.entry.Type == DebugDirectoryEntryType.CodeView)
                {
                    CodeViewDebugDirectoryData data = (CodeViewDebugDirectoryData)debugDirectoryEntry.data;
                    PrintNameValue("Guid", data.Guid.ToString());
                    PrintNameValue("Age", data.Age.ToString());
                    PrintNameValue("Pdb path", data.Path.ToString());
                    PrintNameValue("Stamp", debugDirectoryEntry.entry.Stamp.ToString("X8"));
                }

                Console.WriteLine();
            }

            var pdb = Path.ChangeExtension(dll, ".pdb");

            if (File.Exists(pdb))
            {
                Console.WriteLine("Found " + Path.GetFileName(pdb) + ":");
                CheckMatch(dll, pdb);
            }
        }
コード例 #3
0
 private static IEnumerable <PdbInfo> ReadList(string assemblyFilePath)
 {
     using (var stream = File.OpenRead(assemblyFilePath))
     {
         PEReader reader         = new PEReader(stream);
         var      metadataReader = reader.GetMetadataReader();
         var      debugDirectory = reader.ReadDebugDirectory();
         foreach (var debugDirectoryEntry in debugDirectory)
         {
             if (debugDirectoryEntry.Type == DebugDirectoryEntryType.CodeView)
             {
                 var codeViewDebugDirectoryData = reader.ReadCodeViewDebugDirectoryData(debugDirectoryEntry);
                 var info = new PdbInfo
                 {
                     AssemblyFilePath = assemblyFilePath,
                     Guid             = codeViewDebugDirectoryData.Guid,
                     Age   = codeViewDebugDirectoryData.Age,
                     Path  = codeViewDebugDirectoryData.Path,
                     Stamp = debugDirectoryEntry.Stamp
                 };
                 Log(info.ToString());
                 yield return(info);
             }
         }
     }
 }
コード例 #4
0
 private static void CheckMatch(string dll, string pdb)
 {
     if (PdbInfo.IsMatch(dll, pdb))
     {
         Log("Match", ConsoleColor.Green);
     }
     else
     {
         Log("No match", ConsoleColor.Red);
     }
 }
コード例 #5
0
        public static void DownloadPdb(PdbInfo pdbInfo)
        {
            var client = new HttpClient();
            var text   = client.GetStringAsync(pdbInfo.SymbolsUrl).Result;

            if (text.StartsWith("PATH:"))
            {
                text = text.Substring(5);
            }

            //File.Copy(text, @"C:\Temp\1.pdb", overwrite: true);
        }
コード例 #6
0
        private static void PrintAssemblyInfo(string dll)
        {
            var debugDirectory = PdbInfo.Read(dll);

            foreach (var pdb in debugDirectory)
            {
                PrintNameValue("Guid", pdb.Guid.ToString());
                PrintNameValue("Age", pdb.Age.ToString());
                PrintNameValue("Pdb path", pdb.Path.ToString());
                PrintNameValue("Stamp", pdb.Stamp.ToString("X8"));
                Console.WriteLine();
            }
        }
コード例 #7
0
        private static void DownloadSymbols(string dll, string url)
        {
            var pdbInfo = PdbInfo.Read(dll);

            foreach (var record in pdbInfo)
            {
                if (record.DownloadPdb(url))
                {
                    return;
                }
            }

            Log($"Couldn't find symbols for {dll} at {url}");
        }
コード例 #8
0
        private static void FindMatchingPdb(string dll, string directory)
        {
            var pdbs = Directory.GetFiles(
                directory,
                Path.GetFileNameWithoutExtension(dll) + ".pdb",
                SearchOption.AllDirectories);
            var debugDirectory = PdbInfo.Read(dll);

            foreach (var pdb in pdbs)
            {
                if (PdbInfo.IsMatch(debugDirectory, pdb))
                {
                    Log("Match: " + pdb, ConsoleColor.Green);
                }
            }
        }