Package ghidra.program.model.data
Class StandAloneDataTypeManager
java.lang.Object
ghidra.program.database.data.DataTypeManagerDB
ghidra.program.model.data.StandAloneDataTypeManager
- All Implemented Interfaces:
DataTypeManager,Closeable,AutoCloseable
- Direct Known Subclasses:
BuiltInDataTypeManager,FileDataTypeManager,ProjectDataTypeManager
Basic implementation of the DataTypeManger interface
-
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, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) Constructor for a data-type manager using a specified DBHandle.protectedStandAloneDataTypeManager(ResourceFile packedDbfile, int 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 TypeMethodDescriptionvoidclearProgramArchitecture(TaskMonitor monitor) Clear the program architecture setting and all architecture-specific data from this archive.voidclose()Closes this dataType managerprotected voiddeleteDataTypeIDs(LinkedList<Long> deletedIds, TaskMonitor monitor) Delete all datatype uses external to the datatype manager if applicable.voidendTransaction(int transactionID, boolean commit) Ends the current transactionvoidfinalize()voidForce all pending notification events to be flushedprotected 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.getType()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(int openMode, TaskMonitor monitor) protected voidinitializeOtherAdapters(int openMode, TaskMonitor monitor) Initialize other DB adapters after base implementation adapters has been initialized.protected 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.protected voidreplaceDataTypeIDs(long oldID, long newID) Replace all datatype uses external to the datatype manager if applicable.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.Methods inherited from class ghidra.program.database.data.DataTypeManagerDB
addDataType, addDataTypeManagerListener, addDataTypes, addDataTypeToDelete, addInvalidatedListener, allowsDefaultBuiltInSettings, allowsDefaultComponentSettings, associateDataTypeWithArchive, categoryCreated, categoryMoved, categoryRemoved, categoryRenamed, compilerSpecChanged, contains, containsCategory, createCategory, dataTypeAdded, dataTypeChanged, dataTypeDeleted, dataTypeMoved, dataTypeNameChanged, dataTypeReplaced, dataTypeSettingsChanged, dbError, disassociate, dispose, doSourceArchiveUpdates, favoritesChanged, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, fixupComposites, getAddressMap, getAllComposites, getAllDataTypes, getAllDataTypes, getAllFunctionDefinitions, getAllStructures, getCallingConvention, getCallingConventionID, getCallingConventionName, getCategory, getCategory, getCategoryCount, 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, invalidateCache, isChanged, isCreatingDataType, isFavorite, isTransactionActive, isUpdatable, migrateOldFlexArrayComponentsIfRequired, readDataOrganization, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, replaceSourceArchive, resolve, resolveSourceArchive, saveDataOrganization, setFavorite, sourceArchiveAdded, sourceArchiveChanged, updateID, updateLastChangeTime, updateSourceArchiveName, updateSourceArchiveName
-
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, int 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 UPDATE (seeDBConstants)monitor- 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, int 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 UPDATE (seeDBConstants)errHandler- 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
-
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(int 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 mode (seeDBConstants)monitor- 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(int 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)
-
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
-
flushEvents
public void flushEvents()Description copied from interface:DataTypeManagerForce all pending notification events to be flushed- Specified by:
flushEventsin interfaceDataTypeManager
-
endTransaction
public void endTransaction(int transactionID, boolean commit) Description copied from interface:DataTypeManagerEnds the current transaction- Specified by:
endTransactionin interfaceDataTypeManager- Parameters:
transactionID- id of the transaction to endcommit- true if changes are committed, false if changes in transaction are revoked
-
replaceDataTypeIDs
protected void replaceDataTypeIDs(long oldID, long newID) Description copied from class:DataTypeManagerDBReplace all datatype uses external to the datatype manager if applicable.- Specified by:
replaceDataTypeIDsin classDataTypeManagerDB- Parameters:
oldID- old datatype IDnewID- new datatype ID
-
deleteDataTypeIDs
Description copied from class:DataTypeManagerDBDelete all datatype uses external to the datatype manager if applicable.- Specified by:
deleteDataTypeIDsin classDataTypeManagerDB- Parameters:
deletedIds- old datatype IDs which were deletedmonitor- task monitor
-
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
-