Exemplo n.º 1
0
        private void Analyze(DumpFileInfo dumpFileInfo)
        {
            int      maxRetryCount        = 5;
            int      retryCount           = 0;
            TimeSpan pauseBetweenAttempts = TimeSpan.FromSeconds(5);
            bool     success = false;

            while (retryCount < maxRetryCount && !success)
            {
                try
                {
                    Logger.PrintTrace($"Attempt {++retryCount}");
                    _defaultAnalysis.DumpFiles.Clear();
                    _defaultAnalysis.AddDumpFile(dumpFileInfo.FilePath);
                    _defaultAnalysis.ReportPath = dumpFileInfo.FilePath + ".mht";
                    _defaultAnalysis.Symbols    = DumpAnalyzerConfig.PublicSymbols;
                    if (!string.IsNullOrEmpty(DumpAnalyzerConfig.RelativeSymbolsDirectory))
                    {
                        _defaultAnalysis.Symbols += $";{GetRelativeSymbolsPath(dumpFileInfo)}";
                    }

                    _dumpAnalyzer.RunAnalysis(_defaultAnalysis);
                    success = true;
                }
                catch (FileLoadException ex)
                {
                    Logger.ReportError($"error with reading the file {ex.FileName} - reetry again in {pauseBetweenAttempts}");
                    Logger.PrintError(ex);

                    Thread.Sleep(pauseBetweenAttempts);
                }
            }
        }
 /// <summary>
 /// Receives a list of dump file names with the path separated by commas, no spaces between the paths
 /// try to add the dumpnames to the list of dumps to be analyzed if the dumpname is invalid it wont be added
 /// </summary>
 /// <param name="dumpFilesPaths"></param>
 /// <returns>Boolean indicating if there is at least 1 valid file to process</returns>
 private bool ValidateDumpFiles(string dumpFilesPaths)
 {
     foreach (string dumpName in dumpFilesPaths.Split(','))
     {
         FileAttributes attr = File.GetAttributes(dumpName);
         if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
         {
             string dumpFiles = string.Join(",", Directory.GetFiles(dumpName, "*.dmp"));
             ValidateDumpFiles(dumpFiles);
         }
         else
         {
             _aj.AddDumpFile(dumpName);
         }
     }
     if (_aj.DumpFiles.Count > 0)
     {
         return(true);                         // we have at least one file to analyze, so we can continue
     }
     return(false);
 }