Package cs1302.tracer.trace
Record Class ExecutionSnapshot
java.lang.Object
java.lang.Record
cs1302.tracer.trace.ExecutionSnapshot
- Record Components:
stack- The program's stack. Index 0 is the bottommost frame, the last index is the topmost.statics- Loaded static variables.heap- The program's heap, a mapping of reference IDs to values.stdoutSlice- Captured standard output slice.stderrSlice- Captured standard error slice.sourcePath- Optional relative source file path for the currently executing line.stdinConsumed- Cumulative standard input consumed up to this snapshot point.stdinOffset- Character index reached in standard input up to this snapshot point.threads- Application thread states, or null for legacy capture.triggeringThreadId- Thread producing the event, or null for legacy capture.event- Captured event kind, or null for legacy capture.
public record ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long,TraceValue> heap, OutputSlice stdoutSlice, OutputSlice stderrSlice, Optional<String> sourcePath, String stdinConsumed, int stdinOffset, List<ExecutionSnapshot.ThreadSnapshot> threads, Long triggeringThreadId, String event)
extends Record
A snapshot of a program's memory state.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA key-value pair of identifier to the value it refers to.static final recordA snapshot of the state of a method's stack.static final recordA thread at one suspended observation point. -
Constructor Summary
ConstructorsConstructorDescriptionExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, byte[] stdout, byte[] stderr) Constructs a snapshot without an explicit source file path.ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, byte[] stdout, byte[] stderr, Optional<String> sourcePath) Constructs a snapshot with an explicit source file path defaulting stdin tracking.ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, byte[] stdout, byte[] stderr, Optional<String> sourcePath, String stdinConsumed, int stdinOffset) Constructs a snapshot with raw byte arrays for standard output and error.ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, OutputSlice stdoutSlice, OutputSlice stderrSlice, Optional<String> sourcePath, String stdinConsumed, int stdinOffset) Constructs a legacy snapshot without thread metadata.ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, OutputSlice stdoutSlice, OutputSlice stderrSlice, Optional<String> sourcePath, String stdinConsumed, int stdinOffset, List<ExecutionSnapshot.ThreadSnapshot> threads, Long triggeringThreadId, String event) Compact constructor normalizing null slices, optionals, and strings. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.event()Returns the value of theeventrecord component.final inthashCode()Returns a hash code value for this object.heap()Returns the value of theheaprecord component.Materializes the output slices of this snapshot into self-contained buffers.Returns the value of thesourcePathrecord component.stack()Returns the value of thestackrecord component.statics()Returns the value of thestaticsrecord component.byte[]stderr()Returns captured standard error bytes.intReturns the length in bytes of standard error without allocating.Returns the value of thestderrSlicerecord component.Returns the value of thestdinConsumedrecord component.intReturns the value of thestdinOffsetrecord component.byte[]stdout()Returns captured standard output bytes.intReturns the length in bytes of standard output without allocating.Returns the value of thestdoutSlicerecord component.threads()Returns the value of thethreadsrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetriggeringThreadIdrecord component.withOutput(OutputSlice stdout, OutputSlice stderr) Copies this snapshot with updated output, preserving all execution metadata.
-
Constructor Details
-
ExecutionSnapshot
public ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, OutputSlice stdoutSlice, OutputSlice stderrSlice, Optional<String> sourcePath, String stdinConsumed, int stdinOffset) Constructs a legacy snapshot without thread metadata.- Parameters:
stack- Stack frames.statics- Static fields.heap- Shared objects.stdoutSlice- Standard output.stderrSlice- Standard error.sourcePath- Source location.stdinConsumed- Consumed input.stdinOffset- Input offset.
-
ExecutionSnapshot
public ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, OutputSlice stdoutSlice, OutputSlice stderrSlice, Optional<String> sourcePath, String stdinConsumed, int stdinOffset, List<ExecutionSnapshot.ThreadSnapshot> threads, Long triggeringThreadId, String event) Compact constructor normalizing null slices, optionals, and strings. -
ExecutionSnapshot
public ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, byte[] stdout, byte[] stderr, Optional<String> sourcePath, String stdinConsumed, int stdinOffset) Constructs a snapshot with raw byte arrays for standard output and error.- Parameters:
stack- The program's stack.statics- Loaded static variables.heap- The program's heap.stdout- Bytes that have been output by the program to stdout.stderr- Bytes that have been output by the program to stderr.sourcePath- Optional relative source file path.stdinConsumed- Cumulative standard input consumed up to this snapshot point.stdinOffset- Character index reached in standard input up to this snapshot point.
-
ExecutionSnapshot
public ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, byte[] stdout, byte[] stderr, Optional<String> sourcePath) Constructs a snapshot with an explicit source file path defaulting stdin tracking.- Parameters:
stack- The program's stack.statics- Loaded static variables.heap- The program's heap.stdout- Captured standard output bytes.stderr- Captured standard error bytes.sourcePath- Optional relative source file path.
-
ExecutionSnapshot
public ExecutionSnapshot(List<ExecutionSnapshot.StackSnapshot> stack, List<ExecutionSnapshot.Field> statics, Map<Long, TraceValue> heap, byte[] stdout, byte[] stderr) Constructs a snapshot without an explicit source file path.- Parameters:
stack- The program's stack.statics- Loaded static variables.heap- The program's heap.stdout- Captured standard output bytes.stderr- Captured standard error bytes.
-
-
Method Details
-
materializeOutput
Materializes the output slices of this snapshot into self-contained buffers.- Returns:
- Snapshot with materialized output slices.
-
withOutput
Copies this snapshot with updated output, preserving all execution metadata.- Parameters:
stdout- Updated standard output.stderr- Updated standard error.- Returns:
- Snapshot with the supplied output slices.
-
stdout
public byte[] stdout()Returns captured standard output bytes.- Returns:
- Byte array of standard output.
-
stderr
public byte[] stderr()Returns captured standard error bytes.- Returns:
- Byte array of standard error.
-
stdoutLength
public int stdoutLength()Returns the length in bytes of standard output without allocating.- Returns:
- Standard output length in bytes.
-
stderrLength
public int stderrLength()Returns the length in bytes of standard error without allocating.- Returns:
- Standard error length in bytes.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
stack
Returns the value of thestackrecord component.- Returns:
- the value of the
stackrecord component
-
statics
Returns the value of thestaticsrecord component.- Returns:
- the value of the
staticsrecord component
-
heap
Returns the value of theheaprecord component.- Returns:
- the value of the
heaprecord component
-
stdoutSlice
Returns the value of thestdoutSlicerecord component.- Returns:
- the value of the
stdoutSlicerecord component
-
stderrSlice
Returns the value of thestderrSlicerecord component.- Returns:
- the value of the
stderrSlicerecord component
-
sourcePath
Returns the value of thesourcePathrecord component.- Returns:
- the value of the
sourcePathrecord component
-
stdinConsumed
Returns the value of thestdinConsumedrecord component.- Returns:
- the value of the
stdinConsumedrecord component
-
stdinOffset
public int stdinOffset()Returns the value of thestdinOffsetrecord component.- Returns:
- the value of the
stdinOffsetrecord component
-
threads
Returns the value of thethreadsrecord component.- Returns:
- the value of the
threadsrecord component
-
triggeringThreadId
Returns the value of thetriggeringThreadIdrecord component.- Returns:
- the value of the
triggeringThreadIdrecord component
-
event
Returns the value of theeventrecord component.- Returns:
- the value of the
eventrecord component
-