Package ghidra.program.database.external
Class ExternalManagerDB
java.lang.Object
ghidra.program.database.external.ExternalManagerDB
- All Implemented Interfaces:
ManagerDB
,ExternalManager
Manages the database for external references.
-
Constructor Summary
ConstructorDescriptionExternalManagerDB
(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) Constructs a new ExternalManagerDB -
Method Summary
Modifier and TypeMethodDescriptionaddExternalLibraryName
(String name, SourceType source) Adds a new external library nameaddExtFunction
(Namespace extParentNamespace, String extLabel, Address extAddr, SourceType sourceType) Create an externalFunction
in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
.addExtFunction
(Namespace extNamespace, String extLabel, Address extAddr, SourceType sourceType, boolean reuseExisting) Get or create an externalFunction
in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
.addExtFunction
(String extLibraryName, String extLabel, Address extAddr, SourceType sourceType) addExtLocation
(Namespace extParentNamespace, String extLabel, Address extAddr, SourceType sourceType) Create an external location in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
.addExtLocation
(Namespace extParentNamespace, String extLabel, Address extAddr, SourceType sourceType, boolean reuseExisting) Get or create an external location in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
.addExtLocation
(String extLibraryName, String extLabel, Address extAddr, SourceType sourceType) Get or create an external location associated with a library/file namedlibraryName
and the location within that file identified byextLabel
and/or its memory addressextAddr
.boolean
Determines if the indicated external library name is being managed (exists).void
deleteAddressRange
(Address startAddr, Address endAddr, TaskMonitor monitor) Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.static String
Get the default name for an external function or code symbolgetExternalLibrary
(String name) Get the Library which corresponds to the specified nameString[]
Returns an array of all external names for which locations have been defined.getExternalLibraryPath
(String externalName) Returns the file pathname associated with an external name.getExternalLocation
(Namespace extNamespace, String extLabel) Get an external location.getExternalLocation
(Symbol symbol) Returns the external location associated with the given external symbolgetExternalLocation
(String extName, String extLabel) Get an external location.getExternalLocations
(Address memoryAddress) Get an iterator over all external locations which have been associated to the specified memory addressgetExternalLocations
(Namespace libScope, String extLabel) Returns a list of External Locations matching the given label name in the given Namespace.getExternalLocations
(String externalName) Get an iterator over all external locations associated with the specified externalName.getExternalLocations
(String libraryName, String label) Returns a list of External Locations matching the given label name in the given Library.getExtLocation
(Address externalAddr) Returns the external location associated with the given external addressgetUniqueExternalLocation
(Namespace namespace, String label) Returns the unique external location associated with the given namespace and labelgetUniqueExternalLocation
(String libraryName, String label) Returns the unique external location associated with the given library name and labelvoid
invalidateCache
(boolean all) Clears all data caches.void
moveAddressRange
(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) Move all objects within an address range to a new location.void
programReady
(OpenMode openMode, int currentRevision, TaskMonitor monitor) Callback from program made to each manager after the program has completed initialization.boolean
removeExternalLibrary
(String name) Removes external name if no associated ExternalLocation's existboolean
removeExternalLocation
(Address externalAddr) Removes the external location at the given external addressvoid
setExternalPath
(String externalName, String externalPath, boolean userDefined) Sets the file pathname associated with an existing external name.void
setLanguage
(LanguageTranslator translator, TaskMonitor monitor) void
setProgram
(ProgramDB program) Callback from program used to indicate all manager have been created.void
updateExternalLibraryName
(String oldName, String newName, SourceType source) Update the external program for all references.
-
Constructor Details
-
ExternalManagerDB
public ExternalManagerDB(DBHandle handle, AddressMap addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) throws CancelledException, IOException, VersionException Constructs a new ExternalManagerDB- Parameters:
handle
- the open database handleaddrMap
- the address mapopenMode
- the program open mode.lock
- the program synchronization lockmonitor
- the progress monitor used when upgrading- Throws:
CancelledException
- if the user cancelled while an upgrade was occurringIOException
- if a database io error occurs.VersionException
- if the database version does not match the expected version
-
-
Method Details
-
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:
program
- the program is set when all the initializations have been completed.
-
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.
-
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.
-
deleteAddressRange
public void deleteAddressRange(Address startAddr, Address endAddr, TaskMonitor monitor) throws CancelledException Description copied from interface:ManagerDB
Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly. The specified start and end addresses must form a valid range within a singleAddressSpace
.- Specified by:
deleteAddressRange
in interfaceManagerDB
- Parameters:
startAddr
- the first address in the range.endAddr
- the last address in the range.monitor
- the task monitor to use in any upgrade operations.- Throws:
CancelledException
- if the user cancelled the operation via the task monitor.
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws CancelledException Description copied from interface:ManagerDB
Move all objects within an address range to a new location.- Specified by:
moveAddressRange
in interfaceManagerDB
- Parameters:
fromAddr
- the first address of the range to be moved.toAddr
- the address where to the range is to be moved.length
- the number of addresses to move.monitor
- the task monitor to use in any upgrade operations.- Throws:
CancelledException
- if the user cancelled the operation via the task monitor.
-
addExtLocation
public ExternalLocation addExtLocation(String extLibraryName, String extLabel, Address extAddr, SourceType sourceType) throws InvalidInputException, DuplicateNameException Description copied from interface:ExternalManager
Get or create an external location associated with a library/file namedlibraryName
and the location within that file identified byextLabel
and/or its memory addressextAddr
. Either or bothextLabel
orextAddr
must be specified.- Specified by:
addExtLocation
in interfaceExternalManager
- Parameters:
extLibraryName
- the external library nameextLabel
- the external label or nullextAddr
- the external memory address or nullsourceType
- the source type of this external library's symbol- Returns:
- external location
- Throws:
InvalidInputException
- iflibraryName
is invalid or null, or an invalidextlabel
is specified. Names with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.DuplicateNameException
- if another non-Library namespace has the same name
-
addExtLocation
public ExternalLocation addExtLocation(Namespace extParentNamespace, String extLabel, Address extAddr, SourceType sourceType) throws InvalidInputException Description copied from interface:ExternalManager
Create an external location in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
. Either or bothextLabel
orextAddr
must be specified.- Specified by:
addExtLocation
in interfaceExternalManager
- Parameters:
extParentNamespace
- the external namespaceextLabel
- the external label or nullextAddr
- the external memory address or nullsourceType
- the source type of this external library's symbol- Returns:
- external location
- Throws:
InvalidInputException
- if an invalidextlabel
is specified. Names with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.
-
addExtLocation
public ExternalLocation addExtLocation(Namespace extParentNamespace, String extLabel, Address extAddr, SourceType sourceType, boolean reuseExisting) throws InvalidInputException Description copied from interface:ExternalManager
Get or create an external location in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
. Either or bothextLabel
orextAddr
must be specified.- Specified by:
addExtLocation
in interfaceExternalManager
- Parameters:
extParentNamespace
- the external namespaceextLabel
- the external label or nullextAddr
- the external memory address or nullsourceType
- the source type of this external library's symbolreuseExisting
- if true, this will return an existing matching external location instead of creating a new one.- Returns:
- external location
- Throws:
InvalidInputException
- if an invalidextlabel
is specified. Names with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.
-
addExtFunction
public ExternalLocation addExtFunction(String extLibraryName, String extLabel, Address extAddr, SourceType sourceType) throws InvalidInputException, DuplicateNameException Description copied from interface:ExternalManager
Create an externalFunction
in the externalLibrary
namespacelibararyName
and identified byextLabel
and/or its memory addressextAddr
. Either or bothextLabel
orextAddr
must be specified.- Specified by:
addExtFunction
in interfaceExternalManager
- Parameters:
extLibraryName
- the external library nameextLabel
- label within the external program, may be null if extAddr is not nullextAddr
- memory address within the external program, may be nullsourceType
- the source type of this external library's symbol- Returns:
- external location
- Throws:
InvalidInputException
- iflibraryName
is invalid or null, or an invalidextlabel
is specified. Names with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.DuplicateNameException
- if another non-Library namespace has the same name
-
addExtFunction
public ExternalLocation addExtFunction(Namespace extParentNamespace, String extLabel, Address extAddr, SourceType sourceType) throws InvalidInputException Description copied from interface:ExternalManager
Create an externalFunction
in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
. Either or bothextLabel
orextAddr
must be specified.- Specified by:
addExtFunction
in interfaceExternalManager
- Parameters:
extParentNamespace
- the external namespaceextLabel
- the external label or nullextAddr
- the external memory address or nullsourceType
- the source type of this external library's symbol- Returns:
- external location
- Throws:
InvalidInputException
- if an invalidextlabel
is specified. Names with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.
-
addExtFunction
public ExternalLocation addExtFunction(Namespace extNamespace, String extLabel, Address extAddr, SourceType sourceType, boolean reuseExisting) throws InvalidInputException Description copied from interface:ExternalManager
Get or create an externalFunction
in the indicated external parent namespace and identified byextLabel
and/or its memory addressextAddr
. Either or bothextLabel
orextAddr
must be specified.- Specified by:
addExtFunction
in interfaceExternalManager
- Parameters:
extNamespace
- the external namespaceextLabel
- the external label or nullextAddr
- the external memory address or nullsourceType
- the source type of this external library's symbolreuseExisting
- if true, will return any existing matching location instead of creating a new one. If false, will prefer to create a new one as long as the specified address is not null and not used in an existing location.- Returns:
- external location
- Throws:
InvalidInputException
- if an invalidextlabel
is specified. Names with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.
-
getExternalLocations
Description copied from interface:ExternalManager
Returns a list of External Locations matching the given label name in the given Namespace.- Specified by:
getExternalLocations
in interfaceExternalManager
- Parameters:
libScope
- the Namespace to searchextLabel
- the name of the labels to search for.- Returns:
- a list of External Locations matching the given label name in the given Namespace.
-
getExternalLocations
Description copied from interface:ExternalManager
Returns a list of External Locations matching the given label name in the given Library.- Specified by:
getExternalLocations
in interfaceExternalManager
- Parameters:
libraryName
- the name of the librarylabel
- the name of the label- Returns:
- a list of External Locations matching the given label name in the given Library.
-
getUniqueExternalLocation
Description copied from interface:ExternalManager
Returns the unique external location associated with the given namespace and label- Specified by:
getUniqueExternalLocation
in interfaceExternalManager
- Parameters:
namespace
- the namespacelabel
- the label of the external location- Returns:
- the unique external location or null
-
getUniqueExternalLocation
Description copied from interface:ExternalManager
Returns the unique external location associated with the given library name and label- Specified by:
getUniqueExternalLocation
in interfaceExternalManager
- Parameters:
libraryName
- the library namelabel
- the label of the external location- Returns:
- the unique external location or null
-
getExternalLocation
Description copied from interface:ExternalManager
Get an external location.- Specified by:
getExternalLocation
in interfaceExternalManager
- Parameters:
extName
- the name of the library for which to get an external locationextLabel
- the name of the external location.- Returns:
- first matching external location
-
getExternalLocation
Description copied from interface:ExternalManager
Get an external location.- Specified by:
getExternalLocation
in interfaceExternalManager
- Parameters:
extNamespace
- the namespace containing the external label.extLabel
- the name of the external location.- Returns:
- first matching external location
-
getDefaultExternalName
Get the default name for an external function or code symbol- Parameters:
sym
-- Returns:
- default name
-
getExtLocation
Returns the external location associated with the given external address- Parameters:
externalAddr
- the external address.
-
getExternalLocation
Description copied from interface:ExternalManager
Returns the external location associated with the given external symbol- Specified by:
getExternalLocation
in interfaceExternalManager
- Parameters:
symbol
- the external symbol.- Returns:
- the external location or null
-
removeExternalLocation
Removes the external location at the given external address- Parameters:
externalAddr
- the address at which to remove the external location.
-
removeExternalLibrary
Description copied from interface:ExternalManager
Removes external name if no associated ExternalLocation's exist- Specified by:
removeExternalLibrary
in interfaceExternalManager
- Parameters:
name
- external library name- Returns:
- true if removed, false if unable to due to associated locations/references
-
updateExternalLibraryName
public void updateExternalLibraryName(String oldName, String newName, SourceType source) throws DuplicateNameException, InvalidInputException Update the external program for all references.- Specified by:
updateExternalLibraryName
in interfaceExternalManager
- Parameters:
oldName
- old external program namenewName
- new external program namesource
- the source of this external library: Symbol.DEFAULT, Symbol.ANALYSIS, Symbol.IMPORTED, or Symbol.USER_DEFINED- Throws:
DuplicateNameException
InvalidInputException
-
addExternalLibraryName
public Library addExternalLibraryName(String name, SourceType source) throws DuplicateNameException, InvalidInputException Description copied from interface:ExternalManager
Adds a new external library name- Specified by:
addExternalLibraryName
in interfaceExternalManager
- Parameters:
name
- the new external library name to add.source
- the source of this external library- Returns:
- library external
namespace
- Throws:
DuplicateNameException
- if another non-Library namespace has the same nameInvalidInputException
- iflibraryName
is invalid or null. A library name with spaces or the empty string are not permitted. NeitherextLabel
norextAddr
was specified properly.
-
contains
Description copied from interface:ExternalManager
Determines if the indicated external library name is being managed (exists).- Specified by:
contains
in interfaceExternalManager
- Parameters:
libraryName
- the external library name- Returns:
- true if the name is defined (whether it has a path or not).
-
getExternalLibraryNames
Description copied from interface:ExternalManager
Returns an array of all external names for which locations have been defined.- Specified by:
getExternalLibraryNames
in interfaceExternalManager
- Returns:
- array of external names
-
getExternalLibrary
Description copied from interface:ExternalManager
Get the Library which corresponds to the specified name- Specified by:
getExternalLibrary
in interfaceExternalManager
- Parameters:
name
- name of library- Returns:
- library or null if not found
-
getExternalLibraryPath
Description copied from interface:ExternalManager
Returns the file pathname associated with an external name. Null is returned if either the external name does not exist or a pathname has not been set.- Specified by:
getExternalLibraryPath
in interfaceExternalManager
- Parameters:
externalName
- external name- Returns:
- project file pathname or null
-
setExternalPath
public void setExternalPath(String externalName, String externalPath, boolean userDefined) throws InvalidInputException Description copied from interface:ExternalManager
Sets the file pathname associated with an existing external name.- Specified by:
setExternalPath
in interfaceExternalManager
- Parameters:
externalName
- the name of the library to associate with a file.externalPath
- the path to the program to be associated with the library name.userDefined
- true if the external path is being specified by the user- Throws:
InvalidInputException
-
getExternalLocations
Description copied from interface:ExternalManager
Get an iterator over all external locations which have been associated to the specified memory address- Specified by:
getExternalLocations
in interfaceExternalManager
- Parameters:
memoryAddress
- memory address- Returns:
- external location iterator
-
getExternalLocations
Description copied from interface:ExternalManager
Get an iterator over all external locations associated with the specified externalName.- Specified by:
getExternalLocations
in interfaceExternalManager
- Parameters:
externalName
- the name of the library to get locations for- Returns:
- external location iterator
-
setLanguage
public void setLanguage(LanguageTranslator translator, TaskMonitor monitor) throws CancelledException - Throws:
CancelledException
-