Package ghidra.program.database.data
Class ProgramDataTypeManager
- java.lang.Object
-
- ghidra.program.database.data.DataTypeManagerDB
-
- ghidra.program.database.data.ProgramDataTypeManager
-
- All Implemented Interfaces:
ManagerDB
,DataTypeManager
,DomainFileBasedDataTypeManager
,FileBasedDataTypeManager
,ProgramBasedDataTypeManager
public class ProgramDataTypeManager extends DataTypeManagerDB implements ManagerDB, ProgramBasedDataTypeManager
Class for managing data types in a program
-
-
Field Summary
-
Fields inherited from class ghidra.program.database.data.DataTypeManagerDB
dataOrganization, dbHandle, defaultListener, sourceArchiveAdapter, universalID
-
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
Constructors Constructor Description ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor)
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
categoryCreated(Category newCategory)
protected void
categoryMoved(CategoryPath oldPath, Category category)
protected void
categoryRemoved(Category parent, java.lang.String name, long categoryID)
protected void
categoryRenamed(CategoryPath oldPath, Category category)
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, java.lang.String oldName)
protected void
dataTypeReplaced(long existingDtID, DataTypePath existingPath, DataType replacementDt)
protected void
deleteDataTypeIDs(java.util.LinkedList<java.lang.Long> deletedIds, TaskMonitor monitor)
void
endTransaction(int transactionID, boolean commit)
Ends the current transactionprotected void
favoritesChanged(DataType dataType, boolean isFavorite)
void
flushEvents()
Force all pending notification events to be flushedDataOrganization
getDataOrganization()
Get the data organization associated with this data type manager.DomainFile
getDomainFile()
java.lang.String
getDomainFileID()
java.lang.String
getName()
Returns this data type manager's namejava.lang.String
getPath()
Pointer
getPointer(DataType dt)
Returns a default sized pointer to the given datatype.Program
getProgram()
ArchiveType
getType()
Returns this manager's archive typevoid
invalidateCache(boolean all)
Clears all data caches.boolean
isUpdatable()
Returns true if this DataTypeManager can be modified.void
programReady(int openMode, int currentRevision, TaskMonitor monitor)
Callback from program made to each manager after the program has completed initialization.protected void
replaceDataTypeIDs(long oldDataTypeID, long newDataTypeID)
void
setName(java.lang.String name)
Sets this data type manager's namevoid
setProgram(ProgramDB p)
Callback from program used to indicate all manager have been created.protected void
sourceArchiveAdded(UniversalID sourceArchiveID)
void
sourceArchiveChanged(UniversalID sourceArchiveID)
int
startTransaction(java.lang.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, associateDataTypeWithArchive, clearAllSettings, clearSetting, clearSettings, contains, containsCategory, createCategory, dbError, deleteAddressRange, disassociate, dispose, doSourceArchiveUpdates, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, fixupComposites, getAllComposites, getAllDataTypes, getAllDataTypes, getAllStructures, getByteSettingsValue, getCategory, getCategory, getCategoryCount, getDataType, getDataType, getDataType, getDataType, getDataType, getDataTypeCount, getDataTypes, getDataTypes, getDataTypesContaining, getFavorites, getID, getLastChangeTimeForMyManager, getLocalSourceArchive, getLongSettingsValue, getNames, getPointer, getResolvedID, getRootCategory, getSettings, getSourceArchive, getSourceArchive, getSourceArchives, getStringSettingsValue, getUniqueName, getUniqueName, getUniversalID, getUnusedConflictName, invalidateCache, isChanged, isCreatingDataType, isEmptySetting, isFavorite, isTransactionActive, migrateOldFlexArrayComponentsIfRequired, moveAddressRange, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, replaceSourceArchive, resolve, resolveSourceArchive, setByteSettingsValue, setFavorite, setLongSettingsValue, setSettings, setStringSettingsValue, updateID, 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, associateDataTypeWithArchive, contains, containsCategory, createCategory, disassociate, findDataType, findDataTypeForID, findDataTypes, findDataTypes, findEnumValueNames, getAllComposites, getAllDataTypes, getAllDataTypes, getAllStructures, getCategory, getCategory, getCategoryCount, getDataType, getDataType, getDataType, getDataType, getDataType, getDataTypeCount, getDataTypes, getDataTypesContaining, getFavorites, getID, getLastChangeTimeForMyManager, getLocalSourceArchive, getPointer, getResolvedID, getRootCategory, getSourceArchive, getSourceArchives, getUniqueName, getUniversalID, isFavorite, remove, removeDataTypeManagerListener, removeInvalidatedListener, removeSourceArchive, replaceDataType, resolve, resolveSourceArchive, setFavorite, updateSourceArchiveName, updateSourceArchiveName
-
Methods inherited from interface ghidra.program.database.ManagerDB
deleteAddressRange, dispose, moveAddressRange
-
-
-
-
Constructor Detail
-
ProgramDataTypeManager
public ProgramDataTypeManager(DBHandle handle, AddressMap addrMap, int openMode, ErrorHandler errHandler, Lock lock, TaskMonitor monitor) throws CancelledException, VersionException, java.io.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.java.io.IOException
- if a database io error occurs.
-
-
Method Detail
-
setProgram
public void setProgram(ProgramDB p)
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
public void invalidateCache(boolean all) throws java.io.IOException
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:
java.io.IOException
- if a database io error occurs.
-
programReady
public void programReady(int openMode, int currentRevision, TaskMonitor monitor) throws java.io.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:
java.io.IOException
- if a database io error occurs.CancelledException
- if the user cancelled the operation via the task monitor.
-
getName
public java.lang.String getName()
Description copied from interface:DataTypeManager
Returns this data type manager's name- Specified by:
getName
in interfaceDataTypeManager
- Returns:
- the name
-
getPointer
public Pointer getPointer(DataType dt)
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
- Overrides:
getPointer
in classDataTypeManagerDB
- Parameters:
dt
- the pointed to data type- Returns:
- the pointer
-
setName
public void setName(java.lang.String name) throws InvalidNameException
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
public void sourceArchiveChanged(UniversalID sourceArchiveID)
- Overrides:
sourceArchiveChanged
in classDataTypeManagerDB
-
sourceArchiveAdded
protected void sourceArchiveAdded(UniversalID sourceArchiveID)
- Overrides:
sourceArchiveAdded
in classDataTypeManagerDB
-
dataTypeChanged
public void dataTypeChanged(DataType dt, boolean isAutoChange)
Description copied from interface:DataTypeManager
Notification when data type is changed.- Specified by:
dataTypeChanged
in interfaceDataTypeManager
- 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
protected void dataTypeAdded(DataType newDt, DataType originalDataType)
- Overrides:
dataTypeAdded
in classDataTypeManagerDB
-
dataTypeReplaced
protected void dataTypeReplaced(long existingDtID, DataTypePath existingPath, DataType replacementDt)
- Overrides:
dataTypeReplaced
in classDataTypeManagerDB
-
dataTypeDeleted
protected void dataTypeDeleted(long deletedID, DataTypePath deletedDataTypePath)
- Overrides:
dataTypeDeleted
in classDataTypeManagerDB
-
dataTypeMoved
protected void dataTypeMoved(DataType dt, DataTypePath oldPath, DataTypePath newPath)
- Overrides:
dataTypeMoved
in classDataTypeManagerDB
-
dataTypeNameChanged
protected void dataTypeNameChanged(DataType dt, java.lang.String oldName)
- Overrides:
dataTypeNameChanged
in classDataTypeManagerDB
-
categoryCreated
protected void categoryCreated(Category newCategory)
- Overrides:
categoryCreated
in classDataTypeManagerDB
-
categoryRenamed
protected void categoryRenamed(CategoryPath oldPath, Category category)
- Overrides:
categoryRenamed
in classDataTypeManagerDB
-
categoryRemoved
protected void categoryRemoved(Category parent, java.lang.String name, long categoryID)
- Overrides:
categoryRemoved
in classDataTypeManagerDB
-
categoryMoved
protected void categoryMoved(CategoryPath oldPath, Category category)
- Overrides:
categoryMoved
in classDataTypeManagerDB
-
favoritesChanged
protected void favoritesChanged(DataType dataType, boolean isFavorite)
- Overrides:
favoritesChanged
in classDataTypeManagerDB
-
replaceDataTypeIDs
protected void replaceDataTypeIDs(long oldDataTypeID, long newDataTypeID)
- Specified by:
replaceDataTypeIDs
in classDataTypeManagerDB
-
deleteDataTypeIDs
protected void deleteDataTypeIDs(java.util.LinkedList<java.lang.Long> deletedIds, TaskMonitor monitor) throws CancelledException
- Specified by:
deleteDataTypeIDs
in classDataTypeManagerDB
- Throws:
CancelledException
-
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.
-
startTransaction
public int startTransaction(java.lang.String description)
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
public Program getProgram()
- Specified by:
getProgram
in interfaceProgramBasedDataTypeManager
-
getDomainFile
public DomainFile getDomainFile()
- Specified by:
getDomainFile
in interfaceDomainFileBasedDataTypeManager
-
getDomainFileID
public java.lang.String getDomainFileID()
- Specified by:
getDomainFileID
in classDataTypeManagerDB
-
getPath
public java.lang.String getPath()
- Specified by:
getPath
in interfaceFileBasedDataTypeManager
- Specified by:
getPath
in classDataTypeManagerDB
-
getType
public ArchiveType getType()
Description copied from interface:DataTypeManager
Returns this manager's archive type- Specified by:
getType
in interfaceDataTypeManager
- Returns:
- the type
-
getDataOrganization
public DataOrganization 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
- Overrides:
getDataOrganization
in classDataTypeManagerDB
- Returns:
- data organization (will never be null)
-
-