//private readonly Dictionary<IToken, List<ErrorCode>> reportedVerificationErrors = new Dictionary<IToken, List<ErrorCode>>(); //private readonly List<string> errors = new List<string>(); public void ReportCounterexample(Counterexample ce, string message) { if (message != null) { message = " (" + message + ")"; } else { message = ""; } try { ReturnCounterexample /*?*/ rce = ce as ReturnCounterexample; if (rce != null) { IToken tok = rce.FailingReturn.tok; for (int i = rce.Trace.Length - 1; i >= 0; i--) { foreach (Cmd c in rce.Trace[i].Cmds) { AssertCmd assrt = c as AssertCmd; if (assrt != null) { NAryExpr nary = assrt.Expr as NAryExpr; if (nary != null) { FunctionCall fcall = nary.Fun as FunctionCall; if (fcall != null && fcall.FunctionName == "$position_marker") { tok = assrt.tok; } } } } } ReportOutcomePostconditionFailed(rce.FailingEnsures.tok, tok, message); } AssertCounterexample /*?*/ ace = ce as AssertCounterexample; if (ace != null) { ReportOutcomeAssertFailed(ace.FailingAssert.tok, (ace.FailingAssert is LoopInvMaintainedAssertCmd ? "Loop body invariant" : ace.FailingAssert is LoopInitAssertCmd ? "Loop entry invariant" : "Assertion"), message ); } CallCounterexample /*?*/ cce = ce as CallCounterexample; if (cce != null) { ReportOutcomePreconditionFailed(cce.FailingCall.tok, cce.FailingRequires, message); } } finally { if (commandLineOptions != null && commandLineOptions.PrintCEVModel) { ce.PrintModel(); } } }
internal void ReportCounterexample(Counterexample error) { int WindowWidth; try { WindowWidth = Console.WindowWidth; } catch (IOException) { WindowWidth = 20; } for (int i = 0; i < WindowWidth; i++) { Console.Error.Write("-"); } if (error is CallCounterexample) { CallCounterexample CallCex = (CallCounterexample)error; if (QKeyValue.FindBoolAttribute(CallCex.FailingRequires.Attributes, "barrier_divergence")) { ReportBarrierDivergence(CallCex.FailingCall); } else if (QKeyValue.FindBoolAttribute(CallCex.FailingRequires.Attributes, "race")) { ReportRace(CallCex); } else { ReportRequiresFailure(CallCex.FailingCall, CallCex.FailingRequires); } } else if (error is ReturnCounterexample) { ReturnCounterexample ReturnCex = (ReturnCounterexample)error; ReportEnsuresFailure(ReturnCex.FailingEnsures); } else { AssertCounterexample AssertCex = (AssertCounterexample)error; if (AssertCex.FailingAssert is LoopInitAssertCmd) { ReportInvariantEntryFailure(AssertCex); } else if (AssertCex.FailingAssert is LoopInvMaintainedAssertCmd) { ReportInvariantMaintedFailure(AssertCex); } else if (QKeyValue.FindBoolAttribute(AssertCex.FailingAssert.Attributes, "barrier_invariant")) { ReportFailingBarrierInvariant(AssertCex); } else if (QKeyValue.FindBoolAttribute(AssertCex.FailingAssert.Attributes, "barrier_invariant_access_check")) { ReportFailingBarrierInvariantAccessCheck(AssertCex); } else if (QKeyValue.FindBoolAttribute(AssertCex.FailingAssert.Attributes, "constant_write")) { ReportFailingConstantWriteCheck(AssertCex); } else if (QKeyValue.FindBoolAttribute(AssertCex.FailingAssert.Attributes, "bad_pointer_access")) { ReportFailingBadPointerAccess(AssertCex); } else if (QKeyValue.FindBoolAttribute(AssertCex.FailingAssert.Attributes, "array_bounds")) { ReportFailingArrayBounds(AssertCex); } else { ReportFailingAssert(AssertCex); } } DisplayParameterValues(error); if (((GVCommandLineOptions)CommandLineOptions.Clo).DisplayLoopAbstractions) { DisplayLoopAbstractions(error); } }