Class BlockGraph

java.lang.Object
ghidra.program.model.pcode.PcodeBlock
ghidra.program.model.pcode.BlockGraph
Direct Known Subclasses:
BlockCondition, BlockDoWhile, BlockGoto, BlockIfElse, BlockIfGoto, BlockInfLoop, BlockList, BlockMultiGoto, BlockProperIf, BlockSwitch, BlockWhileDo

public class BlockGraph extends PcodeBlock
A block (with in edges and out edges) that contains other blocks
  • Constructor Details

    • BlockGraph

      public BlockGraph()
  • Method Details

    • addBlock

      public void addBlock(PcodeBlock bl)
      Add a block to this container. There are (initially) no edges between it and any other block in the container.
      Parameters:
      bl - is the new block to add
    • setIndices

      public void setIndices()
      Assign a unique index to all blocks in this container. After this call, getBlock(i) will return the block that satisfies block.getIndex() == i
    • getSize

      public int getSize()
      Returns:
      the number of blocks in this container
    • getBlock

      public PcodeBlock getBlock(int i)
      Retrieve the i-th block from this container
      Parameters:
      i - is the index of the block to fetch
      Returns:
      the block
    • addEdge

      public void addEdge(PcodeBlock begin, PcodeBlock end)
      Add a directed edge between two blocks in this container
      Parameters:
      begin - is the "from" block of the edge
      end - is the "to" block of the edge
    • transferObjectRef

      public void transferObjectRef(BlockGraph ingraph)
      Recursively run through this structured BlockGraph finding the BlockCopy leaves. Using the BlockCopy altindex, lookup the original BlockCopy in -ingraph- and transfer the Object ref and Address into the leaf
      Parameters:
      ingraph - is the original flow graph
    • encodeBody

      protected void encodeBody(Encoder encoder) throws IOException
      Description copied from class: PcodeBlock
      Encode information about the block to stream, other than header and edge info
      Overrides:
      encodeBody in class PcodeBlock
      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
      Description copied from class: PcodeBlock
      Restore the any additional information beyond header and edges from stream
      Overrides:
      decodeBody in class PcodeBlock
      Parameters:
      decoder - is the stream decoder
      resolver - is for looking up edge references
      Throws:
      DecoderException - for invalid encoding
    • decode

      public void decode(Decoder decoder) throws DecoderException
      Decode all blocks and edges in this container from a stream.
      Parameters:
      decoder - is the stream decoder
      Throws:
      DecoderException - if there are invalid encodings