Class SourceFileManagerDB
java.lang.Object
ghidra.program.database.sourcemap.SourceFileManagerDB
- All Implemented Interfaces:
ErrorHandler,ManagerDB,SourceFileManager
public class SourceFileManagerDB
extends Object
implements SourceFileManager, ManagerDB, ErrorHandler
Database Manager for managing source files and source map information.
-
Field Summary
FieldsFields inherited from interface ghidra.program.model.sourcemap.SourceFileManager
DUMMY -
Constructor Summary
ConstructorsConstructorDescriptionSourceFileManagerDB(DBHandle dbh, AddressMapDB addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) Constructor -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddSourceFile(SourceFile sourceFile) Adds aSourceFileto this manager.addSourceMapEntry(SourceFile sourceFile, int lineNumber, Address baseAddr, long length) Creates aSourceMapEntrywithSourceFilesourceFile, line numberlineNumber, and non-negative lengthlengthand adds it to the program database.booleancontainsSourceFile(SourceFile sourceFile) Returns true precisely when this manager containssourceFile.voidNotification that an IO exception occurred.voiddeleteAddressRange(Address start, Address end, TaskMonitor monitor) Delete all objects which have been applied to the address range startAddr to endAddr and update the database accordingly.Returns aListcontaining allSourceFiles of the program.Returns aListcontainingSourceFiles which are mapped to at least one address in the programgetSourceMapEntries(SourceFile sourceFile, int minLine, int maxLine) Returns the sorted list ofSourceMapEntrys forsourceFilewith line number betweenminLineandmaxLine, inclusive.getSourceMapEntries(Address addr) Returns a sorted list ofSourceMapEntrys associated with an addressaddr.getSourceMapEntryIterator(Address address, boolean forward) Returns aSourceMapEntryIteratorstarting ataddress.booleanvoidinvalidateCache(boolean all) Clears all data caches.voidmoveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) Move all objects within an address range to a new location.voidprogramReady(OpenMode openMode, int currentRevision, TaskMonitor monitor) Callback from program made to each manager after the program has completed initialization.booleanremoveSourceFile(SourceFile sourceFile) Removes aSourceFilefrom this manager.booleanRemoves aSourceMapEntryfrom this manager.voidsetProgram(ProgramDB program) Callback from program used to indicate all manager have been created.voidtransferSourceMapEntries(SourceFile source, SourceFile target) Changes the source map so that anySourceMapEntryassociated withsourceis associated withtargetinstead.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ghidra.program.model.sourcemap.SourceFileManager
addSourceMapEntry, getSourceMapEntries, getSourceMapEntries
-
Field Details
-
lock
-
-
Constructor Details
-
SourceFileManagerDB
public SourceFileManagerDB(DBHandle dbh, AddressMapDB addrMap, OpenMode openMode, Lock lock, TaskMonitor monitor) throws VersionException Constructor- Parameters:
dbh- database handleaddrMap- map longs to addressesopenMode- modelock- program synchronization lockmonitor- task monitor- Throws:
VersionException- if the database is incompatible with the current schema
-
-
Method Details
-
setProgram
Description copied from interface:ManagerDBCallback 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:
setProgramin 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:ManagerDBCallback 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:
programReadyin 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:ManagerDBClears all data caches.- Specified by:
invalidateCachein 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 start, Address end, TaskMonitor monitor) throws CancelledException 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.
Note: this method will split any source map entries that intersect the address range but are not entirely contained within it. Parts within the range to delete will be deleted.- Specified by:
deleteAddressRangein interfaceManagerDB- Parameters:
start- first address in rangeend- last address in rangemonitor- task monitor- Throws:
CancelledException- ifmonitoris cancelled
-
moveAddressRange
public void moveAddressRange(Address fromAddr, Address toAddr, long length, TaskMonitor monitor) throws AddressOverflowException, CancelledException Move all objects within an address range to a new location.
Note: this method will move any source map entry which is entirely contained within the source address range. Entries which also contain addresses outside of this range will be split and parts within the range to move will be moved.- Specified by:
moveAddressRangein interfaceManagerDB- Parameters:
fromAddr- first address of range to be movedtoAddr- target addresslength- number of addresses to movemonitor- task monitor- Throws:
AddressOverflowException- if overflow occurs when computing new addressesCancelledException- ifmonitoris cancelled
-
addSourceFile
Description copied from interface:SourceFileManagerAdds aSourceFileto this manager. A SourceFile must be added before it can be associated with any source map information.- Specified by:
addSourceFilein interfaceSourceFileManager- Parameters:
sourceFile- source file to add (can't be null)- Returns:
- true if this manager did not already contain sourceFile
- Throws:
LockException- if invoked without exclusive access
-
removeSourceFile
Description copied from interface:SourceFileManagerRemoves aSourceFilefrom this manager. Any associatedSourceMapEntrys will also be removed.- Specified by:
removeSourceFilein interfaceSourceFileManager- Parameters:
sourceFile- source file to remove- Returns:
- true if sourceFile was in the manager
- Throws:
LockException- if invoked without exclusive access
-
getSourceMapEntries
Description copied from interface:SourceFileManagerReturns a sorted list ofSourceMapEntrys associated with an addressaddr.- Specified by:
getSourceMapEntriesin interfaceSourceFileManager- Parameters:
addr- address- Returns:
- line number
-
addSourceMapEntry
public SourceMapEntry addSourceMapEntry(SourceFile sourceFile, int lineNumber, Address baseAddr, long length) throws LockException, AddressOverflowException Description copied from interface:SourceFileManagerCreates aSourceMapEntrywithSourceFilesourceFile, line numberlineNumber, and non-negative lengthlengthand adds it to the program database.Entries with non-zero lengths must either cover the same address range or be disjoint.
- Specified by:
addSourceMapEntryin interfaceSourceFileManager- Parameters:
sourceFile- source filelineNumber- line numberbaseAddr- minimum address of rangelength- number of addresses in range- Returns:
- created SourceMapEntry
- Throws:
LockException- if invoked without exclusive accessAddressOverflowException- if baseAddr + length-1 overflows
-
intersectsSourceMapEntry
Description copied from interface:SourceFileManager- Specified by:
intersectsSourceMapEntryin interfaceSourceFileManager- Parameters:
addrs- addresses to check- Returns:
- true when at least one address has source map info
-
dbError
Description copied from interface:ErrorHandlerNotification that an IO exception occurred.- Specified by:
dbErrorin interfaceErrorHandler- Parameters:
e-IOExceptionwhich was cause of error- Throws:
RuntimeException- optional exception which may be thrown when responding to error condition.
-
getMappedSourceFiles
Description copied from interface:SourceFileManagerReturns aListcontainingSourceFiles which are mapped to at least one address in the program- Specified by:
getMappedSourceFilesin interfaceSourceFileManager- Returns:
- mapped source file list
-
getAllSourceFiles
Description copied from interface:SourceFileManagerReturns aListcontaining allSourceFiles of the program.- Specified by:
getAllSourceFilesin interfaceSourceFileManager- Returns:
- source file list
-
transferSourceMapEntries
Description copied from interface:SourceFileManagerChanges the source map so that anySourceMapEntryassociated withsourceis associated withtargetinstead. Any entries associated withtargetbefore invocation will still be associated withtargetafter invocation.sourcewill not be associated with any entries after invocation (unlesssourceandtargetare the same). Line number information is not changed.- Specified by:
transferSourceMapEntriesin interfaceSourceFileManager- Parameters:
source- source file to get info fromtarget- source file to move info to- Throws:
LockException- if invoked without exclusive access
-
getSourceMapEntryIterator
Description copied from interface:SourceFileManagerReturns aSourceMapEntryIteratorstarting ataddress.- Specified by:
getSourceMapEntryIteratorin interfaceSourceFileManager- Parameters:
address- starting addressforward- direction of iterator (true = forward)- Returns:
- iterator
-
containsSourceFile
Description copied from interface:SourceFileManagerReturns true precisely when this manager containssourceFile.- Specified by:
containsSourceFilein interfaceSourceFileManager- Parameters:
sourceFile- source file- Returns:
- true if source file already added
-
getSourceMapEntries
Description copied from interface:SourceFileManagerReturns the sorted list ofSourceMapEntrys forsourceFilewith line number betweenminLineandmaxLine, inclusive.- Specified by:
getSourceMapEntriesin interfaceSourceFileManager- Parameters:
sourceFile- source fileminLine- minimum line numbermaxLine- maximum line number- Returns:
- source map entries
-
removeSourceMapEntry
Description copied from interface:SourceFileManagerRemoves aSourceMapEntryfrom this manager.- Specified by:
removeSourceMapEntryin interfaceSourceFileManager- Parameters:
entry- entry to remove- Returns:
- true if entry was in the manager
- Throws:
LockException- if invoked without exclusive access
-