Package ghidra.program.model.sourcemap
Interface SourceFileManager
- All Known Implementing Classes:
DummySourceFileManager
,SourceFileManagerDB
public interface SourceFileManager
This interface defines methods for managing
SourceFile
s and SourceMapEntry
s.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
addSourceFile
(SourceFile sourceFile) Adds aSourceFile
to this manager.addSourceMapEntry
(SourceFile sourceFile, int lineNumber, Address baseAddr, long length) Creates aSourceMapEntry
withSourceFile
sourceFile
, line numberlineNumber
, and non-negative lengthlength
and adds it to the program database.default SourceMapEntry
addSourceMapEntry
(SourceFile sourceFile, int lineNumber, AddressRange range) Adds aSourceMapEntry
withSourceFile
sourceFile
, line numberlineNumber
, andAddressRange
range
to the program database.boolean
containsSourceFile
(SourceFile sourceFile) Returns true precisely when this manager containssourceFile
.Returns aList
containing allSourceFile
s of the program.Returns aList
containingSourceFile
s which are mapped to at least one address in the programdefault List
<SourceMapEntry> getSourceMapEntries
(SourceFile sourceFile) Returns a sorted of list allSourceMapEntry
s in the program corresponding tosourceFile
.default List
<SourceMapEntry> getSourceMapEntries
(SourceFile sourceFile, int lineNumber) getSourceMapEntries
(SourceFile sourceFile, int minLine, int maxLine) Returns the sorted list ofSourceMapEntry
s forsourceFile
with line number betweenminLine
andmaxLine
, inclusive.getSourceMapEntries
(Address addr) Returns a sorted list ofSourceMapEntry
s associated with an addressaddr
.getSourceMapEntryIterator
(Address address, boolean forward) Returns aSourceMapEntryIterator
starting ataddress
.boolean
boolean
removeSourceFile
(SourceFile sourceFile) Removes aSourceFile
from this manager.boolean
Removes aSourceMapEntry
from this manager.void
transferSourceMapEntries
(SourceFile source, SourceFile target) Changes the source map so that anySourceMapEntry
associated withsource
is associated withtarget
instead.
-
Field Details
-
DUMMY
-
-
Method Details
-
getSourceMapEntries
Returns a sorted list ofSourceMapEntry
s associated with an addressaddr
.- Parameters:
addr
- address- Returns:
- line number
-
addSourceMapEntry
default SourceMapEntry addSourceMapEntry(SourceFile sourceFile, int lineNumber, AddressRange range) throws LockException Adds aSourceMapEntry
withSourceFile
sourceFile
, line numberlineNumber
, andAddressRange
range
to 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 aSourceMapEntry
withSourceFile
sourceFile
, line numberlineNumber
, and non-negative lengthlength
and 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 aSourceFile
to 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 aSourceFile
from this manager. Any associatedSourceMapEntry
s 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 aList
containing allSourceFile
s of the program.- Returns:
- source file list
-
getMappedSourceFiles
List<SourceFile> getMappedSourceFiles()Returns aList
containingSourceFile
s which are mapped to at least one address in the program- Returns:
- mapped source file list
-
transferSourceMapEntries
Changes the source map so that anySourceMapEntry
associated withsource
is associated withtarget
instead. Any entries associated withtarget
before invocation will still be associated withtarget
after invocation.source
will not be associated with any entries after invocation (unlesssource
andtarget
are 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 aSourceMapEntryIterator
starting ataddress
.- Parameters:
address
- starting addressforward
- direction of iterator (true = forward)- Returns:
- iterator
-
getSourceMapEntries
Returns the sorted list ofSourceMapEntry
s forsourceFile
with line number betweenminLine
andmaxLine
, 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 allSourceMapEntry
s in the program corresponding tosourceFile
.- Parameters:
sourceFile
- source file- Returns:
- source map entries
-
removeSourceMapEntry
Removes aSourceMapEntry
from this manager.- Parameters:
entry
- entry to remove- Returns:
- true if entry was in the manager
- Throws:
LockException
- if invoked without exclusive access
-