Package ghidra.program.database.data
Class ProgramDataTypeManager
java.lang.Object
ghidra.program.database.data.DataTypeManagerDB
ghidra.program.database.data.ProgramBasedDataTypeManagerDB
ghidra.program.database.data.ProgramDataTypeManager
- All Implemented Interfaces:
ManagerDB
,DataTypeManager
,DomainFileBasedDataTypeManager
,FileBasedDataTypeManager
,ProgramBasedDataTypeManager
Class for managing data types in a program
-
Field Summary
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
-
Constructor Summary
ConstructorDescriptionProgramDataTypeManager
(DBHandle handle, AddressMap addrMap, OpenMode openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) Constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determine if settings are supported for BuiltIn datatypes within this datatype manager.protected void
categoryCreated
(Category newCategory) 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
dataSettingChanged
(Address dataAddr) Provides notification when a data instance setting has changed at a specific address.protected 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) void
Notification when data type settings have changed.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 flushedgetName()
Returns this data type manager's namegetPath()
Get the program instance associated with this datatype managergetType()
Returns this manager's archive typevoid
invalidateCache
(boolean all) Clears all data caches.boolean
Returns true if this DataTypeManager can be modified.void
languageChanged
(TaskMonitor monitor) Update program-architecture information following a language upgrade/changeopenTransaction
(String description) Open new transaction.void
programReady
(OpenMode openMode, int currentRevision, TaskMonitor monitor) Callback from program made to each manager after the program has completed initialization.protected void
replaceDataTypesUsed
(Map<Long, Long> dataTypeReplacementMap) Allow extensions to perform any neccessary fixups to address all datatype replacements.void
Save the current data organization to facilitate future change detection and upgrades.void
Sets this data type manager's namevoid
Callback from program used to indicate all manager have been created.protected void
sourceArchiveAdded
(UniversalID sourceArchiveID) void
sourceArchiveChanged
(UniversalID sourceArchiveID) int
startTransaction
(String description) Starts a transaction for making changes in this data type manager.Methods inherited from class ghidra.program.database.data.ProgramBasedDataTypeManagerDB
clearAllSettings, clearSetting, deleteAddressRange, getDataSettingsAddress, getInstanceSettingsNames, getLongSettingsValue, getSettings, getStringSettingsValue, initializeOtherAdapters, invalidateCache, isChangeAllowed, isEmptySetting, moveAddressRange, setLongSettingsValue, setSettings, setStringSettingsValue
Methods inherited from class ghidra.program.database.data.DataTypeManagerDB
addDataType, addDataTypeManagerListener, addDataTypes, addDataTypeToDelete, addDataTypeToReplace, addInvalidatedListener, allowsDefaultComponentSettings, associateDataTypeWithArchive, compilerSpecChanged, contains, containsCategory, createCategory, 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, getProgramArchitectureSummary, getResolvedID, getRootCategory, getSourceArchive, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, getUnusedConflictName, getUnusedConflictName, getVariableStorageManager, handleDataOrganizationChange, hasDataOrganizationChange, hasParent, isChanged, isCreatingDataType, isFavorite, isTransactionActive, migrateOldFlexArrayComponentsIfRequired, notifyRestored, readDataOrganization, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeParentChildRecord, removeSourceArchive, replaceDataType, replaceSourceArchive, resolve, resolveSourceArchive, setFavorite, setProgramArchitecture, updateID, updateLastChangeTime, updateSourceArchiveName, updateSourceArchiveName
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
addDataType, addDataTypeManagerListener, addDataTypes, addInvalidatedListener, 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, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, resolve, resolveSourceArchive, setFavorite, updateSourceArchiveName, updateSourceArchiveName, withTransaction, withTransaction
Methods inherited from interface ghidra.program.database.ManagerDB
deleteAddressRange, dispose, moveAddressRange
-
Constructor Details
-
ProgramDataTypeManager
public ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, OpenMode openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) throws CancelledException, VersionException, IOException Constructor- Parameters:
handle
- open database handleaddrMap
- the address mapopenMode
- the program open modeerrHandler
- the database io error handlerlock
- the program synchronization lockmonitor
- 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.
-
-
Method Details
-
saveDataOrganization
Save the current data organization to facilitate future change detection and upgrades. This method must be invoked byProgramDB
during the final stage of program creation (i.e., openMode == CREATE).- Overrides:
saveDataOrganization
in classDataTypeManagerDB
- Throws:
IOException
- if failure occured while saving data organization.
-
dataSettingChanged
Description copied from class:ProgramBasedDataTypeManagerDB
Provides notification when a data instance setting has changed at a specific address.- Specified by:
dataSettingChanged
in classProgramBasedDataTypeManagerDB
- Parameters:
dataAddr
- data address
-
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
- Overrides:
allowsDefaultBuiltInSettings
in classDataTypeManagerDB
- Returns:
- true if BuiltIn Settings are permitted
-
setProgram
Description copied from interface:ManagerDB
Callback from program used to indicate all manager have been created. When this method is invoked, all managers have been instantiated but may not be fully initialized.- Specified by:
setProgram
in interfaceManagerDB
- Parameters:
p
- the program is set when all the initializations have been completed.
-
invalidateCache
Description copied from interface:ManagerDB
Clears all data caches.- Specified by:
invalidateCache
in interfaceManagerDB
- Parameters:
all
- if false, some managers may not need to update their cache if they can tell that its not necessary. If this flag is true, then all managers should clear their cache no matter what.- Throws:
IOException
- if a database io error occurs.
-
programReady
public void programReady(OpenMode openMode, int currentRevision, TaskMonitor monitor) throws IOException, CancelledException Description copied from interface:ManagerDB
Callback from program made to each manager after the program has completed initialization. This method may be used by managers to perform additional upgrading which may have been deferred.- Specified by:
programReady
in interfaceManagerDB
- Parameters:
openMode
- the mode that the program is being opened.currentRevision
- current program revision. If openMode is UPGRADE, this value reflects the pre-upgrade value.monitor
- the task monitor to use in any upgrade operations.- Throws:
IOException
- if a database io error occurs.CancelledException
- if the user cancelled the operation via the task monitor.
-
languageChanged
Update program-architecture information following a language upgrade/change- Parameters:
monitor
- task monitor- Throws:
IOException
- if IO error occursCancelledException
- if task monitor cancelled
-
getName
Description copied from interface:DataTypeManager
Returns this data type manager's name- Specified by:
getName
in interfaceDataTypeManager
- Returns:
- the name
-
setName
Description copied from interface:DataTypeManager
Sets this data type manager's name- Specified by:
setName
in interfaceDataTypeManager
- Parameters:
name
- the new name- Throws:
InvalidNameException
- if the given name is invalid (such as when null or empty)
-
sourceArchiveChanged
- Overrides:
sourceArchiveChanged
in classDataTypeManagerDB
-
sourceArchiveAdded
- Overrides:
sourceArchiveAdded
in classDataTypeManagerDB
-
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).
-
dataTypeSettingsChanged
Description copied from class:DataTypeManagerDB
Notification when data type settings have changed.- Overrides:
dataTypeSettingsChanged
in classDataTypeManagerDB
- Parameters:
dt
- data type that is changed
-
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.- Specified by:
replaceDataTypesUsed
in classDataTypeManagerDB
- 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.- Specified by:
deleteDataTypesUsed
in classDataTypeManagerDB
- Parameters:
deletedIds
- list of IDs for all datatypes which are getting removed.
-
isUpdatable
public boolean isUpdatable()Description copied from interface:DataTypeManager
Returns true if this DataTypeManager can be modified.- Specified by:
isUpdatable
in interfaceDataTypeManager
- Overrides:
isUpdatable
in classDataTypeManagerDB
- Returns:
- true if this DataTypeMangaer can be modified.
-
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
- 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
- Parameters:
description
- a short description of the changes to be made.- Returns:
- the transaction ID
-
flushEvents
public void flushEvents()Description copied from interface:DataTypeManager
Force all pending notification events to be flushed- Specified by:
flushEvents
in interfaceDataTypeManager
-
endTransaction
public void endTransaction(int transactionID, boolean commit) Description copied from interface:DataTypeManager
Ends the current transaction- Specified by:
endTransaction
in interfaceDataTypeManager
- Parameters:
transactionID
- id of the transaction to endcommit
- true if changes are committed, false if changes in transaction are revoked
-
close
public void close()Description copied from interface:DataTypeManager
Closes this dataType manager- Specified by:
close
in interfaceDataTypeManager
- Overrides:
close
in classDataTypeManagerDB
-
getProgram
Description copied from interface:ProgramBasedDataTypeManager
Get the program instance associated with this datatype manager- Specified by:
getProgram
in interfaceProgramBasedDataTypeManager
- Returns:
- program instance associated with this datatype manager
-
getDomainFile
- Specified by:
getDomainFile
in interfaceDomainFileBasedDataTypeManager
-
getDomainFileID
- Specified by:
getDomainFileID
in classDataTypeManagerDB
-
getPath
- Specified by:
getPath
in interfaceFileBasedDataTypeManager
- Specified by:
getPath
in classDataTypeManagerDB
-
getType
Description copied from interface:DataTypeManager
Returns this manager's archive type- Specified by:
getType
in interfaceDataTypeManager
- Returns:
- the type
-