public static PersistentProgram RunHoudiniPass(PersistentProgram prog) { Stats.resume("houdini"); HashSet <Variable> templateVars = new HashSet <Variable>(); List <Requires> reqs = new List <Requires>(); List <Ensures> enss = new List <Ensures>(); SimpleHoudini houdini = new SimpleHoudini(templateVars, reqs, enss, -1, -1); houdini.ExtractLoops = true; SimpleHoudini.fastRequiresInference = false; //SimpleHoudini.checkAsserts = true; houdini.printHoudiniQuery = null; // "candidates.bpl"; // turnning on several switches: InImpOutNonNull + InNonNull infer most assertions houdini.InImpOutNonNull = false; houdini.InImpOutNull = false; houdini.InNonNull = false; houdini.OutNonNull = false; houdini.addContracts = false; prog.writeToFile("beforeHoudini.bpl"); PersistentProgram newP = houdini.run(prog); newP.writeToFile("afterHoudini.bpl"); //BoogieUtil.PrintProgram(newP.getProgram(), "afterHoudini.bpl"); Utils.Print("End Houdini Pass ..."); Stats.stop("houdini"); return(newP); }
static void Main(string[] args) { System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.Batch; if (args.Length < 2 || !args[0].EndsWith(".bpl") || !args[1].EndsWith(".bpl")) { Console.WriteLine("Usage: AvHarnessInstrumentation infile.bpl outfile.bpl [options]"); return; } SetOptions(args); // Initialize Boogie CommandLineOptions.Install(new CommandLineOptions()); CommandLineOptions.Clo.PrintInstrumented = true; BoogieUtil.InitializeBoogie(""); ProgTransformation.PersistentProgramIO.useDuplicator = true; var sw = new Stopwatch(); sw.Start(); if (Options.killAfter > 0) { var timer = new System.Timers.Timer(Options.killAfter * 1000); timer.Elapsed += (sender, e) => HandleTimer(sw); timer.Start(); } try { // Get the program, install the harness and do basic instrumentation var inprog = GetProgram(args[0]); Utils.Print(string.Format("#Procs : {0}", inprog.TopLevelDeclarations.OfType <Implementation>().Count()), Utils.PRINT_TAG.AV_STATS); Utils.Print(string.Format("#EntryPoints : {0}", harnessInstrumentation.entrypoints.Count), Utils.PRINT_TAG.AV_STATS); Utils.Print(string.Format("#AssertsBeforeAA : {0}", AssertCountVisitor.Count(inprog)), Utils.PRINT_TAG.AV_STATS); if (Options.delayAA) { PruneRedundantEntryPoints(inprog); BoogieUtil.PrintProgram(inprog, args[1]); } else { var program = new PersistentProgram(inprog, AvnAnnotations.CORRAL_MAIN_PROC, 0); // Run alias analysis Stats.resume("alias.analysis"); Console.WriteLine("Running alias analysis"); program = RunAliasAnalysis(program); Stats.stop("alias.analysis"); var assertCnt = AssertCountVisitor.Count(program.getProgram()); Utils.Print(string.Format("#AssertsAfterAA : {0}", assertCnt), Utils.PRINT_TAG.AV_STATS); // run Houdini pass if (Options.HoudiniPass) { Utils.Print("Running Houdini Pass"); program = RunHoudiniPass(program); assertCnt = AssertCountVisitor.Count(program.getProgram()); Utils.Print(string.Format("#Asserts : {0}", assertCnt), Utils.PRINT_TAG.AV_STATS); } if (assertCnt == 0) { // program has been proved correct // Write a trivial program System.IO.File.WriteAllLines(args[1], new string[] { "procedure {:entrypoint} {:NoVerificationNecessary} dummy() { }" }); } else { program.writeToFile(args[1]); } } } catch (Exception e) { //stacktrace containts source locations, confuses regressions that looks for AV_OUTPUT Utils.Print(String.Format("AngelicVerifier failed with: {0}", e.Message), Utils.PRINT_TAG.AV_OUTPUT); Utils.Print(String.Format("AngelicVerifier failed with: {0}", e.Message + e.StackTrace), Utils.PRINT_TAG.AV_DEBUG); } finally { Stats.printStats(); Utils.Print(string.Format("TotalTime(ms) : {0}", sw.ElapsedMilliseconds), Utils.PRINT_TAG.AV_STATS); } }
static void Main(string[] args) { System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.Batch; if (args.Length < 2 || !args[0].EndsWith(".bpl") || !args[1].EndsWith(".bpl")) { Console.WriteLine("Usage: AvHarnessInstrumentation infile.bpl outfile.bpl [options]"); return; } SetOptions(args); // Initialize Boogie CommandLineOptions.Install(new CommandLineOptions()); CommandLineOptions.Clo.PrintInstrumented = true; BoogieUtil.InitializeBoogie(""); ProgTransformation.PersistentProgramIO.useDuplicator = true; var sw = new Stopwatch(); sw.Start(); try { // Get the program, install the harness and do basic instrumentation var inprog = GetProgram(args[0]); var program = new PersistentProgram(inprog, AvnAnnotations.CORRAL_MAIN_PROC, 0); Utils.Print(string.Format("#Procs : {0}", inprog.TopLevelDeclarations.OfType <Implementation>().Count()), Utils.PRINT_TAG.AV_STATS); Utils.Print(string.Format("#EntryPoints : {0}", harnessInstrumentation.entrypoints.Count), Utils.PRINT_TAG.AV_STATS); Utils.Print(string.Format("#AssertsBeforeAA : {0}", AssertCountVisitor.Count(inprog)), Utils.PRINT_TAG.AV_STATS); // Run alias analysis Stats.resume("alias.analysis"); Console.WriteLine("Running alias analysis"); program = RunAliasAnalysis(program); Stats.stop("alias.analysis"); Utils.Print(string.Format("#AssertsAfterAA : {0}", AssertCountVisitor.Count(program.getProgram())), Utils.PRINT_TAG.AV_STATS); // run Houdini pass if (Options.HoudiniPass) { Utils.Print("Running Houdini Pass"); program = RunHoudiniPass(program); Utils.Print(string.Format("#Asserts : {0}", AssertCountVisitor.Count(program.getProgram())), Utils.PRINT_TAG.AV_STATS); } program.writeToFile(args[1]); } catch (Exception e) { //stacktrace containts source locations, confuses regressions that looks for AV_OUTPUT Utils.Print(String.Format("AngelicVerifier failed with: {0}", e.Message), Utils.PRINT_TAG.AV_OUTPUT); Utils.Print(String.Format("AngelicVerifier failed with: {0}", e.Message + e.StackTrace), Utils.PRINT_TAG.AV_DEBUG); } finally { Stats.printStats(); Utils.Print(string.Format("TotalTime(ms) : {0}", sw.ElapsedMilliseconds), Utils.PRINT_TAG.AV_STATS); } }