Package ghidra.program.model.sourcemap
Interface SourceFileManager
- All Known Implementing Classes:
DummySourceFileManager,SourceFileManagerDB
public interface SourceFileManager
This interface defines methods for managing
SourceFiles and SourceMapEntrys.-
Field Summary
Fields -
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.default SourceMapEntryaddSourceMapEntry(SourceFile sourceFile, int lineNumber, AddressRange range) Adds aSourceMapEntrywithSourceFilesourceFile, line numberlineNumber, andAddressRangerangeto the program database.booleancontainsSourceFile(SourceFile sourceFile) Returns true precisely when this manager containssourceFile.Returns aListcontaining allSourceFiles of the program.Returns aListcontainingSourceFiles which are mapped to at least one address in the programdefault List<SourceMapEntry> getSourceMapEntries(SourceFile sourceFile) Returns a sorted of list allSourceMapEntrys in the program corresponding tosourceFile.default List<SourceMapEntry> getSourceMapEntries(SourceFile sourceFile, int lineNumber) getSourceMapEntries(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.booleanbooleanremoveSourceFile(SourceFile sourceFile) Removes aSourceFilefrom this manager.booleanRemoves aSourceMapEntryfrom this manager.voidtransferSourceMapEntries(SourceFile source, SourceFile target) Changes the source map so that anySourceMapEntryassociated withsourceis associated withtargetinstead.
-
Field Details
-
DUMMY
-
-
Method Details
-
getSourceMapEntries
Returns a sorted list ofSourceMapEntrys associated with an addressaddr.- Parameters:
addr- address- Returns:
- line number
-
addSourceMapEntry
default SourceMapEntry addSourceMapEntry(SourceFile sourceFile, int lineNumber, AddressRange range) throws LockException Adds aSourceMapEntrywithSourceFilesourceFile, line numberlineNumber, andAddressRangerangeto the program database.Entries with non-zero lengths must either cover the same address range or be disjoint.
- Parameters:
sourceFile- source filelineNumber- line numberrange- address range- Returns:
- created SourceMapEntry
- Throws:
LockException- if invoked without exclusive accessIllegalArgumentException- if the range of the new entry intersects, but does not equal, the range of an existing entry or if sourceFile was not previously added to the program.AddressOutOfBoundsException- if the range of the new entry contains addresses that are not in a defined memory block
-
addSourceMapEntry
SourceMapEntry addSourceMapEntry(SourceFile sourceFile, int lineNumber, Address baseAddr, long length) throws AddressOverflowException, LockException Creates 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.
- Parameters:
sourceFile- source filelineNumber- line numberbaseAddr- minimum address of rangelength- number of addresses in range- Returns:
- created SourceMapEntry
- Throws:
AddressOverflowException- if baseAddr + length-1 overflowsLockException- if invoked without exclusive accessIllegalArgumentException- if the range of the new entry intersects, but does not equal, the range of an existing entry or if sourceFile was not previously added to the program.AddressOutOfBoundsException- if the range of the new entry contains addresses that are not in a defined memory block
-
intersectsSourceMapEntry
- Parameters:
addrs- addresses to check- Returns:
- true when at least one address has source map info
-
addSourceFile
Adds aSourceFileto this manager. A SourceFile must be added before it can be associated with any source map information.- 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
Removes aSourceFilefrom this manager. Any associatedSourceMapEntrys will also be removed.- Parameters:
sourceFile- source file to remove- Returns:
- true if sourceFile was in the manager
- Throws:
LockException- if invoked without exclusive access
-
containsSourceFile
Returns true precisely when this manager containssourceFile.- Parameters:
sourceFile- source file- Returns:
- true if source file already added
-
getAllSourceFiles
List<SourceFile> getAllSourceFiles()Returns aListcontaining allSourceFiles of the program.- Returns:
- source file list
-
getMappedSourceFiles
List<SourceFile> getMappedSourceFiles()Returns aListcontainingSourceFiles which are mapped to at least one address in the program- Returns:
- mapped source file list
-
transferSourceMapEntries
Changes 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.- Parameters:
source- source file to get info fromtarget- source file to move info to- Throws:
LockException- if invoked without exclusive accessIllegalArgumentException- if source or target has not been added previously
-
getSourceMapEntryIterator
Returns aSourceMapEntryIteratorstarting ataddress.- Parameters:
address- starting addressforward- direction of iterator (true = forward)- Returns:
- iterator
-
getSourceMapEntries
Returns the sorted list ofSourceMapEntrys forsourceFilewith line number betweenminLineandmaxLine, inclusive.- Parameters:
sourceFile- source fileminLine- minimum line numbermaxLine- maximum line number- Returns:
- source map entries
-
getSourceMapEntries
- Parameters:
sourceFile- source filelineNumber- line number- Returns:
- source map entries
-
getSourceMapEntries
Returns a sorted of list allSourceMapEntrys in the program corresponding tosourceFile.- Parameters:
sourceFile- source file- Returns:
- source map entries
-
removeSourceMapEntry
Removes aSourceMapEntryfrom this manager.- Parameters:
entry- entry to remove- Returns:
- true if entry was in the manager
- Throws:
LockException- if invoked without exclusive access
-