Class TraceSchedule
- All Implemented Interfaces:
Comparable<TraceSchedule>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies forms of a stepping schedule.static enumstatic enumFormat for rendering and parsing snaps and step counts -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTraceSchedule(long snap, Sequence steps, Sequence pSteps) Construct the given schedule, but assumed abnormalTraceSchedule(long snap, Sequence steps, Sequence pSteps, TraceSchedule.Source source) Construct the given schedule -
Method Summary
Modifier and TypeMethodDescriptionadvanced(TraceSchedule next) Compute the schedule resulting from this schedule advanced by the given schedulecompareSchedule(TraceSchedule that) Richly compare two schedulesintbooleanprotected TraceScheduledoSteppedBackward(Trace trace, long tickCount, Set<Long> visited) Drop the p-code stepsbooleanvoidexecute(Trace trace, PcodeMachine<?> machine, TaskMonitor monitor) Realize the machine state for this schedule using the given trace and machinevoidfinish(Trace trace, TraceSchedule position, PcodeMachine<?> machine, TaskMonitor monitor) Realize the machine state for this schedule using the given trace and pre-positioned machinegetEventThread(Trace trace) Get the event thread for this schedule in the context of the given tracegetLastThread(Trace trace) Get the last thread stepped by this schedule in the context of the given tracelongGet the last thread key stepped by this schedulelonggetSnap()Get the source snapshotgetThreads(Trace trace) Get the threads involved in the scheduleinthashCode()booleanhasSteps()Check if this schedule has instruction stepsbooleanCheck if this schedule requires any steppingstatic TraceScheduleAs inparse(String, TimeRadix), but with theTraceSchedule.TimeRadix.DEFAULTradix.static TraceScheduleparse(String spec, TraceSchedule.Source source, TraceSchedule.TimeRadix radix) Parse schedule in the form "snap[:steps[.pSteps]]"static TraceScheduleparse(String spec, TraceSchedule.TimeRadix radix) As inparse(String, Source, TimeRadix), but assumed abnormallongCompute the number of patches, excluding p-code patchespatched(TraceThread thread, Language language, String sleigh) Returns the equivalent of executing this schedule then performing a given patchpatched(TraceThread thread, Language language, List<String> sleigh) Returns the equivalent of executing this schedule then performing the given patcheslongCompute the number of p-code patches appliedlongCompute the number of p-code ticks takenrequireLastThread(Trace trace) Get the last thread stepped by this schedule in the context of the given traceskippedForward(TraceThread thread, long tickCount) Behaves as insteppedForward(TraceThread, long), but by appending skipsskippedPcodeForward(TraceThread thread, int pTickCount) Behaves as insteppedPcodeForward(TraceThread, int), but by appending skipsstatic final TraceSchedulesnap(long snap) Create a schedule that consists solely of a snapshotsteppedBackward(Trace trace, long stepCount) Returns the equivalent of executing count instructions (and all p-code operations) less than this schedulesteppedForward(TraceThread thread, long tickCount) Returns the equivalent of executing the schedule (ignoring p-code steps) followed by stepping the given thread count more instructionssteppedPcodeBackward(int pStepCount) Returns the equivalent of executing count p-code operations less than this schedulesteppedPcodeForward(TraceThread thread, int pTickCount) Returns the equivalent of executing the schedule followed by stepping the given threadpTickCountmore p-code operationslongCompute the number of ticks taken, excluding p-code tickstoString()toString(TraceSchedule.TimeRadix radix) longCompute the total number of patches appliedlongCompute the total number of ticks taken, including the p-code ticksvoidValidate this schedule for the given trace
-
Field Details
-
ZERO
The initial snapshot (with no steps)
-
-
Constructor Details
-
TraceSchedule
Construct the given schedule- Parameters:
snap- the initial trace snapshotsteps- the step sequencepSteps- the p-code step sequencesource- if the p-code steps are known not to exceed one instruction
-
TraceSchedule
Construct the given schedule, but assumed abnormal- Parameters:
snap- the initial trace snapshotsteps- the step sequencepSteps- the p-code step sequence
-
-
Method Details
-
snap
Create a schedule that consists solely of a snapshot- Parameters:
snap- the snapshot key- Returns:
- the schedule
-
parse
public static TraceSchedule parse(String spec, TraceSchedule.Source source, TraceSchedule.TimeRadix radix) Parse schedule in the form "snap[:steps[.pSteps]]"A schedule consists of a snap, a optional
Sequenceof thread instruction-level steps, and optional p-code-level steps (pSteps). The form ofstepsandpStepsis specified bySequence.parse(String, TimeRadix). Each sequence consists of stepping selected threads forward, and/or patching machine state.- Parameters:
spec- the string specificationsource- the presumed source of the scheduleradix- the radix- Returns:
- the parsed schedule
-
parse
As inparse(String, Source, TimeRadix), but assumed abnormal- Parameters:
spec- the string specificationradix- the radix- Returns:
- the parsed schedule
-
parse
As inparse(String, TimeRadix), but with theTraceSchedule.TimeRadix.DEFAULTradix.- Parameters:
spec- the string specification- Returns:
- the parse sequence
-
toString
-
toString
-
compareSchedule
Richly compare two schedulesSchedules starting at different snapshots are never related, because there is no emulator/simulator stepping action which advances to the next snapshot. Though p-code steps may comprise a partial step, we do not consider a partial step to be a prefix of a full step, since we cannot know a priori how many p-code steps comprise a full instruction step. Consider, e.g., the user may specify 100 p-code steps, which could effect 20 instruction steps.
- Parameters:
that- the object of comparison (this being the subject)- Returns:
- a result describing the relationship from subject to object
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<TraceSchedule>
-
isSnapOnly
public boolean isSnapOnly()Check if this schedule requires any stepping- Returns:
- true if no stepping is required, i.e., the resulting state can be realized simply by loading a snapshot
-
hasSteps
public boolean hasSteps()Check if this schedule has instruction steps- Returns:
- true if this indicates at least one instruction step
-
getSnap
public long getSnap()Get the source snapshot- Returns:
- the snapshot key
-
getLastThreadKey
public long getLastThreadKey()Get the last thread key stepped by this schedule- Returns:
- the thread key
-
getEventThread
Get the event thread for this schedule in the context of the given traceThis is the thread stepped when no thread is specified for the first step of the sequence.
- Parameters:
trace- the trace containing the source snapshot and threads- Returns:
- the thread to use as "last thread" for the sequence
-
getLastThread
Get the last thread stepped by this schedule in the context of the given trace- Parameters:
trace- the trace containing the source snapshot and threads- Returns:
- the thread last stepped, or the "event thread" when no steps are taken, or null
-
requireLastThread
Get the last thread stepped by this schedule in the context of the given trace- Parameters:
trace- the trace containing the source snapshot and threads- Returns:
- the thread last stepped, or the "event thread" when no steps are taken
- Throws:
IllegalArgumentException- if the last thread cannot be determined from this schedule and the given trace.
-
totalTickCount
public long totalTickCount()Compute the total number of ticks taken, including the p-code ticksThis is suitable for use with
TaskMonitor.initialize(long), where that monitor will be passed toexecute(Trace, PcodeMachine, TaskMonitor)or similar. Note that patch steps do not count as ticks.- Returns:
- the number of ticks
-
totalPatchCount
public long totalPatchCount()Compute the total number of patches applied- Returns:
- the number of patches
-
tickCount
public long tickCount()Compute the number of ticks taken, excluding p-code ticks- Returns:
- the number of ticks
-
patchCount
public long patchCount()Compute the number of patches, excluding p-code patches- Returns:
- the number of patches
-
pTickCount
public long pTickCount()Compute the number of p-code ticks taken- Returns:
- the number of ticks
-
pPatchCount
public long pPatchCount()Compute the number of p-code patches applied- Returns:
- the number of patches
-
execute
public void execute(Trace trace, PcodeMachine<?> machine, TaskMonitor monitor) throws CancelledException Realize the machine state for this schedule using the given trace and machineThis method executes this schedule and trailing p-code steps on the given machine, assuming that machine is already "positioned" at the initial snapshot. Assuming successful execution, that machine is now said to be "positioned" at this schedule, and its state is the result of said execution.
- Parameters:
trace- the trace containing the source snapshot and threadsmachine- a machine bound to the trace whose current state reflects the initial snapshotmonitor- a monitor for cancellation and progress reporting- Throws:
CancelledException- if the execution is cancelled
-
validate
Validate this schedule for the given traceThis performs a dry run of the sequence on the given trace. If the schedule starts on the "last thread," it verifies the snapshot gives the event thread. It also checks that every thread key in the sequence exists in the trace.
- Parameters:
trace- the trace against which to validate this schedule
-
finish
public void finish(Trace trace, TraceSchedule position, PcodeMachine<?> machine, TaskMonitor monitor) throws CancelledException Realize the machine state for this schedule using the given trace and pre-positioned machineThis method executes the remaining steps of this schedule and trailing p-code steps on the given machine, assuming that machine is already "positioned" at another given schedule. Assuming successful execution, that machine is now said to be "positioned" at this schedule, and its state is the result of said execution.
- Parameters:
trace- the trace containing the source snapshot and threadsposition- the current schedule of the given machinemachine- a machine bound to the trace whose current state reflects the given positionmonitor- a monitor for cancellation and progress reporting- Throws:
CancelledException- if the execution is cancelledIllegalArgumentException- if the given position is not a prefix of this schedule
-
steppedForward
Returns the equivalent of executing the schedule (ignoring p-code steps) followed by stepping the given thread count more instructionsThis schedule is left unmodified. If it had any p-code steps, those steps are dropped in the resulting schedule.
- Parameters:
thread- the thread to step, or null for the "last thread"tickCount- the number of ticks to take the thread forward- Returns:
- the resulting schedule
-
skippedForward
Behaves as insteppedForward(TraceThread, long), but by appending skips- Parameters:
thread- the thread to step, or null for the "last thread"tickCount- the number of skips to take the thread forward- Returns:
- the resulting schedule
-
doSteppedBackward
-
steppedBackward
Returns the equivalent of executing count instructions (and all p-code operations) less than this scheduleThis schedule is left unmodified. If it had any p-code steps, those steps and subsequent patches are dropped in the resulting schedule. If count exceeds this schedule's steps, it will try (recursively) to step the source snapshot's schedule backward, if known. Both ticks and patches counts as steps.
- Parameters:
trace- the trace of this schedule, for contextstepCount- the number of steps to take backward- Returns:
- the resulting schedule or null if it cannot be computed
-
steppedPcodeForward
Returns the equivalent of executing the schedule followed by stepping the given threadpTickCountmore p-code operations- Parameters:
thread- the thread to step, or null for the "last thread"pTickCount- the number of p-code ticks to take the thread forward- Returns:
- the resulting schedule
-
skippedPcodeForward
Behaves as insteppedPcodeForward(TraceThread, int), but by appending skips- Parameters:
thread- the thread to step, or null for the "last thread"pTickCount- the number of p-code skips to take the thread forward- Returns:
- the resulting schedule
-
steppedPcodeBackward
Returns the equivalent of executing count p-code operations less than this scheduleIf
pStepCountexceeds the p-code steps of this schedule, null is returned, since we cannot know a priori how many p-code steps would be required to complete the preceding instruction step. Both p-code ticks and p-code patches counts as p-code steps.- Parameters:
pStepCount- the number of p-code steps to take backward- Returns:
- the resulting schedule or null if it cannot be computed
-
patched
Returns the equivalent of executing this schedule then performing a given patch- Parameters:
thread- the thread context for the patch; cannot be nulllanguage- the sleigh language for the patchsleigh- a single line of sleigh, excluding the terminating semicolon.- Returns:
- the resulting schedule
-
patched
Returns the equivalent of executing this schedule then performing the given patches- Parameters:
thread- the thread context for the patch; cannot be nulllanguage- the sleigh language for the patchsleigh- the lines of sleigh, excluding the terminating semicolons- Returns:
- the resulting schedule
-
advanced
Compute the schedule resulting from this schedule advanced by the given scheduleThis operation cannot be used to append instruction steps after p-code steps. Thus, if this schedule contains any p-code steps and
nexthas instruction steps, an error will be- Parameters:
next- the schedule to append. Its snap is ignored.- Returns:
- the complete schedule
- Throws:
IllegalArgumentException- if the result would have instruction steps following p-code steps
-
dropPSteps
Drop the p-code steps- Returns:
- the schedule without ops
-
getThreads
Get the threads involved in the schedule- Parameters:
trace- the trace whose threads to get- Returns:
- the set of threads
-
assumeRecorded
-
differsOnlyByPatch
-