public override void Execute(StateImpl application, PrtMachine _parent) { UserMachine parent = (UserMachine)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto AnonFun4_1; } (parent).Driver = (application).CreateInterfaceOrMachine((parent).renamedName, "OSRDriverInterface", Events_1448003977.@null); (parent).PrtFunContNewMachine(this, (currFun).locals, 1); return; AnonFun4_1: ; if (!!(Events_1448003977.eUnit).Equals(Events_1448003977.@null)) { throw new PrtAssertFailureException("C:\\\\Workspace\\\\P\\\\Src\\\\PTester\\\\Regressions\\\\Interfaces\\\\User.p (12, 4): Raised event must be non-null"); } Console.Write("<RaiseLog> Machine UserMachine-{0} raised Event {1}\\n", (parent).instanceNumber, (((PrtEventValue)(Events_1448003977.eUnit)).evt).name); (parent).currentTrigger = Events_1448003977.eUnit; (parent).currentPayload = Events_1448003977.@null; (parent).PrtFunContRaise(); return; parent.PrtFunContReturn(null); }
public int depth; // only used with depth bounding public BacktrackingState(StateImpl state) { this.State = state; CurrIndex = 0; ChoiceVector = new List <bool>(); depth = 0; }
public override void Execute(StateImpl application, PrtMachine _parent) { POrbMachine parent = (POrbMachine)(_parent); Broadcast_StackFrame currFun = (Broadcast_StackFrame)(parent.PrtPopFunStackFrame()); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto Broadcast_1; } (currFun).var_index = (new PrtIntValue(0)).Clone(); Broadcast_loop_start_0: ; if (!((PrtBoolValue)(new PrtBoolValue(((PrtIntValue)((currFun).var_index)).nt < ((PrtIntValue)(new PrtIntValue(((currFun).var_machines).Size()))).nt))).bl) { goto Broadcast_loop_end_0; } (((PrtMachineValue)((((PrtSeqValue)((currFun).var_machines)).Lookup((currFun).var_index)).Clone())).mach).PrtEnqueueEvent((PrtEventValue)((currFun).var_ev), (currFun).var_payload, parent, (PrtMachineValue)((((PrtSeqValue)((currFun).var_machines)).Lookup((currFun).var_index)).Clone())); (parent).PrtFunContSend(this, (currFun).locals, 1); return; Broadcast_1: ; (currFun).var_index = (new PrtIntValue(((PrtIntValue)((currFun).var_index)).nt + ((PrtIntValue)(new PrtIntValue(1))).nt)).Clone(); goto Broadcast_loop_start_0; Broadcast_loop_end_0: ; parent.PrtFunContReturn((currFun).locals); }
public static void Main(string[] args) { var options = ParseCommandLine(args); if (options == null) { Environment.Exit((int)TestResult.InvalidParameters); } var asm = Assembly.LoadFrom(options.inputFileName); StateImpl s = (StateImpl)asm.CreateInstance("P.Program.Application", false, BindingFlags.CreateInstance, null, new object[] { true }, null, new object[] { }); if (s == null) { throw new ArgumentException("Invalid assembly"); } int numOfSchedules = 0; int numOfSteps = 0; var randomScheduler = new Random(1); while (numOfSchedules < 100) { var currImpl = (StateImpl)s.Clone(); Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("New Schedule:"); Console.WriteLine("-----------------------------------------------------"); numOfSteps = 0; while (numOfSteps < 1000) { if (currImpl.EnabledMachines.Count == 0) { break; } var num = currImpl.EnabledMachines.Count; var choosenext = randomScheduler.Next(0, num); currImpl.EnabledMachines[choosenext].PrtRunStateMachine(); if (currImpl.Exception != null) { if (currImpl.Exception is PrtAssumeFailureException) { break; } else { Console.WriteLine("Exception hit during execution: {0}", currImpl.Exception.ToString()); Environment.Exit(-1); } } numOfSteps++; } numOfSchedules++; } }
public static PrtImplMachine CreateMachine_UserMachine(StateImpl application, PrtValue payload) { var machine = new UserMachine(application, PrtImplMachine.DefaultMaxBufferSize, false); (((machine).self).permissions).Add(Events_1448003977.eOperationFailure); (((machine).self).permissions).Add(Events_1448003977.eTimerStopped); (((machine).self).permissions).Add(Events_1448003977.eYes); (((machine).self).permissions).Add(Events_1448003977.eNo); (((machine).self).permissions).Add(Events_1448003977.eSetLedStateToUnstableUsingControlTransfer); (((machine).self).permissions).Add(Events_1448003977.eStartDebounceTimer); (((machine).self).permissions).Add(Events_1448003977.eSetLedStateToStableUsingControlTransfer); (((machine).self).permissions).Add(Events_1448003977.eStoppingSuccess); (((machine).self).permissions).Add(Events_1448003977.eStoppingFailure); (((machine).self).permissions).Add(Events_1448003977.eOperationSuccess); (((machine).self).permissions).Add(Events_1448003977.eUnit); (((machine).self).permissions).Add(Events_1448003977.eUpdateBarGraphStateUsingControlTransfer); (((machine).self).permissions).Add(Events_1448003977.eStopTimer); (((machine).self).permissions).Add(Events_1448003977.eTransferFailure); (((machine).self).permissions).Add(Events_1448003977.eTransferSuccess); (((machine).self).permissions).Add(Events_1448003977.eSwitchStatusChange); (((machine).self).permissions).Add(Events_1448003977.eTimerFired); (((machine).self).permissions).Add(Events_1448003977.eD0Exit); (((machine).self).permissions).Add(Events_1448003977.eD0Entry); ((machine).sends).Add(Events_1448003977.eD0Exit); ((machine).sends).Add(Events_1448003977.eD0Entry); (machine).currentPayload = payload; return(machine); }
public static PrtSpecMachine CreateSpec_Blah(StateImpl application) { var machine = new Blah(application); ((machine).observes).Add(Events_1528637394.Ping); return(machine); }
public override void WriteString(StateImpl state, BinaryWriter bw) { bw.Write(this.TypeId); // For each non-static field: // Insert statement template "WriteSimpleField" or "WriteComplexField" }
public ExecutionState(StateImpl s, TraversalInfo predecessor, Via bt, bool MustFingerprint) : base(s, StateType.ExecutionState, predecessor, bt) { Debug.Assert(ProcessInfo != null && ProcessInfo.Length == NumProcesses); stateImpl = s; hasMultipleSuccessors = NumSuccessors() > 1; receipt = s.CheckIn(); if (!ZingerConfiguration.DoRandomSampling) { if (MustFingerprint) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { this.fingerprint = null; this.IsFingerPrinted = false; } } }
public override void Execute(StateImpl application, PrtMachine _parent) { POrbMachine parent = (POrbMachine)(_parent); IsSubscribed_StackFrame currFun = (IsSubscribed_StackFrame)(parent.PrtPopFunStackFrame()); PrtValue swap; (currFun).var_index = (new PrtIntValue(0)).Clone(); IsSubscribed_loop_start_0: ; if (!((PrtBoolValue)(new PrtBoolValue(((PrtIntValue)((currFun).var_index)).nt < ((PrtIntValue)(new PrtIntValue(((currFun).var_machines).Size()))).nt))).bl) { goto IsSubscribed_loop_end_0; } if (!((PrtBoolValue)(new PrtBoolValue(((((PrtSeqValue)((currFun).var_machines)).Lookup((currFun).var_index)).Clone()).Equals((currFun).var_sub)))).bl) { goto IsSubscribed_if_0_else; } (parent).PrtFunContReturnVal(new PrtBoolValue(true), (currFun).locals); return; goto IsSubscribed_if_0_end; IsSubscribed_if_0_else: ; IsSubscribed_if_0_end: ; (currFun).var_index = (new PrtIntValue(((PrtIntValue)((currFun).var_index)).nt + ((PrtIntValue)(new PrtIntValue(1))).nt)).Clone(); goto IsSubscribed_loop_start_0; IsSubscribed_loop_end_0: ; (parent).PrtFunContReturnVal(new PrtBoolValue(false), (currFun).locals); return; parent.PrtFunContReturn((currFun).locals); }
/* private class EdgeCounter : FieldTraverser { private int count = 0; public override void DoTraversal(Object field) { throw new ApplicationException("EdgePrinter should never traverse non Ptrs"); } public override void DoTraversal(Pointer ptr) { if(ptr == 0u) return; count ++; } public void reset(){count = 0;} public int edgeCount(){return count;} } */ public static void TraverseHeap(StateImpl state, FieldTraverser edge, FieldTraverser node) { heapQueue = new Queue(); seen = new Hashtable(); ReferenceTraverser et = new ReferenceTraverser(state, edge); state.TraverseGlobalReferences(et); for (int i = 0; i < state.NumProcesses; i++) { Process p = state.GetProcess(i); for (ZingMethod m = p.TopOfStack; m != null; m = m.Caller) { m.TraverseFields(et); } } while (heapQueue.Count > 0) { Pointer ptr = (Pointer)heapQueue.Dequeue(); if (node != null) node.DoTraversal(ptr); HeapEntry he = (HeapEntry)state.Heap[ptr]; he.heList.TraverseFields(et); } }
public void Update(float deltaTime) { if (CanChangeState == true) { int tranFunCount = m_AllTransitionFuns.Count; StateImpl newStateImpl = null; for (int i = 0; i < tranFunCount; i++) { State newState = ((m_AllTransitionFuns[i] as TransitionFun)(m_CurrState)); if (newState != null) { if (newState.GetType() == typeof(StateImpl)) { newStateImpl = (StateImpl)newState; break; } } } if (newStateImpl != null && m_CurrState != newStateImpl) { SetState(newStateImpl); } } if (m_CurrState != null) { m_CurrState.UpdateState(m_CurrState, deltaTime); } }
public override void Execute(StateImpl application, PrtMachine _parent) { Main parent = (Main)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto foo_1; } (parent).PrtFunContNondet(this, (currFun).locals, 1); return; foo_1: ; if (!((PrtBoolValue)(new PrtBoolValue(((parent).continuation).ReturnAndResetNondet()))).bl) { goto foo_if_0_else; } (parent).x = (new PrtIntValue(((PrtIntValue)((parent).x)).nt + ((PrtIntValue)(new PrtIntValue(1))).nt)).Clone(); goto foo_if_0_end; foo_if_0_else: ; foo_if_0_end: ; parent.PrtFunContReturn(null); }
public override void Execute(StateImpl application, PrtMachine _parent) { Main parent = (Main)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto AnonFun5_1; } (parent).PrtPushFunStackFrame(Action1, (Action1).CreateLocals()); AnonFun5_1: ; (Action1).Execute(application, parent); if (((parent).continuation).reason == PrtContinuationReason.Return) { } else { (parent).PrtPushFunStackFrame(Action1, (currFun).locals, 1); return; } parent.PrtFunContReturn(null); }
public override void Execute(StateImpl application, PrtMachine _parent) { Main parent = (Main)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; if (!((PrtBoolValue)(new PrtBoolValue(((parent).i).Equals(new PrtIntValue(0))))).bl) { goto AnonFun1_if_0_else; } if (!!(Events_1870448896.E).Equals(Events_1870448896.@null)) { throw new PrtAssertFailureException("C:\\\\Workspace\\\\P\\\\Tst\\\\RegressionTests\\\\Integration\\\\Correct\\\\SEM_OneMachine_22\\\\AlonBug_1.p (19, 10): Raised event must be non-null"); } (application).Trace("<RaiseLog> Machine Main-{0} raised Event {1}", (parent).instanceNumber, (((PrtEventValue)(Events_1870448896.E)).evt).name); (parent).currentTrigger = Events_1870448896.E; (parent).currentPayload = Events_1870448896.@null; (parent).PrtFunContRaise(); return; goto AnonFun1_if_0_end; AnonFun1_if_0_else: ; (parent).i = (new PrtIntValue(((PrtIntValue)((parent).i)).nt + ((PrtIntValue)(new PrtIntValue(1))).nt)).Clone(); AnonFun1_if_0_end: ; parent.PrtFunContReturn(null); }
public override void Execute(StateImpl application, PrtMachine _parent) { POrbMachine parent = (POrbMachine)(_parent); AnonFun5_StackFrame currFun = (AnonFun5_StackFrame)(parent.PrtPopFunStackFrame()); PrtValue swap; if (!((PrtBoolValue)(new PrtBoolValue(((PrtMapValue)((parent).var_topicSubscribers)).Contains((((PrtTupleValue)((currFun).var_payload)).fieldValues[0]).Clone())))).bl) { goto AnonFun5_if_1_else; } (currFun).var_list = ((((PrtMapValue)((parent).var_topicSubscribers)).Lookup((((PrtTupleValue)((currFun).var_payload)).fieldValues[0]).Clone())).Clone()).Clone(); if (!((PrtBoolValue)((IsSubscribed).ExecuteToCompletion(application, parent, (((PrtTupleValue)((currFun).var_payload)).fieldValues[1]).Clone(), (currFun).var_list))).bl) { goto AnonFun5_if_0_else; } (application).Trace("<PrintLog> Subscriber is already subscribed to event "); ((((PrtTupleValue)((currFun).var_payload)).fieldValues[0]).Clone()).ToString(); (application).Trace("<PrintLog> \\n"); goto AnonFun5_if_0_end; AnonFun5_if_0_else: ; AnonFun5_if_0_end: ; ((PrtSeqValue)(((PrtMapValue)((parent).var_topicSubscribers)).Lookup((((PrtTupleValue)((currFun).var_payload)).fieldValues[0]).Clone()))).Insert(((PrtTupleValue)(new PrtTupleValue(new PrtIntValue(0), (((PrtTupleValue)((currFun).var_payload)).fieldValues[1]).Clone()))).fieldValues[0], ((PrtTupleValue)(new PrtTupleValue(new PrtIntValue(0), (((PrtTupleValue)((currFun).var_payload)).fieldValues[1]).Clone()))).fieldValues[1]); goto AnonFun5_if_1_end; AnonFun5_if_1_else: ; ((PrtMapValue)((parent).var_topicSubscribers)).Update((((PrtTupleValue)((currFun).var_payload)).fieldValues[0]).Clone(), (PrtValue.PrtMkDefaultValue(Types.type_9_958407665)).Clone()); ((PrtSeqValue)(((PrtMapValue)((parent).var_topicSubscribers)).Lookup((((PrtTupleValue)((currFun).var_payload)).fieldValues[0]).Clone()))).Insert(((PrtTupleValue)(new PrtTupleValue(new PrtIntValue(0), (((PrtTupleValue)((currFun).var_payload)).fieldValues[1]).Clone()))).fieldValues[0], ((PrtTupleValue)(new PrtTupleValue(new PrtIntValue(0), (((PrtTupleValue)((currFun).var_payload)).fieldValues[1]).Clone()))).fieldValues[1]); AnonFun5_if_1_end: ; parent.PrtFunContReturn((currFun).locals); }
public override void Execute(StateImpl application, PrtMachine _parent) { POrbMachine parent = (POrbMachine)(_parent); AnonFun2_StackFrame currFun = (AnonFun2_StackFrame)(parent.PrtPopFunStackFrame()); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto AnonFun2_1; } (parent).PrtPushFunStackFrame(InitializeListener, (InitializeListener).CreateLocals(parent.self)); AnonFun2_1: ; (InitializeListener).Execute(application, parent); if (((parent).continuation).reason == PrtContinuationReason.Return) { } else { (parent).PrtPushFunStackFrame((currFun).fun, (currFun).locals, 1); return; } (application).TraceLine("<GotoLog> Machine {0}-{1} goes to {2}", (parent).Name, (parent).instanceNumber, (POrbMachine_ReadMessagesAndPublish).name); (parent).currentTrigger = Events.@null; (parent).currentPayload = Events.@null; (parent).destOfGoto = POrbMachine_ReadMessagesAndPublish; (parent).PrtFunContGoto(); return; parent.PrtFunContReturn((currFun).locals); }
public override void Execute(StateImpl application, PrtMachine _parent) { Timer parent = (Timer)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; parent.PrtFunContReturn(null); }
public override void Execute(StateImpl application, PrtMachine _parent) { POrbMachine parent = (POrbMachine)(_parent); AnonFun3_StackFrame currFun = (AnonFun3_StackFrame)(parent.PrtPopFunStackFrame()); PrtValue swap; parent.PrtFunContReturn((currFun).locals); }
public static PrtImplMachine CreateMachine_Main(StateImpl application, PrtValue payload) { var machine = new Main(application, PrtImplMachine.DefaultMaxBufferSize, false); (((machine).self).permissions).Add(Events_745868657.dummy); ((machine).sends).Add(Events_745868657.dummy); (machine).currentPayload = payload; return(machine); }
public static PrtImplMachine CreateMachine_POrbMachine(StateImpl application, PrtValue payload) { var machine = new POrbMachine(application, PrtImplMachine.DefaultMaxBufferSize, false); (application).TraceLine("<CreateLog> Created Machine POrbMachine-{0}", (machine).instanceNumber); ((machine).self).permissions = null; (machine).sends = null; (machine).currentPayload = payload; return(machine); }
public override void Execute(StateImpl application, PrtMachine _parent) { Timer parent = (Timer)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto AnonFun7_1; case 2: goto AnonFun7_2; case 3: goto AnonFun7_3; case 4: goto AnonFun7_4; } (parent).PrtFunContNondet(this, (currFun).locals, 4); return; AnonFun7_4: ; if (!((PrtBoolValue)(new PrtBoolValue(((parent).continuation).ReturnAndResetNondet()))).bl) { goto AnonFun7_if_0_else; } (((PrtMachineValue)((parent).client)).mach).PrtEnqueueEvent((PrtEventValue)(Events.CANCEL_SUCCESS), parent.self, parent, (PrtMachineValue)((parent).client)); (parent).PrtFunContSend(this, (currFun).locals, 1); return; AnonFun7_1: ; goto AnonFun7_if_0_end; AnonFun7_if_0_else: ; (((PrtMachineValue)((parent).client)).mach).PrtEnqueueEvent((PrtEventValue)(Events.CANCEL_FAILURE), parent.self, parent, (PrtMachineValue)((parent).client)); (parent).PrtFunContSend(this, (currFun).locals, 2); return; AnonFun7_2: ; (((PrtMachineValue)((parent).client)).mach).PrtEnqueueEvent((PrtEventValue)(Events.TIMEOUT), parent.self, parent, (PrtMachineValue)((parent).client)); (parent).PrtFunContSend(this, (currFun).locals, 3); return; AnonFun7_3: ; AnonFun7_if_0_end: ; parent.PrtFunContReturn(null); }
public override void WriteString(StateImpl state, BinaryWriter bw) { if (UnallocatedWrites != null) UnallocatedWrites.WriteString(state, bw); // for each global, emit a call to bm.Write(). For pointer // types, write a "canonical" pointer obtained by calling // GetCanonicalId(). //bw.Write(member1); ; }
public static PrtImplMachine CreateMachine_Main(StateImpl application, PrtValue payload) { var machine = new Main(application, PrtImplMachine.DefaultMaxBufferSize, false); (application).Trace("<CreateLog> Created Machine Main-{0}", (machine).instanceNumber); (((machine).self).permissions).Add(Events_1870448896.E); (((machine).self).permissions).Add(Events_1870448896.halt); ((machine).sends).Add(Events_1870448896.E); ((machine).sends).Add(Events_1870448896.halt); (machine).currentPayload = payload; return(machine); }
protected void State(Expression <Func <State> > propertyExpression) { PropertyInfo property = propertyExpression.GetPropertyInfo(); string name = property.Name; var state = new StateImpl <TInstance>(name, _eventRaisingObserver, _eventRaisedObserver); property.SetValue(this, state); _stateCache[name] = state; }
public override void Execute(StateImpl application, PrtMachine _parent) { Main parent = (Main)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; if (!((PrtBoolValue)(new PrtBoolValue(false))).bl) { throw new PrtAssertFailureException("C:\\\\Workspace\\\\P\\\\Tst\\\\RegressionTests\\\\Integration\\\\Correct\\\\SEM_OneMachine_22\\\\AlonBug_1.p (12, 10): Assert failed"); } parent.PrtFunContReturn(null); }
internal override void CreateDelegate(int stateNum, List <DfaStatePlaceholder <TResult> > allStates) { var targetStates = new DfaStateImpl <TResult> [targetStateNumbers.Length]; for (var i = 0; i < targetStates.Length; ++i) { var num = targetStateNumbers[i]; targetStates[i] = num < 0 ? null : allStates[num]; } Delegate = new StateImpl(internalNodes, targetStates, accepting, match, stateNum); }
public override void Execute(StateImpl application, PrtMachine _parent) { Main parent = (Main)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; if (!((PrtBoolValue)(new PrtBoolValue(false))).bl) { throw new PrtAssertFailureException("E:\\\\PLanguage\\\\P\\\\Src\\\\PTester\\\\Regressions\\\\PingPong\\\\PingPong.p (18, 25): Assert failed"); } parent.PrtFunContReturn(null); }
private void state(XmlElement stateElement, StateImpl state, ProcessBlockImpl processBlock) { this.node(stateElement, state, processBlock); IEnumerator iter = xmlElement.GetChildElements("field").GetEnumerator(); while (iter.MoveNext()) { FieldImpl field = state.CreateField(); this.field((XmlElement)iter.Current, field, processBlock); } }
public static void RunPSharpTester(StateImpl s) { main_s = s; coverage = new Coverage(); var configuration = Configuration.Create() .WithNumberOfIterations(100); configuration.UserExplicitlySetMaxFairSchedulingSteps = true; configuration.MaxUnfairSchedulingSteps = 100; configuration.MaxFairSchedulingSteps = configuration.MaxUnfairSchedulingSteps * 10; configuration.LivenessTemperatureThreshold = configuration.MaxFairSchedulingSteps / 3; foreach (var machine in main_s.EnabledMachines) { coverage.DeclareMachine(machine); } var engine = Microsoft.PSharp.TestingServices.TestingEngineFactory.CreateBugFindingEngine( configuration, PSharpWrapper.Execute); engine.Run(); Console.WriteLine("Bugs found: {0}", engine.TestReport.NumOfFoundBugs); if (engine.TestReport.NumOfFoundBugs > 0) { if (currentImpl.Exception != null && currentImpl.Exception is PrtException) { Console.WriteLine("{0}", currentImpl.errorTrace.ToString()); Console.WriteLine("ERROR: {0}", currentImpl.Exception.Message); } else if (currentImpl.Exception != null) { Console.WriteLine("{0}", currentImpl.errorTrace.ToString()); Console.WriteLine("[Internal Exception]: Please report to the P Team"); Console.WriteLine("{0}", currentImpl.Exception.ToString()); } else { Console.WriteLine("{0}", currentImpl.errorTrace.ToString()); Console.WriteLine("ERROR: Liveness violation"); } } Console.WriteLine("Dumping coverage information"); coverage.Dump("coverage"); Console.WriteLine("... Writing coverage.txt"); Console.WriteLine("... Writing coverage.dgml"); }
public override void Execute(StateImpl application, PrtMachine _parent) { Main parent = (Main)(_parent); PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); PrtValue swap; switch ((currFun).returnToLocation) { case 1: goto AnonFun0_1; case 2: goto AnonFun0_2; case 3: goto AnonFun0_3; } (((PrtMachineValue)(parent.self)).mach).PrtEnqueueEvent((PrtEventValue)(Events_1528637394.boolPayloadEvent), new PrtBoolValue(true), parent, (PrtMachineValue)(parent.self)); (parent).PrtFunContSend(this, (currFun).locals, 1); return; AnonFun0_1: ; (parent).varBool = (new PrtBoolValue(false)).Clone(); (((PrtMachineValue)(parent.self)).mach).PrtEnqueueEvent((PrtEventValue)(Events_1528637394.boolPayloadEvent), (parent).varBool, parent, (PrtMachineValue)(parent.self)); (parent).PrtFunContSend(this, (currFun).locals, 2); return; AnonFun0_2: ; (parent).pongId = (application).CreateInterfaceOrMachine((parent).renamedName, "PONG", Events_1528637394.@null); (parent).PrtFunContNewMachine(this, (currFun).locals, 3); return; AnonFun0_3: ; if (!!(Events_1528637394.Success).Equals(Events_1528637394.@null)) { throw new PrtAssertFailureException("E:\\\\PLanguage\\\\P\\\\Src\\\\PTester\\\\Regressions\\\\TwoMachines\\\\TwoMachines.p (59, 10): Raised event must be non-null"); } Console.Write("<RaiseLog> Machine Main-{0} raised Event {1}\\n", (parent).instanceNumber, (((PrtEventValue)(Events_1528637394.Success)).evt).name); (parent).currentTrigger = Events_1528637394.Success; (parent).currentPayload = Events_1528637394.@null; (parent).PrtFunContRaise(); return; parent.PrtFunContReturn(null); }
public static PrtImplMachine CreateMachine_PONG(StateImpl application, PrtValue payload) { var machine = new PONG(application, 111, true); (((machine).self).permissions).Add(Events_1528637394.Success); (((machine).self).permissions).Add(Events_1528637394.boolPayloadEvent); (((machine).self).permissions).Add(Events_1528637394.Ping); (((machine).self).permissions).Add(Events_1528637394.intPayloadEvent); ((machine).sends).Add(Events_1528637394.Success); ((machine).sends).Add(Events_1528637394.boolPayloadEvent); ((machine).sends).Add(Events_1528637394.intPayloadEvent); ((machine).sends).Add(Events_1528637394.Ping); (machine).currentPayload = payload; return(machine); }
public static PrtImplMachine CreateMachine_Main(StateImpl application, PrtValue payload) { var machine = new Main(application, PrtImplMachine.DefaultMaxBufferSize, false); (((machine).self).permissions).Add(Events_1528637394.Success); (((machine).self).permissions).Add(Events_1528637394.boolPayloadEvent); (((machine).self).permissions).Add(Events_1528637394.intPayloadEvent); (((machine).self).permissions).Add(Events_1528637394.Ping); ((machine).sends).Add(Events_1528637394.Success); ((machine).sends).Add(Events_1528637394.boolPayloadEvent); ((machine).sends).Add(Events_1528637394.intPayloadEvent); ((machine).sends).Add(Events_1528637394.Ping); (machine).currentPayload = payload; return(machine); }
public override void Execute(StateImpl application, PrtMachine parent) { PrtFunStackFrame currFun = parent.PrtPopFunStackFrame(); if (currFun.returnTolocation == 0) { goto Loc_0; } else { goto Ret; } Loc_0: Ret: parent.PrtFunContReturn(null); }
// Optimization tip, Try to keep the state name as short as possible public State AddNewState(string name, BeginStateFun beginState, UpdateStateFun updateState, EndStateFun endState) { if (m_AllStates.ContainsKey(name)) { Debug.LogError("State named " + name + " already exist"); } else { uint currID = m_CurrId; StateImpl newState = new StateImpl(name, currID, beginState, updateState, endState); m_AllStates[name] = newState; m_AllStatesID[currID] = newState; m_CurrId++; return(newState); } return(null); }
public ExecutionState(StateImpl s, TraversalInfo predecessor, Via bt) : base(s, StateType.ExecutionState, predecessor, bt) { Debug.Assert(ProcessInfo != null && ProcessInfo.Length == NumProcesses); hasMultipleSuccessors = NumSuccessors() > 1; stateImpl = s; currProcess = 0; receipt = s.CheckIn(); #if true //dont fingerprint during random sampling if (!ZingerConfiguration.DoRandomSampling) { if (ZingerConfiguration.FingerprintSingleTransitionStates) { if (this.NumProcesses > 1) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { // Fingerprint with probability p if (ZingerUtilities.rand.NextDouble() <= ZingerConfiguration.NonChooseProbability) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { this.fingerprint = null; this.IsFingerPrinted = false; } } } else { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } } #endif }
public override void WriteString(StateImpl state, BinaryWriter bw) { bw.Write(typeId); bw.Write((ushort) nextBlock); bw.Write(state.GetCanonicalId(privThis)); // Emit a bw.Write() call for each member of locals, inputs, and outputs. // For struct types, emit a call to their WriteString method. inputs.WriteString(state, bw); outputs.WriteString(state, bw); locals.WriteString(state, bw); }
internal abstract void deOrphanize(StateImpl s);
internal override void deOrphanize(StateImpl s) { Debug.Assert(numChoices == s.NumChoices); receipt = s.CheckIn(); Predecessor.Successor = this; }
public override void WriteOutputsString(StateImpl state, BinaryWriter bw) { outputs.WriteString(state, bw); }
// <summary> // Constructor // </summary> // <param name="entryPoint"></param> // <param name="name"></param> // <param name="id"></param> public Process(StateImpl stateObj, ZingMethod entryPoint, string name, uint id) { this.StateImpl = stateObj; this.entryPoint = entryPoint; this.name = name; this.id = id; this.Call(entryPoint); }
// <summary> // Private constructor for cloning only // </summary> private Process(StateImpl stateObj, string myName, uint myId) { StateImpl = stateObj; name = myName; id = myId; }
public ZingExplorer() { startStateStateImpl = StateImpl.Load(ZingerConfiguration.ZingModelFile); Initialize(); }
public override void WriteString(StateImpl state, BinaryWriter bw) { bw.Write(this.TypeId); bw.Write(this.Count); foreach (_ElementType x in array) bw.Write(x); }
internal override void deOrphanize(StateImpl s) { receipt = s.CheckIn(); Predecessor.Successor = this; }
public HeapElementPrinter(StateImpl s) { state = s; nodeTrav = new NodePrinter(this); edgeTrav = new EdgePrinter(this); }
public static void PrintHeapElements(StateImpl state) { HeapElementPrinter hep = new HeapElementPrinter(state); TraverseHeap(state, hep.edgeTrav, hep.nodeTrav); System.Console.WriteLine("============================================"); }
public ReferenceTraverser(StateImpl s, FieldTraverser e) { state = s; perEdgeTraverser = e; }
public ChooseState(StateImpl s, TraversalInfo predecessor, Via bt) : base(s, StateType.ChooseState, predecessor, bt) { numChoices = s.NumChoices; hasMultipleSuccessors = s.NumChoices > 1; stateImpl = s; receipt = s.CheckIn(); if (!ZingerConfiguration.DoRandomSampling) { if (ZingerConfiguration.FingerprintSingleTransitionStates) { if (this.NumChoices > 1) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { // Fingerprint with probability p if (ZingerUtilities.rand.NextDouble() <= ZingerConfiguration.NonChooseProbability) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { this.fingerprint = null; this.IsFingerPrinted = false; } } } else { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } } }
// for each user-defined struct, emit a corresponding struct definition here public void WriteString(StateImpl state, BinaryWriter bw) { }
public TerminalState(StateImpl s, TraversalInfo pred, Via bt, bool MustFingerprint) : base(s, StateType.TerminalState, pred, bt) { hasMultipleSuccessors = false; if (s.IsErroneous) { IsErroneous = true; Error = s.Exception; } else if (s.IsFailedAssumption) { IsFailedAssumption = true; Error = s.Exception; } else if (s.IsValidTermination) { IsValidTermination = true; } stateImpl = s; receipt = s.CheckIn(); if (MustFingerprint) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { this.fingerprint = null; this.IsFingerPrinted = false; } }
public override void WriteString(StateImpl state, BinaryWriter bw) { bw.Write(this.TypeId); bw.Write(this.Count); this.ArrayList.Sort(); foreach (_ElementType x in this.ArrayList) bw.Write((byte) x); }
internal object Clone(StateImpl myState, bool shallowCopy) { Process clone = new Process(myState, Name, Id); clone.atomicityLevel = this.atomicityLevel; clone.middleOfTransition = this.middleOfTransition; clone.backTransitionEncountered = this.backTransitionEncountered; clone.choicePending = this.choicePending; // For parallel exploration clone.myThreadId = myState.MySerialNum; // Recursively clone the entire stack if (this.topOfStack != null) clone.topOfStack = this.topOfStack.Clone(myState, clone, shallowCopy); if (this.lastFunctionCompleted != null) { Debug.Fail("cannot happen anymore (xyc)"); clone.lastFunctionCompleted = this.lastFunctionCompleted.Clone(myState, clone, true); } return clone; }
public void DiscardStateImpl() { stateImpl = null; }
protected static TraversalInfo MakeTraversalInfo(StateImpl s, TraversalInfo pred, Via bt, bool MustFingerprint) { if (s.IsTerminalState) return new TerminalState(s, pred, bt, MustFingerprint); if (s.IsChoicePending) return new ChooseState(s, pred, bt, MustFingerprint); if (s.IsNormalState) return new ExecutionState(s, pred, bt, MustFingerprint); Debug.Fail("unexpected state type"); return null; }
public Process(StateImpl stateObj, ZingMethod entryPoint, string name, uint id, int threadID) : this(stateObj, entryPoint, name, id) { this.MyThreadId = threadID; }
public void WriteString(StateImpl state, BinaryWriter bw) { // Emit a bw.Write() call for each member }
/// <summary> /// Compute the fingerprint of a process. /// The current implementation computes this fingerprint nonincrementally. /// But in the future this can be made incremental /// </summary> /// <param name="state"></param> /// <returns>Fingerprint of a process</returns> public Fingerprint ComputeFingerprint(StateImpl state) { if (memStream == null) { memStream = new MemoryStream(); binWriter = new BinaryWriter(memStream); } binWriter.Seek(0, SeekOrigin.Begin); this.WriteString(state, binWriter); Fingerprint procPrint = StateImpl.FingerprintNonHeapBuffer(memStream.GetBuffer(), (int)memStream.Position); return procPrint; //return Fingerprint.ComputeFingerprint(memStream.GetBuffer(), (int) memStream.Position, 0); }
public ChooseState(StateImpl s, TraversalInfo predecessor, Via bt, bool MustFingerprint) : base(s, StateType.ChooseState, predecessor, bt) { numChoices = s.NumChoices; stateImpl = s; hasMultipleSuccessors = s.NumChoices > 1; receipt = s.CheckIn(); if (!ZingerConfiguration.DoRandomSampling) { if (MustFingerprint) { fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { this.fingerprint = null; this.IsFingerPrinted = false; } } }
internal void WriteString(StateImpl state, BinaryWriter bw) { for (ZingMethod m = topOfStack; m != null; m = m.Caller) m.WriteString(state, bw); if (lastFunctionCompleted != null) { Debug.Assert(state.Exception != null); bw.Write((ushort)0xcafe); lastFunctionCompleted.WriteOutputsString(state, bw); } // We write a unique delimiter at the end of each process to remove any // potential ambiguity from our generated string. We guarantee that the // type id of a stack frame will never be "0xface". Without this delimiter // it's at least theoretically possible that two distinct states could // yield the same string. bw.Write((ushort)0xface); }
public TerminalState(StateImpl s, TraversalInfo pred, Via bt) : base(s, StateType.TerminalState, pred, bt) { hasMultipleSuccessors = false; if (s.IsErroneous) { IsErroneous = true; Error = s.Exception; } else if (s.IsFailedAssumption) { IsFailedAssumption = true; Error = s.Exception; } else if (s.IsValidTermination) { IsValidTermination = true; } stateImpl = s; receipt = s.CheckIn(); #if true if (ZingerConfiguration.FingerprintSingleTransitionStates) { // Fingerprint with probability p if (ZingerUtilities.rand.NextDouble() <= ZingerConfiguration.NonChooseProbability) { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } else { this.fingerprint = null; this.IsFingerPrinted = false; } } else { this.fingerprint = s.Fingerprint; this.IsFingerPrinted = true; } #endif }