Class JitPassage.DecodeErrorInstruction

java.lang.Object
ghidra.app.util.PseudoInstruction
ghidra.pcode.emu.jit.JitPassage.DecodeErrorInstruction
All Implemented Interfaces:
InstructionContext, ProcessorContext, ProcessorContextView, CodeUnit, Instruction, MemBuffer, PropertySet
Enclosing class:
JitPassage

public static class JitPassage.DecodeErrorInstruction extends PseudoInstruction
An instruction denoting a decode error

The Sleigh disassembler normally denotes this with a PseudoInstruction having an InvalidPrototype. We essentially do the same here, but with custom types that are simpler to identify. Additionally, the types contain additional information, e.g., the error message. We also need the prototype to produce a single JitPassage.DecodeErrorPcodeOp.

  • Field Details Link icon

    • address Link icon

      protected Address address
    • maxAddress Link icon

      protected Address maxAddress
    • program Link icon

      protected Program program
    • length Link icon

      protected int length
    • emptyAddrArray Link icon

      protected static final Address[] emptyAddrArray
    • hash Link icon

      protected int hash
    • bytes Link icon

      protected byte[] bytes
    • isBigEndian Link icon

      protected boolean isBigEndian
    • emptyMemRefs Link icon

      protected static final Reference[] emptyMemRefs
    • comments Link icon

      protected Map<Integer,String> comments
    • refMgr Link icon

      protected ReferenceManager refMgr
  • Constructor Details Link icon

  • Method Details Link icon

    • getMessage Link icon

      public String getMessage()
      Get the message for the exception, should this instruction be "executed"
      Returns:
      the error message
    • invalidate Link icon

      public void invalidate()
      Invalidate memory buffer
    • isValid Link icon

      public boolean isValid()
    • getAddressString Link icon

      public String getAddressString(boolean showBlockName, boolean pad)
      Description copied from interface: CodeUnit
      Get the string representation of the starting address for this code unit.
      Specified by:
      getAddressString in interface CodeUnit
      Parameters:
      showBlockName - true if the string should include the memory block name
      pad - if true, the address will be padded with leading zeros. Even if pad is false, the string will be padded to make the address string contain at least 4 digits.
      Returns:
      string representation of address
    • getLength Link icon

      public final int getLength()
      Get the length of the code unit.
      Specified by:
      getLength in interface CodeUnit
      Returns:
      code unit length
    • refreshIfNeeded Link icon

      protected void refreshIfNeeded()
    • getBytes Link icon

      public byte[] getBytes() throws MemoryAccessException
      Gets the bytes for this code unit.
      Specified by:
      getBytes in interface CodeUnit
      Returns:
      an array of bytes that are in memory at the codeunits address. The array length is the same as the codeUnits length
      Throws:
      MemoryAccessException - if the full number of bytes could not be read.
    • getBytes Link icon

      public int getBytes(byte[] b, int offset)
      Description copied from interface: MemBuffer
      Reads b.length bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position. The actual number of bytes may be fewer if bytes can't be read.
      Specified by:
      getBytes in interface MemBuffer
      Parameters:
      b - the buffer into which bytes will be placed
      offset - the offset in this memory buffer from which to start reading bytes.
      Returns:
      the number of bytes read which may be fewer than b.length if available bytes are exhausted or no bytes are available at the specified offset.
    • getBytesInCodeUnit Link icon

      public void getBytesInCodeUnit(byte[] buffer, int bufferOffset) throws MemoryAccessException
      Description copied from interface: CodeUnit
      Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.
      Specified by:
      getBytesInCodeUnit in interface CodeUnit
      Parameters:
      buffer - byte array to copy into
      bufferOffset - offset in byte array the copy will start
      Throws:
      MemoryAccessException - if the full number of bytes could not be read.
    • isBigEndian Link icon

      public boolean isBigEndian()
      Description copied from interface: MemBuffer
      Returns true if the underlying bytes are in big-endian order, false if they are little endian.
      Specified by:
      isBigEndian in interface MemBuffer
      Returns:
      true if the underlying bytes are in big-endian order, false if they are little endian.
    • getShort Link icon

      public short getShort(int offset) throws MemoryAccessException
      Description copied from interface: MemBuffer
      returns the short at the given offset, taking into account the endianness.
      Specified by:
      getShort in interface MemBuffer
      Parameters:
      offset - the offset from the membuffers origin (the address that it is set at)
      Returns:
      the short at the given offset, taking into account the endianness.
      Throws:
      MemoryAccessException - if a 2-byte short value cannot be read at the specified offset
    • getInt Link icon

      public int getInt(int offset) throws MemoryAccessException
      Description copied from interface: MemBuffer
      returns the int at the given offset, taking into account the endianness.
      Specified by:
      getInt in interface MemBuffer
      Parameters:
      offset - the offset from the membuffers origin (the address that it is set at)
      Returns:
      the int at the given offset, taking into account the endianness.
      Throws:
      MemoryAccessException - if a 4-byte integer value cannot be read at the specified offset
    • getLong Link icon

      public long getLong(int offset) throws MemoryAccessException
      Description copied from interface: MemBuffer
      returns the long at the given offset, taking into account the endianness.
      Specified by:
      getLong in interface MemBuffer
      Parameters:
      offset - the offset from the membuffers origin (the address that it is set at)
      Returns:
      the long at the given offset, taking into account the endianness.
      Throws:
      MemoryAccessException - if a 8-byte long value cannot be read at the specified offset
    • getBigInteger Link icon

      public BigInteger getBigInteger(int offset, int size, boolean signed) throws MemoryAccessException
      Description copied from interface: MemBuffer
      returns the value at the given offset, taking into account the endianness.
      Specified by:
      getBigInteger in interface MemBuffer
      Parameters:
      offset - the offset from the membuffers origin (the address that it is set at)
      size - the number of bytes to include in the value
      signed - true if value should be treated as a signed twos-compliment value.
      Returns:
      the value at the given offset, taking into account the endianness.
      Throws:
      MemoryAccessException - if the request size value cannot be read at the specified offset
    • setProperty Link icon

      public void setProperty(String name, Saveable value)
      Set the property name with the given value for this code unit.
      Specified by:
      setProperty in interface PropertySet
      Parameters:
      name - the name of the property to save.
      value - the value of the property to save.
      Throws:
      TypeMismatchException - if the property manager for name does not support object types
      ConcurrentModificationException - if this object is no longer valid.
    • setProperty Link icon

      public void setProperty(String name, String value)
      Set the property name with the given value for this code unit.
      Specified by:
      setProperty in interface PropertySet
      Parameters:
      name - the name of the property to save.
      value - the value of the property to save.
      Throws:
      TypeMismatchException - if the property manager for name does not support string types
      ConcurrentModificationException - if this object is no longer valid.
    • setProperty Link icon

      public void setProperty(String name, int value)
      Set the property name with the given value for this code unit.
      Specified by:
      setProperty in interface PropertySet
      Parameters:
      name - the name of the property to save.
      value - the value of the property to save.
      Throws:
      TypeMismatchException - if the property manager for name does not support int types
      ConcurrentModificationException - if this object is no longer valid.
    • setProperty Link icon

      public void setProperty(String name)
      Mark the property name as having a value for this code unit.
      Specified by:
      setProperty in interface PropertySet
      Parameters:
      name - the name of the property to save.
      Throws:
      TypeMismatchException - if the property manager for name does not support void types
      ConcurrentModificationException - if this object is no longer valid.
    • getObjectProperty Link icon

      public Saveable getObjectProperty(String name)
      Get the object property for name; returns null if there is no name property for this code unit.
      Specified by:
      getObjectProperty in interface PropertySet
      Parameters:
      name - the name of the property.
      Returns:
      Saveable property value, with map-specific implementation class, or null.
      Throws:
      TypeMismatchException - if the property manager for name does not support object types
      ConcurrentModificationException - if this object is no longer valid.
    • getStringProperty Link icon

      public String getStringProperty(String name)
      Get the string property for name; returns null if there is no name property for this code unit.
      Specified by:
      getStringProperty in interface PropertySet
      Parameters:
      name - the name of the property.
      Returns:
      string property value or null
      Throws:
      TypeMismatchException - if the property manager for name does not support string types
      ConcurrentModificationException - if this object is no longer valid.
    • getIntProperty Link icon

      public int getIntProperty(String name) throws NoValueException
      Get the int property for name.
      Specified by:
      getIntProperty in interface PropertySet
      Parameters:
      name - the name of the property.
      Returns:
      integer property value property has been set
      Throws:
      NoValueException - if there is not name property for this code unit
      TypeMismatchException - if the property manager for name does not support int types
      ConcurrentModificationException - if this object is no longer valid.
    • hasProperty Link icon

      public boolean hasProperty(String name)
      Description copied from interface: PropertySet
      Returns true if the codeunit has the given property defined. This method works for all property map types.
      Specified by:
      hasProperty in interface PropertySet
      Parameters:
      name - the name of the property
      Returns:
      true if property has been set, else false
    • getVoidProperty Link icon

      public boolean getVoidProperty(String name)
      Returns whether this code unit is marked as having the name property.
      Specified by:
      getVoidProperty in interface PropertySet
      Parameters:
      name - the name of the property.
      Returns:
      true if property has been set, else false
      Throws:
      TypeMismatchException - if the property manager for name does not support void types
      ConcurrentModificationException - if this object is no longer valid.
    • propertyNames Link icon

      public Iterator<String> propertyNames()
      Description copied from interface: PropertySet
      Get an iterator over the property names which have values applied.
      Specified by:
      propertyNames in interface PropertySet
      Returns:
      iterator of all property map names which have values applied
    • removeProperty Link icon

      public void removeProperty(String name)
      Remove the property value with the given name for this code unit.
      Specified by:
      removeProperty in interface PropertySet
      Parameters:
      name - the name of the property.
    • getLabel Link icon

      @Deprecated public String getLabel()
      Deprecated.
      Get the label for this code unit.
      Specified by:
      getLabel in interface CodeUnit
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getSymbols Link icon

      public Symbol[] getSymbols()
      Get the symbols for this code unit.
      Specified by:
      getSymbols in interface CodeUnit
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getPrimarySymbol Link icon

      public Symbol getPrimarySymbol()
      Get the primary Symbol for this code unit.
      Specified by:
      getPrimarySymbol in interface CodeUnit
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getMinAddress Link icon

      public Address getMinAddress()
      Get the starting address for this code unit.
      Specified by:
      getMinAddress in interface CodeUnit
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getMaxAddress Link icon

      public Address getMaxAddress()
      Get the ending address for this code unit.
      Specified by:
      getMaxAddress in interface CodeUnit
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getNextCodeUnit Link icon

      public CodeUnit getNextCodeUnit()
      Get the code unit after this code unit.
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getPreviousCodeUnit Link icon

      public CodeUnit getPreviousCodeUnit()
      Get the code unit before this code unit.
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getComment Link icon

      public String getComment(int commentType)
      Description copied from interface: CodeUnit
      Get the comment for the given type
      Specified by:
      getComment in interface CodeUnit
      Parameters:
      commentType - either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENT
      Returns:
      the comment string of the appropriate type or null if no comment of that type exists for this codeunit
    • getCommentAsArray Link icon

      public String[] getCommentAsArray(int commentType)
      Get the comment as an array where each element is a single line for the given type.
      Specified by:
      getCommentAsArray in interface CodeUnit
      Parameters:
      commentType - must be either EOL_COMMENT_TYPE, PRE_COMMENT_TYPE, POST_COMMENT_TYPE, or PLATE_COMMENT_TYPE
      Returns:
      an array of strings where each item in the array is a line of text in the comment. If there is no comment of the requested type, an empty array is returned.
      Throws:
      IllegalArgumentException - if type is not one of the three types of comments supported
      ConcurrentModificationException - if this object is no longer valid.
    • setCommentAsArray Link icon

      public void setCommentAsArray(int commentType, String[] comment)
      Set the comment for the given type.
      Specified by:
      setCommentAsArray in interface CodeUnit
      Parameters:
      commentType - must be either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or PLATE_COMMENT
      comment - the lines that make up the comment
      Throws:
      IllegalArgumentException - if type is not one of the three types of comments supported
      ConcurrentModificationException - if this object is no longer valid.
    • setComment Link icon

      public void setComment(int commentType, String comment)
      Set the comment for the given type.
      Specified by:
      setComment in interface CodeUnit
      Parameters:
      commentType - must be either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or PLATE_COMMENT
      comment - the comment
      Throws:
      IllegalArgumentException - if type is not one of the three types of comments supported
      ConcurrentModificationException - if this object is no longer valid.
    • contains Link icon

      public boolean contains(Address testAddr)
      Determines if this code unit contains the indicated address.
      Specified by:
      contains in interface CodeUnit
      Parameters:
      testAddr - the address to test
      Returns:
      true if address is contained in the range.
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • compareTo Link icon

      public int compareTo(Address a)
      Compares the given address to the address range of this node.
      Specified by:
      compareTo in interface CodeUnit
      Parameters:
      a - the address
      Returns:
      a negative integer if addr is greater than the maximum range address zero if addr is in the range a positive integer if addr is less than minimum range address
      Throws:
      ConcurrentModificationException - if this object is no longer valid.
    • getByte Link icon

      public byte getByte(int offset) throws MemoryAccessException
      Get one byte from memory at the current position plus offset.
      Specified by:
      getByte in interface MemBuffer
      Parameters:
      offset - the displacement from the current position.
      Returns:
      the data at offset from the current position.
      Throws:
      AddressOutOfBoundsException - if offset exceeds address space
      IndexOutOfBoundsException - if offset is negative
      MemoryAccessException - if memory cannot be read
    • getAddress Link icon

      public Address getAddress()
      Get the Address which corresponds to the offset 0.
      Specified by:
      getAddress in interface MemBuffer
      Returns:
      the current address of offset 0.
    • getMemory Link icon

      public Memory getMemory()
      Get the Memory object actually used by the MemBuffer. return the Memory used by this MemBuffer.
      Specified by:
      getMemory in interface MemBuffer
      Returns:
      the Memory used by this MemBuffer or null if not available.
    • addMnemonicReference Link icon

      public void addMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)
      Add a reference to the mnemonic for this code unit.
      Specified by:
      addMnemonicReference in interface CodeUnit
      Parameters:
      refAddr - address of reference to add
      refType - type of reference being added
      sourceType - the source of this reference
    • getMnemonicReferences Link icon

      public Reference[] getMnemonicReferences()
      Get references for the mnemonic for this instruction.
      Specified by:
      getMnemonicReferences in interface CodeUnit
      Returns:
      an array of memory references. A zero length array will be returned if there are no references for the mnemonic.
    • removeMnemonicReference Link icon

      public void removeMnemonicReference(Address refAddr)
      Remove a reference to the mnemonic for this instruction.
      Specified by:
      removeMnemonicReference in interface CodeUnit
      Parameters:
      refAddr - the address to remove as a reference.
    • addOperandReference Link icon

      public void addOperandReference(int opIndex, Address refAddr, RefType type, SourceType sourceType)
      Add a user defined reference to the operand at the given index.
      Specified by:
      addOperandReference in interface CodeUnit
      Parameters:
      opIndex - operand index
      refAddr - reference address
      type - the reference type to be added.
      sourceType - the source of this reference
      See Also:
    • removeOperandReference Link icon

      public void removeOperandReference(int opIndex, Address refAddr)
      Remove a user defined reference to the operand at opIndex.
      Specified by:
      removeOperandReference in interface CodeUnit
      Parameters:
      opIndex - operand index
      refAddr - address referencing the operand
    • getReferencesFrom Link icon

      public Reference[] getReferencesFrom()
      Get ALL reference FROM this code unit.
      Specified by:
      getReferencesFrom in interface CodeUnit
      Returns:
      an array of memory references from this codeUnit or an empty array if there are no references.
    • setExternalReference Link icon

      public void setExternalReference(Reference ref)
    • setMemoryReference Link icon

      public void setMemoryReference(int opIndex, Address refAddr, RefType refType)
    • setStackReference Link icon

      public void setStackReference(int opIndex, int offset, SourceType sourceType, RefType refType)
      Description copied from interface: CodeUnit
      Sets a stack reference at the offset on the specified operand index, which effectively substitutes the previous operation interpretation
      NOTE: If another reference was previously set on the operand, then it will be replaced with this stack reference
      Specified by:
      setStackReference in interface CodeUnit
      Parameters:
      opIndex - the index of the operand to set this stack reference
      offset - the (+/-) offset from stack base address
      sourceType - the source of this reference
      refType - type of reference, RefType.READ,WRITE,PTR...
    • setRegisterReference Link icon

      public void setRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType)
      Description copied from interface: CodeUnit
      Sets a register reference at the offset on the specified operand index, which effectively substitutes the previous operation interpretation
      NOTE: If another reference was previously set on the operand, then it will be replaced with this register reference
      Specified by:
      setRegisterReference in interface CodeUnit
      Parameters:
      opIndex - the index of the operand to set this register reference
      reg - a register
      sourceType - the source of this reference
      refType - type of reference, RefType.READ,WRITE,PTR...
    • getPrimaryReference Link icon

      public Reference getPrimaryReference(int index)
      Description copied from interface: CodeUnit
      Get the primary reference for the operand index.
      Specified by:
      getPrimaryReference in interface CodeUnit
      Parameters:
      index - operand index (0 is the first operand)
    • setPrimaryMemoryReference Link icon

      public void setPrimaryMemoryReference(Reference ref)
      Description copied from interface: CodeUnit
      Sets a memory reference to be the primary reference at its address/opIndex location. The primary reference is the one that is used in the getOperandRepresentation() method.
      Specified by:
      setPrimaryMemoryReference in interface CodeUnit
      Parameters:
      ref - the reference to be set as primary.
    • getStackReference Link icon

      public StackReference getStackReference(int opIndex)
    • removeStackReference Link icon

      public void removeStackReference(int opIndex)
    • getExternalReference Link icon

      public ExternalReference getExternalReference(int opIndex)
      Description copied from interface: CodeUnit
      Gets the external reference (if any) at the opIndex
      Specified by:
      getExternalReference in interface CodeUnit
      Parameters:
      opIndex - the operand index to look for external references
      Returns:
      the external reference at the operand or null if none exists.
    • removeExternalReference Link icon

      public void removeExternalReference(int opIndex)
      Description copied from interface: CodeUnit
      Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.
      Specified by:
      removeExternalReference in interface CodeUnit
    • getReferenceIteratorTo Link icon

      public ReferenceIterator getReferenceIteratorTo()
      Description copied from interface: CodeUnit
      Get an iterator over all references TO this code unit.
      Specified by:
      getReferenceIteratorTo in interface CodeUnit
    • getProgram Link icon

      public Program getProgram()
      Description copied from interface: CodeUnit
      Returns the program that generated this CodeUnit.
      Specified by:
      getProgram in interface CodeUnit
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object