private static List <Diagnoser> LoadDiagnosers(XDocument settingsDoc, Dictionary <String, Collector> collectors, Dictionary <String, Analyzer> analyzers) { var diagnosers = new List <Diagnoser>(); var diagnosticSettingsXml = settingsDoc.Element(SettingsXml.DiagnosticSettings); if (diagnosticSettingsXml == null) { return(diagnosers); } var diagnosersXml = diagnosticSettingsXml.Element(SettingsXml.Diagnosers); if (diagnosersXml == null) { return(diagnosers); } foreach (var diagnoserXml in diagnosersXml.Elements(SettingsXml.Diagnoser)) { var diagnoser = new Diagnoser() { Name = diagnoserXml.Attribute(SettingsXml.Name).Value }; var descriptionXml = diagnoserXml.Attribute(SettingsXml.Description); if (descriptionXml != null) { diagnoser.Description = descriptionXml.Value; } var processCleanupOnExitXml = diagnoserXml.Attribute(SettingsXml.ProcessCleanupOnCancel); if (processCleanupOnExitXml != null) { diagnoser.ProcessCleanupOnCancel = processCleanupOnExitXml.Value; } var collectorName = diagnoserXml.Element(SettingsXml.Collector).Attribute(SettingsXml.Name).Value; Collector collector; if (!collectors.TryGetValue(collectorName.ToLower(), out collector)) { throw new Exception(string.Format("Diagnoser {0} specifies a non-existant collector {1}", diagnoser.Name, collectorName)); } diagnoser.Collector = collector; var analyzerName = diagnoserXml.Element(SettingsXml.Analyzer).Attribute(SettingsXml.Name).Value; Analyzer analyzer; if (!analyzers.TryGetValue(analyzerName.ToLower(), out analyzer)) { throw new Exception(string.Format("Diagnoser {0} specifies a non-existant analyzer {1}", diagnoser.Name, analyzerName)); } diagnoser.Analyzer = analyzer; diagnosers.Add(diagnoser); } return(diagnosers); }
private static List <Diagnoser> GetDiagnosersToRun(string[] args, ref int argNum) { var diagnosers = SessionController.GetAllDiagnosers().ToList(); var diagnosersToRun = new List <Diagnoser>(); while (argNum < args.Length) { if (ArguementIsAParameter(args[argNum])) { // Done parsing all diagnosers break; } int timeSpan; if (int.TryParse(args[argNum], out timeSpan)) { // Done parsing all diagnosers, we've reached the timespan now break; } var diagnoserName = args[argNum]; argNum++; Diagnoser diagnoser = null; try { diagnoser = diagnosers.First(d => d.Name.Equals(diagnoserName, StringComparison.OrdinalIgnoreCase)); } catch { Console.WriteLine("There is no diagnoser called {0}. Valid names are below.", diagnoserName); ListDiagnosers(diagnosers); Environment.Exit(-1); } diagnosersToRun.Add(diagnoser); } if (diagnosersToRun.Count == 0) { Console.WriteLine("You must specify at least one diagnoser to run. Valid diagnosers are:"); ListDiagnosers(diagnosers); Environment.Exit(-1); } Console.WriteLine("Will use the following diagnosers:"); foreach (var diagnoser in diagnosersToRun) { Console.WriteLine(" " + diagnoser.Name); } return(diagnosersToRun); }
internal DiagnoserSession(Diagnoser diagnoser, SessionType sessionType) { Diagnoser = diagnoser; switch (sessionType) { case SessionType.Collect: CollectorStatus = DiagnosisStatus.InProgress; AnalyzerStatus = DiagnosisStatus.NotRequested; break; case SessionType.Diagnose: CollectorStatus = DiagnosisStatus.InProgress; AnalyzerStatus = DiagnosisStatus.WaitingForInputs; break; } }
static void Main(string[] args) { CommandLineOptions.Install(new CommandLineOptions()); CommandLineOptions.Clo.PrintInstrumented = true; CommandLineOptions.Clo.DoModSetAnalysis = true; var traceProgram = TTUtil.ReadAndResolve(args[0], false); var tracePre = new Preprocess(traceProgram); var traceDg = new Diagnoser(traceProgram); SplitType traceSt = null; SplitType wholeSt = null; List <HashSet <string> > localSol = null; List <HashSet <string> > globalSol = null; if (args.Any(arg => arg.Equals("/preprocess"))) { tracePre.Run(); TTUtil.PrintProgram(traceProgram, "temp.bpl"); return; } if (args.Any(arg => arg.Equals("/transform"))) { traceDg.Diagnose(); if (!traceDg.getPrecision()) { Console.WriteLine("Got nothing to do"); return; } traceProgram = tracePre.Run(); traceSt = new SplitType(traceProgram, traceDg.getMapSizes()); traceSt.Run(); localSol = traceSt.getSolsInTvFromSolsInInt(); //foreach (var sol in localSol) //{ // Console.WriteLine(string.Join(", ", sol)); //} var rw = new Rewritter(traceProgram, traceSt.getTypes(), Path.GetFileNameWithoutExtension(args[0]) + "_transformed.bpl"); rw.Rewrite(); if (!args.Any(a => a.Equals("/update"))) { return; } } if (args.Any(arg => arg.Equals("/update"))) { var wholeProgram = TTUtil.ReadAndResolve(args[1], false); var wholePre = new Preprocess(wholeProgram); var wholeDg = new Diagnoser(wholeProgram); wholeDg.Diagnose(); wholeProgram = wholePre.Run(); wholeSt = new SplitType(wholeProgram, wholeDg.getMapSizes()); wholeSt.Solve(); globalSol = wholeSt.getSolsInTv(); wholeSt.Merge(localSol); globalSol = wholeSt.getSolsInTv(); wholeSt.updateSolsInInt(); wholeSt.updateExprTypes(); //wholeSt.showUpdatedTypes(); //Console.WriteLine("==================updated global solution================"); //foreach (var sol in globalSol) //{ // Console.WriteLine(string.Join(", ", sol)); //} var rw = new Rewritter(wholeProgram, wholeSt.getTypes(), Path.GetFileNameWithoutExtension(args[1]) + "_updated.bpl"); rw.Rewrite(); } }
public DiagnoserDetails(Diagnoser diagnoser) { Name = diagnoser.Name; Warnings = new List <string>(diagnoser.GetWarnings()); Description = diagnoser.Description; }
private void LoadDiagnoserFromXml(XElement diagnoserXml) { var diagnoserName = diagnoserXml.Attribute(SessionXml.Name).Value; var allDiagnosers = Infrastructure.Settings.GetDiagnosers(); Diagnoser = allDiagnosers.FirstOrDefault(d => d.Name.Equals(diagnoserName, StringComparison.OrdinalIgnoreCase)); if (Diagnoser == null) { // The settings file has changed so that this diagnoser no longer exists. // We can no longer analyze this session but we'll create a mock diagnoser that no-ops on everything Diagnoser = new Diagnoser() { Name = diagnoserName, Collector = new RangeCollector() { Arguments = "", Command = "", Name = "" }, Analyzer = new Analyzer() { Arguments = "", Command = "", Name = "MockAnalyzer" } }; } var collectorXml = diagnoserXml.Element(SessionXml.Collector); var analyzerXml = diagnoserXml.Element(SessionXml.Analyzer); DiagnosisStatus collectorStatus; DiagnosisStatus.TryParse( collectorXml.Attribute(SessionXml.Status).Value, ignoreCase: true, result: out collectorStatus); CollectorStatus = collectorStatus; if (collectorStatus == DiagnosisStatus.InProgress) { CheckAndReturnCollectorDetailedStatus(diagnoserXml); } var collectorRunCountXml = collectorXml.Attribute(SessionXml.RunCount); if (collectorRunCountXml != null && !string.IsNullOrEmpty(collectorRunCountXml.Value)) { _collectorRunCount = int.Parse(collectorRunCountXml.Value); } _collectorFailureCount = int.Parse(collectorXml.Attribute(SessionXml.FailureCount).Value); foreach (var errorXml in collectorXml.Elements(SessionXml.Error)) { _collectorErrors.Add(errorXml.Value); } DiagnosisStatus analyzerStatus; DiagnosisStatus.TryParse( analyzerXml.Attribute(SessionXml.Status).Value, ignoreCase: true, result: out analyzerStatus); AnalyzerStatus = analyzerStatus; if (analyzerXml.Attribute(SessionXml.AnalyzerStartTime) != null) { if (DateTime.TryParse(analyzerXml.Attribute(SessionXml.AnalyzerStartTime).Value, out DateTime analyzerStartTime)) { AnalyzerStartTime = analyzerStartTime.ToUniversalTime(); } } var analyzerRunCountXml = analyzerXml.Attribute(SessionXml.RunCount); if (analyzerRunCountXml != null && !string.IsNullOrEmpty(analyzerRunCountXml.Value)) { _analyzerRunCount = int.Parse(analyzerRunCountXml.Value); } _analyzerFailureCount = int.Parse(analyzerXml.Attribute(SessionXml.FailureCount).Value); foreach (var errorXml in analyzerXml.Elements(SessionXml.Error)) { _analyzerErrors.Add(errorXml.Value); } var logsXml = diagnoserXml.Element(SessionXml.Logs); if (logsXml != null) { foreach (var logXml in logsXml.Elements(SessionXml.Log)) { var logPath = logXml.Attribute(SessionXml.Path).Value; double fileSize = 0; if (logXml.Attribute(SessionXml.FileSize) != null) { double.TryParse(logXml.Attribute(SessionXml.FileSize).Value, out fileSize); } string blobSasUri = string.Empty; if (logXml.Attribute(SessionXml.BlobSasUri) != null) { blobSasUri = logXml.Attribute(SessionXml.BlobSasUri).Value; } var log = Log.GetLogFromPermanentStorage(logPath, fileSize, blobSasUri); if (logXml.Attribute(SessionXml.AnalysisStarted) != null) { if (DateTime.TryParse(logXml.Attribute(SessionXml.AnalysisStarted).Value, out DateTime analysisStarted)) { log.AnalysisStarted = analysisStarted.ToUniversalTime(); } } if (logXml.Attribute(SessionXml.InstanceAnalyzing) != null) { log.InstanceAnalyzing = logXml.Attribute(SessionXml.InstanceAnalyzing).Value; } AddLog(log); if (analyzerStatus == DiagnosisStatus.InProgress) { CheckAndReturnAnalyzerDetailedStatus(log); } foreach (var reportXml in logXml.Elements(SessionXml.Report)) { var reportPath = reportXml.Attribute(SessionXml.Path).Value; var report = Report.GetReport(reportPath); AddReportForLog(log, report); } } } }