Package cs1302.tracer.trace
Class PersistentGuestSession
java.lang.Object
cs1302.tracer.trace.PersistentGuestSession
- All Implemented Interfaces:
AutoCloseable
Manages a persistent guest JVM worker process and its JDI debugger session.
A single persistent session executes multiple tracing jobs sequentially
by resetting state on the resident GuestHarness between runs,
eliminating repeated JVM startup and JDWP handshake overhead.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional consumer for captured execution snapshots. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intReturns the total number of jobs completed by this session instance.static PersistentGuestSessioncreate()Launches a persistent guest JVM and attaches the JDI debugger session.booleanisAlive()Returns whether the persistent guest JVM is alive and ready to process jobs.process()Returns the underlying target Process.traceChronologicalWithSpecs(CompilationHelper.CompilationResult cr, Collection<BreakpointSpec> specs, List<com.github.javaparser.ast.CompilationUnit> parsedSources, boolean includeMainExit, String stdin) Executes a trace job collecting chronological snapshots with optional main exit snapshot.traceChronologicalWithSpecs(CompilationHelper.CompilationResult cr, Collection<BreakpointSpec> specs, List<com.github.javaparser.ast.CompilationUnit> parsedSources, String stdin) Executes a trace job collecting chronological snapshots at specified breakpoints.traceWithSpecs(CompilationHelper.CompilationResult cr, Collection<BreakpointSpec> specs, List<com.github.javaparser.ast.CompilationUnit> parsedSources, String stdin, boolean accumulate) Executes a trace job and returns snapshots mapped by line number.
-
Method Details
-
create
Launches a persistent guest JVM and attaches the JDI debugger session.- Returns:
- Initialized PersistentGuestSession paused at the initial ready hook.
- Throws:
Exception- If launching or handshake fails.
-
process
Returns the underlying target Process.- Returns:
- Target process.
-
isAlive
public boolean isAlive()Returns whether the persistent guest JVM is alive and ready to process jobs.- Returns:
- True if session is alive.
-
completedJobCount
public int completedJobCount()Returns the total number of jobs completed by this session instance.- Returns:
- Completed job count.
-
traceWithSpecs
public Map<Integer,List<ExecutionSnapshot>> traceWithSpecs(CompilationHelper.CompilationResult cr, Collection<BreakpointSpec> specs, List<com.github.javaparser.ast.CompilationUnit> parsedSources, String stdin, boolean accumulate) throws Exception Executes a trace job and returns snapshots mapped by line number.- Parameters:
cr- Compilation result containing class files and metadata.specs- Breakpoint specifications.parsedSources- Parsed AST compilation units.stdin- Standard input string supplied to guest program.accumulate- Whether to retain all snapshots per line.- Returns:
- Map of line number to execution snapshots.
- Throws:
Exception- On tracing or execution failure.
-
traceChronologicalWithSpecs
public List<ExecutionSnapshot> traceChronologicalWithSpecs(CompilationHelper.CompilationResult cr, Collection<BreakpointSpec> specs, List<com.github.javaparser.ast.CompilationUnit> parsedSources, String stdin) throws Exception Executes a trace job collecting chronological snapshots at specified breakpoints.- Parameters:
cr- CompilationResult containing compiled bytecode and class information.specs- Collection of BreakpointSpecs requested for tracing.parsedSources- Parsed AST compilation units.stdin- Standard input string supplied to guest program.- Returns:
- List of execution snapshots in chronological order.
- Throws:
Exception- On tracing or execution failure.
-
traceChronologicalWithSpecs
public List<ExecutionSnapshot> traceChronologicalWithSpecs(CompilationHelper.CompilationResult cr, Collection<BreakpointSpec> specs, List<com.github.javaparser.ast.CompilationUnit> parsedSources, boolean includeMainExit, String stdin) throws Exception Executes a trace job collecting chronological snapshots with optional main exit snapshot.- Parameters:
cr- CompilationResult containing compiled bytecode and class information.specs- Collection of BreakpointSpecs requested for tracing.parsedSources- Parsed AST compilation units.includeMainExit- If true, includes the snapshot when main exits.stdin- Standard input string supplied to guest program.- Returns:
- List of execution snapshots in chronological order.
- Throws:
Exception- On tracing or execution failure.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-