Package ghidra.program.model.block

# Interface CodeBlock

All Superinterfaces:
  `AddressSetView`, `Iterable<AddressRange>`

All Known Implementing Classes:
  `CodeBlockImpl`, `ExtCodeBlockImpl`

public interface CodeBlock extends AddressSetView
CodeBlock represents some group of Instructions/Data. Each block has some set of source blocks that flow into it and some set of destination blocks that flow out of it. A BlockModel is used to produce CodeBlocks. Each model produces blocks based on its interpretation of Instruction/Data grouping and flow between those groups.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CodeBlockReferenceIterator`
  `getDestinations(TaskMonitor monitor)`
  Get an Iterator over the CodeBlocks that are flowed to from this CodeBlock.
  `Address`
  `getFirstStartAddress()`
  Return the first start address of the CodeBlock.
  `FlowType`
  `getFlowType()`
  Return, in theory, how things flow out of this node.
  `CodeBlockModel`
  `getModel()`
  Get the model instance which was used to generate this block.
  `String`
  `getName()`
  Return the name of the block.
  `int`
  `getNumDestinations(TaskMonitor monitor)`
  Get the number of CodeBlocks this block flows to.
  `int`
  `getNumSources(TaskMonitor monitor)`
  Get the number of CodeBlocks that flow into this CodeBlock.
  `CodeBlockReferenceIterator`
  `getSources(TaskMonitor monitor)`
  Get an Iterator over the CodeBlocks that flow into this CodeBlock.
  `Address[]`
  `getStartAddresses()`
  Get all the entry points to this block.

  ### Methods inherited from interface ghidra.program.model.address.AddressSetView

  `contains, contains, contains, findFirstAddressInCommon, getAddresses, getAddresses, getAddressRanges, getAddressRanges, getAddressRanges, getFirstRange, getLastRange, getMaxAddress, getMinAddress, getNumAddresses, getNumAddressRanges, getRangeContaining, hasSameAddresses, intersect, intersectRange, intersects, intersects, isEmpty, iterator, iterator, iterator, subtract, union, xor`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Method Details

  - ### getFirstStartAddress

    Address getFirstStartAddress()
    Return the first start address of the CodeBlock. Depending on the model used to generate the CodeBlock, there may be multiple entry points to the block. This will return the first start address for the block. It should always return the same address for a given block if there is more than one entry point.
    Returns:
      the first start address of the block.

  - ### getStartAddresses

    Address[] getStartAddresses()
    Get all the entry points to this block. Depending on the model, there may be more than one entry point. Entry points will be returned in natural sorted order.
    Returns:
      an array of entry points to this block. a zero length array if there are no entry points.

  - ### getName

    String getName()
    Return the name of the block.
    Returns:
      name of block, normally the symbol at the starting address

  - ### getFlowType

    FlowType getFlowType()
    Return, in theory, how things flow out of this node. If there are any abnormal ways to flow out of this node, (ie: jump, call, etc...) then the flow type of the node takes on that type. If there are multiple unique ways out of the node, then we should return FlowType.UNKNOWN. Fallthrough is returned if that is the only way out.
    Returns:
      flow type of this node

  - ### getNumSources

    int getNumSources(TaskMonitor monitor) throws CancelledException
    Get the number of CodeBlocks that flow into this CodeBlock. Note that this is almost as much work as getting the actual source references.
    Parameters:
      `monitor` - task monitor which allows user to cancel operation.
    Returns:
      number of source CodeBlocks.
    Throws:
      `CancelledException` - if the monitor cancels the operation.
    See Also:
      - `getSources(ghidra.util.task.TaskMonitor)`

  - ### getSources

    CodeBlockReferenceIterator getSources(TaskMonitor monitor) throws CancelledException
    Get an Iterator over the CodeBlocks that flow into this CodeBlock.
    Parameters:
      `monitor` - task monitor which allows user to cancel operation.
    Returns:
      An iterator over CodeBlocks referencing this Block.
    Throws:
      `CancelledException` - if the monitor cancels the operation.

  - ### getNumDestinations

    int getNumDestinations(TaskMonitor monitor) throws CancelledException
    Get the number of CodeBlocks this block flows to. Note that this is almost as much work as getting the actual destination references.
    Parameters:
      `monitor` - task monitor which allows user to cancel operation.
    Returns:
      number of destination CodeBlocks.
    Throws:
      `CancelledException` - if the monitor cancels the operation.
    See Also:
      - `getDestinations(ghidra.util.task.TaskMonitor)`

  - ### getDestinations

    CodeBlockReferenceIterator getDestinations(TaskMonitor monitor) throws CancelledException
    Get an Iterator over the CodeBlocks that are flowed to from this CodeBlock.
    Parameters:
      `monitor` - task monitor which allows user to cancel operation.
    Returns:
      An iterator over CodeBlocks referred to by this Block.
    Throws:
      `CancelledException` - if the monitor cancels the operation.

  - ### getModel

    CodeBlockModel getModel()
    Get the model instance which was used to generate this block.
    Returns:
      the model used to build this CodeBlock