Пример #1
0
        private static void RunParsingEngine()
        {
            Program.StartTimer("ParsingEngine");

            AnalysisContext programAC = null;

            new AnalysisContextParser(Program.FileList[Program.FileList.Count - 1],
                                      "bpl").TryParseNew(ref programAC);

            Refactoring.Factory.CreateProgramSimplifier(programAC).Run();
            Analysis.ModelCleaner.RemoveCorralFunctions(programAC);

            Whoop.IO.BoogieProgramEmitter.Emit(programAC.TopLevelDeclarations, WhoopEngineCommandLineOptions.Get().Files[
                                                   WhoopEngineCommandLineOptions.Get().Files.Count - 1], "wbpl");

            foreach (var ep in DeviceDriver.EntryPoints)
            {
                AnalysisContext ac = null;
                new AnalysisContextParser(Program.FileList[Program.FileList.Count - 1],
                                          "wbpl").TryParseNew(ref ac);
                new ParsingEngine(ac, ep).Run();
            }

            Program.StopTimer();
        }
Пример #2
0
        private static void RunStaticLocksetAnalysisInstrumentationEngine()
        {
            Program.StartTimer("StaticLocksetAnalysisInstrumentationEngine");

            foreach (var ep in DeviceDriver.EntryPoints)
            {
                AnalysisContext ac = null;
                new AnalysisContextParser(Program.FileList[Program.FileList.Count - 1], "wbpl").TryParseNew(
                    ref ac, new List <string> {
                    ep.Name
                });

                Analysis.SharedStateAnalyser.AnalyseMemoryRegions(ac, ep);
                AnalysisContext.RegisterEntryPointAnalysisContext(ac, ep);
            }

            foreach (var ep in DeviceDriver.EntryPoints)
            {
                var ac = AnalysisContext.GetAnalysisContext(ep);
                new StaticLocksetAnalysisInstrumentationEngine(ac, ep).Run();
            }

            Program.StopTimer();

            if (!WhoopEngineCommandLineOptions.Get().SkipInference)
            {
                return;
            }

            SummaryInformationParser.ToFile(Program.FileList);
        }
Пример #3
0
 private static void StopTimer()
 {
     if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
     {
         Program.Timer.Stop();
         Console.WriteLine(" |");
         Console.WriteLine(" |--- [Total] {0}\n", Program.Timer.Result());
     }
 }
Пример #4
0
 private static void StartTimer(string engineName)
 {
     if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
     {
         Console.WriteLine("\n[" + engineName + "] runtime");
         Console.WriteLine(" |");
         Program.Timer = new ExecutionTimer();
         Program.Timer.Start();
     }
 }
Пример #5
0
        public void Run()
        {
            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                Console.WriteLine(" |------ [{0} :: {1}]", this.Pair.EntryPoint1.Name, this.Pair.EntryPoint2.Name);
                Console.WriteLine(" |  |");
                this.Timer = new ExecutionTimer();
                this.Timer.Start();
            }

            Analysis.Factory.CreateLockAbstraction(this.AC).Run();

            if (this.Pair.EntryPoint1.Name.Equals(this.Pair.EntryPoint2.Name))
            {
                Instrumentation.Factory.CreateGlobalRaceCheckingInstrumentation(this.AC, this.Pair.EntryPoint1).Run();
            }
            else
            {
                Instrumentation.Factory.CreateGlobalRaceCheckingInstrumentation(this.AC, this.Pair.EntryPoint1).Run();
                Instrumentation.Factory.CreateGlobalRaceCheckingInstrumentation(this.AC, this.Pair.EntryPoint2).Run();
            }

            Instrumentation.Factory.CreatePairInstrumentation(this.AC, this.Pair).Run();
            Analysis.Factory.CreatePairParameterAliasAnalysis(this.AC, this.Pair).Run();

            ModelCleaner.RemoveOriginalInitFunc(this.AC);
            ModelCleaner.RemoveEntryPointSpecificTopLevelDeclerations(this.AC);
            ModelCleaner.RemoveUnusedTopLevelDeclerations(this.AC);
            ModelCleaner.RemoveUnecesseryInfoFromSpecialFunctions(this.AC);
//      ModelCleaner.RemoveNonPairMemoryRegions(this.AC, pair.Item1, pair.Item2);
            ModelCleaner.RemoveCorralFunctions(this.AC);

            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                this.Timer.Stop();
                Console.WriteLine(" |  |");
                Console.WriteLine(" |  |--- [Total] {0}", this.Timer.Result());
                Console.WriteLine(" |");
            }

            Whoop.IO.BoogieProgramEmitter.Emit(this.AC.TopLevelDeclarations,
                                               WhoopEngineCommandLineOptions.Get().Files[
                                                   WhoopEngineCommandLineOptions.Get().Files.Count - 1], "check_" +
                                               this.Pair.EntryPoint1.Name + "_" + this.Pair.EntryPoint2.Name, "wbpl");
        }
