Class HeapDump.ThreadBuilder

java.lang.Object
org.graalvm.tools.insight.heap.HeapDump.ThreadBuilder
Enclosing class:
HeapDump

public final class HeapDump.ThreadBuilder extends Object
Allows one to describe a state of a thread with local variables and record it in the generated HeapDump.

HeapDump.InstanceBuilder mainBuilder = heap.newInstance(classMain);
final ObjectInstance main = mainBuilder.id();
mainBuilder.put("tom", tom).put("jerry", jerry);

ObjectInstance cathingThread = heap.newThread("Catching Jerry").
    addStackFrame(classActor, "tom", "Actor.java", -1, jerry, tom, main).
    addStackFrame(classMain, "main", "Main.java", -1, main).
    dumpThread();

mainBuilder.put("thread", cathingThread).dumpInstance();
Since:
21.1
See Also:
  • Method Details

    • addStackFrame

      public HeapDump.ThreadBuilder addStackFrame(HeapDump.ClassInstance clazz, String methodName, String sourceFile, int lineNumber, HeapDump.ObjectInstance... locals)
      Adds a StackTraceElement to the thread representation. Contains class/source location information as well as references to local variables.
      Parameters:
      clazz - class for this frame
      methodName - method for this frame
      sourceFile - path/location of a file for this frame
      lineNumber - line number for this frame
      locals - array of references to local objects referenced from the frame
      Returns:
      this builder
      Since:
      21.1
    • dumpThread

      public HeapDump.ObjectInstance dumpThread() throws UncheckedIOException
      Records the prepared thread information into the HeapDump.
      Returns:
      object instance representing the Thread object in the heap
      Throws:
      UncheckedIOException - when an I/O error occurs
      Since:
      21.1