Package ghidra.program.database.code
Class CodeManager
- java.lang.Object
-
- ghidra.program.database.code.CodeManager
-
- All Implemented Interfaces:
ErrorHandler
,ManagerDB
public class CodeManager extends java.lang.Object implements ErrorHandler, ManagerDB
Class to manage database tables for data and instructions.
-
-
Constructor Summary
Constructors Constructor Description CodeManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor)
Constructs a new CodeManager for a program.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateContextLocking()
AddressSetView
addInstructions(InstructionSet instructionSet, boolean overwrite)
Creates a complete set of instructions.void
checkContextWrite(Address start, Address end)
Check if any instruction intersects the specified address rangevoid
clearAll(boolean clearContext, TaskMonitor monitor)
Clear all code units in the program.void
clearCodeUnits(Address start, Address end, boolean clearContext, TaskMonitor monitor)
Remove code units, symbols, equates, and references to code units in the given range (inclusive).void
clearComments(Address start, Address end)
Clears all comments in the given range (inclusive).void
clearData(long[] dataTypeIDs, TaskMonitor monitor)
Removes any data objects that have dataTypes matching the given dataType ids.void
clearProperties(Address start, Address end, TaskMonitor monitor)
Clears the properties in the given range (inclusive).Data
createCodeUnit(Address addr, DataType dataType, int length)
Creates a data at the specified address.Instruction
createCodeUnit(Address address, InstructionPrototype prototype, MemBuffer memBuf, ProcessorContextView context)
Creates an instruction at the specified address.void
dbError(java.io.IOException e)
Notification that an IO exception occurred.void
deleteAddressRange(Address start, Address end, TaskMonitor monitor)
Removes the block of defined bytes from the listing.void
fallThroughChanged(Address fromAddr, Reference newFallThroughRef)
Callback from ReferenceManager when a new fall-through reference is set.CodeUnit
getCodeUnitAfter(Address addr)
Returns the next code unit whose min address is greater than the specified address.CodeUnit
getCodeUnitAt(Address address)
Returns the code unit whose min address equals the specified address.CodeUnit
getCodeUnitBefore(Address address)
Returns the next code unit whose min address is closest to and less than the specified address.CodeUnit
getCodeUnitContaining(Address address)
Returns the code unit whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.CodeUnitIterator
getCodeUnitIterator(java.lang.String property, Address address, boolean forward)
Get an iterator that contains the code units which have the specified property type defined.CodeUnitIterator
getCodeUnitIterator(java.lang.String property, AddressSetView addrSetView, boolean forward)
Get an iterator that contains the code units which have the specified property type defined.CodeUnitIterator
getCodeUnits(Address start, boolean forward)
Returns an iterator over all codeUnits in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.CodeUnitIterator
getCodeUnits(AddressSetView set, boolean forward)
Returns an iterator over all codeUnits in the given addressSet.java.lang.String
getComment(int commentType, Address address)
Get the comment for the given type at the specified address.AddressIterator
getCommentAddressIterator(int commentType, AddressSetView set, boolean forward)
Get a forward iterator over addresses that have comments of the given type.AddressIterator
getCommentAddressIterator(AddressSetView addrSet, boolean forward)
Get a forward iterator over addresses that have comments of any type.CodeUnitIterator
getCommentCodeUnitIterator(int commentType, AddressSetView set)
Get a forward iterator over code units that have comments of the given type.CommentHistory[]
getCommentHistory(Address addr, int commentType)
Get the comment history for the comment type at the given addressDataIterator
getCompositeData(Address start, boolean forward)
Returns a composite data iterator beginning at the specified start address.DataIterator
getCompositeData(AddressSetView addrSet, boolean forward)
Returns a composite data iterator limited to the addresses in the specified address set.DataIterator
getData(Address start, boolean forward)
Returns an iterator over all data in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.DataIterator
getData(AddressSetView addrSet, boolean forward)
Returns an iterator over all data in the given addressSet.Data
getDataAfter(Address addr)
Returns the next data whose min address is greater than the specified address.Data
getDataAt(Address address)
Returns the data whose min address equals the specified address.Data
getDataBefore(Address addr)
Returns the next data whose min address is closest to and less than the specified address.Data
getDataContaining(Address addr)
Returns the data whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.DataIterator
getDefinedData(Address address, boolean forward)
Returns an iterator over all defined data in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.DataIterator
getDefinedData(AddressSetView addrSet, boolean forward)
Returns an iterator over all defined data in the given addressSet.Data
getDefinedDataAfter(Address addr)
Returns the next defined data whose min address is greater than the specified address.Data
getDefinedDataAt(Address address)
Returns the defined data whose min address equals the specified address.Data
getDefinedDataBefore(Address addr)
Returns the next defined data whose min address is closest to and less than the specified address.Data
getDefinedDataContaining(Address addr)
Returns the defined data whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.Data
getFirstUndefinedData(AddressSetView set, TaskMonitor monitor)
Returns the next undefined data whose min address falls within the address set searching in the forward direction (e.g., 0 -> 0xfff).Data
getFirstUndefinedDataAfter(Address addr, TaskMonitor monitor)
Returns the next undefined data whose min address is greater than the specified address.Data
getFirstUndefinedDataBefore(Address addr, TaskMonitor monitor)
Returns the next undefined data whose min address is closest to and less than the specified address.Instruction
getInstructionAfter(Address addr)
Returns the next instruction whose min address is greater than the specified address.Instruction
getInstructionAt(Address address)
Returns the instruction whose min address equals the specified address or null if the address is not the beginning address of some codeunit.Instruction
getInstructionBefore(Address addr)
Returns the next instruction whose min address is closest to and less than the specified address.Instruction
getInstructionContaining(Address address)
Returns the instruction whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.protected Record
getInstructionRecord(long addr)
InstructionIterator
getInstructions(Address address, boolean forward)
Returns an iterator over all instructions in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.InstructionIterator
getInstructions(AddressSetView set, boolean forward)
Returns an iterator over all instructions in the given addressSet.int
getNumDefinedData()
Returns the number of defined data in the program.int
getNumInstructions()
Returns the number of instructions in the program.PropertyMap
getPropertyMap(java.lang.String propertyName)
Returns the property map object that is associated with the specified property name.ReferenceManager
getReferenceMgr()
Returns the reference manager being used by this code manager.Data
getUndefinedAt(Address address)
Returns the undefined data whose min address equals the specified address.AddressSetView
getUndefinedRanges(AddressSetView set, boolean initializedMemoryOnly, TaskMonitor monitor)
java.util.Iterator<java.lang.String>
getUserDefinedProperties()
Returns an iterator over all user-defined properties.void
invalidateCache(boolean all)
Invalidates all cached database objectsvoid
invalidateCodeUnitCache()
Invalidates the cache for the codeUnits.protected boolean
isUndefined(Address address, long addr)
boolean
isUndefined(Address start, Address end)
Checks if all the addresses from start to end have undefined data.void
memoryChanged(Address addr, Address end)
Notification that memory has changed, so clear the cache for the affected code units.void
moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor)
Move a block of code from one address to a new address.void
programReady(int openMode, int currentRevision, TaskMonitor monitor)
Callback from program made to each manager after the program has completed initialization.void
reDisassembleAllInstructions(int bookmarkLimit, TaskMonitor monitor)
Complete language transformation of all instructions.void
removeUserDefinedProperty(java.lang.String propertyName)
Removes the user-defined property with the specified property name.void
replaceDataTypes(long oldDataTypeID, long newDataTypeID)
void
setComment(Address address, int commentType, java.lang.String comment)
Set the comment for the given comment type at the specified address.void
setProgram(ProgramDB program)
Set the program after all the managers have been created.void
updateDataReferences(Data data)
Update the data references on this data item.
-
-
-
Constructor Detail
-
CodeManager
public CodeManager(DBHandle handle, AddressMap addrMap, int openMode, Lock lock, TaskMonitor monitor) throws VersionException, CancelledException, java.io.IOException
Constructs a new CodeManager for a program.- Parameters:
handle
- handle to databaseaddrMap
- addressMap to convert between addresses and long values.openMode
- either READ_ONLY, UPDATE, or UPGRADElock
- the program synchronization lockmonitor
- the task monitor use while upgrading.- Throws:
VersionException
- if the database is incompatible with the current schemajava.io.IOException
- if a database io error occursCancelledException
- if the user cancels the upgrade operation
-
-
Method Detail
-
setProgram
public void setProgram(ProgramDB program)
Set the program after all the managers have been created.- Specified by:
setProgram
in interfaceManagerDB
- Parameters:
program
- The program object that this manager belongs to.
-
programReady
public void programReady(int openMode, 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:
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)
-
activateContextLocking
public void activateContextLocking()
-
dbError
public void dbError(java.io.IOException e)
Description copied from interface:ErrorHandler
Notification that an IO exception occurred.- Specified by:
dbError
in interfaceErrorHandler
- See Also:
ErrorHandler.dbError(java.io.IOException)
-
addInstructions
public AddressSetView addInstructions(InstructionSet instructionSet, boolean overwrite)
Creates a complete set of instructions. A preliminary pass will be made checking for code unit conflicts which will be marked within the instructionSet causing dependent blocks to get pruned.- Parameters:
instructionSet
- the set of instructions to be added. All code unit conflicts will be marked within the instructionSet and associated blocks.- Throws:
CodeUnitInsertionException
- if the instruction set is incompatible with the program memory
-
createCodeUnit
public Instruction createCodeUnit(Address address, InstructionPrototype prototype, MemBuffer memBuf, ProcessorContextView context) throws CodeUnitInsertionException
Creates an instruction at the specified address.- Parameters:
address
- start address of instructionprototype
- instruction definition objectmemBuf
- the MemBuffer to use to get the bytes from memorycontext
- object that has the state of all the registers.- Throws:
CodeUnitInsertionException
- thrown if code unit overlaps with an existing code unit
-
deleteAddressRange
public void deleteAddressRange(Address start, Address end, TaskMonitor monitor) throws CancelledException
Removes the block of defined bytes from the listing. All necessary checks will be made by listing before this method is called, so just do the work.- Specified by:
deleteAddressRange
in interfaceManagerDB
- Parameters:
start
- the first address in the range.end
- the last address in the range.monitor
- the TaskMonitor that tracks progress and is used to tell if the user cancels the operation.- Throws:
CancelledExeption
- if the user cancels the operation.CancelledException
- if the user cancelled the operation via the task monitor.
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException
Move a block of code from one address to a new address. Updates all property managers, symbols, and references.- Specified by:
moveAddressRange
in interfaceManagerDB
- Parameters:
fromAddr
- the first address in the range to be moved.toAddr
- the address to move to.length
- the number of addresses to move.monitor
- the TaskMonitor that tracks progress and is used to tell if the user cancels the operation.- Throws:
CancelledExeption
- if the user cancels the operation.CancelledException
- if the user cancelled the operation via the task monitor.
-
getCodeUnitAt
public CodeUnit getCodeUnitAt(Address address)
Returns the code unit whose min address equals the specified address.- Parameters:
address
- the min address of the code unit to return- Returns:
- CodeUnit the code unit at the specified address, or null if a code unit does not exist
-
getCodeUnitAfter
public CodeUnit getCodeUnitAfter(Address addr)
Returns the next code unit whose min address is greater than the specified address.- Parameters:
addr
- the address to look after- Returns:
- CodeUnit the code unit after the specified address, or null if a code unit does not exist
-
getUserDefinedProperties
public java.util.Iterator<java.lang.String> getUserDefinedProperties()
Returns an iterator over all user-defined properties.- Returns:
- Iterator an iterator over all user-defined properties
-
removeUserDefinedProperty
public void removeUserDefinedProperty(java.lang.String propertyName)
Removes the user-defined property with the specified property name.- Parameters:
propertyName
- the name of the user-defined property to remove
-
getPropertyMap
public PropertyMap getPropertyMap(java.lang.String propertyName)
Returns the property map object that is associated with the specified property name.- Parameters:
propertyName
- the name of the property- Returns:
- PropertyMap the property map object associated to the property name
-
getCodeUnitBefore
public CodeUnit getCodeUnitBefore(Address address)
Returns the next code unit whose min address is closest to and less than the specified address.- Parameters:
address
- the address to look before- Returns:
- CodeUnit the code unit before the specified address, or null if a code unit does not exist
-
getCodeUnitContaining
public CodeUnit getCodeUnitContaining(Address address)
Returns the code unit whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.codeunit.minAddress() <= addr <= codeunit.maxAddress()
- Parameters:
address
- the address for which to find the code containing it.- Returns:
- CodeUnit the code unit containing the specified address, or null if a code unit does not exist
-
getCodeUnitIterator
public CodeUnitIterator getCodeUnitIterator(java.lang.String property, Address address, boolean forward)
Get an iterator that contains the code units which have the specified property type defined. Only code units at an address greater than or equal to the specified start address will be returned by the iterator. If the start address is null then check the entire program.
Standard property types are defined in the CodeUnit class. The property types are:- COMMENT_PROPERTY
- INSTRUCTION_PROPERTY
- DEFINED_DATA_PROPERTY
- Parameters:
property
- the name of the user defined property type or special standard name from above.address
- the address to start the iterator, or null to iterator the entire programforward
- true means get iterator in the forward direction- Returns:
- a CodeUnitIterator that returns all code units from the indicated start address that have the specified property type defined.
-
getCodeUnitIterator
public CodeUnitIterator getCodeUnitIterator(java.lang.String property, AddressSetView addrSetView, boolean forward)
Get an iterator that contains the code units which have the specified property type defined. Only code units starting within the address set specified will be returned by the iterator. If the address set is null then check the entire program.
Standard property types are defined in the CodeUnit class. The property types are:- REFERENCE_PROPERTY
- INSTRUCTION_PROPERTY
- DEFINED_DATA_PROPERTY
- Parameters:
property
- the name of the property type, or this can be user defined.addrSetView
- the address set to iterate, or null to iterate over the entire programforward
- true means the iterator is in the forward direction- Returns:
- a CodeUnitIterator that returns all code units from the indicated address set that have the specified property type defined.
-
getCommentCodeUnitIterator
public CodeUnitIterator getCommentCodeUnitIterator(int commentType, AddressSetView set)
Get a forward iterator over code units that have comments of the given type.- Parameters:
commentType
- comment type defined in CodeUnitset
- address set
-
getCommentAddressIterator
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView set, boolean forward)
Get a forward iterator over addresses that have comments of the given type.- Parameters:
commentType
- comment type defined in CodeUnitset
- address set
-
getCommentAddressIterator
public AddressIterator getCommentAddressIterator(AddressSetView addrSet, boolean forward)
Get a forward iterator over addresses that have comments of any type.- Parameters:
set
- address set
-
getInstructionAt
public Instruction getInstructionAt(Address address)
Returns the instruction whose min address equals the specified address or null if the address is not the beginning address of some codeunit.- Parameters:
address
- the min address of the instruction to return- Returns:
- CodeUnit the instruction at the specified address, or null if a instruction does not exist starting at the given address.
-
getDefinedDataAt
public Data getDefinedDataAt(Address address)
Returns the defined data whose min address equals the specified address.- Parameters:
address
- the min address of the data defined to return- Returns:
- CodeUnit the defined data at the specified address, or null if a defined data does not exist
-
getInstructionBefore
public Instruction getInstructionBefore(Address addr)
Returns the next instruction whose min address is closest to and less than the specified address.- Parameters:
addr
- the address to look before- Returns:
- Instruction the instruction before the specified address, or null if a instruction does not exist
-
getInstructionAfter
public Instruction getInstructionAfter(Address addr)
Returns the next instruction whose min address is greater than the specified address.- Parameters:
addr
- the address to look after- Returns:
- Instruction the instruction after the specified address, or null if a instruction does not exist
-
getInstructionContaining
public Instruction getInstructionContaining(Address address)
Returns the instruction whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.instruction.minAddress() <= addr <= instruction.maxAddress()
- Parameters:
address
- the address to be contained- Returns:
- Instruction the instruction containing the specified address, or null if a instruction does not exist
-
getDataAt
public Data getDataAt(Address address)
Returns the data whose min address equals the specified address.- Parameters:
address
- the min address of the data to return- Returns:
- Data the data at the specified address, or null if data does not exist
-
getDataBefore
public Data getDataBefore(Address addr)
Returns the next data whose min address is closest to and less than the specified address.- Parameters:
addr
- the address to look before- Returns:
- Data the data before the specified address, or null if a data does not exist
-
getDataAfter
public Data getDataAfter(Address addr)
Returns the next data whose min address is greater than the specified address.- Parameters:
addr
- the address to look after- Returns:
- Data the data after the specified address, or null if a data does not exist
-
getDataContaining
public Data getDataContaining(Address addr)
Returns the data whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.data.minAddress() <= addr <= data.maxAddress()
- Parameters:
addr
- the address to be contained- Returns:
- Data the data containing the specified address, or null if a data does not exist that starts at that address.
-
getDefinedDataAfter
public Data getDefinedDataAfter(Address addr)
Returns the next defined data whose min address is greater than the specified address.- Parameters:
addr
- the address to look after- Returns:
- Data the defined data after the specified address, or null if a defined data does not exist
-
getDefinedDataBefore
public Data getDefinedDataBefore(Address addr)
Returns the next defined data whose min address is closest to and less than the specified address.- Parameters:
addr
- the address to look before- Returns:
- Data the defined data before the specified address, or null if a defined data does not exist
-
getDefinedDataContaining
public Data getDefinedDataContaining(Address addr)
Returns the defined data whose min address is less than or equal to the specified address and whose max address is greater than or equal to the specified address.data.minAddress() <= addr <= data.maxAddress()
- Parameters:
addr
- the address to be contained- Returns:
- Data the defined data containing the specified address, or null if a defined data does not exist
-
getUndefinedRanges
public AddressSetView getUndefinedRanges(AddressSetView set, boolean initializedMemoryOnly, TaskMonitor monitor) throws CancelledException
- Throws:
CancelledException
-
getUndefinedAt
public Data getUndefinedAt(Address address)
Returns the undefined data whose min address equals the specified address.- Parameters:
address
- the min address of the undefined data to return- Returns:
- Data the undefined data at the specified address, or null if undefined data does not exist
-
getFirstUndefinedDataAfter
public Data getFirstUndefinedDataAfter(Address addr, TaskMonitor monitor)
Returns the next undefined data whose min address is greater than the specified address.- Parameters:
addr
- the address to look after- Returns:
- Data the undefined data after the specified address, or null if a undefined data does not exist
-
getFirstUndefinedData
public Data getFirstUndefinedData(AddressSetView set, TaskMonitor monitor)
Returns the next undefined data whose min address falls within the address set searching in the forward direction (e.g., 0 -> 0xfff).- Parameters:
addrSet
- the address Set to look within- Returns:
- Data the first undefined data within the address set, or null if there is none.
-
getFirstUndefinedDataBefore
public Data getFirstUndefinedDataBefore(Address addr, TaskMonitor monitor)
Returns the next undefined data whose min address is closest to and less than the specified address.- Parameters:
addr
- the address to look before- Returns:
- Data the undefined data before the specified address, or null if a undefined data does not exist
-
createCodeUnit
public Data createCodeUnit(Address addr, DataType dataType, int length) throws CodeUnitInsertionException
Creates a data at the specified address.- Parameters:
addr
- Starting address of code unitdataType
- data prototype for the code unit- Throws:
CodeUnitInsertionException
- thrown if code unit overlaps with an existing code unit
-
updateDataReferences
public void updateDataReferences(Data data)
Update the data references on this data item. Get rid of any references first, then add in any new ones.- Parameters:
data
- the data object to be updated
-
clearComments
public void clearComments(Address start, Address end)
Clears all comments in the given range (inclusive).- Parameters:
start
- the start address of the range to clearend
- the end address of the range to clear
-
clearProperties
public void clearProperties(Address start, Address end, TaskMonitor monitor) throws CancelledException
Clears the properties in the given range (inclusive).- Parameters:
start
- the start address of the range to clearend
- the end address of the range to clear- Throws:
CancelledException
-
clearCodeUnits
public void clearCodeUnits(Address start, Address end, boolean clearContext, TaskMonitor monitor) throws CancelledException
Remove code units, symbols, equates, and references to code units in the given range (inclusive). Comments and comment history will be retained.- Parameters:
start
- the start address of the range to clearend
- the end address of the range to clearclearContext
- if true all context-register values will be cleared over rangemonitor
- the TaskMonitor that tracks progress and is used to tell if the user cancels the operation.- Throws:
CancelledException
-
clearAll
public void clearAll(boolean clearContext, TaskMonitor monitor)
Clear all code units in the program.
-
getNumInstructions
public int getNumInstructions()
Returns the number of instructions in the program.
-
getNumDefinedData
public int getNumDefinedData()
Returns the number of defined data in the program.
-
getCompositeData
public DataIterator getCompositeData(Address start, boolean forward)
Returns a composite data iterator beginning at the specified start address.- Parameters:
start
- the address to begin iteratorforward
- true means get iterator in forward direction- Returns:
- DataIterator the composite data iterator
-
getCompositeData
public DataIterator getCompositeData(AddressSetView addrSet, boolean forward)
Returns a composite data iterator limited to the addresses in the specified address set.- Parameters:
addrSet
- the address set to limit the iteratorforward
- determines if the iterator will go from the lowest address to the highest or the other way around.- Returns:
- DataIterator the composite data iterator
-
getCodeUnits
public CodeUnitIterator getCodeUnits(Address start, boolean forward)
Returns an iterator over all codeUnits in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.- Parameters:
start
- the starting address for the iterator.forward
- if true the iterator returns all codeUnits from the given start address to the end of the program, otherwise it returns all codeUnits from the given start address to the start of the program.
-
getCodeUnits
public CodeUnitIterator getCodeUnits(AddressSetView set, boolean forward)
Returns an iterator over all codeUnits in the given addressSet. The iterator will go from the lowest address to the largest or from the largest to the lowest depending on the forward parameter.- Parameters:
forward
- determines if the iterator goes from lowest address to highest or the other way around.
-
getInstructions
public InstructionIterator getInstructions(Address address, boolean forward)
Returns an iterator over all instructions in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.- Parameters:
address
- the starting address for the iterator.forward
- if true the iterator returns all instructions from the given start address to the end of the program, otherwise it returns all instructions from the given start address to the start of the program.
-
getDefinedData
public DataIterator getDefinedData(Address address, boolean forward)
Returns an iterator over all defined data in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.- Parameters:
address
- the starting address for the iterator.forward
- if true the iterator returns all defined data from the given start address to the end of the program, otherwise it returns all defined data from the given start address to the start of the program.
-
getInstructions
public InstructionIterator getInstructions(AddressSetView set, boolean forward)
Returns an iterator over all instructions in the given addressSet. The iterator will go from the lowest address to the largest or from the largest to the lowest depending on the forward parameter.- Parameters:
forward
- determines if the iterator goes from lowest address to highest or the other way around.
-
getData
public DataIterator getData(Address start, boolean forward)
Returns an iterator over all data in the program from the given start address to either the end address or the start address, depending if the iterator is forward or not.- Parameters:
start
- the starting address for the iterator.forward
- if true the iterator returns all data from the given start address to the end of the program, otherwise it returns all data from the given start address to the start of the program.
-
getData
public DataIterator getData(AddressSetView addrSet, boolean forward)
Returns an iterator over all data in the given addressSet. The iterator will go from the lowest address to the largest or from the largest to the lowest depending on the forward parameter.- Parameters:
forward
- determines if the iterator goes from lowest address to highest or the other way around.
-
getDefinedData
public DataIterator getDefinedData(AddressSetView addrSet, boolean forward)
Returns an iterator over all defined data in the given addressSet. The iterator will go from the lowest address to the largest or from the largest to the lowest depending on the forward parameter.- Parameters:
forward
- determines if the iterator goes from lowest address to highest or the other way around.
-
checkContextWrite
public void checkContextWrite(Address start, Address end) throws ContextChangeException
Check if any instruction intersects the specified address range- Parameters:
start
- start of rangeend
- end of range- Throws:
ContextChangeException
-
isUndefined
public boolean isUndefined(Address start, Address end)
Checks if all the addresses from start to end have undefined data.- Parameters:
start
- the first address in the range to check.end
- the last address in the range to check.- Returns:
- true if all the addresses in the range have undefined data.
-
isUndefined
protected boolean isUndefined(Address address, long addr)
-
clearData
public void clearData(long[] dataTypeIDs, TaskMonitor monitor) throws CancelledException
Removes any data objects that have dataTypes matching the given dataType ids.- Parameters:
dataTypeIDs
- the list of ids of dataTypes that have been deleted.monitor
- TaskMonitor used to monitor progress and keeps track if the user cancels the operation.- Throws:
CancelledException
-
getReferenceMgr
public ReferenceManager getReferenceMgr()
Returns the reference manager being used by this code manager.- Returns:
- ReferenceManager the reference manager being used by this code manager
-
getInstructionRecord
protected Record getInstructionRecord(long addr)
-
invalidateCache
public void invalidateCache(boolean all)
Invalidates all cached database objects- 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.
-
invalidateCodeUnitCache
public void invalidateCodeUnitCache()
Invalidates the cache for the codeUnits.
-
memoryChanged
public void memoryChanged(Address addr, Address end)
Notification that memory has changed, so clear the cache for the affected code units.- Parameters:
addr
- start of changeend
- end address of change
-
fallThroughChanged
public void fallThroughChanged(Address fromAddr, Reference newFallThroughRef)
Callback from ReferenceManager when a new fall-through reference is set.- Parameters:
fromAddr
- fall-through from locationnewFallThroughRef
- new fallthrough reference or null if removed
-
getComment
public java.lang.String getComment(int commentType, Address address)
Get the comment for the given type at the specified address.- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, PLATE_COMMENT, or REPEATABLE_COMMENTaddress
- the address of the comment.- Returns:
- the comment string of the appropriate type or null if no comment of that type exists for this codeunit
- Throws:
java.lang.IllegalArgumentException
- if type is not one of the types of comments supported
-
setComment
public void setComment(Address address, int commentType, java.lang.String comment)
Set the comment for the given comment type at the specified address.- Parameters:
address
- the address of the comment.commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, PLATE_COMMENT, or REPEATABLE_COMMENTcomment
- comment to set at the address- Throws:
java.lang.IllegalArgumentException
- if type is not one of the types of comments supported
-
getCommentHistory
public CommentHistory[] getCommentHistory(Address addr, int commentType)
Get the comment history for the comment type at the given address- Parameters:
addr
- address for the comment historycommentType
- comment type- Returns:
- zero length array if no history exists
-
replaceDataTypes
public void replaceDataTypes(long oldDataTypeID, long newDataTypeID)
-
reDisassembleAllInstructions
public void reDisassembleAllInstructions(int bookmarkLimit, TaskMonitor monitor) throws java.io.IOException, CancelledException
Complete language transformation of all instructions. All existing prototypes will be discarded and all instructions redisassembled following flow and adjusting context as needed. Instructions which fail to redisassemble will be marked - since only one byte will be skipped, such bad instruction disassembly may cause subsequent errors due to possible instruction shift. This method is only intended for use by the ProgramDB setLanguage method.- Parameters:
lang
- new languagebookmarkLimit
- maximum number of errors to bookmarkmonitor
- task monitor- Throws:
java.io.IOException
CancelledException
LockException
-
-