Пример #6
0
        public void Run()
        {
            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                Console.WriteLine(" |------ [{0}]", this.EP.Name);
                Console.WriteLine(" |  |");
                this.Timer = new ExecutionTimer();
                this.Timer.Start();
            }

            Analysis.Factory.CreateFunctionPointerUseAnalysis(this.AC, this.EP).Run();
            Analysis.Factory.CreateWatchdogInformationAnalysis(this.AC, this.EP).Run();

            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                this.Timer.Stop();
                Console.WriteLine(" |  |");
                Console.WriteLine(" |  |--- [Total] {0}", this.Timer.Result());
                Console.WriteLine(" |");
            }
        }
Пример #7
0
        public void Run()
        {
            if (ParsingEngine.AlreadyParsed.Contains(this.EP.Name))
            {
                return;
            }

            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                Console.WriteLine(" |------ [{0}]", this.EP.Name);
                Console.WriteLine(" |  |");
                this.Timer = new ExecutionTimer();
                this.Timer.Start();
            }

            Analysis.Factory.CreateLockAbstraction(this.AC).Run();
            Refactoring.Factory.CreateLockRefactoring(this.AC, this.EP).Run();
            Refactoring.Factory.CreateFunctionPointerRefactoring(this.AC, this.EP).Run();
            Refactoring.Factory.CreateEntryPointRefactoring(this.AC, this.EP).Run();

            ModelCleaner.RemoveCorralFunctions(this.AC);
            ModelCleaner.RemoveModelledProcedureBodies(this.AC);

            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                this.Timer.Stop();
                Console.WriteLine(" |  |");
                Console.WriteLine(" |  |--- [Total] {0}", this.Timer.Result());
                Console.WriteLine(" |");
            }

            Whoop.IO.BoogieProgramEmitter.Emit(this.AC.TopLevelDeclarations, WhoopEngineCommandLineOptions.Get().Files[
                                                   WhoopEngineCommandLineOptions.Get().Files.Count - 1], this.EP.Name, "wbpl");

            ParsingEngine.AlreadyParsed.Add(this.EP.Name);
        }
Пример #8
0
        private static void RunSummaryGenerationEngine()
        {
            if (WhoopEngineCommandLineOptions.Get().SkipInference)
            {
                return;
            }

            Program.StartTimer("SummaryGenerationEngine");

            foreach (var ep in DeviceDriver.EntryPoints)
            {
                var ac = AnalysisContext.GetAnalysisContext(ep);
                new WatchdogAnalysisEngine(ac, ep).Run();
            }

            foreach (var ep in DeviceDriver.EntryPoints)
            {
                var ac = AnalysisContext.GetAnalysisContext(ep);
                new SummaryGenerationEngine(ac, ep).Run();
            }

            Program.StopTimer();
            SummaryInformationParser.ToFile(Program.FileList);
        }
Пример #9
0
        public void Run()
        {
            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                Console.WriteLine(" |------ [{0}]", this.EP.Name);
                Console.WriteLine(" |  |");
                this.Timer = new ExecutionTimer();
                this.Timer.Start();
            }

//      Analysis.Factory.CreatePairWatchdogInformationAnalysis(this.AC, this.EP).Run();

            if (!WhoopEngineCommandLineOptions.Get().CheckInParamAliasing)
            {
                Analysis.Factory.CreateParameterAliasAnalysis(this.AC, this.EP).Run();
            }

            Summarisation.Factory.CreateLocksetSummaryGeneration(this.AC, this.EP).Run();
            Summarisation.Factory.CreateAccessCheckingSummaryGeneration(this.AC, this.EP).Run();
