public void Run() { if (WhoopRaceCheckerCommandLineOptions.Get().MeasurePassExecutionTime) { Console.WriteLine(" |------ [{0} :: {1}]", this.EP1.Name, this.EP2.Name); Console.WriteLine(" | |"); this.Timer = new ExecutionTimer(); this.Timer.Start(); } Instrumentation.Factory.CreateAsyncCheckingInstrumentation(this.AC, this.Pair).Run(); Instrumentation.Factory.CreateYieldInstrumentation(this.AC, this.RaceCheckedAC, this.Pair, this.ErrorReporter).Run(); if (WhoopRaceCheckerCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |"); Console.WriteLine(" | |--- [Total] {0}", this.Timer.Result()); Console.WriteLine(" |"); } Whoop.IO.BoogieProgramEmitter.Emit(this.AC.TopLevelDeclarations, WhoopRaceCheckerCommandLineOptions.Get().Files[ WhoopRaceCheckerCommandLineOptions.Get().Files.Count - 1], "check_racy_" + this.EP1.Name + "_" + this.EP2.Name, "bpl"); }
public static void Main(string[] args) { Contract.Requires(cce.NonNullElements(args)); CommandLineOptions.Install(new WhoopRaceCheckerCommandLineOptions()); try { WhoopRaceCheckerCommandLineOptions.Get().RunningBoogieFromCommandLine = true; if (!WhoopRaceCheckerCommandLineOptions.Get().Parse(args)) { Environment.Exit((int)Outcome.FatalError); } if (WhoopRaceCheckerCommandLineOptions.Get().Files.Count == 0) { Whoop.IO.Reporter.ErrorWriteLine("Whoop: error: no input files were specified"); Environment.Exit((int)Outcome.FatalError); } List <string> fileList = new List <string>(); foreach (string file in WhoopRaceCheckerCommandLineOptions.Get().Files) { string extension = Path.GetExtension(file); if (extension != null) { extension = extension.ToLower(); } fileList.Add(file); } foreach (string file in fileList) { Contract.Assert(file != null); string extension = Path.GetExtension(file); if (extension != null) { extension = extension.ToLower(); } if (extension != ".bpl") { Whoop.IO.Reporter.ErrorWriteLine("Whoop: error: {0} is not a .bpl file", file); Environment.Exit((int)Outcome.FatalError); } } DeviceDriver.ParseAndInitialize(fileList); Summarisation.SummaryInformationParser.FromFile(fileList); PipelineStatistics stats = new PipelineStatistics(); ExecutionTimer timer = null; if (WhoopRaceCheckerCommandLineOptions.Get().MeasurePassExecutionTime) { Console.WriteLine("\n[RaceChecker] runtime"); Console.WriteLine(" |"); timer = new ExecutionTimer(); timer.Start(); } var pairMap = new Dictionary <EntryPointPair, Tuple <AnalysisContext, ErrorReporter> >(); foreach (var pair in DeviceDriver.EntryPointPairs) { AnalysisContext ac = null; var parser = new AnalysisContextParser(fileList[fileList.Count - 1], "wbpl"); var errorReporter = new ErrorReporter(pair); if (pair.EntryPoint1.Name.Equals(pair.EntryPoint2.Name)) { string extension = null; if (Summarisation.SummaryInformationParser.AvailableSummaries.Contains(pair.EntryPoint1.Name)) { extension = "$summarised"; } else { extension = "$instrumented"; } parser.TryParseNew(ref ac, new List <string> { "check_" + pair.EntryPoint1.Name + "_" + pair.EntryPoint2.Name, pair.EntryPoint1.Name + extension }); } else { string extension1 = null; if (Summarisation.SummaryInformationParser.AvailableSummaries.Contains(pair.EntryPoint1.Name)) { extension1 = "$summarised"; } else { extension1 = "$instrumented"; } string extension2 = null; if (Summarisation.SummaryInformationParser.AvailableSummaries.Contains(pair.EntryPoint2.Name)) { extension2 = "$summarised"; } else { extension2 = "$instrumented"; } parser.TryParseNew(ref ac, new List <string> { "check_" + pair.EntryPoint1.Name + "_" + pair.EntryPoint2.Name, pair.EntryPoint1.Name + extension1, pair.EntryPoint2.Name + extension2 }); } new StaticLocksetAnalyser(ac, pair, errorReporter, stats).Run(); pairMap.Add(pair, new Tuple <AnalysisContext, ErrorReporter>(ac, errorReporter)); } if (WhoopRaceCheckerCommandLineOptions.Get().FindBugs) { foreach (var pair in pairMap) { if (!WhoopRaceCheckerCommandLineOptions.Get().YieldAll&& WhoopRaceCheckerCommandLineOptions.Get().SkipRaceFreePairs&& !pair.Value.Item2.FoundErrors) { continue; } AnalysisContext ac = null; new AnalysisContextParser(fileList[fileList.Count - 1], "wbpl").TryParseNew(ref ac); new YieldInstrumentationEngine(ac, pair.Key, pair.Value.Item1, pair.Value.Item2).Run(); } } if (WhoopRaceCheckerCommandLineOptions.Get().MeasurePassExecutionTime) { timer.Stop(); Console.WriteLine(" |"); Console.WriteLine(" |--- [Total] {0}", timer.Result()); } Whoop.IO.Reporter.WriteTrailer(stats); Outcome oc = Outcome.Done; if ((stats.ErrorCount + stats.InconclusiveCount + stats.TimeoutCount + stats.OutOfMemoryCount) > 0) { oc = Outcome.LocksetAnalysisError; } Environment.Exit((int)oc); } catch (Exception e) { Console.Error.Write("Exception thrown in Whoop: "); Console.Error.WriteLine(e); Environment.Exit((int)Outcome.FatalError); } }
public void Run() { if (WhoopRaceCheckerCommandLineOptions.Get().MeasurePassExecutionTime) { Console.WriteLine(" |------ [{0} :: {1}]", this.EP1.Name, this.EP2.Name); Console.WriteLine(" | |"); this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AC.EliminateDeadVariables(); this.AC.Inline(); if (WhoopRaceCheckerCommandLineOptions.Get().LoopUnrollCount != -1) { this.AC.Program.UnrollLoops(WhoopRaceCheckerCommandLineOptions.Get().LoopUnrollCount, WhoopRaceCheckerCommandLineOptions.Get().SoundLoopUnrolling); } string checkerName = "check$" + this.EP1.Name + "$" + this.EP2.Name; Implementation checker = this.AC.TopLevelDeclarations.OfType <Implementation>().ToList(). Find(val => val.Name.Equals(checkerName)); Contract.Assert(checker != null); VC.ConditionGeneration vcgen = null; try { vcgen = new VC.VCGen(this.AC.Program, WhoopRaceCheckerCommandLineOptions.Get().SimplifyLogFilePath, WhoopRaceCheckerCommandLineOptions.Get().SimplifyLogFileAppend, new List <Checker>()); } catch (ProverException e) { Whoop.IO.Reporter.ErrorWriteLine("Fatal Error: ProverException: {0}", e); Environment.Exit((int)Outcome.FatalError); } int prevAssertionCount = vcgen.CumulativeAssertionCount; List <Counterexample> errors; DateTime start = new DateTime(); if (WhoopRaceCheckerCommandLineOptions.Get().Trace) { start = DateTime.UtcNow; if (WhoopRaceCheckerCommandLineOptions.Get().Trace) { Console.WriteLine(""); Console.WriteLine("Verifying {0} ...", checker.Name.Substring(5)); } } VC.VCGen.Outcome vcOutcome; try { vcOutcome = vcgen.VerifyImplementation(checker, out errors); } catch (VC.VCGenException e) { Whoop.IO.Reporter.ReportBplError(checker, String.Format("Error BP5010: {0} Encountered in implementation {1}.", e.Message, checker.Name), true, true); errors = null; vcOutcome = VC.VCGen.Outcome.Inconclusive; } catch (UnexpectedProverOutputException e) { Whoop.IO.Reporter.AdvisoryWriteLine("Advisory: {0} SKIPPED because of internal error: unexpected prover output: {1}", checker.Name, e.Message); errors = null; vcOutcome = VC.VCGen.Outcome.Inconclusive; } string timeIndication = ""; DateTime end = DateTime.UtcNow; TimeSpan elapsed = end - start; if (WhoopRaceCheckerCommandLineOptions.Get().Trace) { int poCount = vcgen.CumulativeAssertionCount - prevAssertionCount; timeIndication = string.Format(" [{0:F3} s, {1} proof obligation{2}] ", elapsed.TotalSeconds, poCount, poCount == 1 ? "" : "s"); } this.ProcessOutcome(checker, vcOutcome, errors, timeIndication, this.Stats); if (vcOutcome == VC.VCGen.Outcome.Errors || WhoopRaceCheckerCommandLineOptions.Get().Trace) { Console.Out.Flush(); } WhoopRaceCheckerCommandLineOptions.Get().TheProverFactory.Close(); // cce.NonNull(WhoopRaceCheckerCommandLineOptions.Get().TheProverFactory).Close(); vcgen.Dispose(); if (WhoopRaceCheckerCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [StaticLocksetAnalyser] {0}", this.Timer.Result()); Console.WriteLine(" |"); } }
private void ProcessOutcome(Implementation impl, VC.VCGen.Outcome outcome, List <Counterexample> errors, string timeIndication, PipelineStatistics stats) { switch (outcome) { case VC.VCGen.Outcome.ReachedBound: Whoop.IO.Reporter.Inform(String.Format("{0}verified", timeIndication)); Console.WriteLine(string.Format("Stratified Inlining: Reached recursion bound of {0}", WhoopRaceCheckerCommandLineOptions.Get().RecursionBound)); stats.VerifiedCount++; break; case VC.VCGen.Outcome.Correct: if (WhoopRaceCheckerCommandLineOptions.Get().vcVariety == CommandLineOptions.VCVariety.Doomed) { Whoop.IO.Reporter.Inform(String.Format("{0}credible", timeIndication)); stats.VerifiedCount++; } else { Whoop.IO.Reporter.Inform(String.Format("{0}verified", timeIndication)); stats.VerifiedCount++; } break; case VC.VCGen.Outcome.TimedOut: stats.TimeoutCount++; Whoop.IO.Reporter.Inform(String.Format("{0}timed out", timeIndication)); break; case VC.VCGen.Outcome.OutOfMemory: stats.OutOfMemoryCount++; Whoop.IO.Reporter.Inform(String.Format("{0}out of memory", timeIndication)); break; case VC.VCGen.Outcome.Inconclusive: stats.InconclusiveCount++; Whoop.IO.Reporter.Inform(String.Format("{0}inconclusive", timeIndication)); break; case VC.VCGen.Outcome.Errors: Contract.Assert(errors != null); if (WhoopRaceCheckerCommandLineOptions.Get().vcVariety == CommandLineOptions.VCVariety.Doomed) { Whoop.IO.Reporter.Inform(String.Format("{0}doomed", timeIndication)); stats.ErrorCount++; } errors.Sort(new CounterexampleComparer()); int errorCount = 0; foreach (Counterexample error in errors) { errorCount += this.ErrorReporter.ReportCounterexample(error); } if (errorCount == 0) { Whoop.IO.Reporter.Inform(String.Format("{0}verified", timeIndication)); stats.VerifiedCount++; } else { Whoop.IO.Reporter.Inform(String.Format("{0}error{1}", timeIndication, errorCount == 1 ? "" : "s")); stats.ErrorCount += errorCount; } break; default: Contract.Assert(false); // unexpected outcome throw new cce.UnreachableException(); } }