Class InvalidPrototype

java.lang.Object
ghidra.program.model.lang.InvalidPrototype
All Implemented Interfaces:
InstructionPrototype, ParserContext

public class InvalidPrototype extends Object implements InstructionPrototype, ParserContext
Class to represent an invalid instruction prototype.
  • Constructor Details

    • InvalidPrototype

      public InvalidPrototype(Language lang)
      Construct a new invalid instruction prototype.
      Parameters:
      lang - is the Language for which the invalid instruction is discovered
  • Method Details

    • hasDelaySlots

      public boolean hasDelaySlots()
      Description copied from interface: InstructionPrototype
      Returns true if instruction prototype expects one or more delay slotted instructions to exist.
      Specified by:
      hasDelaySlots in interface InstructionPrototype
      Returns:
      true if instruction prototype expects one or more delay slotted instructions to exist
    • hasCrossBuildDependency

      public boolean hasCrossBuildDependency()
      Description copied from interface: InstructionPrototype
      Returns true if instruction semantics have a crossbuild instruction dependency which may require a robust InstructionContext with access to preceding instructions.
      Specified by:
      hasCrossBuildDependency in interface InstructionPrototype
      Returns:
      true if instruction semantics have a crossbuild instruction dependency which may require a robust InstructionContext with access to preceding instructions
    • hasNext2Dependency

      public boolean hasNext2Dependency()
      Description copied from interface: InstructionPrototype
      Returns true if instruction semantics contain a reference to inst_next2..
      Specified by:
      hasNext2Dependency in interface InstructionPrototype
      Returns:
      true if instruction semantics contain a reference to inst_next2
    • getInstructionMask

      public Mask getInstructionMask()
      Description copied from interface: InstructionPrototype
      Returns the Mask that describe which bits of this instruction determine the opcode, or null if unknown.
      Specified by:
      getInstructionMask in interface InstructionPrototype
      Returns:
      the Mask that describe which bits of this instruction determine the opcode, or null if unknown
    • getOperandValueMask

      public Mask getOperandValueMask(int operandIndex)
      Description copied from interface: InstructionPrototype
      Returns the Mask that describe which bits of this instruction determine a specific operand's value, or null if unknown.
      Specified by:
      getOperandValueMask in interface InstructionPrototype
      Parameters:
      operandIndex - the 0-up index of the operand
      Returns:
      the Mask that describe which bits of this instruction determine a specific operand's value, or null if unknown
    • getFlowType

      public FlowType getFlowType(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the flow type of this instruction.

      This is used for analysis purposes. i.e., how this instruction flows to the next instruction.

      Specified by:
      getFlowType in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the flow type of this instruction
    • getDelaySlotDepth

      public int getDelaySlotDepth(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the number of delay slot instructions following this instruction.

      This should be 0 for instructions which don't have a delay slot. This is used to support the delay slots found on some RISC processors such as SPARC and the PA-RISC. This returns an integer instead of a boolean in case some other processor executes more than one instruction from a delay slot.

      Specified by:
      getDelaySlotDepth in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the number of delay slot instructions following this instruction
    • isInDelaySlot

      public boolean isInDelaySlot()
      Description copied from interface: InstructionPrototype
      Returns true if this prototype was disassembled in a delay slot.
      Specified by:
      isInDelaySlot in interface InstructionPrototype
      Returns:
      true if this prototype was disassembled in a delay slot
    • getNumOperands

      public int getNumOperands()
      Description copied from interface: InstructionPrototype
      Returns the number of operands in this instruction.
      Specified by:
      getNumOperands in interface InstructionPrototype
      Returns:
      the number of operands in this instruction
    • getOpType

      public int getOpType(int opIndex, InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the type of a specific operand.
      Specified by:
      getOpType in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context.
      Returns:
      the type of a specific operand
    • getFallThrough

      public Address getFallThrough(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the Address for fall-through flow after this instruction, or null if flow cannot fall through this instruction.
      Specified by:
      getFallThrough in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the Address for fall-through flow after this instruction, or null if flow cannot fall through this instruction
    • getFallThroughOffset

      public int getFallThroughOffset(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the byte offset to the fall-through flow after this instruction.

      Ordinarily, this is just the length (in bytes) of this instruction. However, if this instruction has delay-slotted instruction(s), their lengths are included. Even if flow cannot fall through this instruction, this method will still return a the fall-through offset.

      Specified by:
      getFallThroughOffset in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the byte offset to the fall-through flow after this instruction
    • getFlows

      public Address[] getFlows(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the Addresses for all flows other than a fall-through, or null if no flows.

      A null return is equivalent to an empty array. Note the result may include Address.NO_ADDRESS to indicate flow to an address that could not be evaluated, e.g., to inst_next2 when the skipped instruction could not be parsed.

      Specified by:
      getFlows in interface InstructionPrototype
      Parameters:
      context - the instruction context.
      Returns:
      the Addresses for all flows other than a fall-through, or null if no flows
    • getOpRepresentation

      public String getOpRepresentation(int opIndex, MemBuffer buf, ProcessorContextView context, String label)
    • getOpRepresentationList

      public ArrayList<Object> getOpRepresentationList(int opIndex, InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns a the objects for rendering an operand's representation.

      Each element is one of Address, Register, Scalar, VariableOffset, Character, or null. This method may also return null (as in no list at all) if the operation is not supported. Nulls should be rendered as empty strings.

      Specified by:
      getOpRepresentationList in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context
      Returns:
      a the objects for rendering an operand's representation
    • getAddress

      public Address getAddress(int opIndex, InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the Address value of a specific operand, or null if its value is not an Address.
      Specified by:
      getAddress in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context.
      Returns:
      the Address value of a specific operand, or null if its value is not an Address
    • getScalar

      public Scalar getScalar(int opIndex, InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the Scalar value of a specific operand, or null if its value is not an Scalar.
      Specified by:
      getScalar in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context
      Returns:
      the Scalar value of a specific operand, or null if its value is not an Scalar
    • getRegister

      public Register getRegister(int opIndex, InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the Register value of a specific operand, or null if its value is not an Register.
      Specified by:
      getRegister in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context
      Returns:
      the Register value of a specific operand, or null if its value is not an Register
    • getOpObjects

      public Object[] getOpObjects(int opIndex, InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the objects used by a specific operand.

      Each element is one of Address, Register, Scalar, or VariableOffset.

      Specified by:
      getOpObjects in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context
      Returns:
      the objects used by a specific operand
    • hasDelimeter

      public boolean hasDelimeter(int opIndex)
      Description copied from interface: InstructionPrototype
      Returns true if a specific operand ought to have a delimiter following it.
      Specified by:
      hasDelimeter in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      Returns:
      true if a specific operand ought to have a delimiter following it
    • getInputObjects

      public Object[] getInputObjects(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the objects used as input by this instruction.

      Each element should probably only be one of Address or Register.

      Specified by:
      getInputObjects in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the objects used as input by this instruction
    • getResultObjects

      public Object[] getResultObjects(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the objects affected by this instruction.

      Each element should probably only be one of Address or Register.

      Specified by:
      getResultObjects in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the objects affected by this instruction
    • getPcode

      public PcodeOp[] getPcode(InstructionContext context, PcodeOverride override)
      Description copied from interface: InstructionPrototype
      Returns the p-code operations (micro code) that this instruction performs.

      This will return an empty array if the language does not support p-code for this instruction.

      Specified by:
      getPcode in interface InstructionPrototype
      Parameters:
      context - the instruction context
      override - if not null, may indicate that different elements of the pcode generation are overridden
      Returns:
      the p-code operations (micro code) that this instruction performs
    • getPcodePacked

      public void getPcodePacked(PatchEncoder encoder, InstructionContext context, PcodeOverride override) throws IOException
      Description copied from interface: InstructionPrototype
      Does the same as InstructionPrototype.getPcode(InstructionContext, PcodeOverride) but emits the operations directly to an encoder to optimize transfer to other processes}
      Specified by:
      getPcodePacked in interface InstructionPrototype
      Parameters:
      encoder - is the encoder receiving the operations
      context - the instruction context
      override - if not null, may indicate that different elements of the pcode generation are overridden
      Throws:
      IOException - for errors writing to any stream underlying the encoder
    • getPcode

      public PcodeOp[] getPcode(InstructionContext context, int opIndex)
      Description copied from interface: InstructionPrototype
      Returns the p-code operations (micro code) that perform the computation of a particular operand's value.
      Specified by:
      getPcode in interface InstructionPrototype
      Parameters:
      context - the instruction context
      opIndex - the 0-up index of the operand
      Returns:
      the p-code operations (micro code) that perform the computation of a particular operand's value
    • getMnemonic

      public String getMnemonic(InstructionContext context)
      Description copied from interface: InstructionPrototype
      Returns the mnemonic for this prototype.

      Examples: "MOV" and "CALL"

      Specified by:
      getMnemonic in interface InstructionPrototype
      Parameters:
      context - the instruction context
      Returns:
      the mnemonic for this prototype
    • getLength

      public int getLength()
      Description copied from interface: InstructionPrototype
      Returns the length in bytes of this prototype.
      Specified by:
      getLength in interface InstructionPrototype
      Returns:
      the length in bytes of this prototype
    • getSeparator

      public String getSeparator(int opIndex)
      Description copied from interface: InstructionPrototype
      Returns the separator string before a specific operand, or null.

      In particular, the separator string for operand 0 are the characters before the first operand. The separator string for numOperands are the characters after the last operand. A null return value is equivalent to an empty string.

      Specified by:
      getSeparator in interface InstructionPrototype
      Parameters:
      opIndex - valid values are 0 thru numOperands, inclusive
      Returns:
      the separator string before a specific operand, or null
    • getOperandRefType

      public RefType getOperandRefType(int opIndex, InstructionContext context, PcodeOverride override)
      Description copied from interface: InstructionPrototype
      Returns the suggested reference type for a specific operand.
      Specified by:
      getOperandRefType in interface InstructionPrototype
      Parameters:
      opIndex - the 0-up index of the operand
      context - the instruction context
      override - if not null, steers local overrides of p-code generation
      Returns:
      the suggested reference type for a specific operand
    • getLanguage

      public Language getLanguage()
      Description copied from interface: InstructionPrototype
      Returns the processor language module associated with this prototype.
      Specified by:
      getLanguage in interface InstructionPrototype
      Returns:
      the processor language module associated with this prototype
    • getParserContext

      public ParserContext getParserContext(MemBuffer buf, ProcessorContextView processorContext) throws MemoryAccessException
      Description copied from interface: InstructionPrototype
      Returns a new instance of an instruction ParserContext.
      Specified by:
      getParserContext in interface InstructionPrototype
      Parameters:
      buf - the memory from which this prototype was parsed, or an equivalent cache
      processorContext - the (incoming) processor context during parse
      Returns:
      a new instance of an instruction ParserContext
      Throws:
      MemoryAccessException - if the memory buffer cannot be accessed
    • getPrototype

      public InstructionPrototype getPrototype()
      Specified by:
      getPrototype in interface ParserContext
    • getDelaySlotByteCount

      public int getDelaySlotByteCount()
      Description copied from interface: InstructionPrototype
      Returns the number of delay-slot instruction bytes which correspond to this prototype.
      Specified by:
      getDelaySlotByteCount in interface InstructionPrototype
      Returns:
      the number of delay-slot instruction bytes which correspond to this prototype
    • getPseudoParserContext

      Description copied from interface: InstructionPrototype
      Returns a ParserContext by parsing bytes outside of the normal disassembly process.
      Specified by:
      getPseudoParserContext in interface InstructionPrototype
      Parameters:
      addr - where the ParserContext is needed, i.e., the first address of an instruction to be parsed
      buffer - of actual bytes
      processorContext - the (incoming) processor context
      Returns:
      a ParserContext by parsing bytes outside of the normal disassembly process
      Throws:
      InsufficientBytesException - if not enough bytes are in the buffer
      UnknownInstructionException - if the bytes do not constitute a valid instruction
      UnknownContextException - if contextual dependencies, e.g. crossbuild instructions, are not available
      MemoryAccessException - if the memory buffer cannot be accessed