Class 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
    • 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 trace
        entryPoint - 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