Package ghidra.program.database.symbol
Class EquateManager
- java.lang.Object
-
- ghidra.program.database.symbol.EquateManager
-
- All Implemented Interfaces:
ErrorHandler,ManagerDB,EquateTable
public class EquateManager extends java.lang.Object implements EquateTable, ErrorHandler, ManagerDB
Implementation for the Equate Table.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDATATYPE_TAGstatic java.lang.StringERROR_TAGstatic java.lang.StringFORMAT_DELIMITER
-
Constructor Summary
Constructors Constructor Description EquateManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyEnum(AddressSetView addresses, Enum enoom, TaskMonitor monitor, boolean shouldDoOnSubOps)Creates equates and/or adds references for scalars in the given address set using the given data type.EquatecreateEquate(java.lang.String name, long value)Creates a new equatevoiddbError(java.io.IOException e)Notification that an IO exception occurred.voiddeleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor)Removes all equates defined in the given range.static java.lang.StringformatNameForEquate(UniversalID dtID, long equateValue)Formats a string to the equate format given the enum UUID and the value for the equate.static java.lang.StringformatNameForEquateError(long equateValue)Formats a string to the equate error format given the value.static UniversalIDgetDataTypeUUID(java.lang.String formattedEquateName)Pulls out the enum data type UUID given a formatted equate name.EquategetEquate(Address reference, int opIndex, long scalarValue)Returns the first equate found that is associated with the given value at the given reference address and operand position;EquategetEquate(java.lang.String name)Returns the equate with the given name, null if no such equate exists.AddressIteratorgetEquateAddresses()Returns an address iterator over all the addresses where equates have been set.AddressIteratorgetEquateAddresses(Address startAddr)Return an address iterator over each address with an equate reference starting at the start address.AddressIteratorgetEquateAddresses(AddressSetView set)Return an address iterator over each address with an equate reference that is in the specified address set.java.util.Iterator<Equate>getEquates()Returns an iterator over all equates.java.util.List<Equate>getEquates(long value)Returns all equates defined for value.java.util.List<Equate>getEquates(Address reference)Returns the equates (one for each scalar and opIndex) at the given reference address.java.util.List<Equate>getEquates(Address reference, int opIndex)Returns the equates (one for each scalar) at the given reference address and operand position; For an instruction a given operand can have multiple scalars.static longgetEquateValueFromFormattedName(java.lang.String formattedEquateName)Pulls out the value of the equate given the formatted equate name.voidinvalidateCache(boolean all)Clears all data caches.voidmoveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)Move all objects within an address range to a new location.voidprogramReady(int openMode, int currentRevision, TaskMonitor monitor)Callback from program made to each manager after the program has completed initialization.booleanremoveEquate(java.lang.String name)Removes the equate from the program.voidsetProgram(ProgramDB program)Callback from program used to indicate all manager have been created.
-
-
-
Field Detail
-
DATATYPE_TAG
public static final java.lang.String DATATYPE_TAG
- See Also:
- Constant Field Values
-
ERROR_TAG
public static final java.lang.String ERROR_TAG
- See Also:
- Constant Field Values
-
FORMAT_DELIMITER
public static final java.lang.String FORMAT_DELIMITER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EquateManager
public EquateManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor) throws VersionException, java.io.IOException
Constructor- Parameters:
handle- database handleaddrMap- map that converts addresses to longs and longs to addressesopenMode- one of ProgramDB.CREATE, UPDATE, UPGRADE, or READ_ONLYlock- the program synchronization lockmonitor- the progress monitor used when upgrading.- Throws:
VersionException- if the database version doesn't match the current version.java.io.IOException- if a database error occurs.CancelledException- if the user cancels the upgrade.
-
-
Method Detail
-
setProgram
public void setProgram(ProgramDB program)
Description copied from interface:ManagerDBCallback 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:
setProgramin interfaceManagerDB- Parameters:
program- the program is set when all the initializations have been completed.- See Also:
ManagerDB.setProgram(ghidra.program.database.ProgramDB)
-
programReady
public void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws java.io.IOException, CancelledExceptionDescription copied from interface:ManagerDBCallback 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:
programReadyin interfaceManagerDB- Parameters:
openMode- 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)
-
dbError
public void dbError(java.io.IOException e)
Description copied from interface:ErrorHandlerNotification that an IO exception occurred.- Specified by:
dbErrorin interfaceErrorHandler- See Also:
ErrorHandler.dbError(java.io.IOException)
-
applyEnum
public void applyEnum(AddressSetView addresses, Enum enoom, TaskMonitor monitor, boolean shouldDoOnSubOps) throws CancelledException
Description copied from interface:EquateTableCreates equates and/or adds references for scalars in the given address set using the given data type. The data type given must be an enumeration data type.- Specified by:
applyEnumin interfaceEquateTable- Parameters:
addresses- the address set to use.enoom- the data type to use.monitor- task monitor to cancel the remove operationshouldDoOnSubOps- true if the enum should be applied inside sub-operands as well.- Throws:
CancelledException- if the operation is cancelled
-
createEquate
public Equate createEquate(java.lang.String name, long value) throws DuplicateNameException, InvalidInputException
Description copied from interface:EquateTableCreates a new equate- Specified by:
createEquatein interfaceEquateTable- Parameters:
name- the name to associate with the given value.value- the value to associate with the given name.- Throws:
DuplicateNameException- thrown if name is already in use as an equate.InvalidInputException- if name contains blank characters, is zero length, or is null- See Also:
EquateTable.createEquate(java.lang.String, long)
-
getEquate
public Equate getEquate(Address reference, int opIndex, long scalarValue)
Description copied from interface:EquateTableReturns the first equate found that is associated with the given value at the given reference address and operand position;- Specified by:
getEquatein interfaceEquateTable- Parameters:
reference- address where the equate is used.opIndex- the operand index of the operand where the equate is used.scalarValue- the value where the equate is used.- Returns:
- the equate or null if there is no such equate.
- See Also:
EquateTable.getEquate(ghidra.program.model.address.Address, int, long)
-
getEquates
public java.util.List<Equate> getEquates(Address reference, int opIndex)
Description copied from interface:EquateTableReturns the equates (one for each scalar) at the given reference address and operand position; For an instruction a given operand can have multiple scalars.- Specified by:
getEquatesin interfaceEquateTable- Parameters:
reference- address where the equate is used.opIndex- the operand index of the operand where the equate is used.- Returns:
- the list of equates or empty list if there is no such equate.
- See Also:
EquateTable.getEquates(ghidra.program.model.address.Address, int)
-
getEquates
public java.util.List<Equate> getEquates(Address reference)
Description copied from interface:EquateTableReturns the equates (one for each scalar and opIndex) at the given reference address. For an instruction a given operand can have multiple scalars.- Specified by:
getEquatesin interfaceEquateTable- Parameters:
reference- address where the equate is used.- Returns:
- the list of equates or empty list if there is no such equate.
- See Also:
EquateTable.getEquates(ghidra.program.model.address.Address)
-
getEquate
public Equate getEquate(java.lang.String name)
Description copied from interface:EquateTableReturns the equate with the given name, null if no such equate exists.- Specified by:
getEquatein interfaceEquateTable- Parameters:
name- the of the equate to be retrieved.- See Also:
EquateTable.getEquate(java.lang.String)
-
getEquateAddresses
public AddressIterator getEquateAddresses()
Description copied from interface:EquateTableReturns an address iterator over all the addresses where equates have been set.- Specified by:
getEquateAddressesin interfaceEquateTable- See Also:
EquateTable.getEquateAddresses()
-
getEquateAddresses
public AddressIterator getEquateAddresses(Address startAddr)
Description copied from interface:EquateTableReturn an address iterator over each address with an equate reference starting at the start address.- Specified by:
getEquateAddressesin interfaceEquateTable- Parameters:
startAddr- start address- Returns:
- an AddressIterator over addresses with defined equate references
- See Also:
EquateTable.getEquateAddresses(ghidra.program.model.address.Address)
-
getEquateAddresses
public AddressIterator getEquateAddresses(AddressSetView set)
Description copied from interface:EquateTableReturn an address iterator over each address with an equate reference that is in the specified address set.- Specified by:
getEquateAddressesin interfaceEquateTable- Parameters:
set- the address set- Returns:
- AddressIterator over addresses with defined equate references
- See Also:
EquateTable.getEquateAddresses(ghidra.program.model.address.AddressSetView)
-
getEquates
public java.util.Iterator<Equate> getEquates()
Description copied from interface:EquateTableReturns an iterator over all equates.- Specified by:
getEquatesin interfaceEquateTable- See Also:
EquateTable.getEquates()
-
getEquates
public java.util.List<Equate> getEquates(long value)
Description copied from interface:EquateTableReturns all equates defined for value.- Specified by:
getEquatesin interfaceEquateTable- Parameters:
value- the value to get all equates for.- See Also:
EquateTable.getEquates(long)
-
deleteAddressRange
public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException
Description copied from interface:EquateTableRemoves all equates defined in the given range.- Specified by:
deleteAddressRangein interfaceEquateTable- Specified by:
deleteAddressRangein interfaceManagerDB- Parameters:
startAddr- start of the rangeendAddr- end of the rangemonitor- task monitor to cancel the remove operation- Throws:
CancelledException- if the operation was cancelled.- See Also:
ManagerDB.deleteAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, ghidra.util.task.TaskMonitor)
-
removeEquate
public boolean removeEquate(java.lang.String name)
Description copied from interface:EquateTableRemoves the equate from the program.- Specified by:
removeEquatein interfaceEquateTable- Parameters:
name- the name of the equate to remove.- Returns:
- true if the equate existed, false otherwise.
- See Also:
EquateTable.removeEquate(java.lang.String)
-
invalidateCache
public void invalidateCache(boolean all)
Description copied from interface:ManagerDBClears all data caches.- Specified by:
invalidateCachein 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.- See Also:
ManagerDB.invalidateCache(boolean)
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
Description copied from interface:ManagerDBMove all objects within an address range to a new location.- Specified by:
moveAddressRangein 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:
CancelledException- if the user cancelled the operation via the task monitor.- See Also:
ManagerDB.moveAddressRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address, long, ghidra.util.task.TaskMonitor)
-
formatNameForEquate
public static java.lang.String formatNameForEquate(UniversalID dtID, long equateValue)
Formats a string to the equate format given the enum UUID and the value for the equate. The formatted strings are used when setting equates from datatypes so that information can be stored with an equate to point back to that datatype.- Parameters:
dtID- The enums data type UUIDequateValue- The value intended for the equate- Returns:
- The formatted equate name
-
formatNameForEquateError
public static java.lang.String formatNameForEquateError(long equateValue)
Formats a string to the equate error format given the value. Used for rendering formatted equates that do not point back to a datatype.- Parameters:
equateValue- The value of the equate- Returns:
- The error formatted equate name
-
getDataTypeUUID
public static UniversalID getDataTypeUUID(java.lang.String formattedEquateName)
Pulls out the enum data type UUID given a formatted equate name. This UUID should point back to a datatype.- Parameters:
formattedEquateName- The formatted equate name to pull the UUID from- Returns:
- The enum data type UUID or null if the given name is not formatted.
-
getEquateValueFromFormattedName
public static long getEquateValueFromFormattedName(java.lang.String formattedEquateName)
Pulls out the value of the equate given the formatted equate name. The value stored in the equate info is a decimal.- Parameters:
formattedEquateName- The formatted equate name to pull the value from- Returns:
- The value of the equate, or -1 if the given name is not formatted.
-
-