Package ghidra.program.database.module
Class TreeManager
- java.lang.Object
-
- ghidra.program.database.module.TreeManager
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_TREE_NAME
The name of the default tree that is created when a program is created.
-
Constructor Summary
Constructors Constructor Description TreeManager(DBHandle handle, ErrorHandler errHandler, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor)
Construct a new TreeManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMemoryBlock(java.lang.String name, AddressRange range)
Add a memory block with the given range.ProgramModule
createRootModule(java.lang.String treeName)
Create a new tree with given name.void
deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)
Remove a memory block with the given rangeProgramModule
getDefaultRootModule()
Returns the root module for the default program tree.ProgramFragment
getFragment(java.lang.String treeName, Address addr)
Get the fragment that contains the given address within the tree identified by the treeName.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.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.ProgramModule
getRootModule(long treeID)
Get the root module for the tree that has the given ID.ProgramModule
getRootModule(java.lang.String treeName)
Get the root module of the tree with the given name.java.lang.String[]
getTreeNames()
Get the names of all the trees in the program.void
imageBaseChanged(boolean commit)
void
invalidateCache(boolean all)
Clears all data caches.void
moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
Move a memory block to new place.void
programReady(int openMode1, int currentRevision, TaskMonitor monitor)
Callback from program made to each manager after the program has completed initialization.boolean
removeTree(java.lang.String treeName)
Remove the tree with the given name.void
renameTree(java.lang.String oldName, java.lang.String newName)
Rename the tree to the new name.void
setProgram(ProgramDB program)
Set the program.void
setProgramName(java.lang.String oldName, java.lang.String newName)
-
-
-
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 handleerrHandler
- error handleraddrMap
- map to convert addresses to longs and longs to addressesopenMode
- the open mode for the program.lock
- the program synchronization lockmonitor
- Task monitor for upgrading- Throws:
java.io.IOException
- if a database io error occurs.VersionException
- if the database version is different from the expected versionCancelledException
-
-
Method Detail
-
setProgram
public void setProgram(ProgramDB program)
Set the program.- Specified by:
setProgram
in interfaceManagerDB
- 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 interfaceManagerDB
- 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 modulenewName
- 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 treename
- 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 treename
- 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 treeaddr
- 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.
-
deleteAddressRange
public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException
Remove a memory block with the given range- Specified by:
deleteAddressRange
in interfaceManagerDB
- 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
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws AddressOverflowException, CancelledException
Move a memory block to new place.- Specified by:
moveAddressRange
in interfaceManagerDB
- Parameters:
fromRange
- old placetoRange
- new place- Throws:
AddressOverflowException
- if the length is such that a address wrap occursCancelledException
- if the user cancelled the operation via the task monitor.
-
invalidateCache
public void invalidateCache(boolean all) throws java.io.IOException
Description copied from interface:ManagerDB
Clears all data caches.- Specified by:
invalidateCache
in interfaceManagerDB
- 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:
ID
- of the tree- Returns:
- root module
-
-