Package ghidra.program.database

# Class ProgramAddressFactory

java.lang.Object
ghidra.program.model.address.DefaultAddressFactory
ghidra.program.database.ProgramAddressFactory

All Implemented Interfaces:
  `AddressFactory`

Direct Known Subclasses:
  `TraceAddressFactory`

public class ProgramAddressFactory extends DefaultAddressFactory

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final OverlayRegionSupplier`
  `overlayRegionSupplier`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProgramAddressFactory(Language language, CompilerSpec compilerSpec, OverlayRegionSupplier overlayRegionSupplier)`
  Construct a Program address factory which augments the `DefaultAddressFactory` supplied by a `Language`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected ProgramOverlayAddressSpace`
  `addOverlaySpace(long key, String overlayName, AddressSpace baseSpace)`
  Create a new ProgramOverlayAddressSpace based upon the given overlay blockName and base AddressSpace
  `protected void`
  `addOverlaySpace(ProgramOverlayAddressSpace ovSpace)`
  Add an overlay address space to this factory
  `void`
  `checkValidOverlaySpaceName(String name)`
  `Address`
  `getAddress(int spaceID, long offset)`
  Get an address using the addressSpace with the given id and having the given offset.
  `Address`
  `getAddress(String addrString)`
  Create an address from String.
  `AddressSpace`
  `getStackSpace()`
  Returns the "stack" address space.
  `boolean`
  `hasStaleOverlayCondition()`
  Determine if this address factory contains a stale overlay address space whose name was recently changed.
  `void`
  `invalidateOverlayCache()`
  `protected boolean`
  `isValidOverlayBaseSpace(AddressSpace baseSpace)`
  Determine whether the given space can have an overlay
  `protected void`
  `overlaySpaceRenamed(String oldOverlaySpaceName, String newName, boolean refreshStatusIfNeeded)`
  `protected void`
  `refreshStaleOverlayStatus()`
  Examine all overlay spaces and update the stale status indicator (see `hasStaleOverlays`).
  `protected void`
  `removeOverlaySpace(String name)`
  Remove an overlay space.

  ### Methods inherited from class ghidra.program.model.address.DefaultAddressFactory

  `addAddressSpace, equals, getAddressSet, getAddressSet, getAddressSpace, getAddressSpace, getAddressSpaces, getAllAddresses, getAllAddresses, getAllAddressSpaces, getConstantAddress, getConstantSpace, getDefaultAddressSpace, getIndex, getNumAddressSpaces, getPhysicalSpace, getPhysicalSpaces, getRegisterSpace, getUniqueSpace, hasMultipleMemorySpaces, isValidAddress, oldGetAddressFromLong, overlaySpaceRenamed, removeAddressSpace`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### overlayRegionSupplier

    protected final OverlayRegionSupplier overlayRegionSupplier

- ## Constructor Details

  - ### ProgramAddressFactory

    public ProgramAddressFactory(Language language, CompilerSpec compilerSpec, OverlayRegionSupplier overlayRegionSupplier)
    Construct a Program address factory which augments the `DefaultAddressFactory` supplied by a `Language`. The following additional address spaces are added:
    - `AddressSpace.OTHER_SPACE`
    - `AddressSpace.EXTERNAL_SPACE`
    - A stack space (see `AddressSpace.TYPE_STACK`)
    - `AddressSpace.HASH_SPACE`
    - A join space (see `AddressSpace.TYPE_JOIN`)
    In addition, support is provided for `ProgramOverlayAddressSpace`.
    Parameters:
      `language` - language specification
      `compilerSpec` - compiler specification
      `overlayRegionSupplier` - overlay space defined region supplier which will be invoked when specific queries are performed on overlay address spaces. If memory is not yet available a null AddressSet may be returned by the supplier.

- ## Method Details

  - ### invalidateOverlayCache

    public void invalidateOverlayCache()

  - ### getStackSpace

    public AddressSpace getStackSpace()
    Description copied from interface: `AddressFactory`
    Returns the "stack" address space.
    Specified by:
      `getStackSpace` in interface `AddressFactory`
    Overrides:
      `getStackSpace` in class `DefaultAddressFactory`

  - ### isValidOverlayBaseSpace

    protected boolean isValidOverlayBaseSpace(AddressSpace baseSpace)
    Determine whether the given space can have an overlay
    Parameters:
      `baseSpace` - the overlay base address space
    Returns:
      true to allow, false to prohibit

  - ### addOverlaySpace

    protected void addOverlaySpace(ProgramOverlayAddressSpace ovSpace) throws DuplicateNameException
    Add an overlay address space to this factory
    Parameters:
      `ovSpace` - overlay space
    Throws:
      `DuplicateNameException` - if name of overlay space already exists in this factory

  - ### addOverlaySpace

    protected ProgramOverlayAddressSpace addOverlaySpace(long key, String overlayName, AddressSpace baseSpace) throws DuplicateNameException
    Create a new ProgramOverlayAddressSpace based upon the given overlay blockName and base AddressSpace
    Parameters:
      `key` - overlay record key
      `overlayName` - overlay name
      `baseSpace` - the base AddressSpace to overlay
    Returns:
      the new overlay space
    Throws:
      `DuplicateNameException` - if overlay name duplicates another address space name
      `IllegalArgumentException` - if baseSpace is not permitted or not found.

  - ### checkValidOverlaySpaceName

    public void checkValidOverlaySpaceName(String name) throws InvalidNameException, DuplicateNameException
    Throws:
      `InvalidNameException`
      `DuplicateNameException`

  - ### getAddress

    public Address getAddress(int spaceID, long offset)
    Description copied from interface: `AddressFactory`
    Get an address using the addressSpace with the given id and having the given offset.
    Specified by:
      `getAddress` in interface `AddressFactory`
    Overrides:
      `getAddress` in class `DefaultAddressFactory`
    Parameters:
      `spaceID` - the id of the address space to use to create the new address.
      `offset` - the offset of the new address to be created.
    Returns:
      the new address.

  - ### getAddress

    public Address getAddress(String addrString)
    Description copied from interface: `AddressFactory`
    Create an address from String. Attempts to use the "default" address space first. Otherwise loops through each addressSpace, returning the first valid address that any addressSpace creates from the string. Returns an Address if the string is valid, otherwise null.
    Specified by:
      `getAddress` in interface `AddressFactory`
    Overrides:
      `getAddress` in class `DefaultAddressFactory`
    See Also:
      - `AddressFactory.getAddress(java.lang.String)`

  - ### removeOverlaySpace

    protected void removeOverlaySpace(String name)
    Remove an overlay space. It may be neccessary to invoke `refreshStaleOverlayStatus()` when an overlay is removed.
    Parameters:
      `name` - overlay space name

  - ### overlaySpaceRenamed

    protected void overlaySpaceRenamed(String oldOverlaySpaceName, String newName, boolean refreshStatusIfNeeded)

  - ### refreshStaleOverlayStatus

    protected void refreshStaleOverlayStatus()
    Examine all overlay spaces and update the stale status indicator (see `hasStaleOverlays`).

  - ### hasStaleOverlayCondition

    public boolean hasStaleOverlayCondition()
    Description copied from interface: `AddressFactory`
    Determine if this address factory contains a stale overlay address space whose name was recently changed. When this condition occurs, issues may arise when comparing `Address` and `AddressSpace`-related objects when overlay address spaces are involved. A common case for this is a Diff type operation.
    Returns:
      true if this factory contains one or more stale overlay address space instances.