Class TreeManager

java.lang.Object
ghidra.program.database.module.TreeManager
All Implemented Interfaces:
ManagerDB

public class TreeManager extends Object implements ManagerDB
Manage the set of trees in the program.
  • Field Details

    • DEFAULT_TREE_NAME

      public static final String DEFAULT_TREE_NAME
      The name of the default tree that is created when a program is created.
      See Also:
  • Constructor Details

  • Method Details

    • setProgram

      public void setProgram(ProgramDB program)
      Description copied from interface: ManagerDB
      Callback from program used to indicate all manager have been created. When this method is invoked, all managers have been instantiated but may not be fully initialized.
      Specified by:
      setProgram in interface ManagerDB
      Parameters:
      program - the program is set when all the initializations have been completed.
    • programReady

      public void programReady(OpenMode openMode1, int currentRevision, TaskMonitor monitor) throws IOException, CancelledException
      Description copied from interface: ManagerDB
      Callback from program made to each manager after the program has completed initialization. This method may be used by managers to perform additional upgrading which may have been deferred.
      Specified by:
      programReady in interface ManagerDB
      Parameters:
      openMode1 - the mode that the program is being opened.
      currentRevision - current program revision. If openMode is UPGRADE, this value reflects the pre-upgrade value.
      monitor - the task monitor to use in any upgrade operations.
      Throws:
      IOException - if a database io error occurs.
      CancelledException - if the user cancelled the operation via the task monitor.
    • imageBaseChanged

      public void imageBaseChanged(boolean commit)
    • createRootModule

      public ProgramModule createRootModule(String treeName) throws DuplicateNameException
      Create a new tree with given name.
      Parameters:
      treeName - name of the tree (not the root module)
      Returns:
      root module for the new tree
      Throws:
      DuplicateNameException - if there is already tree named treeName
    • getRootModule

      public ProgramModule getRootModule(String treeName)
      Get the root module of the tree with the given name.
      Parameters:
      treeName - tree name
      Returns:
      root module, or null if there is no tree with the given name
    • getDefaultRootModule

      public ProgramModule getDefaultRootModule()
      Returns the root module for the default program tree. The default tree is the oldest tree.
      Returns:
      the root module for the default program tree. The default tree is the oldest tree.
    • getTreeNames

      public String[] getTreeNames()
      Get the names of all the trees in the program.
      Returns:
      sorted array of tree names
    • renameTree

      public void renameTree(String oldName, String newName) throws DuplicateNameException
      Rename the tree to the new name. This method has no effect on the name of the root module.
      Parameters:
      oldName - old name of root module
      newName - new name for root module
      Throws:
      DuplicateNameException - if newName exists as the name for another root
    • removeTree

      public boolean removeTree(String treeName)
      Remove the tree with the given name.
      Parameters:
      treeName - tree name
      Returns:
      true if the tree was removed
    • getModule

      public ProgramModule getModule(String treeName, String name)
      Get the module with the given name that is in the tree identified by the treeName.
      Parameters:
      treeName - name of the tree
      name - module name to look for
      Returns:
      null if there is no module with the given name in the tree
    • getFragment

      public ProgramFragment getFragment(String treeName, String name)
      Get the fragment with the given name that is in the tree identified by the treeName.
      Parameters:
      treeName - name of the tree
      name - name of fragment to look for
      Returns:
      null if there is no fragment with the given name in the tree
    • getFragment

      public ProgramFragment getFragment(String treeName, Address addr)
      Get the fragment that contains the given address within the tree identified by the treeName.
      Parameters:
      treeName - name of the tree
      addr - address contained within some fragment
      Returns:
      fragment containing addr, or null if addr does not exist in memory
    • addMemoryBlock

      public void addMemoryBlock(String name, AddressRange range)
      Add a memory block with the given range.
      Parameters:
      name - memory block name (name of new fragment)
      range - memory block address range
    • deleteAddressRange

      public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException
      Description copied from interface: ManagerDB
      Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly. The specified start and end addresses must form a valid range within a single AddressSpace.
      Specified by:
      deleteAddressRange in interface ManagerDB
      Parameters:
      startAddr - the first address in the range.
      endAddr - the last address in the range.
      monitor - the task monitor to use in any upgrade operations.
      Throws:
      CancelledException - if the user cancelled the operation via the task monitor.
    • moveAddressRange

      public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws AddressOverflowException, CancelledException
      Description copied from interface: ManagerDB
      Move all objects within an address range to a new location.
      Specified by:
      moveAddressRange in interface ManagerDB
      Parameters:
      fromAddr - the first address of the range to be moved.
      toAddr - the address where to the range is to be moved.
      length - the number of addresses to move.
      monitor - the task monitor to use in any upgrade operations.
      Throws:
      AddressOverflowException - if the length is such that a address wrap occurs
      CancelledException - if the user cancelled the operation via the task monitor.
    • invalidateCache

      public void invalidateCache(boolean all) throws IOException
      Description copied from interface: ManagerDB
      Clears all data caches.
      Specified by:
      invalidateCache in interface ManagerDB
      Parameters:
      all - if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.
      Throws:
      IOException - if a database io error occurs.
    • setProgramName

      public void setProgramName(String oldName, String newName)
    • getRootModule

      public ProgramModule getRootModule(long treeID)
      Get the root module for the tree that has the given ID.
      Parameters:
      treeID - ID of the tree
      Returns:
      root module