Class StandAloneDataTypeManager
- All Implemented Interfaces:
DataTypeManager,Closeable,AutoCloseable
- Direct Known Subclasses:
BuiltInDataTypeManager,FileDataTypeManager,ProjectDataTypeManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enum -
Field Summary
FieldsFields inherited from class ghidra.program.database.data.DataTypeManagerDB
addrMap, dbHandle, DEFAULT_CALLING_CONVENTION_ID, defaultListener, errHandler, lock, readOnlyMode, sourceArchiveAdapter, tablePrefix, universalID, UNKNOWN_CALLING_CONVENTION_IDFields 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
ConstructorsModifierConstructorDescriptionprotectedStandAloneDataTypeManager(DBHandle handle, OpenMode openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) Constructor for a data-type manager using a specified DBHandle.protectedStandAloneDataTypeManager(ResourceFile packedDbfile, OpenMode openMode, TaskMonitor monitor) Constructor for a data-type manager backed by a packed database file.StandAloneDataTypeManager(String rootName) Constructor for new temporary data-type manager using the default DataOrganization.StandAloneDataTypeManager(String rootName, DataOrganization dataOrganzation) Constructor for new temporary data-type manager using a specified DataOrganization. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanRedo()booleancanUndo()Determine if there is a previous transaction that can be reverted/undone (seeundo()).voidclearProgramArchitecture(TaskMonitor monitor) Clear the program architecture setting and all architecture-specific data from this archive.protected voidClear undo/redo stack.voidclose()Closes this dataType managerprotected voiddeleteDataTypesUsed(Set<Long> deletedIds) Allow extensions to perform any neccessary fixups for all datatype removals listed.booleanendTransaction(int transactionID, boolean commit) Ends the current transaction.voidfinalize()voidForce all pending notification events to be flushedGet all transaction names that are available within theredo()stack.Get all transaction names that are available within theundo()stack.protected StringgetName()Returns this data type manager's namegetPath()Get the path name associated with the storage of this stand alone datatype manager.Get the program architecture information which has been associated with this datatype manager.protected intGet the number of active datatype manager transactionsgetType()Returns this manager's archive typeGet theStandAloneDataTypeManager.ArchiveWarningwhich may have occured immediately following instatiation of thisStandAloneDataTypeManager.Get the detail exception associated withStandAloneDataTypeManager.ArchiveWarning.LANGUAGE_NOT_FOUNDorStandAloneDataTypeManager.ArchiveWarning.COMPILER_SPEC_NOT_FOUNDwarning (seegetWarning()) immediately following instatiation of thisStandAloneDataTypeManager.getWarningMessage(boolean includeDetails) Get a suitable warning message.protected voidhandleDataOrganizationChange(OpenMode openMode, TaskMonitor monitor) protected voidinitializeOtherAdapters(OpenMode openMode, TaskMonitor monitor) Initialize other DB adapters after base implementation adapters has been initialized.protected voidprotected booleanDetermine if a program architecture change is permittedbooleanIndicates that a failure occured establishing the program architecture for the associated archive.booleanIndicates that an program architecture upgrade is required in order to constitute associated data.protected voidopenTransaction(String description) Open new transaction.voidredo()protected voidreplaceDataTypesUsed(Map<Long, Long> dataTypeReplacementMap) Allow extensions to perform any neccessary fixups to address all datatype replacements.protected voidSet instance as immutable by disabling use of transactions.voidSets this data type manager's namevoidsetProgramArchitecture(Language language, CompilerSpecID compilerSpecId, StandAloneDataTypeManager.LanguageUpdateOption updateOption, TaskMonitor monitor) Establish the program architecture for this datatype manager.protected voidsetProgramArchitecture(ProgramArchitecture programArchitecture, VariableStorageManager variableStorageMgr, boolean store, TaskMonitor monitor) Set the architecture-specific details associated with a new datatype manager.intstartTransaction(String description) Starts a transaction for making changes in this data type manager.voidundo()Methods inherited from class ghidra.program.database.data.DataTypeManagerDB
addDataType, addDataTypeManagerListener, addDataTypes, addDataTypeToDelete, addDataTypeToReplace, addInvalidatedListener, allowsDefaultBuiltInSettings, allowsDefaultComponentSettings, associateDataTypeWithArchive, categoryCreated, categoryMoved, categoryRemoved, categoryRenamed, compilerSpecChanged, contains, containsCategory, createCategory, dataTypeAdded, dataTypeChanged, dataTypeDeleted, dataTypeMoved, dataTypeNameChanged, dataTypeReplaced, dataTypeSettingsChanged, dbError, dedupeAllConflicts, dedupeConflicts, disassociate, dispose, doSourceArchiveUpdates, favoritesChanged, 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, updateSourceArchiveNameMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.program.model.data.DataTypeManager
withTransaction, withTransaction
-
Field Details
-
name
-
-
Constructor Details
-
StandAloneDataTypeManager
Constructor for new temporary data-type manager using the default DataOrganization. Note that this manager does not support the save or saveAs operation.- Parameters:
rootName- Name of the root category.- Throws:
RuntimeIOException- if database error occurs during creation
-
StandAloneDataTypeManager
public StandAloneDataTypeManager(String rootName, DataOrganization dataOrganzation) throws RuntimeIOException Constructor for new temporary data-type manager using a specified DataOrganization. Note that this manager does not support the save or saveAs operation.- Parameters:
rootName- Name of the root category.dataOrganzation- applicable data organization- Throws:
RuntimeIOException- if database error occurs during creation
-
StandAloneDataTypeManager
protected StandAloneDataTypeManager(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:
logWarning()should be invoked immediately after instantiating aStandAloneDataTypeManagerfor an existing database aftergetName()andgetPath()can be invoked safely. In addition, it may be appropriate to usecheck for warningsprior to use.- Parameters:
packedDbfile- packed datatype archive file (i.e., *.gdt resource).openMode- open mode CREATE, READ_ONLY or UPDATEmonitor- the progress 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
-
StandAloneDataTypeManager
protected StandAloneDataTypeManager(DBHandle handle, OpenMode openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) throws CancelledException, VersionException, IOException Constructor for a data-type manager using a specified DBHandle.
NOTE:logWarning()should be invoked immediately after instantiating aStandAloneDataTypeManagerfor an existing database aftergetName()andgetPath()can be invoked safely. In addition, it may be appropriate to usecheck for warningsprior to use.- Parameters:
handle- open database handleopenMode- open mode CREATE, READ_ONLY or UPDATEerrHandler- the database I/O error handlerlock- the program synchronization lockmonitor- the progress monitor- Throws:
CancelledException- if task cancelledVersionException- if the database does not match the expected version.IOException- if a database I/O error occurs.
-
-
Method Details
-
setImmutable
protected void setImmutable()Set instance as immutable by disabling use of transactions. Attempts to start a transaction will result in aTerminatedTransactionException. -
getWarning
Get theStandAloneDataTypeManager.ArchiveWarningwhich may have occured immediately following instatiation of thisStandAloneDataTypeManager.StandAloneDataTypeManager.ArchiveWarning.NONEwill be returned if not warning condition.- Returns:
- warning type.
-
getWarningDetail
Get the detail exception associated withStandAloneDataTypeManager.ArchiveWarning.LANGUAGE_NOT_FOUNDorStandAloneDataTypeManager.ArchiveWarning.COMPILER_SPEC_NOT_FOUNDwarning (seegetWarning()) immediately following instatiation of thisStandAloneDataTypeManager.- Returns:
- warning detail exception or null
-
getWarningMessage
Get a suitable warning message. SeegetWarning()for type and its severity levelStandAloneDataTypeManager.ArchiveWarning.level().- Parameters:
includeDetails- if false simple message returned, otherwise more details are included.- Returns:
- warning message or null if
getWarning()isStandAloneDataTypeManager.ArchiveWarning.NONE.
-
logWarning
protected void logWarning() -
initializeOtherAdapters
protected void initializeOtherAdapters(OpenMode openMode, TaskMonitor monitor) throws CancelledException, IOException, VersionException Description copied from class:DataTypeManagerDBInitialize other DB adapters after base implementation adapters has been initialized.- Overrides:
initializeOtherAdaptersin classDataTypeManagerDB- Parameters:
openMode- the DB open modemonitor- the progress monitor- Throws:
CancelledException- if the user cancels an upgradeIOException- if a database IO error occurs.VersionException- if the database does not match the expected version.
-
handleDataOrganizationChange
protected void handleDataOrganizationChange(OpenMode openMode, TaskMonitor monitor) throws LanguageVersionException, CancelledException, IOException - Overrides:
handleDataOrganizationChangein classDataTypeManagerDB- Throws:
LanguageVersionExceptionCancelledExceptionIOException
-
getProgramArchitectureSummary
Get the program architecture information which has been associated with this datatype manager. IfDataTypeManagerDB.getProgramArchitecture()returns null this method may still return information if the program architecture was set on an archive and eitherisProgramArchitectureMissing()orisProgramArchitectureUpgradeRequired()returns true.- Specified by:
getProgramArchitectureSummaryin interfaceDataTypeManager- Overrides:
getProgramArchitectureSummaryin classDataTypeManagerDB- Returns:
- program architecture summary if it has been set
-
isProgramArchitectureUpgradeRequired
public boolean isProgramArchitectureUpgradeRequired()Indicates that an program architecture upgrade is required in order to constitute associated data. If true, the associated archive must be open for update to allow the upgrade to complete, or a new program architecture may be set/cleared if such an operation is supported.- Returns:
- true if a program architecture upgrade is required, else false
-
isProgramArchitectureMissing
public boolean isProgramArchitectureMissing()Indicates that a failure occured establishing the program architecture for the associated archive.- Returns:
- true if a failure occured establishing the program architecture
-
clearProgramArchitecture
public void clearProgramArchitecture(TaskMonitor monitor) throws CancelledException, IOException, LockException 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.- 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 requiredjavax.help.UnsupportedOperationException- if architecture change is not permitted by implementation (e.g.,BuiltInDataTypeManager).
-
setProgramArchitecture
public void setProgramArchitecture(Language language, CompilerSpecID compilerSpecId, StandAloneDataTypeManager.LanguageUpdateOption updateOption, TaskMonitor monitor) throws CompilerSpecNotFoundException, LanguageNotFoundException, IOException, CancelledException, LockException, javax.help.UnsupportedOperationException, IncompatibleLanguageException 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.- Parameters:
language- languagecompilerSpecId- compiler specification ID defined by the language.updateOption- indicates how variable storage data should be transitioned. IfisProgramArchitectureMissing()is true andStandAloneDataTypeManager.LanguageUpdateOption.TRANSLATEspecified, 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 occursCancelledException- if task cancelled. If thrown, this data type manager is no longer stable and should be closed without saving.LockException- failure if exclusive access is requiredjavax.help.UnsupportedOperationException- if architecture change is not permittedIncompatibleLanguageException- if translation requested but not possible due to incompatible language architectures
-
setProgramArchitecture
protected void setProgramArchitecture(ProgramArchitecture programArchitecture, VariableStorageManager variableStorageMgr, boolean store, TaskMonitor monitor) throws IOException, CancelledException Set the architecture-specific details associated with a new datatype manager. This method is intended to be used during instantiation of derived implementations.- Overrides:
setProgramArchitecturein classDataTypeManagerDB- Parameters:
programArchitecture- program architecture details (required)variableStorageMgr- variable storage manager. Must be 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. If true and no variable storage is specified it will be created.monitor- task monitor- Throws:
IOException- if IO error occursCancelledException- if task cancelledjavax.help.UnsupportedOperationException- if language was previously set
-
isArchitectureChangeAllowed
protected boolean isArchitectureChangeAllowed()Determine if a program architecture change is permitted- Returns:
- true if change allowed else false if disallowed
-
getName
Description copied from interface:DataTypeManagerReturns this data type manager's name- Specified by:
getNamein interfaceDataTypeManager- Returns:
- the name
-
setName
Description copied from interface:DataTypeManagerSets this data type manager's name- Specified by:
setNamein interfaceDataTypeManager- Parameters:
name- the new name- Throws:
InvalidNameException- if the given name is invalid (such as when null or empty)
-
initTransactionState
protected void initTransactionState() -
openTransaction
Description copied from interface:DataTypeManagerOpen new transaction. This should generally be done with a try-with-resources block:try (Transaction tx = dtm.openTransaction(description)) { // ... Do something }- Specified by:
openTransactionin interfaceDataTypeManager- Parameters:
description- a short description of the changes to be made.- Returns:
- transaction object
- Throws:
IllegalStateException- if thisDataTypeManagerhas already been closed.
-
startTransaction
Description copied from interface:DataTypeManagerStarts a transaction for making changes in this data type manager.- Specified by:
startTransactionin interfaceDataTypeManager- Parameters:
description- a short description of the changes to be made.- Returns:
- the transaction ID
-
getTransactionCount
protected int getTransactionCount()Get the number of active datatype manager transactions- Returns:
- number of active datatype manager transactions
-
endTransaction
public boolean endTransaction(int transactionID, boolean commit) Description copied from interface:DataTypeManagerEnds the current transaction.NOTE: If multiple transactions are outstanding the full transaction will not be ended until all transactions have been ended. If any of the transactions indicate a false for
committhe transaction will ultimately be rolled-back when the final transaction is ended.NOTE: Use of rollback (
commit=falseshould be avoided unless absolutely neccessary since it will incur overhead to revert changes and may rollback multiple concurrent transactions if they exist.NOTE: If this manager is part of a larger
DomainObjectits transactions may become entangled with other transactions at a higher level. In such cases, use of theDomainObjecttransaction interface is preferred. The return value from this method cannot be relied on in such cases.- Specified by:
endTransactionin interfaceDataTypeManager- Parameters:
transactionID- id of the transaction to endcommit- true if changes are committed, false if changes in transaction should be rolled back.- Returns:
- true if this invocation was the final transaction and all changes were comitted.
-
undo
public void undo() -
redo
public void redo() -
clearUndo
protected void clearUndo()Clear undo/redo stack.
NOTE: It is important that this always be invoked following any save operation that compacts the checkpoints within the databaseBufferMgr. -
canRedo
public boolean canRedo()- Returns:
- true if there is a transaction previously undone that can be redone, else false
-
canUndo
public boolean canUndo()Determine if there is a previous transaction that can be reverted/undone (seeundo()).- Returns:
- true if there is a previous transaction that can be reverted/undone, else false.
-
getRedoName
- Returns:
- transaction name that is available for
redo()or empty String.
-
getUndoName
- Returns:
- transaction name that is available for
undo()or empty String.
-
getAllUndoNames
Get all transaction names that are available within theundo()stack.- Returns:
- all transaction names that are available within the
undo()stack.
-
getAllRedoNames
Get all transaction names that are available within theredo()stack.- Returns:
- all transaction names that are available within the
redo()stack.
-
flushEvents
public void flushEvents()Description copied from interface:DataTypeManagerForce all pending notification events to be flushed- Specified by:
flushEventsin interfaceDataTypeManager
-
replaceDataTypesUsed
Description copied from class:DataTypeManagerDBAllow extensions to perform any neccessary fixups to address all datatype replacements.- Specified by:
replaceDataTypesUsedin classDataTypeManagerDB- Parameters:
dataTypeReplacementMap- map of datatype replacements (oldID maps to replacementID).
-
deleteDataTypesUsed
Description copied from class:DataTypeManagerDBAllow extensions to perform any neccessary fixups for all datatype removals listed.- Specified by:
deleteDataTypesUsedin classDataTypeManagerDB- Parameters:
deletedIds- list of IDs for all datatypes which are getting removed.
-
close
public void close()Description copied from interface:DataTypeManagerCloses this dataType manager- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceDataTypeManager- Overrides:
closein classDataTypeManagerDB
-
finalize
public void finalize() -
getDomainFileID
- Specified by:
getDomainFileIDin classDataTypeManagerDB
-
getPath
Get the path name associated with the storage of this stand alone datatype manager.- Specified by:
getPathin classDataTypeManagerDB- Returns:
- path name or null if not applicable
-
getType
Description copied from interface:DataTypeManagerReturns this manager's archive type- Specified by:
getTypein interfaceDataTypeManager- Returns:
- the type
-