Package ghidra.program.database
Class ProjectDataTypeManager
java.lang.Object
ghidra.program.database.data.DataTypeManagerDB
ghidra.program.model.data.StandAloneDataTypeManager
ghidra.program.database.ProjectDataTypeManager
- All Implemented Interfaces:
DataTypeManager
,DomainFileBasedDataTypeManager
,FileBasedDataTypeManager
,ProjectArchiveBasedDataTypeManager
,Closeable
,AutoCloseable
public class ProjectDataTypeManager
extends StandAloneDataTypeManager
implements ProjectArchiveBasedDataTypeManager
Class for managing data types in a project archive
NOTE: default data organization is used.
-
Nested Class Summary
Nested classes/interfaces inherited from class ghidra.program.model.data.StandAloneDataTypeManager
StandAloneDataTypeManager.ArchiveWarning, StandAloneDataTypeManager.ArchiveWarningLevel, StandAloneDataTypeManager.LanguageUpdateOption
-
Field Summary
Fields inherited from class ghidra.program.model.data.StandAloneDataTypeManager
name
Fields inherited from class ghidra.program.database.data.DataTypeManagerDB
addrMap, dbHandle, DEFAULT_CALLING_CONVENTION_ID, defaultListener, errHandler, lock, readOnlyMode, sourceArchiveAdapter, tablePrefix, universalID, UNKNOWN_CALLING_CONVENTION_ID
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
archiveReady
(OpenMode openMode, TaskMonitor monitor) boolean
canRedo()
Determine if there is a transaction previously undone (seeStandAloneDataTypeManager.undo()
) that can be redone (seeStandAloneDataTypeManager.redo()
).boolean
canUndo()
Determine if there is a previous transaction that can be reverted/undone (seeStandAloneDataTypeManager.undo()
).protected void
categoryCreated
(Category newCategory) protected void
categoryMoved
(CategoryPath oldPath, Category category) protected void
categoryRemoved
(Category parent, String categoryName, long categoryID) protected void
categoryRenamed
(CategoryPath oldPath, Category category) void
clearProgramArchitecture
(TaskMonitor monitor) Clear the program architecture setting and all architecture-specific data from this archive.void
Clear undo/redo stack.void
close()
Closes this dataType managerprotected 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 oldPath, DataTypePath newPath) protected void
dataTypeNameChanged
(DataType dt, String oldName) protected void
dataTypeReplaced
(long existingDtID, DataTypePath existingPath, DataType replacementDt) protected void
deleteDataTypesUsed
(Set<Long> deletedIds) Allow extensions to perform any neccessary fixups for all datatype removals listed.void
endTransaction
(int transactionID, boolean commit) Ends the current transactionprotected void
favoritesChanged
(DataType dataType, boolean isFavorite) void
Force all pending notification events to be flushedGet all transaction names that are available within theStandAloneDataTypeManager.redo()
stack.Get all transaction names that are available within theStandAloneDataTypeManager.undo()
stack.getName()
Returns this data type manager's namegetPath()
Get the path name associated with the storage of this stand alone datatype manager.Get the transaction name that is available forStandAloneDataTypeManager.redo()
(seeStandAloneDataTypeManager.canRedo()
).getType()
Returns this manager's archive typeGet the transaction name that is available forStandAloneDataTypeManager.undo()
(seeStandAloneDataTypeManager.canUndo()
).protected void
openTransaction
(String description) Open new transaction.void
redo()
protected void
replaceDataTypesUsed
(Map<Long, Long> dataTypeReplacementMap) Allow extensions to perform any neccessary fixups to address all datatype replacements.void
Sets this data type manager's namevoid
setProgramArchitecture
(Language language, CompilerSpecID compilerSpecId, StandAloneDataTypeManager.LanguageUpdateOption updateOption, TaskMonitor monitor) Establish the program architecture for this datatype manager.int
startTransaction
(String description) Starts a transaction for making changes in this data type manager.void
undo()
Methods inherited from class ghidra.program.model.data.StandAloneDataTypeManager
finalize, getProgramArchitectureSummary, getTransactionCount, getWarning, getWarningDetail, getWarningMessage, handleDataOrganizationChange, initializeOtherAdapters, isArchitectureChangeAllowed, isProgramArchitectureMissing, isProgramArchitectureUpgradeRequired, logWarning, setImmutable, setProgramArchitecture
Methods inherited from class ghidra.program.database.data.DataTypeManagerDB
addDataType, addDataTypeManagerListener, addDataTypes, addDataTypeToDelete, addDataTypeToReplace, addInvalidatedListener, allowsDefaultBuiltInSettings, allowsDefaultComponentSettings, associateDataTypeWithArchive, compilerSpecChanged, contains, containsCategory, createCategory, dataTypeSettingsChanged, dbError, dedupeAllConflicts, dedupeConflicts, disassociate, dispose, doSourceArchiveUpdates, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, fixupComposites, getAddressMap, getAllComposites, getAllDataTypes, getAllDataTypes, getAllFunctionDefinitions, getAllStructures, getCallingConvention, getCallingConventionID, getCallingConventionName, getCategory, getCategory, getCategoryCount, getChildIds, getDataMap, getDataOrganization, getDataType, getDataType, getDataType, getDataType, getDataType, getDataTypeCount, getDataTypes, getDataTypes, getDataTypesContaining, getDefaultCallingConvention, getDefinedCallingConventionNames, getFavorites, getID, getKnownCallingConventionNames, getLastChangeTimeForMyManager, getLocalSourceArchive, getPointer, getPointer, getProgramArchitecture, getProgramArchitectureSummary, getResolvedID, getRootCategory, getSourceArchive, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, getUnusedConflictName, getUnusedConflictName, getVariableStorageManager, hasDataOrganizationChange, hasParent, invalidateCache, isChanged, isCreatingDataType, isFavorite, isTransactionActive, isUpdatable, migrateOldFlexArrayComponentsIfRequired, notifyRestored, readDataOrganization, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeParentChildRecord, removeSourceArchive, replaceDataType, replaceSourceArchive, resolve, resolveSourceArchive, saveDataOrganization, setFavorite, sourceArchiveAdded, sourceArchiveChanged, updateID, updateLastChangeTime, updateSourceArchiveName, updateSourceArchiveName
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.program.model.data.DataTypeManager
addDataType, addDataTypeManagerListener, addDataTypes, addInvalidatedListener, allowsDefaultBuiltInSettings, allowsDefaultComponentSettings, associateDataTypeWithArchive, contains, containsCategory, createCategory, disassociate, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, getAddressMap, getAllComposites, getAllDataTypes, getAllDataTypes, getAllFunctionDefinitions, getAllStructures, getCallingConvention, getCategory, getCategory, getCategoryCount, getDataOrganization, getDataType, getDataType, getDataType, getDataType, getDataType, getDataTypeCount, getDataTypes, getDataTypesContaining, getDefaultCallingConvention, getDefinedCallingConventionNames, getFavorites, getID, getKnownCallingConventionNames, getLastChangeTimeForMyManager, getLocalSourceArchive, getPointer, getPointer, getProgramArchitecture, getProgramArchitectureSummary, getResolvedID, getRootCategory, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, isFavorite, isUpdatable, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, resolve, resolveSourceArchive, setFavorite, updateSourceArchiveName, updateSourceArchiveName, withTransaction, withTransaction
-
Method Details
-
getName
Description copied from interface:DataTypeManager
Returns this data type manager's name- Specified by:
getName
in interfaceDataTypeManager
- Overrides:
getName
in classStandAloneDataTypeManager
- Returns:
- the name
-
setName
Description copied from interface:DataTypeManager
Sets this data type manager's name- Specified by:
setName
in interfaceDataTypeManager
- Overrides:
setName
in classStandAloneDataTypeManager
- Parameters:
name
- the new name- Throws:
InvalidNameException
- if the given name is invalid (such as when null or empty)
-
clearProgramArchitecture
public void clearProgramArchitecture(TaskMonitor monitor) throws CancelledException, IOException, LockException Description copied from class:StandAloneDataTypeManager
Clear the program architecture setting and all architecture-specific data from this archive. Archive will revert to using the defaultDataOrganization
. Archive must be open for update for this method to be used.- Overrides:
clearProgramArchitecture
in classStandAloneDataTypeManager
- Parameters:
monitor
- task monitor- Throws:
CancelledException
- if task cancelled. If thrown, this data type manager is no longer stable and should be closed without saving.IOException
- if IO error occursLockException
- failure if exclusive access is required
-
setProgramArchitecture
public void setProgramArchitecture(Language language, CompilerSpecID compilerSpecId, StandAloneDataTypeManager.LanguageUpdateOption updateOption, TaskMonitor monitor) throws CompilerSpecNotFoundException, LanguageNotFoundException, IOException, LockException, javax.help.UnsupportedOperationException, IncompatibleLanguageException, CancelledException Description copied from class:StandAloneDataTypeManager
Establish the program architecture for this datatype manager. The current setting can be determined fromDataTypeManagerDB.getProgramArchitecture()
. Archive must be open for update for this method to be used.- Overrides:
setProgramArchitecture
in classStandAloneDataTypeManager
- Parameters:
language
- languagecompilerSpecId
- compiler specification ID defined by the language.updateOption
- indicates how variable storage data should be transitioned. IfStandAloneDataTypeManager.isProgramArchitectureMissing()
is true andStandAloneDataTypeManager.LanguageUpdateOption.TRANSLATE
specified, the translator will be based on whatever language version can be found. In this situation it may be best to force aStandAloneDataTypeManager.LanguageUpdateOption.CLEAR
.monitor
- task monitor (cancel not permitted to avoid corrupt state)- Throws:
CompilerSpecNotFoundException
- if invalid compilerSpecId specified for languageLanguageNotFoundException
- if current language is not found (if required for data transition)IOException
- if IO error occursLockException
- failure if exclusive access is requiredjavax.help.UnsupportedOperationException
- if architecture change is not permittedIncompatibleLanguageException
- if translation requested but not possible due to incompatible language architecturesCancelledException
- if task cancelled. If thrown, this data type manager is no longer stable and should be closed without saving.
-
dataTypeChanged
Description copied from class:DataTypeManagerDB
Notification when data type is changed.- Overrides:
dataTypeChanged
in classDataTypeManagerDB
- 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).
-
dataTypeAdded
- Overrides:
dataTypeAdded
in classDataTypeManagerDB
-
dataTypeReplaced
protected void dataTypeReplaced(long existingDtID, DataTypePath existingPath, DataType replacementDt) - Overrides:
dataTypeReplaced
in classDataTypeManagerDB
-
dataTypeDeleted
- Overrides:
dataTypeDeleted
in classDataTypeManagerDB
-
dataTypeMoved
- Overrides:
dataTypeMoved
in classDataTypeManagerDB
-
dataTypeNameChanged
- Overrides:
dataTypeNameChanged
in classDataTypeManagerDB
-
categoryCreated
- Overrides:
categoryCreated
in classDataTypeManagerDB
-
categoryRenamed
- Overrides:
categoryRenamed
in classDataTypeManagerDB
-
categoryRemoved
- Overrides:
categoryRemoved
in classDataTypeManagerDB
-
categoryMoved
- Overrides:
categoryMoved
in classDataTypeManagerDB
-
favoritesChanged
- Overrides:
favoritesChanged
in classDataTypeManagerDB
-
replaceDataTypesUsed
Description copied from class:DataTypeManagerDB
Allow extensions to perform any neccessary fixups to address all datatype replacements.- Overrides:
replaceDataTypesUsed
in classStandAloneDataTypeManager
- Parameters:
dataTypeReplacementMap
- map of datatype replacements (oldID maps to replacementID).
-
deleteDataTypesUsed
Description copied from class:DataTypeManagerDB
Allow extensions to perform any neccessary fixups for all datatype removals listed.- Overrides:
deleteDataTypesUsed
in classStandAloneDataTypeManager
- Parameters:
deletedIds
- list of IDs for all datatypes which are getting removed.
-
initTransactionState
protected void initTransactionState()- Overrides:
initTransactionState
in classStandAloneDataTypeManager
-
openTransaction
Description copied from interface:DataTypeManager
Open new transaction. This should generally be done with a try-with-resources block:try (Transaction tx = dtm.openTransaction(description)) { // ... Do something }
- Specified by:
openTransaction
in interfaceDataTypeManager
- Overrides:
openTransaction
in classStandAloneDataTypeManager
- Parameters:
description
- a short description of the changes to be made.- Returns:
- transaction object
- Throws:
IllegalStateException
- if thisDataTypeManager
has already been closed.
-
startTransaction
Description copied from interface:DataTypeManager
Starts a transaction for making changes in this data type manager.- Specified by:
startTransaction
in interfaceDataTypeManager
- Overrides:
startTransaction
in classStandAloneDataTypeManager
- Parameters:
description
- a short description of the changes to be made.- Returns:
- the transaction ID
-
endTransaction
public void endTransaction(int transactionID, boolean commit) Description copied from interface:DataTypeManager
Ends the current transaction- Specified by:
endTransaction
in interfaceDataTypeManager
- Overrides:
endTransaction
in classStandAloneDataTypeManager
- Parameters:
transactionID
- id of the transaction to endcommit
- true if changes are committed, false if changes in transaction are revoked
-
undo
public void undo()- Overrides:
undo
in classStandAloneDataTypeManager
-
redo
public void redo()- Overrides:
redo
in classStandAloneDataTypeManager
-
clearUndo
public void clearUndo()Description copied from class:StandAloneDataTypeManager
Clear undo/redo stack.
NOTE: It is important that this always be invoked following any save operation that compacts the checkpoints within the databaseBufferMgr
.- Overrides:
clearUndo
in classStandAloneDataTypeManager
-
canRedo
public boolean canRedo()Description copied from class:StandAloneDataTypeManager
Determine if there is a transaction previously undone (seeStandAloneDataTypeManager.undo()
) that can be redone (seeStandAloneDataTypeManager.redo()
).- Overrides:
canRedo
in classStandAloneDataTypeManager
- Returns:
- true if there is a transaction previously undone that can be redone, else false
-
canUndo
public boolean canUndo()Description copied from class:StandAloneDataTypeManager
Determine if there is a previous transaction that can be reverted/undone (seeStandAloneDataTypeManager.undo()
).- Overrides:
canUndo
in classStandAloneDataTypeManager
- Returns:
- true if there is a previous transaction that can be reverted/undone, else false.
-
getRedoName
Description copied from class:StandAloneDataTypeManager
Get the transaction name that is available forStandAloneDataTypeManager.redo()
(seeStandAloneDataTypeManager.canRedo()
).- Overrides:
getRedoName
in classStandAloneDataTypeManager
- Returns:
- transaction name that is available for
StandAloneDataTypeManager.redo()
or empty String.
-
getUndoName
Description copied from class:StandAloneDataTypeManager
Get the transaction name that is available forStandAloneDataTypeManager.undo()
(seeStandAloneDataTypeManager.canUndo()
).- Overrides:
getUndoName
in classStandAloneDataTypeManager
- Returns:
- transaction name that is available for
StandAloneDataTypeManager.undo()
or empty String.
-
getAllUndoNames
Description copied from class:StandAloneDataTypeManager
Get all transaction names that are available within theStandAloneDataTypeManager.undo()
stack.- Overrides:
getAllUndoNames
in classStandAloneDataTypeManager
- Returns:
- all transaction names that are available within the
StandAloneDataTypeManager.undo()
stack.
-
getAllRedoNames
Description copied from class:StandAloneDataTypeManager
Get all transaction names that are available within theStandAloneDataTypeManager.redo()
stack.- Overrides:
getAllRedoNames
in classStandAloneDataTypeManager
- Returns:
- all transaction names that are available within the
StandAloneDataTypeManager.redo()
stack.
-
flushEvents
public void flushEvents()Description copied from interface:DataTypeManager
Force all pending notification events to be flushed- Specified by:
flushEvents
in interfaceDataTypeManager
- Overrides:
flushEvents
in classStandAloneDataTypeManager
-
getDomainFile
- Specified by:
getDomainFile
in interfaceDomainFileBasedDataTypeManager
-
getDomainFileID
- Overrides:
getDomainFileID
in classStandAloneDataTypeManager
-
getPath
Description copied from class:StandAloneDataTypeManager
Get the path name associated with the storage of this stand alone datatype manager.- Specified by:
getPath
in interfaceFileBasedDataTypeManager
- Overrides:
getPath
in classStandAloneDataTypeManager
- Returns:
- path name or null if not applicable
-
getType
Description copied from interface:DataTypeManager
Returns this manager's archive type- Specified by:
getType
in interfaceDataTypeManager
- Overrides:
getType
in classStandAloneDataTypeManager
- Returns:
- the type
-
archiveReady
public void archiveReady(OpenMode openMode, TaskMonitor monitor) throws IOException, CancelledException - Throws:
IOException
CancelledException
-
close
public void close()Description copied from interface:DataTypeManager
Closes this dataType manager- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceDataTypeManager
- Overrides:
close
in classStandAloneDataTypeManager
-