Package ghidra.program.database.data
Class DataTypeManagerDB
java.lang.Object
ghidra.program.database.data.DataTypeManagerDB
- All Implemented Interfaces:
DataTypeManager
- Direct Known Subclasses:
ProgramBasedDataTypeManagerDB
,StandAloneDataTypeManager
Base class for DB-backed data type managers.
Important Notes:
Important Notes:
- When invoking
DataType.isEquivalent(DataType)
involving DataTypeDB objects it is important to invoke the method on DataTypeDB. This will ensure that the internal optimization mechanisms are used. - It is important that the use of
DataType.clone(DataTypeManager)
andDataType.copy(DataTypeManager)
be avoided when possible to ensure full benefit of theequivalenceCache
andresolveCache
.
-
Field Summary
Modifier and TypeFieldDescriptionprotected AddressMap
protected final DBHandle
static final byte
protected DataTypeManagerChangeListenerHandler
protected final ErrorHandler
protected final Lock
protected final boolean
protected ghidra.program.database.data.SourceArchiveAdapter
protected final String
protected UniversalID
static final byte
Fields inherited from interface ghidra.program.model.data.DataTypeManager
BAD_DATATYPE_ID, BUILT_IN_ARCHIVE_KEY, BUILT_IN_ARCHIVE_UNIVERSAL_ID, BUILT_IN_DATA_TYPES_NAME, DEFAULT_DATATYPE_ID, LOCAL_ARCHIVE_KEY, LOCAL_ARCHIVE_UNIVERSAL_ID, NULL_DATATYPE_ID
-
Constructor Summary
ModifierConstructorDescriptionprotected
DataTypeManagerDB
(DBHandle handle, AddressMap addrMap, OpenMode openMode, String tablePrefix, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) Constructor for a database-backedDataTypeManagerDB
extension.protected
DataTypeManagerDB
(ResourceFile packedDBfile, OpenMode openMode, TaskMonitor monitor) Constructor for a data-type manager backed by a packed database file.protected
DataTypeManagerDB
(DataOrganization dataOrganization) Construct a new temporary data-type manager. -
Method Summary
Modifier and TypeMethodDescriptionaddDataType
(DataType originalDataType, DataTypeConflictHandler handler) Returns a data type after adding it to this data manager.void
Add a listener that is notified when the dataTypeManger changes.void
addDataTypes
(Collection<DataType> dataTypes, DataTypeConflictHandler handler, TaskMonitor monitor) Sequentially adds a collection of datatypes to this data manager.protected void
addDataTypeToDelete
(long id) Queue a datatype to deleted in response to another datatype being deleted.protected void
addDataTypeToReplace
(DataType oldDataType, DataType replacementDataType) Queue a datatype to be replaced by another datatype in response to its referenced datatype being replaced.void
addInvalidatedListener
(InvalidatedListener listener) Adds a listener that will be notified when this manager's cache is invalidated.boolean
Determine if settings are supported for BuiltIn datatypes within this datatype manager.final boolean
Determine if settings are supported for datatype components within this datatype manager (i.e., for structure and union components).void
associateDataTypeWithArchive
(DataType datatype, SourceArchive archive) Change the given data type and its dependencies so thier source archive is set to given archive.protected void
categoryCreated
(Category cat) protected void
categoryMoved
(CategoryPath oldPath, Category category) protected void
categoryRemoved
(Category parent, String name, long categoryID) protected void
categoryRenamed
(CategoryPath oldPath, Category category) void
close()
Closes this dataType managerprotected void
compilerSpecChanged
(TaskMonitor monitor) Perform updates related to a compiler spec change, including: data organization changes which may impact datatype components and packing NOTE: this manager must be open for update.boolean
Return true if the given dataType exists in this data type managerboolean
containsCategory
(CategoryPath path) Returns true if the given category path exists in this datatype managercreateCategory
(CategoryPath path) Create a category for the given path; returns the current category if it already exitsprotected void
dataTypeAdded
(DataType newDt, DataType originalDataType) void
dataTypeChanged
(DataType dt, boolean isAutoChange) Notification when data type is changed.protected void
dataTypeDeleted
(long deletedID, DataTypePath deletedDataTypePath) protected void
dataTypeMoved
(DataType dt, DataTypePath oldDataTypePath, DataTypePath newDataTypePath) protected void
dataTypeNameChanged
(DataType dt, String oldName) protected void
dataTypeReplaced
(long existingDtID, DataTypePath replacedDataTypePath, DataType replacementDt) void
Notification when data type settings have changed.void
Handles IOExceptionsvoid
dedupeAllConflicts
(TaskMonitor monitor) De-duplicate equivalent conflict datatypes which share a common base data type name and are found to be equivalent.boolean
dedupeConflicts
(DataType dataType) De-duplicate equivalent conflict datatypes which share a common base data type name and are found to be equivalent.protected abstract void
deleteDataTypesUsed
(Set<Long> deletedIds) Allow extensions to perform any neccessary fixups for all datatype removals listed.void
disassociate
(DataType dataType) If the indicated data type is associated with a source archive, this will remove the association and the data type will become local to this data type manager.void
dispose()
protected void
doSourceArchiveUpdates
(TaskMonitor monitor) This method is only invoked during an upgrade.protected void
favoritesChanged
(DataType dataType, boolean isFavorite) findDataType
(String dataTypePath) Gets the dataType for the given path.findDataTypeForID
(UniversalID datatypeID) Get's the data type with the matching universal data type id.void
findDataTypes
(String name, List<DataType> list) Begin searching at the root category for all data types with the given name.void
findDataTypes
(String name, List<DataType> list, boolean caseSensitive, TaskMonitor monitor) Begin searching at the root category for all data types with names that match the given name that may contain wildcards using familiar globbing characters '*' and '?'.void
findEnumValueNames
(long value, Set<String> enumValueNames) Adds all enum value names that match the given value, to the given set.void
fixupComposites
(TaskMonitor monitor) Fixup all composites and thier components which may be affected by a data organization change include primitive type size changes and alignment changes.Returns the associated AddressMap used by this datatype manager.Returns an iterator over all composite data types (structures and unions) in this managerReturns an iterator over all the dataTypes in this managervoid
getAllDataTypes
(List<DataType> list) Adds all data types to the specified list.]Returns an iterator over all function definition data types in this managerReturns an iterator over all structures in this managergetCallingConvention
(String name) Get the prototype model of the calling convention with the specified name from the associated compiler specification.byte
getCallingConventionID
(String name, boolean restrictive) Get (and assign if needed thus requiring open transaction) the ID associated with the specified calling convention name.getCallingConventionName
(byte id) Get calling convention name corresponding to existing specified id.getCategory
(long id) Get the category for the given ID.getCategory
(CategoryPath path) Get the category that has the given pathint
Returns the total number of data type categoriesgetChildIds
(long parentID) protected DBStringMapAdapter
getDataMap
(boolean createIfNeeded) Get the manager string data map.final DataOrganization
Get the data organization associated with this data type manager.getDataType
(long dataTypeID) Returns the dataType associated with the given dataTypeId or null if the dataTypeId is not validgetDataType
(CategoryPath path, String name) Gets the data type with the indicated name in the indicated category.getDataType
(DataTypePath dataTypePath) Find the dataType for the given dataTypePath.getDataType
(SourceArchive sourceArchive, UniversalID datatypeID) Finds the data type using the given source archive and id.getDataType
(String dataTypePath) Retrieve the data type with the fully qualified path.int
getDataTypeCount
(boolean includePointersAndArrays) Returns the total number of defined data types.DataType[]
getDataTypes
(CategoryPath path) Gets the datatypes in the given category pathgetDataTypes
(SourceArchive sourceArchive) Returns all data types within this manager that have as their source the given archivegetDataTypesContaining
(DataType dataType) Returns the data types within this data type manager that contain the specified data type.Get the default calling convention's prototype model in this datatype manager if known.Get the ordered list of defined calling convention names.protected abstract String
Returns a list of datatypes that have been designated as favorites.long
Returns the dataTypeId for the given dataType.Get the ordered list of known calling convention names.long
Returns the timestamp of the last time this manager was changedReturns the source archive for this managerprotected abstract String
getPath()
final Pointer
getPointer
(DataType dt) Returns a default sized pointer to the given datatype.final Pointer
getPointer
(DataType dt, int size) Returns a pointer of the given size to the given datatype.Get the optional program architecture details associated with this archiveGet the program architecture information which has been associated with this datatype manager.protected static String
getProgramArchitectureSummary
(LanguageID languageId, int languageVersion, CompilerSpecID compilerSpecId) long
Returns the dataTypeId for the given dataType.Returns the root category ManagergetSourceArchive
(UniversalID sourceID) Returns the source archive for the given IDgetSourceArchive
(String fileID) Returns a list of source archives not including the builtin or the program's archive.getUniqueName
(CategoryPath path, String baseName) Returns a unique name not currently used by any other dataType or category with the same baseName.Returns the universal ID for this dataType managergetUnusedConflictName
(CategoryPath path, DataType dt) This method gets a ".conflict" name that is not currently used by any data types in the indicated category within this data type manager.This method gets a ".conflict" name that is not currently used by any data types in the datatype's category within this data type manager.protected VariableStorageManager
Get the variable storage manager if it has been established.protected void
handleDataOrganizationChange
(OpenMode openMode, TaskMonitor monitor) protected final boolean
hasDataOrganizationChange
(boolean ifPreviouslyStored) Check if the activegetDataOrganization()
differs from the stored data organization.protected boolean
hasParent
(long childID) protected void
initializeOtherAdapters
(OpenMode openMode, TaskMonitor monitor) Initialize other DB adapters after base implementation adapters has been initialized.void
Invalidates the cache.boolean
protected boolean
boolean
isFavorite
(DataType dataType) Returns true if the given datatype has been designated as a favorite.protected final boolean
Determine if transaction is active.boolean
Returns true if this DataTypeManager can be modified.protected void
During any UPGRADE instantiation this method should be invoked with an open transaction once the associated DomainObject is ready.void
This method should be invoked following an undo/redo or a transaction rollback situation.protected DataOrganization
Read the DB-serialized data organization.boolean
remove
(DataType dataType, TaskMonitor monitor) Remove the given datatype from this managervoid
Remove the DataTypeManger change listener.void
removeInvalidatedListener
(InvalidatedListener listener) Removes a previously added InvalidatedListenerprotected void
removeParentChildRecord
(long parentID, long childID) void
removeSourceArchive
(SourceArchive sourceArchive) Removes the source archive from this manager.replaceDataType
(DataType existingDt, DataType replacementDt, boolean updateCategoryPath) Replace an existing dataType with another.protected abstract void
replaceDataTypesUsed
(Map<Long, Long> dataTypeReplacementMap) Allow extensions to perform any neccessary fixups to address all datatype replacements.void
replaceSourceArchive
(SourceArchive oldSourceArchive, SourceArchive newSourceArchive) Replace one source archive (oldDTM) with another (newDTM).resolve
(DataType dataType, DataTypeConflictHandler handler) Returns a dataType that is "in" (ie suitable implementation) this Manager, creating a new one if necessary.resolveSourceArchive
(SourceArchive sourceArchive) Returns or creates a persisted version of the given source archiveprotected void
Save the current data organization to facilitate future change detection and upgrades.void
setFavorite
(DataType dataType, boolean isFavorite) Sets the given dataType to be either a favorite or not a favorite.protected void
setProgramArchitecture
(ProgramArchitecture programArchitecture, VariableStorageManager variableStorageMgr, boolean store, TaskMonitor monitor) Set the architecture-specific details associated with this datatype manager.protected void
sourceArchiveAdded
(UniversalID sourceArchiveID) void
sourceArchiveChanged
(UniversalID sourceArchiveID) void
updateID()
protected void
boolean
updateSourceArchiveName
(UniversalID sourceID, String name) Updates the name associated with a source archive in this data type manager.boolean
updateSourceArchiveName
(String archiveFileID, String name) Updates the name associated with a source archive in this data type manager.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.program.model.data.DataTypeManager
endTransaction, flushEvents, getName, getType, openTransaction, setName, startTransaction, withTransaction, withTransaction
-
Field Details
-
UNKNOWN_CALLING_CONVENTION_ID
public static final byte UNKNOWN_CALLING_CONVENTION_ID- See Also:
-
DEFAULT_CALLING_CONVENTION_ID
public static final byte DEFAULT_CALLING_CONVENTION_ID- See Also:
-
sourceArchiveAdapter
protected ghidra.program.database.data.SourceArchiveAdapter sourceArchiveAdapter -
readOnlyMode
protected final boolean readOnlyMode -
dbHandle
-
tablePrefix
-
errHandler
-
defaultListener
-
universalID
-
addrMap
-
lock
-
-
Constructor Details
-
DataTypeManagerDB
Construct a new temporary data-type manager. Note that this manager does not support the save or saveAs operation. No Language is associated with instance.- Parameters:
dataOrganization
- applicable data organization- Throws:
RuntimeIOException
- if database error occurs during creation
-
DataTypeManagerDB
protected DataTypeManagerDB(ResourceFile packedDBfile, OpenMode openMode, TaskMonitor monitor) throws IOException, CancelledException Constructor for a data-type manager backed by a packed database file. When opening for UPDATE an automatic upgrade will be performed if required. NOTE: Default DataOrganization will be used for new archive.- Parameters:
packedDBfile
- packed datatype archive file (i.e., *.gdt resource).openMode
- open mode CREATE, READ_ONLY or UPDATEmonitor
- task monitor- Throws:
IOException
- a low-level IO error. This exception may also be thrown when a version error occurs (cause is VersionException).CancelledException
- if task cancelled
-
DataTypeManagerDB
protected DataTypeManagerDB(DBHandle handle, AddressMap addrMap, OpenMode openMode, String tablePrefix, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) throws CancelledException, IOException, VersionException Constructor for a database-backedDataTypeManagerDB
extension. NOTE: This does not check for and handle data organization changes which must be handled later (usehasDataOrganizationChange(boolean)
andcompilerSpecChanged(TaskMonitor)
to check for and initiate response to changes).- Parameters:
handle
- database handleaddrMap
- address map (may be null)openMode
- open mode CREATE, READ_ONLY, UPDATE, UPGRADE.tablePrefix
- DB table prefix to be applied to all associated table names. This need only be specified when using multiple instances with the same DB handle (null or empty string for no-prefix).errHandler
- the error handlerlock
- database lockmonitor
- the current task monitor- Throws:
CancelledException
- if an upgrade is cancelledIOException
- if there is a problem reading the databaseVersionException
- if any database handle's version doesn't match the expected version. This exception will never be thrown in READ_ONLY mode.
-
-
Method Details
-
initializeOtherAdapters
protected void initializeOtherAdapters(OpenMode openMode, TaskMonitor monitor) throws CancelledException, IOException, VersionException Initialize other DB adapters after base implementation adapters has been initialized.- Parameters:
openMode
- the DB open modemonitor
- the progress monitor- Throws:
CancelledException
- if the user cancels an upgradeVersionException
- if the database does not match the expected version.IOException
- if a database IO error occurs.
-
handleDataOrganizationChange
protected void handleDataOrganizationChange(OpenMode openMode, TaskMonitor monitor) throws IOException, LanguageVersionException, CancelledException -
getDataMap
Get the manager string data map.- Parameters:
createIfNeeded
- if true map will be created if it does not exist- Returns:
- manager string data map or null
- Throws:
IOException
- if an IO error occurs
-
setProgramArchitecture
protected void setProgramArchitecture(ProgramArchitecture programArchitecture, VariableStorageManager variableStorageMgr, boolean store, TaskMonitor monitor) throws IOException, CancelledException Set the architecture-specific details associated with this datatype manager. The data organization will be obtained from the compiler spec specified by the program architecture. Fixup of all composites will be performed, if store is true, to reflect any changes in the data organization. The caller is resposible for ensuring that this setting is done consistent with theaddrMap
setting used during construction if applicable.
If not storing caller may need to check for data organization change to communicate change or to facilitate an upgrade situation.- Parameters:
programArchitecture
- program architecture details (may be null) in which case default data organization will be used.variableStorageMgr
- variable storage manager (within same database) or null to disable variable storage support. Ignored if programArchitecture is null;store
- if true database update will occur and datatypes will be updated if any change to the data organization is detected (a stored copy may be used to detect this condition). This should never be passed as true if opened read-only. This should be false during create mode where only the state is affected without changing the Database or existing datatypes.monitor
- task monitor- Throws:
IOException
- if IO error occursCancelledException
- if processing cancelled - data types may not properly reflect updated compiler specificationjavax.help.UnsupportedOperationException
- if language was previously set
-
compilerSpecChanged
Perform updates related to a compiler spec change, including:- data organization changes which may impact datatype components and packing
- Parameters:
monitor
- task monitor- Throws:
ReadOnlyException
- if this manager has not been open for updateIOException
- if an IO error occurs while performing updatesCancelledException
- if processing cancelled - data types may not properly reflect updated compiler specification
-
hasDataOrganizationChange
Check if the activegetDataOrganization()
differs from the stored data organization. False will be returned whenifPreviouslyStored
is true and data organization has never beeen saved.- Parameters:
ifPreviouslyStored
- if true and data organization has never been saved false will be returned- Returns:
- true if a data organization change has occured
- Throws:
IOException
- if an IO error occurs
-
saveDataOrganization
Save the current data organization to facilitate future change detection and upgrades.- Throws:
IOException
- if failure occured while saving data organization.
-
readDataOrganization
Read the DB-serialized data organization. If one has not been stored a suitable default will be returned.- Returns:
- stored data organization or suitable default.
- Throws:
IOException
- if DB error orccurs
-
getProgramArchitecture
Description copied from interface:DataTypeManager
Get the optional program architecture details associated with this archive- Specified by:
getProgramArchitecture
in interfaceDataTypeManager
- Returns:
- program architecture details or null if none
-
getProgramArchitectureSummary
protected static String getProgramArchitectureSummary(LanguageID languageId, int languageVersion, CompilerSpecID compilerSpecId) -
getProgramArchitectureSummary
Description copied from interface:DataTypeManager
Get the program architecture information which has been associated with this datatype manager. IfDataTypeManager.getProgramArchitecture()
returns null this method may still return information if the program architecture was set on an archive but unable to properly instantiate.- Specified by:
getProgramArchitectureSummary
in interfaceDataTypeManager
- Returns:
- program architecture summary if it has been set
-
getVariableStorageManager
Get the variable storage manager if it has been established.- Returns:
- variable storage manager or null if no associated architecture.
-
isTransactionActive
protected final boolean isTransactionActive()Determine if transaction is active. With proper lock established this method may be useful for determining if a lazy record update may be performed.- Returns:
- true if database transaction if active, else false
-
notifyRestored
public void notifyRestored()This method should be invoked following an undo/redo or a transaction rollback situation. This will notifyDataTypeManagerChangeListenerHandler
and its listeners that this manager has just been restored (e.g., undo/redo/rollback). -
getDomainFileID
-
getPath
-
getUniversalID
Description copied from interface:DataTypeManager
Returns the universal ID for this dataType manager- Specified by:
getUniversalID
in interfaceDataTypeManager
- Returns:
- the universal ID for this dataType manager
-
updateID
public void updateID() -
getFavorites
Description copied from interface:DataTypeManager
Returns a list of datatypes that have been designated as favorites.- Specified by:
getFavorites
in interfaceDataTypeManager
- Returns:
- the list of favorite datatypes in this manager.
-
isFavorite
Description copied from interface:DataTypeManager
Returns true if the given datatype has been designated as a favorite. If the datatype does not belong to this datatype manager, then false will be returned.- Specified by:
isFavorite
in interfaceDataTypeManager
- Parameters:
dataType
- the datatype to check.- Returns:
- true if the given datatype is a favorite in this manager.
-
setFavorite
Description copied from interface:DataTypeManager
Sets the given dataType to be either a favorite or not a favorite.- Specified by:
setFavorite
in interfaceDataTypeManager
- Parameters:
dataType
- the datatype for which to change its status as a favorite.isFavorite
- true if the datatype is to be a favorite or false otherwise.
-
getUniqueName
Description copied from interface:DataTypeManager
Returns a unique name not currently used by any other dataType or category with the same baseName. This does not produce a conflict name and is intended to be used when generating an artifical datatype name only (e.g.,temp_1
,temp_2
; forbaseName="temp"
.- Specified by:
getUniqueName
in interfaceDataTypeManager
- Parameters:
path
- the path of the namebaseName
- the base name to be made unique- Returns:
- a unique name starting with baseName
-
getCategory
Description copied from interface:DataTypeManager
Get the category that has the given path- Specified by:
getCategory
in interfaceDataTypeManager
- Parameters:
path
- the path- Returns:
- the category if defined, otherwise null
-
getCategory
Get the category for the given ID.- Specified by:
getCategory
in interfaceDataTypeManager
- Parameters:
id
- id of the desired category- Returns:
- null if no category exists with the given ID.
-
resolve
Description copied from interface:DataTypeManager
Returns a dataType that is "in" (ie suitable implementation) this Manager, creating a new one if necessary. Also the returned dataType will be in a category in this dataTypeManager that is equivalent to the category of the passed in dataType.- Specified by:
resolve
in interfaceDataTypeManager
- Parameters:
dataType
- the dataType to be resolved.handler
- used to resolve conflicts with existing dataTypes.- Returns:
- an equivalent dataType that "belongs" to this dataTypeManager.
-
getUnusedConflictName
This method gets a ".conflict" name that is not currently used by any data types in the datatype's category within this data type manager. If the baseName without conflict suffix is not used that name will be returned.
NOTE: The original datatype name will be returned unchanged for pointers and arrays since they cannot be renamed.- Parameters:
dt
- datatype who name is used to establish non-conflict base name- Returns:
- the unused conflict name or original name for datatypes whose name is automatic
-
getUnusedConflictName
This method gets a ".conflict" name that is not currently used by any data types in the indicated category within this data type manager. If the baseName without conflict suffix is not used that name will be returned.
NOTE: The original datatype name will be returned unchanged for pointers and arrays since they cannot be renamed.
NOTE: Otherwise, if category does not exist the non-conflict name will be returned.- Parameters:
path
- the category path of the category where the new data type live in the data type manager.dt
- datatype who name is used to establish non-conflict base name- Returns:
- the unused conflict name
-
addDataType
Description copied from interface:DataTypeManager
Returns a data type after adding it to this data manager. The returned dataType will be in a category in this dataTypeManager that is equivalent to the category of the passed in dataType.- Specified by:
addDataType
in interfaceDataTypeManager
- Parameters:
originalDataType
- the dataType to be resolved.handler
- used to resolve conflicts with existing dataTypes.- Returns:
- an equivalent dataType that "belongs" to this dataTypeManager.
-
addDataTypes
public void addDataTypes(Collection<DataType> dataTypes, DataTypeConflictHandler handler, TaskMonitor monitor) throws CancelledException Description copied from interface:DataTypeManager
Sequentially adds a collection of datatypes to this data manager. This method provides the added benefit of equivalence caching for improved performance.
WARNING: This is an experimental method whose use may cause the GUI and task monitor to become unresponsive due to extended hold times on the manager lock.- Specified by:
addDataTypes
in interfaceDataTypeManager
- Parameters:
dataTypes
- collection of datatypeshandler
- conflict handlermonitor
- task monitor- Throws:
CancelledException
- if monitor is cancelled
-
resolveSourceArchive
Description copied from interface:DataTypeManager
Returns or creates a persisted version of the given source archive- Specified by:
resolveSourceArchive
in interfaceDataTypeManager
- Parameters:
sourceArchive
- the archive- Returns:
- the archive
-
removeSourceArchive
Description copied from interface:DataTypeManager
Removes the source archive from this manager. This will disassociate all data types in this manager from the given archive.- Specified by:
removeSourceArchive
in interfaceDataTypeManager
- Parameters:
sourceArchive
- the archive
-
replaceDataType
public DataType replaceDataType(DataType existingDt, DataType replacementDt, boolean updateCategoryPath) throws DataTypeDependencyException Description copied from interface:DataTypeManager
Replace an existing dataType with another. All instances and references will be updated to use the replacement dataType.- Specified by:
replaceDataType
in interfaceDataTypeManager
- Parameters:
existingDt
- the dataType to be replaced.replacementDt
- the dataType to use as the replacement.updateCategoryPath
- if true, the replacementDt will have its categoryPath changed to the exitingDt's path.- Returns:
- the resolved replacement dataType.
- Throws:
DataTypeDependencyException
- if the replacement datatype depends on the existing dataType;
-
replaceDataTypesUsed
Allow extensions to perform any neccessary fixups to address all datatype replacements.- Parameters:
dataTypeReplacementMap
- map of datatype replacements (oldID maps to replacementID).
-
replaceSourceArchive
Replace one source archive (oldDTM) with another (newDTM). Any data types whose source was the oldDTM will be changed to have a source that is the newDTM. The oldDTM will no longer be referenced as a source by this data type manager.- Parameters:
oldSourceArchive
- data type manager for the old source archivenewSourceArchive
- data type manager for the new source archive- Throws:
IllegalArgumentException
- if the oldDTM isn't currently a source archive for this data type manager or if the old and new source archives already have the same unique ID.
-
findDataTypes
Description copied from interface:DataTypeManager
Begin searching at the root category for all data types with the given name. Places all the data types in this data type manager with the given name into the list. Presence of.conflict
extension will be ignored for both specified name and returned results.- Specified by:
findDataTypes
in interfaceDataTypeManager
- Parameters:
name
- name of the data type (wildcards are not supported and will be treated as explicit search characters)list
- list that will be populated with matching DataType objects
-
findDataTypes
public void findDataTypes(String name, List<DataType> list, boolean caseSensitive, TaskMonitor monitor) Description copied from interface:DataTypeManager
Begin searching at the root category for all data types with names that match the given name that may contain wildcards using familiar globbing characters '*' and '?'.- Specified by:
findDataTypes
in interfaceDataTypeManager
- Parameters:
name
- name to match; may contain wildcardslist
- list that will be populated with matching DataType objectscaseSensitive
- true if the match is case sensitivemonitor
- task monitor to cancel the search
-
getDataType
Description copied from interface:DataTypeManager
Find the dataType for the given dataTypePath.- Specified by:
getDataType
in interfaceDataTypeManager
- Parameters:
dataTypePath
- the DataTypePath for the datatype- Returns:
- the datatype for the given path.
-
getDataType
Description copied from interface:DataTypeManager
Retrieve the data type with the fully qualified path. So you can get the data named "bar" in the category "foo" by calling getDataType("/foo/bar"). This method can be problematic now that datatype names can contain slashes. It will work provided that the part of the datatype name that precedes its internal slash is not also the name of a category in the same category as the datatype. For example, if you call getDataType("/a/b/c"), and "b/c" is the name of your datatype, it will find it unless there is also a category "b" under category "a". A better solution is to use theDataTypeManager.getDataType(DataTypePath)
method because the DataTypePath keeps the category and datatype name separate.- Specified by:
getDataType
in interfaceDataTypeManager
- Parameters:
dataTypePath
- path- Returns:
- the dataType or null if it isn't found
-
findDataType
Description copied from interface:DataTypeManager
Gets the dataType for the given path. SeeDataTypeManager.getDataType(String)
for details.- Specified by:
findDataType
in interfaceDataTypeManager
- Parameters:
dataTypePath
- dataType path- Returns:
- dataType at the given path
-
findEnumValueNames
Description copied from interface:DataTypeManager
Adds all enum value names that match the given value, to the given set.- Specified by:
findEnumValueNames
in interfaceDataTypeManager
- Parameters:
value
- the value to look for enum name matchesenumValueNames
- the set to add matches to.
-
getResolvedID
Description copied from interface:DataTypeManager
Returns the dataTypeId for the given dataType. If the dataType is not currently in the dataTypeManger, it will be added- Specified by:
getResolvedID
in interfaceDataTypeManager
- Parameters:
dt
- the data type- Returns:
- the ID of the resolved type
-
getID
Description copied from interface:DataTypeManager
Returns the dataTypeId for the given dataType. If the dataType does not exist, a -1 will be returned- Specified by:
getID
in interfaceDataTypeManager
- Parameters:
dt
- the datatype to get an id for- Returns:
- the ID of the type
-
getDataType
Description copied from interface:DataTypeManager
Returns the dataType associated with the given dataTypeId or null if the dataTypeId is not valid- Specified by:
getDataType
in interfaceDataTypeManager
- Parameters:
dataTypeID
- the ID- Returns:
- the type
-
addInvalidatedListener
Description copied from interface:DataTypeManager
Adds a listener that will be notified when this manager's cache is invalidated. This will happen when the system has changed and the manager cannot determine the exact change, like during an undo or a redo.- Specified by:
addInvalidatedListener
in interfaceDataTypeManager
- Parameters:
listener
- The listener to add
-
removeInvalidatedListener
Description copied from interface:DataTypeManager
Removes a previously added InvalidatedListener- Specified by:
removeInvalidatedListener
in interfaceDataTypeManager
- Parameters:
listener
- the listener to remove.
-
deleteDataTypesUsed
Allow extensions to perform any neccessary fixups for all datatype removals listed.- Parameters:
deletedIds
- list of IDs for all datatypes which are getting removed.
-
remove
Description copied from interface:DataTypeManager
Remove the given datatype from this manager- Specified by:
remove
in interfaceDataTypeManager
- Parameters:
dataType
- the dataType to be removedmonitor
- the task monitor- Returns:
- true if the data type existed and was removed
-
associateDataTypeWithArchive
Description copied from interface:DataTypeManager
Change the given data type and its dependencies so thier source archive is set to given archive. Only those data types not already associated with a source archive will be changed.- Specified by:
associateDataTypeWithArchive
in interfaceDataTypeManager
- Parameters:
datatype
- the typearchive
- the archive
-
disassociate
Description copied from interface:DataTypeManager
If the indicated data type is associated with a source archive, this will remove the association and the data type will become local to this data type manager.- Specified by:
disassociate
in interfaceDataTypeManager
- Parameters:
dataType
- the data type to be disassociated from a source archive.
-
addDataTypeToDelete
protected void addDataTypeToDelete(long id) Queue a datatype to deleted in response to another datatype being deleted.- Parameters:
id
- datatype ID to be removed
-
addDataTypeToReplace
Queue a datatype to be replaced by another datatype in response to its referenced datatype being replaced.- Parameters:
oldDataType
- datatype to be replacedreplacementDataType
- datatype which is the replacement
-
contains
Description copied from interface:DataTypeManager
Return true if the given dataType exists in this data type manager- Specified by:
contains
in interfaceDataTypeManager
- Parameters:
dataType
- the type- Returns:
- true if the type is in this manager
-
containsCategory
Description copied from interface:DataTypeManager
Returns true if the given category path exists in this datatype manager- Specified by:
containsCategory
in interfaceDataTypeManager
- Parameters:
path
- the path- Returns:
- true if the given category path exists in this datatype manager
-
createCategory
Description copied from interface:DataTypeManager
Create a category for the given path; returns the current category if it already exits- Specified by:
createCategory
in interfaceDataTypeManager
- Parameters:
path
- the path- Returns:
- the category
-
getRootCategory
Description copied from interface:DataTypeManager
Returns the root category Manager- Specified by:
getRootCategory
in interfaceDataTypeManager
- Returns:
- the category
-
getDataTypes
Gets the datatypes in the given category path- Parameters:
path
- the category path in which to look for datatypes- Returns:
- array of datatypes contained with specified category
-
getDataType
Description copied from interface:DataTypeManager
Gets the data type with the indicated name in the indicated category.- Specified by:
getDataType
in interfaceDataTypeManager
- Parameters:
path
- the path for the categoryname
- the data type's name- Returns:
- the data type.
-
getCategoryCount
public int getCategoryCount()Description copied from interface:DataTypeManager
Returns the total number of data type categories- Specified by:
getCategoryCount
in interfaceDataTypeManager
- Returns:
- the count
-
getDataTypeCount
public int getDataTypeCount(boolean includePointersAndArrays) Description copied from interface:DataTypeManager
Returns the total number of defined data types.- Specified by:
getDataTypeCount
in interfaceDataTypeManager
- Parameters:
includePointersAndArrays
- if true all pointers and array data types will be included- Returns:
- the count
-
isChanged
public boolean isChanged() -
updateLastChangeTime
protected void updateLastChangeTime() -
getSourceArchives
Description copied from interface:DataTypeManager
Returns a list of source archives not including the builtin or the program's archive.- Specified by:
getSourceArchives
in interfaceDataTypeManager
- Returns:
- a list of source archives not including the builtin or the program's archive.
-
getSourceArchive
-
getSourceArchive
Description copied from interface:DataTypeManager
Returns the source archive for the given ID- Specified by:
getSourceArchive
in interfaceDataTypeManager
- Parameters:
sourceID
- the ID- Returns:
- the archive; null if the ID is null; null if the archive does not exist
-
getLocalSourceArchive
Description copied from interface:DataTypeManager
Returns the source archive for this manager- Specified by:
getLocalSourceArchive
in interfaceDataTypeManager
- Returns:
- the archive; null if the ID is null; null if the archive does not exist
-
updateSourceArchiveName
Description copied from interface:DataTypeManager
Updates the name associated with a source archive in this data type manager.- Specified by:
updateSourceArchiveName
in interfaceDataTypeManager
- Parameters:
archiveFileID
- Universal domain file ID of the source data type archive that has a new name.name
- the new name of the program or archive.- Returns:
- true if the name associated with the source data type archive was changed. false if it wasn't changed.
-
updateSourceArchiveName
Description copied from interface:DataTypeManager
Updates the name associated with a source archive in this data type manager.- Specified by:
updateSourceArchiveName
in interfaceDataTypeManager
- Parameters:
sourceID
- Universal archive ID of the source data type archive that has a new name.name
- the new name of the program or archive.- Returns:
- true if the name associated with the source data type archive was changed. false if it wasn't changed.
-
getDataTypes
Description copied from interface:DataTypeManager
Returns all data types within this manager that have as their source the given archive- Specified by:
getDataTypes
in interfaceDataTypeManager
- Parameters:
sourceArchive
- the archive- Returns:
- the types
-
dbError
Handles IOExceptions- Parameters:
e
- the exception to handle
-
getAllDataTypes
Description copied from interface:DataTypeManager
Returns an iterator over all the dataTypes in this manager- Specified by:
getAllDataTypes
in interfaceDataTypeManager
- Returns:
- an iterator over all the dataTypes in this manager
-
getAllDataTypes
Description copied from interface:DataTypeManager
Adds all data types to the specified list.]- Specified by:
getAllDataTypes
in interfaceDataTypeManager
- Parameters:
list
- the result list into which the types will be placed
-
getAllFunctionDefinitions
Description copied from interface:DataTypeManager
Returns an iterator over all function definition data types in this manager- Specified by:
getAllFunctionDefinitions
in interfaceDataTypeManager
- Returns:
- the iterator
-
getAllStructures
Description copied from interface:DataTypeManager
Returns an iterator over all structures in this manager- Specified by:
getAllStructures
in interfaceDataTypeManager
- Returns:
- the iterator
-
getAllComposites
Description copied from interface:DataTypeManager
Returns an iterator over all composite data types (structures and unions) in this manager- Specified by:
getAllComposites
in interfaceDataTypeManager
- Returns:
- the iterator
-
dispose
public void dispose() -
close
public void close()Description copied from interface:DataTypeManager
Closes this dataType manager- Specified by:
close
in interfaceDataTypeManager
-
invalidateCache
public void invalidateCache()Invalidates the cache. -
isUpdatable
public boolean isUpdatable()Description copied from interface:DataTypeManager
Returns true if this DataTypeManager can be modified.- Specified by:
isUpdatable
in interfaceDataTypeManager
- Returns:
- true if this DataTypeMangaer can be modified.
-
allowsDefaultBuiltInSettings
public boolean allowsDefaultBuiltInSettings()Description copied from interface:DataTypeManager
Determine if settings are supported for BuiltIn datatypes within this datatype manager.- Specified by:
allowsDefaultBuiltInSettings
in interfaceDataTypeManager
- Returns:
- true if BuiltIn Settings are permitted
-
allowsDefaultComponentSettings
public final boolean allowsDefaultComponentSettings()Description copied from interface:DataTypeManager
Determine if settings are supported for datatype components within this datatype manager (i.e., for structure and union components).- Specified by:
allowsDefaultComponentSettings
in interfaceDataTypeManager
- Returns:
- true if BuiltIn Settings are permitted
-
removeParentChildRecord
protected void removeParentChildRecord(long parentID, long childID) -
getChildIds
-
hasParent
protected boolean hasParent(long childID) -
getDataTypesContaining
Description copied from interface:DataTypeManager
Returns the data types within this data type manager that contain the specified data type. The specified dataType must belong to this datatype manager. An empty set will be returned for unsupported datatype instances.- Specified by:
getDataTypesContaining
in interfaceDataTypeManager
- Parameters:
dataType
- the data type- Returns:
- a set of data types that contain the specified data type.
-
getPointer
Description copied from interface:DataTypeManager
Returns a default sized pointer to the given datatype. The pointer size is established dynamically based upon the data organization established by the compiler specification.- Specified by:
getPointer
in interfaceDataTypeManager
- Parameters:
dt
- the pointed to data type- Returns:
- the pointer
-
getPointer
Description copied from interface:DataTypeManager
Returns a pointer of the given size to the given datatype. Note: It is preferred to use default sized pointers when possible (i.e., size=-1, seeDataTypeManager.getPointer(DataType)
) instead of explicitly specifying the size value.- Specified by:
getPointer
in interfaceDataTypeManager
- Parameters:
dt
- the pointed to data typesize
- the size of the pointer to be created or -1 for a default sized pointer- Returns:
- the pointer
-
addDataTypeManagerListener
Description copied from interface:DataTypeManager
Add a listener that is notified when the dataTypeManger changes.- Specified by:
addDataTypeManagerListener
in interfaceDataTypeManager
- Parameters:
l
- the listener
-
removeDataTypeManagerListener
Description copied from interface:DataTypeManager
Remove the DataTypeManger change listener.- Specified by:
removeDataTypeManagerListener
in interfaceDataTypeManager
- Parameters:
l
- the listener
-
isCreatingDataType
protected boolean isCreatingDataType()- Returns:
- true if manager is in the process of adding/creating a new type
-
dataTypeChanged
Notification when data type is changed.- Parameters:
dt
- data type that is changedisAutoChange
- true if change was an automatic change in response to another datatype's change (e.g., size, alignment).
-
dataTypeSettingsChanged
Notification when data type settings have changed.- Parameters:
dt
- data type that is changed
-
dataTypeAdded
-
dataTypeReplaced
protected void dataTypeReplaced(long existingDtID, DataTypePath replacedDataTypePath, DataType replacementDt) -
dataTypeDeleted
-
dataTypeMoved
protected void dataTypeMoved(DataType dt, DataTypePath oldDataTypePath, DataTypePath newDataTypePath) -
dataTypeNameChanged
-
categoryCreated
-
categoryRenamed
-
categoryRemoved
-
categoryMoved
-
favoritesChanged
-
sourceArchiveChanged
-
sourceArchiveAdded
-
getLastChangeTimeForMyManager
public long getLastChangeTimeForMyManager()Description copied from interface:DataTypeManager
Returns the timestamp of the last time this manager was changed- Specified by:
getLastChangeTimeForMyManager
in interfaceDataTypeManager
- Returns:
- the timestamp
-
getDataType
Description copied from interface:DataTypeManager
Finds the data type using the given source archive and id.- Specified by:
getDataType
in interfaceDataTypeManager
- Parameters:
sourceArchive
- the optional source archive; required when the type is associated with that source archivedatatypeID
- the type's id- Returns:
- the type or null
-
findDataTypeForID
Description copied from interface:DataTypeManager
Get's the data type with the matching universal data type id.- Specified by:
findDataTypeForID
in interfaceDataTypeManager
- Parameters:
datatypeID
- The universal id of the data type to search for- Returns:
- The data type with the matching UUID, or null if no such data type can be found.
-
getAddressMap
Description copied from interface:DataTypeManager
Returns the associated AddressMap used by this datatype manager.- Specified by:
getAddressMap
in interfaceDataTypeManager
- Returns:
- the AddressMap used by this datatype manager or null if one has not be established.
-
getDataOrganization
Description copied from interface:DataTypeManager
Get the data organization associated with this data type manager. Note that the DataOrganization settings may not be changed dynamically.- Specified by:
getDataOrganization
in interfaceDataTypeManager
- Returns:
- data organization (will never be null)
-
getCallingConventionName
Get calling convention name corresponding to existing specified id.- Parameters:
id
- calling convention ID- Returns:
- calling convention name if found else unknown
-
getCallingConventionID
public byte getCallingConventionID(String name, boolean restrictive) throws InvalidInputException, IOException Get (and assign if needed thus requiring open transaction) the ID associated with the specified calling convention name. If name is a new convention and the number of stored convention names exceeds 127 the returned ID will correspond to the unknown calling convention.- Parameters:
name
- calling convention namerestrictive
- if true an error will be thrown if name is not defined byGenericCallingConvention
or the associated compiler specification if datatype manager has an associated program architecture.- Returns:
- calling convention ID
- Throws:
IOException
- if database IO error occursInvalidInputException
- if restrictive is true and name is not defined byGenericCallingConvention
or the associated compiler specification if datatype manager has an associated program architecture.
-
getDefinedCallingConventionNames
Description copied from interface:DataTypeManager
Get the ordered list of defined calling convention names. The reserved names "unknown" and "default" are not included. The returned collection may not include all names referenced by various functions and function-definitions. This set is generally limited to those defined by the associated compiler specification. If this instance does not have an assigned architecture theGenericCallingConvention
names will be returned.For a set of all known names (including those that are not defined by compiler spec) see
DataTypeManager.getKnownCallingConventionNames()
.- Specified by:
getDefinedCallingConventionNames
in interfaceDataTypeManager
- Returns:
- the set of defined calling convention names.
-
getKnownCallingConventionNames
Description copied from interface:DataTypeManager
Get the ordered list of known calling convention names. The reserved names "unknown" and "default" are not included. The returned collection will include all names ever used or resolved by associatedFunction
andFunctionDefinition
objects, even if not currently defined by the associatedCompilerSpec
orProgram
SpecExtension
. To get only those calling conventions formally defined, the methodCompilerSpec.getCallingConventions()
should be used.- Specified by:
getKnownCallingConventionNames
in interfaceDataTypeManager
- Returns:
- all known calling convention names.
-
getDefaultCallingConvention
Description copied from interface:DataTypeManager
Get the default calling convention's prototype model in this datatype manager if known.- Specified by:
getDefaultCallingConvention
in interfaceDataTypeManager
- Returns:
- the default calling convention prototype model or null.
-
getCallingConvention
Description copied from interface:DataTypeManager
Get the prototype model of the calling convention with the specified name from the associated compiler specification. If an architecture has not been established this method will return null. IfFunction.DEFAULT_CALLING_CONVENTION_STRING
is specifiedDataTypeManager.getDefaultCallingConvention()
will be returned.- Specified by:
getCallingConvention
in interfaceDataTypeManager
- Parameters:
name
- the calling convention name- Returns:
- the named function calling convention prototype model or null.
-
migrateOldFlexArrayComponentsIfRequired
protected void migrateOldFlexArrayComponentsIfRequired(TaskMonitor monitor) throws IOException, CancelledException During any UPGRADE instantiation this method should be invoked with an open transaction once the associated DomainObject is ready. This late stage upgrade is required since it may entail resolving new array datatypes which requires this manager to be in a fully functional state.- Parameters:
monitor
- task monitor- Throws:
IOException
- if an IO error occurs on databaseCancelledException
- if monitor is cancelled
-
doSourceArchiveUpdates
This method is only invoked during an upgrade.- Parameters:
monitor
- task monitor- Throws:
CancelledException
- if task cancelled
-
fixupComposites
Fixup all composites and thier components which may be affected by a data organization change include primitive type size changes and alignment changes. It is highly recommended that this program be open with exclusive access before invoking this method to avoid excessive merge conflicts with other users.- Parameters:
monitor
- task monitor- Throws:
CancelledException
- if processing cancelled - data types may not properly reflect updated compiler specification
-
dedupeConflicts
De-duplicate equivalent conflict datatypes which share a common base data type name and are found to be equivalent.- Parameters:
dataType
- data type whose related conflict types should be de-duplicated- Returns:
- true if one or more datatypes were de-duplicted or dde-conflicted, else false
-
dedupeAllConflicts
De-duplicate equivalent conflict datatypes which share a common base data type name and are found to be equivalent.- Parameters:
monitor
- task monitor- Throws:
CancelledException
- if task is cancelled
-