Class TreeManager

  • All Implemented Interfaces:
    ManagerDB

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

      • DEFAULT_TREE_NAME

        public static final java.lang.String DEFAULT_TREE_NAME
        The name of the default tree that is created when a program is created.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TreeManager

        public TreeManager​(DBHandle handle,
                           ErrorHandler errHandler,
                           AddressMap addrMap,
                           int openMode,
                           Lock lock,
                           TaskMonitor monitor)
                    throws java.io.IOException,
                           VersionException,
                           CancelledException
        Construct a new TreeManager.
        Parameters:
        handle - database handle
        errHandler - error handler
        addrMap - map to convert addresses to longs and longs to addresses
        openMode - the open mode for the program.
        lock - the program synchronization lock
        monitor - Task monitor for upgrading
        Throws:
        java.io.IOException - if a database io error occurs.
        VersionException - if the database version is different from the expected version
        CancelledException
    • Method Detail

      • setProgram

        public void setProgram​(ProgramDB program)
        Set the program.
        Specified by:
        setProgram in interface ManagerDB
        Parameters:
        program - the program is set when all the initializations have been completed.
      • programReady

        public void programReady​(int openMode1,
                                 int currentRevision,
                                 TaskMonitor monitor)
                          throws java.io.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:
        java.io.IOException - if a database io error occurs.
        CancelledException - if the user cancelled the operation via the task monitor.
        See Also:
        ManagerDB.programReady(int, int, ghidra.util.task.TaskMonitor)
      • imageBaseChanged

        public void imageBaseChanged​(boolean commit)
      • createRootModule

        public ProgramModule createRootModule​(java.lang.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​(java.lang.String treeName)
        Get the root module of the tree with the given 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 java.lang.String[] getTreeNames()
        Get the names of all the trees in the program.
        Returns:
        sorted array of tree names
      • renameTree

        public void renameTree​(java.lang.String oldName,
                               java.lang.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​(java.lang.String treeName)
        Remove the tree with the given name.
        Returns:
        true if the tree was removed
      • getModule

        public ProgramModule getModule​(java.lang.String treeName,
                                       java.lang.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​(java.lang.String treeName,
                                           java.lang.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​(java.lang.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​(java.lang.String name,
                                   AddressRange range)
        Add a memory block with the given range.
      • invalidateCache

        public void invalidateCache​(boolean all)
                             throws java.io.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:
        java.io.IOException - if a database io error occurs.
      • setProgramName

        public void setProgramName​(java.lang.String oldName,
                                   java.lang.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