Class ThreadTracer
- java.lang.Object
-
- edu.berkeley.cs.jqf.instrument.tracing.ThreadTracer
-
public class ThreadTracer extends Object
This class is responsible for tracing for an instruction stream generated by a single thread in the application.A ThreadTracer instance processes low-level bytecode instructions instrumented by JQF/Janala and converts them into appropriate
TraceEvent
instances, which are then emitted to be processed by the guidance-provided callback.- Author:
- Rohan Padhye
-
-
Field Summary
Fields Modifier and Type Field Description protected Consumer<TraceEvent>
callback
protected RuntimeException
callBackException
protected String
entryPointClass
protected String
entryPointMethod
protected Thread
tracee
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThreadTracer(Thread tracee, String entryPoint, Consumer<TraceEvent> callback)
Creates a new tracer that will process instructions executed by an application thread.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
consume(Instruction ins)
Handles tracing of a single bytecode instruction.protected void
emit(TraceEvent e)
Emits a trace event to be consumed by the registered callback.protected static ThreadTracer
spawn(Thread thread)
Spawns a thread tracer for the given thread.
-
-
-
Field Detail
-
tracee
protected final Thread tracee
-
entryPointClass
protected final String entryPointClass
-
entryPointMethod
protected final String entryPointMethod
-
callback
protected final Consumer<TraceEvent> callback
-
callBackException
protected RuntimeException callBackException
-
-
Constructor Detail
-
ThreadTracer
protected ThreadTracer(Thread tracee, String entryPoint, Consumer<TraceEvent> callback)
Creates a new tracer that will process instructions executed by an application thread.- Parameters:
tracee
- the thread to traceentryPoint
- the outermost method call to trace (formatted as fq-class#method)callback
- the callback to invoke whenever a trace event is emitted
-
-
Method Detail
-
spawn
protected static ThreadTracer spawn(Thread thread)
Spawns a thread tracer for the given thread.- Parameters:
thread
- the thread to trace- Returns:
- a tracer for the given thread
-
emit
protected final void emit(TraceEvent e)
Emits a trace event to be consumed by the registered callback.- Parameters:
e
- the event to emit
-
consume
protected final void consume(Instruction ins)
Handles tracing of a single bytecode instruction.- Parameters:
ins
- the instruction to process
-
-