//      Summarisation.Factory.CreateDomainKnowledgeSummaryGeneration(this.AC, this.EP).Run();

            Summarisation.SummaryInformationParser.RegisterSummaryName(this.EP.Name);

            ModelCleaner.RemoveCorralFunctions(this.AC);

            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                this.Timer.Stop();
                Console.WriteLine(" |  |");
                Console.WriteLine(" |  |--- [Total] {0}", this.Timer.Result());
                Console.WriteLine(" |");
            }

            Whoop.IO.BoogieProgramEmitter.Emit(this.AC.TopLevelDeclarations, WhoopEngineCommandLineOptions.Get().Files[
                                                   WhoopEngineCommandLineOptions.Get().Files.Count - 1], this.EP.Name + "$instrumented", "wbpl");
        }
        public void Run()
        {
            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                Console.WriteLine(" |------ [{0}]", this.EP.Name);
                Console.WriteLine(" |  |");
                this.Timer = new ExecutionTimer();
                this.Timer.Start();
            }

            SharedStateAnalyser.AnalyseMemoryRegionsWithPairInformation(this.AC, this.EP);

            Instrumentation.Factory.CreateInstrumentationRegionsConstructor(this.AC, this.EP).Run();
            Instrumentation.Factory.CreateGlobalRaceCheckingInstrumentation(this.AC, this.EP).Run();

            Instrumentation.Factory.CreateLocksetInstrumentation(this.AC, this.EP).Run();
            Instrumentation.Factory.CreateDomainKnowledgeInstrumentation(this.AC, this.EP).Run();
            Instrumentation.Factory.CreateRaceInstrumentation(this.AC, this.EP).Run();

            Analysis.Factory.CreateSharedStateAbstraction(this.AC).Run();

            if (this.EP.IsEnablingDevice)
            {
                Refactoring.Factory.CreateDeviceEnableProgramSlicing(this.AC, this.EP).Run();
            }
            else if (this.EP.IsDisablingDevice)
            {
                Refactoring.Factory.CreateDeviceDisableProgramSlicing(this.AC, this.EP).Run();
            }

            if (this.EP.IsClone && this.EP.IsGoingToDisableNetwork)
            {
                Refactoring.Factory.CreateNetDisableProgramSlicing(this.AC, this.EP).Run();
            }
            else if (this.EP.IsClone && this.EP.IsCalledWithNetworkDisabled)
            {
                Refactoring.Factory.CreateNetEnableProgramSlicing(this.AC, this.EP).Run();
            }

            Instrumentation.Factory.CreateErrorReportingInstrumentation(this.AC, this.EP).Run();

            if (WhoopEngineCommandLineOptions.Get().SkipInference)
            {
                ModelCleaner.RemoveGenericTopLevelDeclerations(this.AC, this.EP);
                ModelCleaner.RemoveUnusedTopLevelDeclerations(this.AC);
                ModelCleaner.RemoveGlobalLocksets(this.AC);
                ModelCleaner.RemoveInlineFromHelperFunctions(this.AC, this.EP);
            }
            else if (WhoopEngineCommandLineOptions.Get().InliningBound > 0 &&
                     this.AC.GetNumOfEntryPointRelatedFunctions(this.EP.Name) <=
                     WhoopEngineCommandLineOptions.Get().InliningBound)
            {
                this.AC.InlineEntryPoint(this.EP);
            }
            else
            {
                ModelCleaner.RemoveInlineFromHelperFunctions(this.AC, this.EP);
            }

            ModelCleaner.RemoveUnecesseryInfoFromSpecialFunctions(this.AC);
            ModelCleaner.RemoveCorralFunctions(this.AC);

            if (WhoopEngineCommandLineOptions.Get().MeasurePassExecutionTime)
            {
                this.Timer.Stop();
                Console.WriteLine(" |  |");
                Console.WriteLine(" |  |--- [Total] {0}", this.Timer.Result());
                Console.WriteLine(" |");
            }

            if (WhoopEngineCommandLineOptions.Get().SkipInference)
            {
                Whoop.IO.BoogieProgramEmitter.Emit(this.AC.TopLevelDeclarations, WhoopEngineCommandLineOptions.Get().Files[
                                                       WhoopEngineCommandLineOptions.Get().Files.Count - 1], this.EP.Name + "$instrumented", "wbpl");
            }
        }
Пример #11
0
        public static void Main(string[] args)
        {
            Contract.Requires(cce.NonNullElements(args));

            CommandLineOptions.Install(new WhoopEngineCommandLineOptions());

            try
            {
                WhoopEngineCommandLineOptions.Get().RunningBoogieFromCommandLine = true;
                WhoopEngineCommandLineOptions.Get().PrintUnstructured            = 2;

                if (!WhoopEngineCommandLineOptions.Get().Parse(args))
                {
                    Environment.Exit((int)Outcome.FatalError);
                }

                if (WhoopEngineCommandLineOptions.Get().Files.Count == 0)
                {
                    Whoop.IO.Reporter.ErrorWriteLine("Whoop: error: no input files were specified");
                    Environment.Exit((int)Outcome.FatalError);
                }

                foreach (string file in WhoopEngineCommandLineOptions.Get().Files)
                {
                    string extension = Path.GetExtension(file);
                    if (extension != null)
                    {
                        extension = extension.ToLower();
                    }
                    Program.FileList.Add(file);
                }

                foreach (string file in Program.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(Program.FileList);
                FunctionPointerInformation.ParseAndInitialize(Program.FileList);

                if (WhoopEngineCommandLineOptions.Get().PrintPairs)
                {
                    DeviceDriver.EmitEntryPointPairs(Program.FileList);
                }

                Program.RunParsingEngine();
                Program.RunStaticLocksetAnalysisInstrumentationEngine();
                Program.RunSummaryGenerationEngine();
                Program.RunPairWiseCheckingInstrumentationEngine();

                Environment.Exit((int)Outcome.Done);
            }
            catch (Exception e)
            {
                Console.Error.Write("Exception thrown in Whoop: ");
                Console.Error.WriteLine(e);
                Environment.Exit((int)Outcome.FatalError);
            }
        }