Class MemoryRanges
java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.analyzer.MemoryRanges
A collection of byte-addressable memory ranges. The final addressable byte (e.g., @ 0xFFFFFFFF in a
32-bit address space) cannot be part of any range.
This class is not thread-safe.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreate memory ranges for a 64-bit address space.MemoryRanges(int spaceBits) Create memory ranges for an address space width.Create memory ranges from the allocated pages of a virtual memory object. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(long begin0, long end0) Add a memory range.longGet the sum of all range sizes.asList()voidclear()Remove all ranges.booleancontains(long address) Indicate if an address is defined in thisMemoryRangesintcount()Get the number of recorded ranges.getLocalBegin(long address0) Get the start of the range containing an address.getLocalEnd(long address0) Get the end of the range containing an address.getLocalRange(long address0) Get the range containing an address.getNextRange(long address0) Get the first range after an address.getPreviousRange(long address0) Get the first range before an address.booleanintersects(long addressStart, long addressEnd) Indicate if an element from range [addressStart:addressEnd[ is defined in thisMemoryRanges.max()Get the highest range end address.min()Get the lowest range start address.voidremove(long begin0, long end0) Remove a memory range.longspanSize()Get the size spanned by all ranges.toString()
-
Constructor Details
-
MemoryRanges
public MemoryRanges(int spaceBits) Create memory ranges for an address space width.- Parameters:
spaceBits- number of bits in the address space
-
MemoryRanges
public MemoryRanges()Create memory ranges for a 64-bit address space. -
MemoryRanges
Create memory ranges from the allocated pages of a virtual memory object.- Parameters:
mem- virtual memory
-
-
Method Details
-
add
public void add(long begin0, long end0) Add a memory range.- Parameters:
begin0- start address, inclusiveend0- end address, exclusive
-
remove
public void remove(long begin0, long end0) Remove a memory range.- Parameters:
begin0- start address, inclusiveend0- end address, exclusive
-
clear
public void clear()Remove all ranges. -
min
Get the lowest range start address.- Returns:
- lowest address, or null if no range is recorded
-
max
Get the highest range end address.- Returns:
- highest exclusive end address, or null if no range is recorded
-
count
public int count()Get the number of recorded ranges.- Returns:
- range count
-
asList
- Returns:
- the list of
MemoryRanges
-
contains
public boolean contains(long address) Indicate if an address is defined in thisMemoryRanges- Parameters:
address- address to test- Returns:
- true if
MemoryRangescontains this address
-
intersects
public boolean intersects(long addressStart, long addressEnd) Indicate if an element from range [addressStart:addressEnd[ is defined in thisMemoryRanges.- Parameters:
addressStart- start address (inclusive)addressEnd- end address (exclusive)- Returns:
- true if
MemoryRangescontains at least one address from the given range
-
getLocalBegin
Get the start of the range containing an address.- Parameters:
address0- address to look up- Returns:
- range start address, or null if the address is not contained in a range
-
getLocalEnd
Get the end of the range containing an address.- Parameters:
address0- address to look up- Returns:
- range exclusive end address, or null if the address is not contained in a range
-
getNextRange
Get the first range after an address.- Parameters:
address0- address to look up- Returns:
- next range as a start/end pair, or null if none exists
-
getPreviousRange
Get the first range before an address.- Parameters:
address0- address to look up- Returns:
- previous range as a start/end pair, or null if none exists
-
getLocalRange
Get the range containing an address.- Parameters:
address0- address to look up- Returns:
- containing range as a start/end pair, or null if none exists
-
spanSize
public long spanSize()Get the size spanned by all ranges.- Returns:
- distance between the lowest start and highest end, or 0 if no range is recorded
-
aggregatedRangesSize
public long aggregatedRangesSize()Get the sum of all range sizes.- Returns:
- aggregate size of all ranges
-
toString
-