Package ghidra.program.database.map
Class NormalizedAddressSet
- java.lang.Object
-
- ghidra.program.database.map.NormalizedAddressSet
-
- All Implemented Interfaces:
AddressSetView,java.lang.Iterable<AddressRange>
public class NormalizedAddressSet extends java.lang.Object implements AddressSetView
AddressSetView implementation that handles image base changes. NOTE: THIS IMPLEMENTATION ASSUMES THAT ONLY ADDRESS RANGES THAT ARE PART OF THE MEMORY MAP WILL BE ADDED TO THIS ADDRESS SET. IT IS INTENDED FOR USE BY THE CHANGE SET.
-
-
Constructor Summary
Constructors Constructor Description NormalizedAddressSet(AddressMap addrMap)Constructs a NormalizedAddressSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Address addr)Adds the address to the set.voidadd(AddressRange range)Adds the address range to this set.voidadd(AddressSetView set)Adds the addressSet to this set.voidaddRange(Address startAddr, Address endAddr)Adds the address range to this set.voidclear()Removes all addresses from this set.booleancontains(Address addr)Test if the address is contained within this set.booleancontains(Address startAddr, Address endAddr)Test if the given address range is contained in this set.booleancontains(AddressSetView rangeSet)Test if the given address set is a subset of this set.voiddelete(AddressSetView view)REmoves all the addresses in the given address set from this set.AddressfindFirstAddressInCommon(AddressSetView set)Finds the first address in this collection that is also in the given addressSet.AddressIteratorgetAddresses(boolean forward)Returns an iterator over all addresses in this set.AddressIteratorgetAddresses(Address start, boolean forward)Returns an iterator over the addresses in this address set starting at the start addressAddressRangeIteratorgetAddressRanges()Returns an iterator over the address ranges in this address set.AddressRangeIteratorgetAddressRanges(boolean forward)Returns an iterator over the ranges in the specified orderAddressRangeIteratorgetAddressRanges(Address start, boolean forward)Returns an iterator of address ranges starting with the range that contains the given address.AddressRangegetFirstRange()Returns the first range in this set or null if the set is empty;AddressRangegetLastRange()Returns the last range in this set or null if the set is empty;AddressgetMaxAddress()Return the maximum address for this set.AddressgetMinAddress()Return the minimum address for this set.longgetNumAddresses()Returns the number of addresses in this set.intgetNumAddressRanges()Return the number of address ranges in this set.AddressRangegetRangeContaining(Address address)Returns the range that contains the given addressbooleanhasSameAddresses(AddressSetView view)Returns true if the given address set contains the same set of addresses as this set.AddressSetintersect(AddressSetView view)Computes the intersection of this address set with the given address set.AddressSetintersectRange(Address start, Address end)Computes the intersection of this address set with the given address range.booleanintersects(Address start, Address end)Determine if the start and end range intersects with the specified address set.booleanintersects(AddressSetView addrSet)Determine if this address set intersects with the specified address set.booleanisEmpty()Returns true if this set is empty.java.util.Iterator<AddressRange>iterator()Returns an iterator over the address ranges in this address set.java.util.Iterator<AddressRange>iterator(boolean forward)Returns an iterator over the ranges in the specified orderjava.util.Iterator<AddressRange>iterator(Address start, boolean forward)Returns an iterator of address ranges starting with the range that contains the given address.AddressSetsubtract(AddressSetView addrSet)Computes the difference of this address set with the given address set (this - set).java.lang.StringtoString()AddressSetunion(AddressSetView addrSet)Computes the union of this address set with the given address set.AddressSetxor(AddressSetView addrSet)Computes the exclusive-or of this address set with the given set.
-
-
-
Constructor Detail
-
NormalizedAddressSet
public NormalizedAddressSet(AddressMap addrMap)
Constructs a NormalizedAddressSet- Parameters:
addrMap- the address map
-
-
Method Detail
-
add
public void add(Address addr)
Adds the address to the set.- Parameters:
addr- the address to add
-
add
public void add(AddressSetView set)
Adds the addressSet to this set.- Parameters:
set- the set of addresses to add/
-
add
public void add(AddressRange range)
Adds the address range to this set.- Parameters:
range- the range to add.
-
addRange
public void addRange(Address startAddr, Address endAddr)
Adds the address range to this set.- Parameters:
startAddr- the first address in the range to add.endAddr- the last address in the range to add.
-
clear
public void clear()
Removes all addresses from this set.
-
delete
public void delete(AddressSetView view)
REmoves all the addresses in the given address set from this set.- Parameters:
view- the set of addresses to remove.
-
contains
public boolean contains(Address addr)
Description copied from interface:AddressSetViewTest if the address is contained within this set.- Specified by:
containsin interfaceAddressSetView- Parameters:
addr- address to test.- Returns:
- true if addr exists in the set, false otherwise.
- See Also:
AddressSetView.contains(ghidra.program.model.address.Address)
-
contains
public boolean contains(Address startAddr, Address endAddr)
Description copied from interface:AddressSetViewTest if the given address range is contained in this set.- Specified by:
containsin interfaceAddressSetView- Parameters:
startAddr- the first address in the range.endAddr- the last address in the range.- Returns:
- true if entire range is contained within the set, false otherwise.
- See Also:
AddressSetView.contains(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
-
contains
public boolean contains(AddressSetView rangeSet)
Description copied from interface:AddressSetViewTest if the given address set is a subset of this set.- Specified by:
containsin interfaceAddressSetView- Parameters:
rangeSet- the set to test.- Returns:
- true if the entire set is contained within this set, false otherwise.
- See Also:
AddressSetView.contains(ghidra.program.model.address.AddressSetView)
-
isEmpty
public boolean isEmpty()
Description copied from interface:AddressSetViewReturns true if this set is empty.- Specified by:
isEmptyin interfaceAddressSetView- See Also:
AddressSetView.isEmpty()
-
getMinAddress
public Address getMinAddress()
Description copied from interface:AddressSetViewReturn the minimum address for this set. Returns null if the set is empty.- Specified by:
getMinAddressin interfaceAddressSetView- See Also:
AddressSetView.getMinAddress()
-
getMaxAddress
public Address getMaxAddress()
Description copied from interface:AddressSetViewReturn the maximum address for this set. Returns null if the set is empty.- Specified by:
getMaxAddressin interfaceAddressSetView- See Also:
AddressSetView.getMaxAddress()
-
getNumAddressRanges
public int getNumAddressRanges()
Description copied from interface:AddressSetViewReturn the number of address ranges in this set.- Specified by:
getNumAddressRangesin interfaceAddressSetView- See Also:
AddressSetView.getNumAddressRanges()
-
getAddressRanges
public AddressRangeIterator getAddressRanges()
Description copied from interface:AddressSetViewReturns an iterator over the address ranges in this address set.- Specified by:
getAddressRangesin interfaceAddressSetView- See Also:
AddressSetView.getAddressRanges()
-
iterator
public java.util.Iterator<AddressRange> iterator()
Description copied from interface:AddressSetViewReturns an iterator over the address ranges in this address set.- Specified by:
iteratorin interfaceAddressSetView- Specified by:
iteratorin interfacejava.lang.Iterable<AddressRange>
-
getAddressRanges
public AddressRangeIterator getAddressRanges(boolean forward)
Description copied from interface:AddressSetViewReturns an iterator over the ranges in the specified order- Specified by:
getAddressRangesin interfaceAddressSetView- Parameters:
forward- the ranges are returned from lowest to highest, otherwise from highest to lowest- Returns:
- an iterator over all the addresse ranges in the set.
- See Also:
AddressSetView.getAddressRanges(boolean)
-
getNumAddresses
public long getNumAddresses()
Description copied from interface:AddressSetViewReturns the number of addresses in this set.- Specified by:
getNumAddressesin interfaceAddressSetView- See Also:
AddressSetView.getNumAddresses()
-
getAddresses
public AddressIterator getAddresses(boolean forward)
Description copied from interface:AddressSetViewReturns an iterator over all addresses in this set.- Specified by:
getAddressesin interfaceAddressSetView- Parameters:
forward- if true the address are return in increasing order, otherwise in decreasing order.- See Also:
AddressSetView.getAddresses(boolean)
-
getAddresses
public AddressIterator getAddresses(Address start, boolean forward)
Description copied from interface:AddressSetViewReturns an iterator over the addresses in this address set starting at the start address- Specified by:
getAddressesin interfaceAddressSetView- Parameters:
start- address to start iterating at in the address setforward- if true address are return from lowest to highest, else from highest to lowest- See Also:
AddressSetView.getAddresses(ghidra.program.model.address.Address, boolean)
-
intersects
public boolean intersects(AddressSetView addrSet)
Description copied from interface:AddressSetViewDetermine if this address set intersects with the specified address set.- Specified by:
intersectsin interfaceAddressSetView- Parameters:
addrSet- address set to check intersection with.- See Also:
AddressSetView.intersects(ghidra.program.model.address.AddressSetView)
-
intersects
public boolean intersects(Address start, Address end)
Description copied from interface:AddressSetViewDetermine if the start and end range intersects with the specified address set.- Specified by:
intersectsin interfaceAddressSetView- Parameters:
start- start of rangeend- end of range- Returns:
- true if the given range intersects this address set.
- See Also:
AddressSetView.intersects(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
-
intersect
public AddressSet intersect(AddressSetView view)
Description copied from interface:AddressSetViewComputes the intersection of this address set with the given address set. This method does not modify this address set.- Specified by:
intersectin interfaceAddressSetView- Parameters:
view- the address set to intersect with.- Returns:
- AddressSet a new address set that contains all addresses that are contained in both this set and the given set.
- See Also:
AddressSetView.intersect(ghidra.program.model.address.AddressSetView)
-
intersectRange
public AddressSet intersectRange(Address start, Address end)
Description copied from interface:AddressSetViewComputes the intersection of this address set with the given address range. This method does not modify this address set.- Specified by:
intersectRangein interfaceAddressSetView- Parameters:
start- start of rangeend- end of range- Returns:
- AddressSet a new address set that contains all addresses that are contained in both this set and the given range.
- See Also:
AddressSetView.intersectRange(ghidra.program.model.address.Address, ghidra.program.model.address.Address)
-
union
public AddressSet union(AddressSetView addrSet)
Description copied from interface:AddressSetViewComputes the union of this address set with the given address set. This method does not change this address set.- Specified by:
unionin interfaceAddressSetView- Parameters:
addrSet- The address set to be unioned with this address set.- Returns:
- AddressSet A new address set which contains all the addresses from both this set and the given set.
- See Also:
AddressSetView.union(ghidra.program.model.address.AddressSetView)
-
subtract
public AddressSet subtract(AddressSetView addrSet)
Description copied from interface:AddressSetViewComputes the difference of this address set with the given address set (this - set). Note that this is not the same as (set - this). This method does not change this address set.- Specified by:
subtractin interfaceAddressSetView- Parameters:
addrSet- the set to subtract from this set.- Returns:
- AddressSet a new address set which contains all the addresses that are in this set, but not in the given set.
- See Also:
AddressSetView.subtract(ghidra.program.model.address.AddressSetView)
-
xor
public AddressSet xor(AddressSetView addrSet)
Description copied from interface:AddressSetViewComputes the exclusive-or of this address set with the given set. This method does not modify this address set.- Specified by:
xorin interfaceAddressSetView- Returns:
- AddressSet a new address set containing all addresses that are in either this set or the given set, but not in both sets
- See Also:
AddressSetView.xor(ghidra.program.model.address.AddressSetView)
-
hasSameAddresses
public boolean hasSameAddresses(AddressSetView view)
Description copied from interface:AddressSetViewReturns true if the given address set contains the same set of addresses as this set.- Specified by:
hasSameAddressesin interfaceAddressSetView- Parameters:
view- the address set to compare.- Returns:
- true if the given set contains the same addresses as this set.
- See Also:
AddressSetView.hasSameAddresses(ghidra.program.model.address.AddressSetView)
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
getAddressRanges
public AddressRangeIterator getAddressRanges(Address start, boolean forward)
Description copied from interface:AddressSetViewReturns an iterator of address ranges starting with the range that contains the given address. If there is no range containing the start address, then the the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address- Specified by:
getAddressRangesin interfaceAddressSetView- Parameters:
start- the address the the first range should contain.forward- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
getFirstRange
public AddressRange getFirstRange()
Description copied from interface:AddressSetViewReturns the first range in this set or null if the set is empty;- Specified by:
getFirstRangein interfaceAddressSetView- Returns:
- the first range in this set or null if the set is empty;
-
getLastRange
public AddressRange getLastRange()
Description copied from interface:AddressSetViewReturns the last range in this set or null if the set is empty;- Specified by:
getLastRangein interfaceAddressSetView- Returns:
- the last range in this set or null if the set is empty;
-
getRangeContaining
public AddressRange getRangeContaining(Address address)
Description copied from interface:AddressSetViewReturns the range that contains the given address- Specified by:
getRangeContainingin interfaceAddressSetView- Parameters:
address- the address for which to find a range.- Returns:
- the range that contains the given address.
-
iterator
public java.util.Iterator<AddressRange> iterator(Address start, boolean forward)
Description copied from interface:AddressSetViewReturns an iterator of address ranges starting with the range that contains the given address. If there is no range containing the start address, then the the first range will be the next range greater than the start address if going forward, otherwise the range less than the start address- Specified by:
iteratorin interfaceAddressSetView- Parameters:
start- the address the the first range should contain.forward- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
iterator
public java.util.Iterator<AddressRange> iterator(boolean forward)
Description copied from interface:AddressSetViewReturns an iterator over the ranges in the specified order- Specified by:
iteratorin interfaceAddressSetView- Parameters:
forward- the ranges are returned from lowest to highest, otherwise from highest to lowest- Returns:
- an iterator over all the addresse ranges in the set.
-
findFirstAddressInCommon
public Address findFirstAddressInCommon(AddressSetView set)
Description copied from interface:AddressSetViewFinds the first address in this collection that is also in the given addressSet.- Specified by:
findFirstAddressInCommonin interfaceAddressSetView- Parameters:
set- the addressSet to search for the first (lowest) common address.- Returns:
- the first address that is contained in this set and the given set.
-
-