Class PcodeProgram

java.lang.Object
ghidra.pcode.exec.PcodeProgram
Direct Known Subclasses:
PcodeExpression

public class PcodeProgram extends Object
A p-code program to be executed by a PcodeExecutor

This is a list of p-code operations together with a map of expected userops.

  • Field Details

  • Constructor Details

    • PcodeProgram

      protected PcodeProgram(SleighLanguage language, List<PcodeOp> code, Map<Integer,ghidra.pcodeCPort.slghsymbol.UserOpSymbol> useropSymbols)
      Construct a p-code program with the given bindings
      Parameters:
      language - the language that generated the p-code
      code - the list of p-code ops
      useropSymbols - a map of expected userop symbols
  • Method Details

    • fromInstruction

      public static PcodeProgram fromInstruction(Instruction instruction)
      Generate a p-code program from the given instruction, without overrides
      Parameters:
      instruction - the instruction
      Returns:
      the p-code program
    • fromInstruction

      public static PcodeProgram fromInstruction(Instruction instruction, boolean includeOverrides)
      Generate a p-code program from the given instruction
      Parameters:
      instruction - the instruction
      includeOverrides - as in Instruction.getPcode(boolean)
      Returns:
      the p-code program
    • fromInject

      public static PcodeProgram fromInject(Program program, String name, int type) throws MemoryAccessException, UnknownInstructionException, NotFoundException, IOException
      Generate a p-code program from a given program's inject library
      Parameters:
      program - the program
      name - the name of the snippet
      type - the type of the snippet
      Returns:
      the p-code program
      Throws:
      MemoryAccessException - for problems establishing the injection context
      IOException - for problems while emitting the injection p-code
      UnknownInstructionException - if there is no underlying instruction being injected
      NotFoundException - if an expected aspect of the injection is not present in context
    • getLanguage

      public SleighLanguage getLanguage()
      Get the language generating this program
      Returns:
      the language
    • getCode

      public List<PcodeOp> getCode()
    • execute

      public <T> void execute(PcodeExecutor<T> executor, PcodeUseropLibrary<T> library)
      Execute this program using the given executor and library
      Type Parameters:
      T - the type of values to be operated on
      Parameters:
      executor - the executor
      library - the library
    • getHead

      protected String getHead()
      For display purposes, get the header above the frame, usually the class name
      Returns:
      the frame's display header
    • toString

      public String toString()
      Overrides:
      toString in class Object