示例#1
0
        private static GeneralInfo GetGeneralInfo(AnalyserOptions options)
        {
            var creationTime = File.GetCreationTime(options.Path);
            var fileName     = Path.GetFileName(options.Path);

            return(new GeneralInfo
            {
                DumpFilePath = options.Path,
                DumpFileCreationTime = creationTime,
                DumpFileName = fileName
            });
        }
示例#2
0
        public AnalysisResult RunAnalysis(AnalyserOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            try
            {
                ValidateOptions(options);
            }
            catch (InvalidOptionsException exception)
            {
                Log.Error(exception, "Provided analyser options are invalid");
                throw;
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Error while validating options");
                throw;
            }

            ClrRuntime runtime;

            try
            {
                runtime = LoadDump(options.Path);
                Log.Verbose("Loaded crash dump at {path}", options.Path);
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to load dump");
                throw;
            }

            var analysisResult = new AnalysisResult
            {
                GeneralInfo   = GetGeneralInfo(options),
                RuntimeInfo   = GetRuntimeInfo(runtime),
                AppDomains    = GetAppDomains(runtime),
                Threads       = GetThreads(runtime),
                MemoryRegions = GetMemoryRegions(runtime),
                HeapSegments  = GetHeapSegments(runtime),
                HeapBalance   = GetHeapBalance(runtime),
                Objects       = GetObjects(runtime)
            };

            Log.Verbose("Finished analysis");

            return(analysisResult);
        }
示例#3
0
        private static void ValidateOptions(AnalyserOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.Path))
            {
                throw new InvalidOptionsException("No path defined");
            }

            if (!File.Exists(options.Path))
            {
                throw new InvalidOptionsException($"Dump File does not exist: {options.Path}");
            }

            Log.Verbose("Analyser Options are valid: {@options}", options);
        }