Ejemplo n.º 1
0
        public void RunAnalysis(AnalysisJob analysis)
        {
            using (NetAnalyzer analyzer = new NetAnalyzer())
            {
                List <AnalysisRuleInfo> ari = analysis.AnalisysRuleInfos;

                if (ari.Count < 1 && analysis.Modules.Count < 1)
                {
                    Logger.ReportError("Could not find any rule that matches the parameters.\r\n");
                    Logger.ShowCommandLineOptions();
                    return;
                }

                Logger.PrintProgress(("\r\nThe Dump Files being analyzed are: \n\r"));

                foreach (string dumpName in analysis.DumpFiles)
                {
                    Logger.PrintTrace(dumpName);
                }
                Logger.PrintTrace();

                foreach (Assembly module in analysis.Modules)
                {
                    analyzer.AddAnalysisRulesToRunList(module);
                }

                //analyzer.AnalysisRuleInfos = analysisRuleInfos;
                analyzer.AnalysisRuleInfos.AddRange(ari);

                Logger.PrintProgress("The rules being executed are: \n\r");

                foreach (AnalysisRuleInfo ruleInfo in analyzer.AnalysisRuleInfos)
                {
                    Logger.PrintTrace(ruleInfo.DisplayName);
                }
                Logger.PrintTrace("");

                Logger.PrintProgress("The symbols sources are: \n\r");

                Logger.PrintTrace(analysis.Symbols);
                Logger.PrintTrace("");

                //Add Dump list to Analizer object so we can analyze them with the debugger
                analyzer.AddDumpFiles(analysis.DumpFiles, analysis.Symbols);

                NetProgress np = new NetProgress();
                np.OnSetOverallStatusChanged += new EventHandler <SetOverallStatusEventArgs>(np_OnSetOverallStatusChanged);
                //np.OnSetCurrentPositionChanged += new EventHandler<SetCurrentPositionEventArgs>(np_OnSetCurrentPositionChanged);
                np.OnSetCurrentStatusChanged += new EventHandler <SetCurrentStatusEventArgs>(np_OnSetCurrentStatusChanged);
                np.OnEnd += new EventHandler(np_OnEnd);

                Logger.PrintTrace($"{DateTime.Now.ToLongTimeString()} - Start Analysis");
                _stopwatch.Start();

                try
                {
                    analyzer.RunAnalysisRules(np, analysis.Symbols, "", analysis.ReportPath);
                }
                catch (Exception ex)
                {
                    Logger.PrintError(ex);
                }
                finally
                {
                    _stopwatch.Stop();
                }
                np.End();

                if (analysis.ShowResults)
                {
                    analyzer.ShowReportFiles();
                }
            }
        }
Ejemplo n.º 2
0
        static void RunAnalysis()
        {
            using (NetAnalyzer analyzer = new NetAnalyzer())
            {
                List <AnalysisRuleInfo> ari = _analysis.AnalisysRuleInfos;

                if (ari.Count < 1 && _analysis.Modules.Count < 1)
                {
                    ErrorHandler.ReportError("Could not find any rule that matches the parameters.\r\n");
                    ErrorHandler.ShowCommandLineOptions();
                    return;
                }

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\r\nThe Dump Files being analyzed are: \n\r");
                Console.ResetColor();

                foreach (string dumpName in _analysis.DumpFiles)
                {
                    Console.WriteLine(dumpName);
                }
                Console.WriteLine();

                foreach (Assembly module in _analysis.Modules)
                {
                    analyzer.AddAnalysisRulesToRunList(module);
                }

                //analyzer.AnalysisRuleInfos = analysisRuleInfos;
                analyzer.AnalysisRuleInfos.AddRange(ari);

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("The rules being executed are: \n\r");
                Console.ResetColor();

                foreach (AnalysisRuleInfo ruleInfo in analyzer.AnalysisRuleInfos)
                {
                    Console.WriteLine(ruleInfo.DisplayName);
                }
                Console.WriteLine();

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("The symbols sources are: \n\r");
                Console.ResetColor();

                Console.WriteLine(_analysis.Symbols);
                Console.WriteLine();

                //Add Dump list to Analizer object so we can analyze them with the debugger
                analyzer.AddDumpFiles(_analysis.DumpFiles, _analysis.Symbols);

                NetProgress np = new NetProgress();
                np.OnSetOverallStatusChanged += new EventHandler <SetOverallStatusEventArgs>(np_OnSetOverallStatusChanged);
                //np.OnSetCurrentPositionChanged += new EventHandler<SetCurrentPositionEventArgs>(np_OnSetCurrentPositionChanged);
                np.OnSetCurrentStatusChanged += new EventHandler <SetCurrentStatusEventArgs>(np_OnSetCurrentStatusChanged);
                np.OnEnd += new EventHandler(np_OnEnd);

                Console.WriteLine(string.Format("{0} - Start Analysis", DateTime.Now.ToLongTimeString()));
                stopwatch.Start();

                try
                {
                    analyzer.RunAnalysisRules(np, _analysis.Symbols, "", _analysis.ReportPath);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
                finally
                {
                    stopwatch.Stop();
                }
                np.End();

                if (_analysis.ShowResults)
                {
                    analyzer.ShowReportFiles();
                }
            }
        }
Ejemplo n.º 3
0
        private static void RunAnalysis(Options options)
        {
            var dumpFile = new FileInfo(options.DumpFile);

            if (!dumpFile.Exists)
            {
                PrintError("Dump file does not exist: {0}", dumpFile);
                return;
            }

            var reportPath = new FileInfo(options.ReportFile);

            if (reportPath.Exists && options.Overwrite == false)
            {
                PrintError("Report file does already exist");
                return;
            }

            if (string.IsNullOrEmpty(options.SymbolPath))
            {
                options.SymbolPath = Environment.GetEnvironmentVariable("_NT_SYMBOL_PATH");
            }

            using (var analyzer = new NetAnalyzer()) {
                //analyzer.Initialize(true, true, true, true);
                analyzer.AddDumpFile(dumpFile.FullName, options.SymbolPath);

                if (options.AnalysisRules == null || options.AnalysisRules.Count() == 0)
                {
                    options.AnalysisRules = new List <string>()
                    {
                        "CrashHangAnalysis",
                        "MemoryAnalysis",
                        "DotNetMemoryAnalysis"
                    };
                }

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("DebugDiag analysis");
                Console.ResetColor();

                Console.WriteLine("Dump: {0}", dumpFile);
                Console.WriteLine("Report file: {0}", options.ReportFile);
                Console.WriteLine("Analysis rules: {0}", string.Join(",", options.AnalysisRules.ToArray()));
                Console.WriteLine("Symbol path: {0}", options.SymbolPath);

                foreach (Type analysisRule in DebugDiagHelper.GetAnalysisRules(options.AnalysisRules))
                {
                    analyzer.AddAnalysisRuleToRunList(analysisRule);
                }

                NetProgress progress = new NetProgress();
                try {
                    stopwatch.Start();
                    progress.OnSetCurrentStatusChanged += Progress_OnSetCurrentStatusChanged;
                    progress.OnSetOverallStatusChanged += Progress_OnSetOverallStatusChanged;
                    progress.OnEnd += Progress_OnEnd;

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("Start DebugDiag analysis");
                    Console.ResetColor();

                    analyzer.RunAnalysisRules(progress, options.SymbolPath, options.ImagePath, options.ReportFile);
                } finally {
                    stopwatch.Stop();
                }
                progress.End();
            }
        }