public BootableAppVerb(SourcePath dfyroot, DafnyCCVerb.FramePointerMode useFramePointer, VerificationRequest verificationRequest) { this.dfyroot = dfyroot; this.verificationRequest = verificationRequest; string concreteId = verificationRequest.ToString() + "," + useFramePointer.ToString(); this.abstractId = new AbstractId(this.GetType().Name, version, dfyroot.ToString(), concrete: concreteId); string targetDirectory = Path.Combine( BuildEngine.theEngine.getObjRoot(), dfyroot.getDirPath(), "bootable-" + verificationRequest.ToString()); this.bootIniFile = new BuildObject(Path.Combine(targetDirectory, "safeos\\boot.ini")); // TODO: Create the bootloader verb. this.loaderVerb = new IroncladAppVerb(new SourcePath(LOADER_DFY), IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest); this.appVerb = new IroncladAppVerb(dfyroot, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest); this.batchVerb = new BatchVerifyVerb(dfyroot, new HashSet <IObligationsProducer>() { this.appVerb, this.loaderVerb }, BatchVerifyVerb.BatchMode.APP); this.batchSummaryVerb = new VerificationResultSummaryVerb(this.batchVerb); this.loaderCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.loaderVerb))); this.bootloaderCopy = new BuildObject(Path.Combine(targetDirectory, this.bootloader.getFileName())); this.appExecutableCopy = new BuildObject(Path.Combine(targetDirectory, this.targetExecutableName(this.appVerb))); }
void parseArgs(string[] args) { this.args = args; argi = 0; while (argi < args.Count()) { string next = takeArg("option or verb"); // Should always succeed due to while condition. if (next.StartsWith("-")) { if (next.Equals("--ironRoot")) { if (this.ironRoot != null) { usage("ironRoot set after use"); } this.ironRoot = takeArg("value for ironRoot"); } else if (next.Equals("-j") || next.Equals("--jobs")) { this.jobParallelism = Int32.Parse(takeArg("value for jobs")); } else if (next.Equals("--localcache")) { BuildEngine.theEngine.setLocalCache(takeArg("path for localcache")); } else if (next.ToLower().Equals("--cloudcache")) { this.useCloudCache = true; } else if (next.ToLower().Equals("--no-cloudcache")) { this.useCloudCache = false; } else if (next.Equals("--cloudexecution")) { this.useCloudExecution = true; } else if (next.ToLower().Equals("--verify")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.Verify; } else if (next.ToLower().Equals("--no-verify")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.NoVerify; } else if (next.ToLower().Equals("--no-symdiff")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.NoSymDiff; } else if (next.ToLower().Equals("--verify-select")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.SelectiveVerify; this.verificationRequest.selectiveVerifyModuleNames.Add(takeArg("filename for selective-verify")); } else if (next.ToLower().Equals("--html")) { this.html_output = takeArg("filename for html report"); } else if (next.ToLower().Equals("--windows")) { this.target_platform = IroncladAppVerb.TARGET.WINDOWS; } else if (next.ToLower().Equals("--useframepointer")) { this.useFramePointer = DafnyCCVerb.FramePointerMode.UseFramePointer; } else if (next.ToLower().Equals("--debug")) { this.releaseBuild = false; } else { usage("unrecognized option " + next); } } else { string verb = next; string target = takeArg("verb-target"); fixIronRoot(); if (verb.Equals("DafnyVerifyTree")) { verbs.Add(new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(conditionSourcePath(target)))); } else if (verb.Equals("BatchDafny")) { if (!target.EndsWith(".batch")) { usage("Batching expects a .batch file containing a list of .dfy files"); } verbs.Add(new VerificationResultSummaryVerb(new BatchVerifyVerb(conditionSourcePath(target), BatchVerifyVerb.BatchMode.DAFNY, this.verificationRequest, useFramePointer))); } else if (verb.Equals("BatchApps")) { if (!target.EndsWith(".batch")) { usage("Batching expects a .batch file containing a list of .dfy files"); } verbs.Add(new VerificationResultSummaryVerb(new BatchVerifyVerb(conditionSourcePath(target), BatchVerifyVerb.BatchMode.APP, this.verificationRequest, useFramePointer))); } else if (verb.Equals("Beat")) { verbs.Add(new BeatVerb(BuildEngine.theEngine.getVerveContextVerb(PoundDefines.empty()), conditionSourcePath(target), appLabel: null)); } else if (verb.Equals("Boogie")) { verbs.Add(new BoogieVerb(BuildEngine.theEngine.getVerveContextVerb(PoundDefines.empty()), conditionSourcePath(target), symdiff: this.verificationRequest.getSymDiffMode())); } else if (verb.Equals("IroncladApp")) { verbs.Add(new IroncladAppVerb(conditionSourcePath(target), target_platform, this.useFramePointer, this.verificationRequest)); } else if (verb.Equals("IronfleetApp")) { verbs.Add(new IronfleetAppVerb(conditionSourcePath(target), this.verificationRequest, this.releaseBuild)); } else if (verb.Equals("DafnyCompileOne")) { verbs.Add(new DafnyCompileOneVerb(conditionSourcePath(target))); } else if (verb.Equals("VSSolution")) { verbs.Add(new VSSolutionVerb(new SourcePath(target, SourcePath.SourceType.Tools))); } else if (verb.Equals("nmake")) { verbs.Add(new NmakeVerb(new SourcePath(target, SourcePath.SourceType.Tools))); } else if (verb.Equals("BootableApp")) { verbs.Add(new BootableAppVerb(conditionSourcePath(target), this.useFramePointer, this.verificationRequest)); } else { usage("Unknown verb " + verb); } } } fixIronRoot(); }
public BatchVerifyVerb(SourcePath batch_file, BatchMode mode, VerificationRequest verificationRequest, DafnyCCVerb.FramePointerMode useFramePointer) { this.mode = mode; this.producers = new HashSet<IObligationsProducer>(); foreach (string line in File.ReadAllLines(batch_file.getFilesystemPath())) { if (line[0] == '#') { continue; } SourcePath src = new SourcePath(line); switch (mode) { case BatchMode.DAFNY: if (verificationRequest.verifyMode != VerificationRequest.VerifyMode.Verify) { throw new UserError("BatchVerify DAFNY only supports full verification (but maybe we should add selective?)"); } this.producers.Add(new DafnyVerifyTreeVerb(src)); break; case BatchMode.APP: this.producers.Add(new IroncladAppVerb(src, IroncladAppVerb.TARGET.BARE_METAL, useFramePointer, verificationRequest)); break; default: throw new Exception("Unknown batch file type"); } } string parameters = mode.ToString() + "," + verificationRequest.ToString(); outputObject = batch_file.makeLabeledOutputObject(parameters, BATCH_EXTN + VerificationObligationList.VOL_EXTN); abstractId = new AbstractId(this.GetType().Name, version, batch_file.ToString(), concrete:parameters); }
void parseArgs(string[] args) { this.args = args; argi = 0; while (argi < args.Count()) { string next = takeArg("option or verb"); // Should always succeed due to while condition. if (next.StartsWith("-")) { if (next.Equals("--ironRoot")) { if (this.ironRoot != null) { usage("ironRoot set after use"); } this.ironRoot = takeArg("value for ironRoot"); } else if (next.Equals("-j") || next.Equals("--jobs")) { this.jobParallelism = Int32.Parse(takeArg("value for jobs")); } else if (next.Equals("--localcache")) { BuildEngine.theEngine.setLocalCache(takeArg("path for localcache")); } else if (next.ToLower().Equals("--cloudcache")) { this.useCloudCache = true; } else if (next.ToLower().Equals("--no-cloudcache")) { this.useCloudCache = false; } else if (next.Equals("--cloudexecution")) { this.useCloudExecution = true; } else if (next.ToLower().Equals("--verify")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.Verify; } else if (next.ToLower().Equals("--no-verify")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.NoVerify; } else if (next.ToLower().Equals("--no-symdiff")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.NoSymDiff; } else if (next.ToLower().Equals("--verify-select")) { this.verificationRequest.verifyMode = VerificationRequest.VerifyMode.SelectiveVerify; this.verificationRequest.selectiveVerifyModuleNames.Add(takeArg("filename for selective-verify")); } else if (next.ToLower().Equals("--html")) { this.html_output = takeArg("filename for html report"); } else if (next.ToLower().Equals("--windows")) { this.target_platform = IroncladAppVerb.TARGET.WINDOWS; } else if (next.ToLower().Equals("--useframepointer")) { this.useFramePointer = DafnyCCVerb.FramePointerMode.UseFramePointer; } else if (next.ToLower().Equals("--debug")) { this.releaseBuild = false; } else { usage("unrecognized option " + next); } } else { string verb = next; string target = takeArg("verb-target"); fixIronRoot(); if (verb.Equals("DafnyVerifyTree")) { verbs.Add(new VerificationResultSummaryVerb(new DafnyVerifyTreeVerb(conditionSourcePath(target)))); } else if (verb.Equals("BatchDafny")) { if (!target.EndsWith(".batch")) { usage("Batching expects a .batch file containing a list of .dfy files"); } verbs.Add(new VerificationResultSummaryVerb(new BatchVerifyVerb(conditionSourcePath(target), BatchVerifyVerb.BatchMode.DAFNY, this.verificationRequest, useFramePointer))); } else if (verb.Equals("BatchApps")) { if (!target.EndsWith(".batch")) { usage("Batching expects a .batch file containing a list of .dfy files"); } verbs.Add(new VerificationResultSummaryVerb(new BatchVerifyVerb(conditionSourcePath(target), BatchVerifyVerb.BatchMode.APP, this.verificationRequest, useFramePointer))); } else if (verb.Equals("Beat")) { verbs.Add(new BeatVerb(BuildEngine.theEngine.getVerveContextVerb(PoundDefines.empty()), conditionSourcePath(target), appLabel: null)); } else if (verb.Equals("Boogie")) { verbs.Add(new BoogieVerb(BuildEngine.theEngine.getVerveContextVerb(PoundDefines.empty()), conditionSourcePath(target), symdiff: this.verificationRequest.getSymDiffMode())); } else if (verb.Equals("IroncladApp")) { verbs.Add(new IroncladAppVerb(conditionSourcePath(target), target_platform, this.useFramePointer, this.verificationRequest)); } else if (verb.Equals("IronfleetApp")) { verbs.Add(new IronfleetAppVerb(conditionSourcePath(target), this.verificationRequest, this.releaseBuild)); } else if (verb.Equals("DafnyCompileOne")) { verbs.Add(new DafnyCompileOneVerb(conditionSourcePath(target))); } else if (verb.Equals("VSSolution")) { verbs.Add(new VSSolutionVerb(new SourcePath(target, SourcePath.SourceType.Tools))); } else if (verb.Equals("nmake")) { verbs.Add(new NmakeVerb(new SourcePath(target, SourcePath.SourceType.Tools))); } else if (verb.Equals("BootableApp")) { verbs.Add(new BootableAppVerb(conditionSourcePath(target), this.useFramePointer, this.verificationRequest)); } else { usage("Unknown verb " + verb); } } } fixIronRoot(); }
public IroncladAppVerb(SourcePath dfyroot, TARGET target, DafnyCCVerb.FramePointerMode framePointerMode, VerificationRequest verificationRequest) { this.dfyroot = dfyroot; // TODO this is the only #define we support just yet, so I'm stuffing it in here. // We'll need to plumb more carefully when we want to add x64. if (dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last().Equals("AppLoader")) { this.poundDefines = new PoundDefines(new string[] { "AppLoader" }); } else { this.poundDefines = PoundDefines.empty(); } this.verificationRequest = verificationRequest; this.abstractId = new AbstractId( this.GetType().Name, version, dfyroot.ToString(), this.poundDefines, concrete: string.Format( "{0},{1},{2}", target, framePointerMode.ToString(), verificationRequest.ToString())); this.appLabel = dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last(); this.dafnyspecVerb = new DafnySpecVerb(dfyroot, this.appLabel); this.dafnyccVerb = new DafnyCCVerb(dfyroot, this.appLabel, framePointerMode); bool isLoader = dfyroot.getRelativePath().Equals(BootableAppVerb.LOADER_DFY); // NB we keep dafnyccVerb as the lowest-priority context, so that our hand-written // beat impls will override its output. IContextGeneratingVerb contextWithDafny = new ConcatContextVerb( BuildEngine.theEngine.getVerveContextVerb(this.poundDefines), new VerbOutputsContextVerb(this.dafnyspecVerb, false), new VerbOutputsContextVerb(this.dafnyccVerb, true), this.poundDefines); this.stitcherVerb = new EntryStitcherVerb(contextWithDafny, this.appLabel); IContextGeneratingVerb contextWithDafnyAndEntry = new ConcatContextVerb( new VerbOutputsContextVerb(this.stitcherVerb, false), contextWithDafny, this.poundDefines); BuildObject entryImpObj = this.stitcherVerb.getEntryImpOutput(); BoogieAsmLinkVerb entryVerb = new BoogieAsmLinkVerb(contextWithDafnyAndEntry, entryImpObj); if (target == TARGET.BARE_METAL) { MasmVerb masmVerb = new MasmVerb(entryVerb); this.linkerVerb = new LinkerVerb(masmVerb, isLoader); } else if (target == TARGET.WINDOWS) { // Rewrite the asm that comes out of entryVerb before linking it AsmRewriterVerb rewriter = new AsmRewriterVerb(entryVerb); MasmVerb masmVerb = new MasmVerb(rewriter); this.linkerVerb = new WinLinkerVerb(masmVerb, isLoader); } BoogieAsmVerificationObligationListVerb bavolVerb = new BoogieAsmVerificationObligationListVerb(contextWithDafnyAndEntry, entryImpObj, verificationRequest); this.verifyResultsVerb = new VerificationResultSummaryVerb(bavolVerb); this.srcObject = this.linkerVerb.getUntrustedExe(); if (verificationRequest.isComplete()) { this.exeObject = dfyroot.makeOutputObject(TRUSTED_EXE_EXTN); this.outputObject = this.exeObject; } else { this.exeObject = this.srcObject; this.outputObject = dfyroot.makeVirtualObject(UNVERIFIED_SENTINEL_EXTENSION); } }