Exemple #1
0
 /// <summary>
 /// Returns the state corresponding to the
 /// specified schedule step.
 /// </summary>
 /// <param name="key">ScheduleStep</param>
 /// <returns>State</returns>
 internal State this[ScheduleStep key]
 {
     get
     {
         return this.StateMap[key];
     }
 }
Exemple #2
0
        /// <summary>
        /// Creates a nondeterministic boolean choice schedule step.
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="choice">Choice</param>
        /// <returns>ScheduleStep</returns>
        internal static ScheduleStep CreateNondeterministicBooleanChoice(int index, bool choice)
        {
            var scheduleStep = new ScheduleStep();

            scheduleStep.Index = index;
            scheduleStep.Type  = ScheduleStepType.NondeterministicChoice;

            scheduleStep.BooleanChoice = choice;
            scheduleStep.IntegerChoice = null;

            scheduleStep.Previous = null;
            scheduleStep.Next     = null;

            return(scheduleStep);
        }
Exemple #3
0
        /// <summary>
        /// Determines whether the specified System.Object is equal
        /// to the current System.Object.
        /// </summary>
        /// <param name="obj">Object</param>
        /// <returns>Boolean</returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ScheduleStep step = obj as ScheduleStep;

            if (step == null)
            {
                return(false);
            }

            return(Index == step.Index);
        }
Exemple #4
0
        /// <summary>
        /// Creates a schedule step.
        /// </summary>
        /// <param name="index">Index</param>
        /// <param name="scheduledMachineId">Scheduled machine id</param>
        /// <returns>ScheduleStep</returns>
        internal static ScheduleStep CreateSchedulingChoice(int index, ulong scheduledMachineId)
        {
            var scheduleStep = new ScheduleStep();

            scheduleStep.Index = index;
            scheduleStep.Type  = ScheduleStepType.SchedulingChoice;

            scheduleStep.ScheduledMachineId = scheduledMachineId;

            scheduleStep.BooleanChoice = null;
            scheduleStep.IntegerChoice = null;

            scheduleStep.Previous = null;
            scheduleStep.Next     = null;

            return(scheduleStep);
        }
Exemple #5
0
        /// <summary>
        /// Captures a snapshot of the program state.
        /// </summary>
        /// <param name="scheduleStep">ScheduleStep</param>
        internal void CaptureState(ScheduleStep scheduleStep)
        {
            var fingerprint = this.Runtime.GetProgramState();
            var enabledMachines = this.Runtime.BugFinder.GetEnabledMachines();
            var state = new State(fingerprint, enabledMachines, this.Runtime.LivenessChecker.GetMonitorStatus());

            if (scheduleStep.Type == ScheduleStepType.SchedulingChoice)
            {
                IO.Debug("<LivenessDebug> Captured program state '{0}' at " +
                    "scheduling choice.", fingerprint.GetHashCode());
            }
            else if (scheduleStep.Type == ScheduleStepType.NondeterministicChoice &&
                scheduleStep.BooleanChoice != null)
            {
                IO.Debug("<LivenessDebug> Captured program state '{0}' at nondeterministic " +
                    "choice '{1}'.", fingerprint.GetHashCode(), scheduleStep.BooleanChoice.Value);
            }
            else if (scheduleStep.Type == ScheduleStepType.FairNondeterministicChoice &&
                scheduleStep.BooleanChoice != null)
            {
                IO.Debug("<LivenessDebug> Captured program state '{0}' at fair nondeterministic choice " +
                    "'{1}-{2}'.", fingerprint.GetHashCode(), scheduleStep.NondetId, scheduleStep.BooleanChoice.Value);
            }
            else if (scheduleStep.Type == ScheduleStepType.NondeterministicChoice &&
                scheduleStep.IntegerChoice != null)
            {
                IO.Debug("<LivenessDebug> Captured program state '{0}' at nondeterministic " +
                    "choice '{1}'.", fingerprint.GetHashCode(), scheduleStep.IntegerChoice.Value);
            }

            var stateExists = this.StateMap.Values.Any(val => val.Fingerprint.Equals(fingerprint));

            this.StateMap.Add(scheduleStep, state);

            if (stateExists)
            {
                IO.Debug("<LivenessDebug> Detected potential infinite execution.");
                this.Runtime.LivenessChecker.CheckLivenessAtTraceCycle(state.Fingerprint);
            }
        }
Exemple #6
0
 /// <summary>
 /// Removes the specified schedule step from the cache.
 /// </summary>
 /// <param name="scheduleStep">ScheduleStep</param>
 internal void Remove(ScheduleStep scheduleStep)
 {
     this.StateMap.Remove(scheduleStep);
 }