Class PcodeBlock

java.lang.Object
ghidra.program.model.pcode.PcodeBlock
Direct Known Subclasses:
BlockCopy, BlockGraph, PcodeBlockBasic

public class PcodeBlock extends Object
Blocks of PcodeOps
  • Field Details

  • Constructor Details

    • PcodeBlock

      public PcodeBlock()
  • Method Details

    • typeToName

      public static String typeToName(int type)
    • nameToType

      public static int nameToType(String name)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getType

      public int getType()
    • getStart

      public Address getStart()
      Returns:
      the first Address covered by this block
    • getStop

      public Address getStop()
      Returns:
      the last Address covered by this block
    • setIndex

      public void setIndex(int i)
    • getIndex

      public int getIndex()
    • getParent

      public PcodeBlock getParent()
    • addInEdge

      protected void addInEdge(PcodeBlock b, int lab)
    • decodeNextInEdge

      protected void decodeNextInEdge(Decoder decoder, BlockMap resolver) throws DecoderException
      Decode the next input edge from the stream
      Parameters:
      decoder - is the stream decoder
      resolver - is used to find PcodeBlocks
      Throws:
      DecoderException - for any invalid encoding
    • decodeNextInEdge

      protected void decodeNextInEdge(Decoder decoder, ArrayList<? extends PcodeBlock> blockList) throws DecoderException
      Decode the next input edge from the stream. Resolve block indices via a blockList
      Parameters:
      decoder - is the stream decoder
      blockList - allows lookup of PcodeBlock via index
      Throws:
      DecoderException - for any invalid encoding
    • getIn

      public PcodeBlock getIn(int i)
    • getOut

      public PcodeBlock getOut(int i)
    • getOutRevIndex

      public int getOutRevIndex(int i)
      Get reverse index of the i-th outgoing block. I.e this.getOut(i).getIn(reverse_index) == this
      Parameters:
      i - is the outgoing block to request reverse index from
      Returns:
      the reverse index
    • getInRevIndex

      public int getInRevIndex(int i)
      Get reverse index of the i-th incoming block. I.e. this.getIn(i).getOut(reverse_index) == this
      Parameters:
      i - is the incoming block to request reverse index from
      Returns:
      the reverse index
    • getFalseOut

      public PcodeBlock getFalseOut()
      Assuming paths out of this block depend on a boolean condition
      Returns:
      the PcodeBlock coming out of this if the condition is false
    • getTrueOut

      public PcodeBlock getTrueOut()
      Assuming paths out of this block depend on a boolean condition
      Returns:
      the PcodeBlock coming out of this if the condition is true
    • getInSize

      public int getInSize()
    • getOutSize

      public int getOutSize()
    • calcDepth

      public int calcDepth(PcodeBlock leaf)
    • getFrontLeaf

      public PcodeBlock getFrontLeaf()
    • encodeHeader

      protected void encodeHeader(Encoder encoder) throws IOException
      Encode basic attributes to stream. Assume this block's element is already started.
      Parameters:
      encoder - is the stream encoder
      Throws:
      IOException - for errors writing to the underlying stream
    • decodeHeader

      protected void decodeHeader(Decoder decoder) throws DecoderException
      Throws:
      DecoderException
    • encodeBody

      protected void encodeBody(Encoder encoder) throws IOException
      Encode information about the block to stream, other than header and edge info
      Parameters:
      encoder - is the stream encoder
      Throws:
      IOException - for errors writing to the underlying stream
    • encodeEdges

      protected void encodeEdges(Encoder encoder) throws IOException
      Encode information about this blocks edges to stream
      Parameters:
      encoder - is the stream encoder
      Throws:
      IOException - for errors writing to the underlying stream
    • decodeBody

      protected void decodeBody(Decoder decoder, BlockMap resolver) throws DecoderException
      Restore the any additional information beyond header and edges from stream
      Parameters:
      decoder - is the stream decoder
      resolver - is for looking up edge references
      Throws:
      DecoderException - for invalid encoding
    • decodeEdges

      protected void decodeEdges(Decoder decoder, BlockMap resolver) throws DecoderException
      Throws:
      DecoderException
    • encode

      public void encode(Encoder encoder) throws IOException
      Encode this block to a stream
      Parameters:
      encoder - is the stream encoder
      Throws:
      IOException - for errors writing to the underlying stream
    • decode

      public void decode(Decoder decoder, BlockMap resolver) throws DecoderException
      Decode this block from a stream
      Parameters:
      decoder - is the stream decoder
      resolver - is the map from reference to block object
      Throws:
      DecoderException - for errors in the encoding