Class CodeBlockImpl
- All Implemented Interfaces:
AddressSetView,CodeBlock,Iterable<AddressRange>
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCodeBlockImpl(CodeBlockModel model, Address[] starts, AddressSetView body) Construct a multi-entry CodeBlock associated with a CodeBlockModel. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest if the address is contained within this set.booleanTest 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.booleanfindFirstAddressInCommon(AddressSetView otherSet) Finds the first address in this collection that is also in the given addressSet.getAddresses(boolean forward) Returns an iterator over all addresses in this set.getAddresses(Address start, boolean forward) Returns an iterator over the addresses in this address set starting at the start addressgetAddressRanges(boolean startAtFront) Returns an iterator over the ranges in the specified ordergetAddressRanges(Address start, boolean forward) Returns an iterator of address ranges starting with the range that contains the given address.getDestinations(TaskMonitor monitor) Get an Iterator over the CodeBlocks that are flowed to from this CodeBlock.Returns the first range in this set or null if the set is emptyReturn the first start address of the CodeBlock.Return, in theory, how things flow out of this node.Returns the last range in this set or null if the set is emptyGet the maximum address for this address set.Get the minimum address for this address set.getModel()Get the model instance which was used to generate this block.getName()Return the name of the block.longintintgetNumDestinations(TaskMonitor monitor) Get the number of CodeBlocks this block flows to.intgetNumSources(TaskMonitor monitor) Get the number of CodeBlocks that flow into this CodeBlock.getRangeContaining(Address address) Returns the range that contains the given addressgetSources(TaskMonitor monitor) Get an Iterator over the CodeBlocks that flow into this CodeBlock.Address[]Get all the entry points to this block.inthashCode()booleanReturns true if the given address set contains the same set of addresses as this set.intersect(AddressSetView view) Computes the intersection of this address set with the given address set.intersectRange(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()iterator()Returns an iterator over the address ranges in this address set.iterator(boolean forward) Returns an iterator over the ranges in the specified orderReturns an iterator of address ranges starting with the range that contains the given address.subtract(AddressSetView addrSet) Computes the difference of this address set with the given address set (this - set).toString()union(AddressSetView addrSet) Computes the union of this address set with the given address set.xor(AddressSetView addrSet) Computes the exclusive-or of this address set with the given set.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.program.model.address.AddressSetView
getAddressCountBefore, spliterator, spliterator, spliterator, stream, stream, stream
-
Constructor Details
-
CodeBlockImpl
Construct a multi-entry CodeBlock associated with a CodeBlockModel. The significance of the start Addresses is model dependent.- Parameters:
model- the model instance which produced this block.starts- the entry points for the block. Any of these addresses may be used to identify this block within the model that produced it.body- the address set which makes-up the body of this block.
-
-
Method Details
-
getFirstStartAddress
Description copied from interface:CodeBlockReturn the first start address of the CodeBlock. Depending on the model used to generate the CodeBlock, there may be multiple entry points to the block. This will return the first start address for the block. It should always return the same address for a given block if there is more than one entry point.- Specified by:
getFirstStartAddressin interfaceCodeBlock- Returns:
- the first start address of the block.
- See Also:
-
getStartAddresses
Description copied from interface:CodeBlockGet all the entry points to this block. Depending on the model, there may be more than one entry point. Entry points will be returned in natural sorted order.- Specified by:
getStartAddressesin interfaceCodeBlock- Returns:
- an array of entry points to this block. a zero length array if there are no entry points.
- See Also:
-
getName
Description copied from interface:CodeBlockReturn the name of the block. -
getFlowType
Description copied from interface:CodeBlockReturn, in theory, how things flow out of this node. If there are any abnormal ways to flow out of this node, (ie: jump, call, etc...) then the flow type of the node takes on that type. If there are multiple unique ways out of the node, then we should return FlowType.UNKNOWN. Fallthrough is returned if that is the only way out.- Specified by:
getFlowTypein interfaceCodeBlock- Returns:
- flow type of this node
- See Also:
-
getNumSources
Description copied from interface:CodeBlockGet the number of CodeBlocks that flow into this CodeBlock. Note that this is almost as much work as getting the actual source references.- Specified by:
getNumSourcesin interfaceCodeBlock- Parameters:
monitor- task monitor which allows user to cancel operation.- Returns:
- number of source CodeBlocks.
- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getSources
Description copied from interface:CodeBlockGet an Iterator over the CodeBlocks that flow into this CodeBlock.- Specified by:
getSourcesin interfaceCodeBlock- Parameters:
monitor- task monitor which allows user to cancel operation.- Returns:
- An iterator over CodeBlocks referencing this Block.
- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getNumDestinations
Description copied from interface:CodeBlockGet the number of CodeBlocks this block flows to. Note that this is almost as much work as getting the actual destination references.- Specified by:
getNumDestinationsin interfaceCodeBlock- Parameters:
monitor- task monitor which allows user to cancel operation.- Returns:
- number of destination CodeBlocks.
- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getDestinations
Description copied from interface:CodeBlockGet an Iterator over the CodeBlocks that are flowed to from this CodeBlock.- Specified by:
getDestinationsin interfaceCodeBlock- Parameters:
monitor- task monitor which allows user to cancel operation.- Returns:
- An iterator over CodeBlocks referred to by this Block.
- Throws:
CancelledException- if the monitor cancels the operation.- See Also:
-
getModel
Description copied from interface:CodeBlockGet the model instance which was used to generate this block. -
toString
-
contains
Description copied from interface:AddressSetViewTest if the address is contained within this set.- Specified by:
containsin interfaceAddressSetView- Parameters:
a- address to test.- Returns:
- true if addr exists in the set, false otherwise.
- See Also:
-
contains
Description copied from interface:AddressSetViewTest if the given address range is contained in this set.The specified start and end addresses must form a valid range within a single
AddressSpace.- Specified by:
containsin interfaceAddressSetView- Parameters:
start- the first address in the range.end- the last address in the range.- Returns:
- true if entire range is contained within the set, false otherwise.
- See Also:
-
contains
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:
-
intersects
Description copied from interface:AddressSetViewDetermine if the start and end range intersects with the specified address set.The specified start and end addresses must form a valid range within a single
AddressSpace.- Specified by:
intersectsin interfaceAddressSetView- Parameters:
start- start of rangeend- end of range- Returns:
- true if the given range intersects this address set.
- See Also:
-
intersects
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.- Returns:
- true if this set intersects the specified addrSet else false
- See Also:
-
intersect
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:
-
intersectRange
Description copied from interface:AddressSetViewComputes the intersection of this address set with the given address range.This method does not modify this address set. The specified start and end addresses must form a valid range within a single
AddressSpace.- 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:
-
union
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:
-
xor
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- Parameters:
addrSet- address set to exclusive-or with.- 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:
-
subtract
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:
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceAddressSetView- Returns:
- true if this set is empty.
- See Also:
-
getMinAddress
Description copied from interface:AddressSetViewGet the minimum address for this address set.NOTE: An
AddressRangeshould generally not be formed using this address andAddressSetView.getMaxAddress()since it may span multipleAddressSpaces.- Specified by:
getMinAddressin interfaceAddressSetView- Returns:
- the minimum address for this set. Returns null if the set is empty.
- See Also:
-
getMaxAddress
Description copied from interface:AddressSetViewGet the maximum address for this address set.NOTE: An
AddressRangeshould generally not be formed using this address andAddressSetView.getMaxAddress()since it may span multipleAddressSpaces.- Specified by:
getMaxAddressin interfaceAddressSetView- Returns:
- the maximum address for this set. Returns null if the set is empty.
- See Also:
-
getNumAddressRanges
public int getNumAddressRanges()- Specified by:
getNumAddressRangesin interfaceAddressSetView- Returns:
- the number of address ranges in this set.
- See Also:
-
getAddressRanges
- Specified by:
getAddressRangesin interfaceAddressSetView- Returns:
- an iterator over the address ranges in this address set.
- See Also:
-
iterator
Description copied from interface:AddressSetViewReturns an iterator over the address ranges in this address set.- Specified by:
iteratorin interfaceAddressSetView- Specified by:
iteratorin interfaceIterable<AddressRange>
-
getNumAddresses
public long getNumAddresses()- Specified by:
getNumAddressesin interfaceAddressSetView- Returns:
- the number of addresses in this set.
- See Also:
-
getAddresses
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.- Returns:
- an iterator over all addresses in this set.
- See Also:
-
getAddresses
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- Returns:
- an iterator over the addresses in this address set starting at the start address
- See Also:
-
hasSameAddresses
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:
-
equals
-
getAddressRanges
Description copied from interface:AddressSetViewReturns an iterator over the ranges in the specified order- Specified by:
getAddressRangesin interfaceAddressSetView- Parameters:
startAtFront- 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:
-
hashCode
public int hashCode() -
getAddressRanges
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 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 first range should contain.forward- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
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
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
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
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 address ranges in the set.
-
iterator
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 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 that the first range should contain.forward- true iterators forward, false backwards- Returns:
- the AddressRange iterator
-
findFirstAddressInCommon
Description copied from interface:AddressSetViewFinds the first address in this collection that is also in the given addressSet.- Specified by:
findFirstAddressInCommonin interfaceAddressSetView- Parameters:
otherSet- the addressSet to search for the first (lowest) common address.- Returns:
- the first address that is contained in this set and the given set.
-