/// <summary> /// Runs a pair instrumentation pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } PairCheckingRegion region = new PairCheckingRegion(this.AC, this.EP1, this.EP2); AnalysisContext.RegisterPairEntryPointAnalysisContext(region, this.EP1, this.EP2); if (this.EP1.IsInit || this.EP2.IsInit) { this.CreateDeviceStructConstant(); } this.AC.TopLevelDeclarations.Add(region.Procedure()); this.AC.TopLevelDeclarations.Add(region.Implementation()); this.AC.ResContext.AddProcedure(region.Procedure()); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [PairInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AddUpdateLocksetFunc(); this.AddUpdateLocksetFunc(Microsoft.Boogie.Type.Bool); this.AddNonCheckedFunc(); this.AddEnableNetworkFunc(); this.AddDisableNetworkFunc(); foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentImplementation(region); } this.AnalyseDomainSpecificLockUsage(); this.InstrumentEntryPointProcedure(); foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentProcedure(region); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [LocksetInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { base.Timer = new ExecutionTimer(); base.Timer.Start(); } // foreach (var region in base.InstrumentationRegions) // { // if (!base.EP.Name.Equals(region.Implementation().Name)) // continue; // // this.InstrumentRegisteredDeviceVarInEntryPointRegion(region); // } // foreach (var region in base.InstrumentationRegions) // { // if (base.EP.Name.Equals(region.Implementation().Name)) // continue; // // this.InstrumentRegisteredDeviceVarInRegion(region); // } base.InstrumentExistentialBooleans(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { base.Timer.Stop(); Console.WriteLine(" | |------ [DomainKnowledgeSummaryGeneration] {0}", base.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var impl in this.AC.TopLevelDeclarations.OfType <Implementation>()) { if (this.SkipFromAnalysis(impl)) { continue; } InstrumentationRegion region = new InstrumentationRegion(this.AC, this.EP, impl); this.AC.InstrumentationRegions.Add(region); } this.EP.RebuildCallGraph(this.AC); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [InstrumentationRegionsConstructor] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AddAccessFuncs(AccessType.WRITE); this.AddAccessFuncs(AccessType.READ); foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentImplementation(region); } foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentProcedure(region); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [RaceInstrumentation] {0}", this.Timer.Result()); } }
protected void InstrumentAssertCandidate(Block block, Variable variable, bool value, bool capture = false) { if (!WhoopCommandLineOptions.Get().MergeExistentials) { capture = false; } var dict = this.GetExistentialDictionary(value); Constant cons = null; if (capture && dict.ContainsKey(variable) && dict[variable].ContainsKey("$whoop$")) { cons = dict[variable]["$whoop$"]; } else { cons = this.CreateConstant(); } Expr expr = this.CreateImplExpr(cons, variable, value); block.Cmds.Insert(0, new AssertCmd(Token.NoToken, expr)); if (capture && !dict.ContainsKey(variable)) { dict.Add(variable, new Dictionary <string, Constant>()); dict[variable].Add("$whoop$", cons); } else if (capture && !dict[variable].ContainsKey("$whoop$")) { dict[variable].Add("$whoop$", cons); } }
/// <summary> /// Runs an async checking instrumentation pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } var initImpl = this.AC.GetImplementation(DeviceDriver.InitEntryPoint); this.InstrumentCheckerFunction(); this.InstrumentInitFunction(initImpl); this.VisitFunctionsInImplementation(initImpl); this.SimplifyProgram(); // HACK foreach (var proc in this.AC.TopLevelDeclarations.OfType <Procedure>()) { if (proc.Name.StartsWith("$memcpy") || proc.Name.StartsWith("$memset")) { proc.Ensures.Clear(); } } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [AsyncCheckingInstrumentation] {0}", this.Timer.Result()); } }
private void InstrumentImplementation(Implementation impl) { this.InstrumentYieldsInLocks(impl); if (!WhoopCommandLineOptions.Get().YieldNoAccess&& (this.ErrorReporter.FoundErrors || WhoopCommandLineOptions.Get().YieldAll)) { this.InstrumentYieldsInMemoryAccesses(impl); } }
private Expr ComputeExpr(Expr ptrExpr, Expr access) { Expr result = null; if (access is NAryExpr) { var a = (access as NAryExpr).Args[1]; if (ptrExpr is NAryExpr) { var ptr = ptrExpr as NAryExpr; if (!(ptr.Args[1] is LiteralExpr) || !(a is LiteralExpr)) { return(result); } int l = (ptr.Args[1] as LiteralExpr).asBigNum.ToInt; int r = (a as LiteralExpr).asBigNum.ToInt; if (ptr.Fun.FunctionName == "$add" || ptr.Fun.FunctionName == "+") { if ((access as NAryExpr).Fun.FunctionName == "$add" || (access as NAryExpr).Fun.FunctionName == "+") { result = Expr.Add(ptr.Args[0], new LiteralExpr(Token.NoToken, BigNum.FromInt(l + r))); } } } else if (ptrExpr is IdentifierExpr) { if (this.AC.GetNumOfEntryPointRelatedFunctions(this.EP.Name) > WhoopCommandLineOptions.Get().EntryPointFunctionCallComplexity) { return(result); } var ptr = ptrExpr as IdentifierExpr; if (!ptr.Type.IsInt) { return(result); } if ((access as NAryExpr).Fun.FunctionName == "$add" || (access as NAryExpr).Fun.FunctionName == "+") { result = Expr.Add(ptr, new LiteralExpr(Token.NoToken, (a as LiteralExpr).asBigNum)); } } } else { result = ptrExpr; } return(result); }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } var epImpls = this.RaceCheckedAC.GetEntryPoints(); var epHelpers = this.RaceCheckedAC.GetEntryPointHelpers(); foreach (var impl in this.AC.TopLevelDeclarations.OfType <Implementation>()) { if (impl.Name.Equals(DeviceDriver.InitEntryPoint) && !(this.Pair.EntryPoint1.IsInit || this.Pair.EntryPoint2.IsInit)) { continue; } if (impl.Equals(this.AC.Checker)) { continue; } if (impl.Name.Equals("$static_init") || impl.Name.Equals("__SMACK_nondet")) { continue; } if (impl.Name.Equals("mutex_lock") || impl.Name.Equals("mutex_lock_interruptible") || impl.Name.Equals("mutex_unlock") || impl.Name.Equals("spin_lock") || impl.Name.Equals("spin_lock_irqsave") || impl.Name.Equals("spin_unlock") || impl.Name.Equals("spin_unlock_irqrestore")) { continue; } if (!epHelpers.Any(val => val.Name.Split('$')[0].Equals(impl.Name)) && !epImpls.Any(val => val.Name.Equals(impl.Name))) { continue; } this.InstrumentImplementation(impl); } if (WhoopCommandLineOptions.Get().CountYields) { Console.WriteLine("#y: " + YieldInstrumentation.YieldCounter); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [YieldInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var region in this.AC.InstrumentationRegions) { if (region.IsNotAccessingResources) { continue; } this.PtrAnalysisCache.Add(region, new PointerArithmeticAnalyser( this.AC, this.EP, region.Implementation())); } foreach (var region in this.AC.InstrumentationRegions) { if (region.IsNotAccessingResources) { continue; } this.InstrumentInParamAliasInformationInRegion(region); } foreach (var region in this.RequiresMap) { foreach (var req in region.Value) { region.Key.Procedure().Requires.Add(req); } } foreach (var region in this.AssumesMap) { foreach (var block in region.Value) { foreach (var pair in block.Value) { block.Key.Cmds.Insert(pair.Item2, pair.Item1); } } } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [ParameterAliasAnalysis] {0}", this.Timer.Result()); } }
private void InstrumentAsyncFuncs() { foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentSourceLocationInfo(region); this.InstrumentRaceCheckingCaptureStates(region); if (!WhoopCommandLineOptions.Get().OnlyRaceChecking) { this.InstrumentDeadlockCheckingCaptureStates(region); } } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.RefactorFunctionPointers(this.Implementation); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [FunctionPointerRefactoring] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.InstrumentInParamAliasInformation(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [PairParameterAliasAnalysis] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.InstrumentAsyncFuncs(); this.CleanUp(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [ErrorReportingInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.ComputePairAccesses(); this.SliceWatchedAccesses(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [PairWatchdogInformationAnalysis] {0}", this.Timer.Result()); } }
/// <summary> /// Run a lock abstraction pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.IdentifyAndCreateUniqueLocks(); this.CreateKernelLocks(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [LockAbstraction] {0}", this.Timer.Result()); } }
/// <summary> /// Run a lock abstraction pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.EP.OriginalCallGraph = this.BuildCallGraph(); this.AnalyseAndInstrumentLocks(this.Implementation); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [LockRefactoring] {0}", this.Timer.Result()); } }
/// <summary> /// Emits the entry point pairs in an XML file. /// </summary> /// <param name="files">List of file names</param> public static void EmitEntryPointPairs(List <string> files) { XDocument epXmlDoc = new XDocument(); XElement root = new XElement("driver", new XAttribute("name", WhoopCommandLineOptions.Get().OriginalFile)); foreach (var ep in DeviceDriver.EntryPointPairs) { root.Add(new XElement("pair", new XAttribute("ep1", ep.EntryPoint1.Name), new XAttribute("ep2", ep.EntryPoint2.Name), new XAttribute("bug", false))); } epXmlDoc.Add(root); string pairXmlFile = files[files.Count - 1].Substring(0, files[files.Count - 1].LastIndexOf(".")) + ".pairs.xml"; epXmlDoc.Save(pairXmlFile); }
private void AnalyseLocalAccessesInRegions() { var optimise = false; if (WhoopCommandLineOptions.Get().OptimiseHeavyAsyncCalls&& (this.AC.GetNumOfEntryPointRelatedFunctions(this.EP.Name) > WhoopCommandLineOptions.Get().EntryPointFunctionCallComplexity)) { optimise = true; } foreach (var region in this.AC.InstrumentationRegions) { this.PtrAnalysisCache.Add(region, new PointerArithmeticAnalyser( this.AC, this.EP, region.Implementation(), optimise)); this.AnalyseLocalAccessesInRegion(region); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var region in this.AC.InstrumentationRegions) { this.FindUseOfFunctionPointers(region); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [FunctionPointerUseAnalysis] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AddCurrentLocksets(); this.AddMemoryLocksets(); this.AddAccessCheckingVariables(); this.AddAccessWatchdogConstants(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [GlobalRaceCheckingInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AnalyseLocalAccessesInRegions(); this.IdentifyCallAccessesInRegions(); this.AnalyseCallAccessesInRegions(); this.MapAxiomAccessesInRegions(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [WatchdogInformationAnalysis] {0}", this.Timer.Result()); } }
protected void InstrumentImpliesEnsuresCandidate(InstrumentationRegion region, Expr implExpr, Variable variable, bool value, bool capture = false) { if (this.EP.IsInlined) { return; } if (!WhoopCommandLineOptions.Get().MergeExistentials) { capture = false; } var dict = this.GetExistentialDictionary(value); Constant cons = null; bool consExists = false; if (capture && dict.ContainsKey(variable) && GetConstantFromDictionary(out cons, dict[variable], implExpr)) { consExists = true; } else { cons = this.CreateConstant(); } Expr rExpr = this.CreateImplExpr(implExpr, variable, value); Expr lExpr = Expr.Imp(new IdentifierExpr(cons.tok, cons), rExpr); region.Procedure().Ensures.Add(new Ensures(false, lExpr)); if (capture && !dict.ContainsKey(variable) && !consExists) { dict.Add(variable, new Dictionary <string, Constant>()); dict[variable].Add(implExpr.ToString(), cons); } else if (capture && !consExists) { dict[variable].Add(implExpr.ToString(), cons); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var region in this.AC.InstrumentationRegions) { this.AbstractReadAccesses(region); this.AbstractWriteAccesses(region); this.CleanUpModset(region); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [SharedStateAbstraction] {0}", this.Timer.Result()); } }
/// <summary> /// Run a program simplification pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var impl in AC.TopLevelDeclarations.OfType <Implementation>()) { this.RemoveUnecesseryAssumes(impl); this.RemoveUnecesseryCalls(impl); this.SimplifyPointersInImplementation(impl); this.SimplifyImplementation(impl); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [ProgramSimplifier] {0}", this.Timer.Result()); } }
protected void InstrumentEnsuresCandidate(InstrumentationRegion region, Variable variable, bool value, bool capture = false) { if (this.EP.IsInlined) { return; } if (!WhoopCommandLineOptions.Get().MergeExistentials) { capture = false; } var dict = this.GetExistentialDictionary(value); Constant cons = null; if (capture && dict.ContainsKey(variable) && dict[variable].ContainsKey("$whoop$")) { cons = dict[variable]["$whoop$"]; } else { cons = this.CreateConstant(); } Expr expr = this.CreateImplExpr(cons, variable, value); region.Procedure().Ensures.Add(new Ensures(false, expr)); if (capture && !dict.ContainsKey(variable)) { dict.Add(variable, new Dictionary <string, Constant>()); dict[variable].Add("$whoop$", cons); } else if (capture && !dict[variable].ContainsKey("$whoop$")) { dict[variable].Add("$whoop$", cons); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AddRegisterDeviceFunc(); this.AddUnregisterDeviceFunc(); if (this.EP.IsInit) { this.CreateDeviceStructConstant(); } foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentImplementation(region); } this.AnalyseDomainSpecificEnableUsage("register_netdev"); // this.AnalyseDomainSpecificDisableUsage("unregister_netdev"); this.AnalyseDomainSpecificEnableUsage("network"); this.AnalyseDomainSpecificEnableUsage("misc_register"); // this.AnalyseDomainSpecificDisableUsage("misc_deregister"); this.AnalyseDomainSpecificEnableUsage("nfc_register_device"); // this.AnalyseDomainSpecificDisableUsage("nfc_free_device"); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [DomainKnowledgeInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { base.Timer = new ExecutionTimer(); base.Timer.Start(); } foreach (var region in base.InstrumentationRegions) { if (!base.EP.Name.Equals(region.Implementation().Name)) { continue; } this.InstrumentWriteAccessInvariantsInEntryPointRegion(region); this.InstrumentReadAccessInvariantsInEntryPointRegion(region); } foreach (var region in base.InstrumentationRegions) { if (base.EP.Name.Equals(region.Implementation().Name)) { continue; } this.InstrumentWriteAccessInvariantsInRegion(region); this.InstrumentReadAccessInvariantsInRegion(region); } base.InstrumentExistentialBooleans(); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { base.Timer.Stop(); Console.WriteLine(" | |------ [AccessCheckingSummaryGeneration] {0}", base.Timer.Result()); } }
protected void InstrumentImpliesAssertCandidate(Block block, Expr implExpr, Variable variable, bool value, bool capture = false) { if (!WhoopCommandLineOptions.Get().MergeExistentials) { capture = false; } var dict = this.GetExistentialDictionary(value); Constant cons = null; bool consExists = false; if (capture && dict.ContainsKey(variable) && GetConstantFromDictionary(out cons, dict[variable], implExpr)) { consExists = true; } else { cons = this.CreateConstant(); } Expr rExpr = this.CreateImplExpr(implExpr, variable, value); Expr lExpr = Expr.Imp(new IdentifierExpr(cons.tok, cons), rExpr); block.Cmds.Insert(0, new AssertCmd(Token.NoToken, lExpr)); if (capture && !dict.ContainsKey(variable) && !consExists) { dict.Add(variable, new Dictionary <string, Constant>()); dict[variable].Add(implExpr.ToString(), cons); } else if (capture && !consExists) { dict[variable].Add(implExpr.ToString(), cons); } }