Esempio n. 1
0
 public void AddState(ExecutionState toAdd)
 {
     InitLoopInfoFor(toAdd);
     UnderlyingScheduler.AddState(toAdd);
 }
Esempio n. 2
0
 public void RemoveState(ExecutionState toRemove)
 {
     StateToCurrentLoops.Remove(toRemove);
     UnderlyingScheduler.RemoveState(toRemove);
 }
Esempio n. 3
0
        protected override void DoTask(Executor e, ExecutionState State)
        {
            string terminatationTypeName = null;

            if (State.TerminationType == null)
            {
                terminatationTypeName = "NonTerminated";
            }
            else
            {
                terminatationTypeName = State.TerminationType.GetType().ToString();
            }

            var path = Path.Combine(Directory, ((State.Id >= 0)?State.Id.ToString():"initial") + "-" + terminatationTypeName + ".smt2");

            using (var SW = new StreamWriter(path))
            {
                Console.WriteLine("Logging State {0} constraints to {1}", State.Id, path);
                var outputFile = new SMTLIBQueryPrinter(SW, true, true);

                outputFile.AnnotateAssertsWithNames = false; // Enabling this is really only useful for getting the unsat-core

                // FIXME: This **all** needs to be refactored. The solvers do something very similar
                foreach (var constraint in State.Constraints.Constraints)
                {
                    outputFile.AddDeclarations(constraint);
                }

                // Add declarations for any variables in the condition for sat if its available
                if (State.TerminationType is TerminationTypeWithSatAndUnsatExpr)
                {
                    var terminationType = State.TerminationType as TerminationTypeWithSatAndUnsatExpr;
                    Debug.Assert(terminationType.ConditionForSat != null, "ConditionForSat should not be null");
                    outputFile.AddDeclarations(terminationType.ConditionForSat);
                }

                outputFile.PrintSetOption("produce-models", "true");

                if (State.TerminationType == null)
                {
                    outputFile.PrintCommentLine("Non terminated state");
                }
                else
                {
                    outputFile.PrintCommentLine(State.TerminationType.GetMessage());
                }

                outputFile.PrintSortDeclarations();
                outputFile.PrintFunctionDeclarations();
                outputFile.PrintVariableDeclarations();

                foreach (var constraint in State.Constraints.Constraints)
                {
                    outputFile.PrintCommentLine("Origin : " + constraint.Origin.ToString());
                    outputFile.PrintAssert(constraint.Condition);
                }

                // This adds the last constraint if there is one
                if (State.TerminationType is TerminationTypeWithSatAndUnsatExpr)
                {
                    var terminationType = State.TerminationType as TerminationTypeWithSatAndUnsatExpr;
                    outputFile.PrintCommentLine("Query Expr:SAT");
                    outputFile.PrintAssert(terminationType.ConditionForSat);
                }

                outputFile.PrintCheckSat();
                outputFile.PrintGetModel();
                outputFile.PrintExit();
            }
        }
 public void AddState(ExecutionState toAdd)
 {
     Debug.Assert(!NotAboutToDoGoto.Contains(toAdd), "Cannot add state already held by scheduler");
     Debug.Assert(!AboutToDoGoto.Contains(toAdd), "Cannot add state already held by scheduler");
     AboutToDoGoto.Add(toAdd);
 }
Esempio n. 5
0
 // Symbolic from a procedure's modeset
 public SymbolicVariable GetFreshSymbolic(Procedure proc, int modSetIndex, ExecutionState owner)
 {
     ++Count;
     return(new SymbolicVariable(GetNewSymbolicVariableName(proc, modSetIndex), proc, modSetIndex));
 }
        protected override void DoTask(Executor e, ExecutionState State)
        {
            string terminatationTypeName = State.TerminationType.GetType().ToString();

            if (!(State.TerminationType is TerminationTypeWithSatAndUnsatExpr))
            {
                return;
            }

            var terminationType = State.TerminationType as TerminationTypeWithSatAndUnsatExpr;

            if (terminationType.ConditionForUnsat == null)
            {
                return;
            }

            var path = Path.Combine(Directory, ((State.Id >= 0)?State.Id.ToString():"initial") + "-" + terminatationTypeName + ".unsatcore.smt2");

            using (var SW = new StreamWriter(path))
            {
                Console.WriteLine("Logging State {0} unsat core constraints to {1}", State.Id, path);
                var outputFile = new SMTLIBQueryPrinter(SW, true, true);

                outputFile.AnnotateAssertsWithNames = true; // Needed for unsat-core

                // FIXME: This **all** needs to be refactored. The solvers do something very similar
                foreach (var constraint in State.Constraints.Constraints)
                {
                    outputFile.AddDeclarations(constraint);
                }

                outputFile.AddDeclarations(terminationType.ConditionForUnsat);

                outputFile.PrintSetOption("produce-unsat-cores", "true");

                if (State.TerminationType == null)
                {
                    outputFile.PrintCommentLine("Non terminated state");
                }
                else
                {
                    outputFile.PrintCommentLine(State.TerminationType.GetMessage());
                }

                outputFile.PrintSortDeclarations();
                outputFile.PrintFunctionDeclarations();
                outputFile.PrintVariableDeclarations();

                foreach (var constraint in State.Constraints.Constraints)
                {
                    outputFile.PrintCommentLine("Origin : " + constraint.Origin.ToString());
                    outputFile.PrintAssert(constraint.Condition);
                }


                outputFile.PrintCommentLine("Query Expr:UNSAT");
                outputFile.PrintAssert(terminationType.ConditionForUnsat);


                outputFile.PrintCheckSat();
                outputFile.PrintGetUnsatCore();
                outputFile.PrintExit();
            }
        }
Esempio n. 7
0
 public SymbolicVariable GetFreshSymbolic(Variable Origin, ExecutionState owner)
 {
     ++Count;
     return(new SymbolicVariable(GetNewSymbolicVariableName(Origin), Origin));
 }
Esempio n. 8
0
 public SymbolicVariable GetFreshSymbolic(HavocCmd cmd, int varsIndex, ExecutionState owner)
 {
     ++Count;
     return(new SymbolicVariable(GetNewSymbolicVariableName(cmd, varsIndex), cmd, varsIndex));
 }
Esempio n. 9
0
 public DFSStateScheduler()
 {
     States = new List <ExecutionState>();
     Popped = null;
 }
Esempio n. 10
0
 public void AddState(ExecutionState toAdd)
 {
     Debug.Assert(!States.Contains(toAdd), "ExecutionStates already in the scheduler should not be added again");
     States.Add(toAdd);
 }
 public void RemoveState(ExecutionState toRemove)
 {
     Debug.Assert(States.Contains(toRemove), "Cannot remove state not stored in the state scheduler");
     States.Remove(toRemove);
 }
 public void AddState(ExecutionState toAdd)
 {
     States.Add(toAdd);
 }
Esempio n. 13
0
 protected abstract void DoTask(Executor e, ExecutionState State);
Esempio n. 14
0
 public ExecutionStateNestedLoopInfo(ExecutionState state)
 {
     NestedLoops = new Stack <ExecutionStateSingleLoopInfo>();
     State       = state;
 }
Esempio n. 15
0
 public InitialStateTerminated(Executor executor, ExecutionState state) : base(executor, "Cannot execute terminated state")
 {
     this.State = state;
 }