Package ghidra.pcode.emu.jit.gen

# Record Class ExceptionHandler

java.lang.Object
java.lang.Record
ghidra.pcode.emu.jit.gen.ExceptionHandler

Record Components:
  `op` - the op which may cause an exception
  `block` - the block containing the op
  `label` - the label at the start of the handler

public record ExceptionHandler(PcodeOp op, JitControlFlowModel.JitBlock block, org.objectweb.asm.Label label) extends Record
A requested exception handler

When an exception occurs, we must retire all of the variables before we pop the `run` method's frame. We also write out the program counter and disassembly context so that the emulator can resume appropriately. After that, we re-throw the exception.

When the code generator knows the code it's emitting can cause a user exception, e.g., the Direct invocation of a userop, and there are live variables in scope, then it should request a handler (via `JitCodeGenerator.requestExceptionHandler(DecodedPcodeOp, JitBlock)`) and surround the code in a `try-catch` on `Throwable` directing it to this handler.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ExceptionHandler(PcodeOp op, JitControlFlowModel.JitBlock block)`
  Construct a handler, generating a new label
  `ExceptionHandler(PcodeOp op, JitControlFlowModel.JitBlock block, org.objectweb.asm.Label label)`
  Creates an instance of a `ExceptionHandler` record class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `JitControlFlowModel.JitBlock`
  `block()`
  Returns the value of the `block` record component.
  `final boolean`
  `equals(Object o)`
  Indicates whether some other object is "equal to" this one.
  `void`
  `generateRunCode(JitCodeGenerator gen, org.objectweb.asm.MethodVisitor rv)`
  Emit the handler's code into the `run` method.
  `final int`
  `hashCode()`
  Returns a hash code value for this object.
  `org.objectweb.asm.Label`
  `label()`
  Returns the value of the `label` record component.
  `PcodeOp`
  `op()`
  Returns the value of the `op` record component.
  `final String`
  `toString()`
  Returns a string representation of this record class.

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ExceptionHandler

    public ExceptionHandler(PcodeOp op, JitControlFlowModel.JitBlock block)
    Construct a handler, generating a new label
    Parameters:
      `op` - the op which may cause an exception
      `block` - the block containing the op

  - ### ExceptionHandler

    public ExceptionHandler(PcodeOp op, JitControlFlowModel.JitBlock block, org.objectweb.asm.Label label)
    Creates an instance of a `ExceptionHandler` record class.
    Parameters:
      `op` - the value for the `op` record component
      `block` - the value for the `block` record component
      `label` - the value for the `label` record component

- ## Method Details

  - ### generateRunCode

    public void generateRunCode(JitCodeGenerator gen, org.objectweb.asm.MethodVisitor rv)
    Emit the handler's code into the `run` method.
    Parameters:
      `gen` - the code generator
      `rv` - the visitor for the `run` method

  - ### toString

    public final String 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.
    Specified by:
      `toString` in class `Record`
    Returns:
      a string representation of this object

  - ### 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.
    Specified by:
      `hashCode` in class `Record`
    Returns:
      a hash code value for this object

  - ### equals

    public final boolean equals(Object o)
    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. All components in this record class are compared with `Objects::equals(Object,Object)`.
    Specified by:
      `equals` in class `Record`
    Parameters:
      `o` - the object with which to compare
    Returns:
      `true` if this object is the same as the `o` argument; `false` otherwise.

  - ### op

    public PcodeOp op()
    Returns the value of the `op` record component.
    Returns:
      the value of the `op` record component

  - ### block

    public JitControlFlowModel.JitBlock block()
    Returns the value of the `block` record component.
    Returns:
      the value of the `block` record component

  - ### label

    public org.objectweb.asm.Label label()
    Returns the value of the `label` record component.
    Returns:
      the value of the `label` record component