Package ghidra.program.database.module
Class TreeManager
java.lang.Object
ghidra.program.database.module.TreeManager
- All Implemented Interfaces:
ManagerDB
Manage the set of trees in the program.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the default tree that is created when a program is created. -
Constructor Summary
ConstructorDescriptionTreeManager
(DBHandle handle, ErrorHandler errHandler, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) Construct a new TreeManager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMemoryBlock
(String name, AddressRange range) Add a memory block with the given range.createRootModule
(String treeName) Create a new tree with given name.void
deleteAddressRange
(Address startAddr, Address endAddr, TaskMonitor monitor) Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.Returns the root module for the default program tree.getFragment
(String treeName, Address addr) Get the fragment that contains the given address within the tree identified by the treeName.getFragment
(String treeName, String name) Get the fragment with the given name that is in the tree identified by the treeName.Get the module with the given name that is in the tree identified by the treeName.getRootModule
(long treeID) Get the root module for the tree that has the given ID.getRootModule
(String treeName) Get the root module of the tree with the given name.String[]
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 all objects within an address range to a new location.void
programReady
(OpenMode openMode1, int currentRevision, TaskMonitor monitor) Callback from program made to each manager after the program has completed initialization.boolean
removeTree
(String treeName) Remove the tree with the given name.void
renameTree
(String oldName, String newName) Rename the tree to the new name.void
setProgram
(ProgramDB program) Callback from program used to indicate all manager have been created.void
setProgramName
(String oldName, String newName)
-
Field Details
-
DEFAULT_TREE_NAME
The name of the default tree that is created when a program is created.- See Also:
-
-
Constructor Details
-
TreeManager
public TreeManager(DBHandle handle, ErrorHandler errHandler, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) throws 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:
IOException
- if a database io error occurs.VersionException
- if the database version is different from the expected versionCancelledException
- if instantiation has been cancelled
-
-
Method Details
-
setProgram
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 interfaceManagerDB
- 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 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:
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
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
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
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
Get the names of all the trees in the program.- Returns:
- sorted array of tree names
-
renameTree
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
Remove the tree with the given name.- Parameters:
treeName
- tree name- Returns:
- true if the tree was removed
-
getModule
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
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
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
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 singleAddressSpace
.- 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
- 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 interfaceManagerDB
- 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 occursCancelledException
- if the user cancelled the operation via the task monitor.
-
invalidateCache
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:
IOException
- if a database io error occurs.
-
setProgramName
-
getRootModule
Get the root module for the tree that has the given ID.- Parameters:
treeID
- ID of the tree- Returns:
- root module
-