Package ghidra.program.model
Class ReferenceManagerTestDouble
- java.lang.Object
-
- ghidra.program.model.ReferenceManagerTestDouble
-
- All Implemented Interfaces:
ReferenceManager
- Direct Known Subclasses:
ReferenceState
public class ReferenceManagerTestDouble extends java.lang.Object implements ReferenceManager
-
-
Field Summary
-
Fields inherited from interface ghidra.program.model.symbol.ReferenceManager
MNEMONIC
-
-
Constructor Summary
Constructors Constructor Description ReferenceManagerTestDouble()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Reference
addExternalReference(Address fromAddr, int opIndex, ExternalLocation location, SourceType source, RefType type)
Adds an external reference.Reference
addExternalReference(Address fromAddr, Namespace extNamespace, java.lang.String extLabel, Address extAddr, SourceType source, int opIndex, RefType type)
Adds an external reference.Reference
addExternalReference(Address fromAddr, java.lang.String libraryName, java.lang.String extLabel, Address extAddr, SourceType source, int opIndex, RefType type)
Adds an external reference.Reference
addMemoryReference(Address fromAddr, Address toAddr, RefType type, SourceType source, int opIndex)
Adds a memory reference.Reference
addOffsetMemReference(Address fromAddr, Address toAddr, long offset, RefType type, SourceType source, int opIndex)
Add an offset memory reference.Reference
addReference(Reference reference)
Add a memory, stack, register or external referenceReference
addRegisterReference(Address fromAddr, int opIndex, Register register, RefType type, SourceType source)
Add a reference to a register.Reference
addShiftedMemReference(Address fromAddr, Address toAddr, int shiftValue, RefType type, SourceType source, int opIndex)
Add a shifted memory reference; the "to" address is computed as the value at the operand at opIndex shifted by some number of bits, specified in the shiftValue parameter.Reference
addStackReference(Address fromAddr, int opIndex, int stackOffset, RefType type, SourceType source)
Add a reference to a stack location.void
delete(Reference ref)
Deletes the given reference objectReferenceIterator
getExternalReferences()
Returns an iterator over all external referencesReference[]
getFlowReferencesFrom(Address addr)
Get the flow references from the given address.Reference
getPrimaryReferenceFrom(Address addr, int opIndex)
Get the primary reference from the given address.Reference
getReference(Address fromAddr, Address toAddr, int opIndex)
Get the reference that has the given from and to address, and operand index.int
getReferenceCountFrom(Address fromAddr)
Returns the number of memory References from the specifiedfromAddr
int
getReferenceCountTo(Address toAddr)
Returns the number of memory References to the specifiedtoAddr
int
getReferenceDestinationCount()
Return the number of references for "to" addresses.AddressIterator
getReferenceDestinationIterator(Address startAddr, boolean forward)
Returns an iterator over all addresses that are the "To" address in a reference.AddressIterator
getReferenceDestinationIterator(AddressSetView addrSet, boolean forward)
Returns an iterator over all addresses that are the "To" address in a memory reference, restricted by the given address set.Variable
getReferencedVariable(Reference reference)
Returns the referenced function variable.ReferenceIterator
getReferenceIterator(Address startAddr)
Get an iterator over references starting with the specified fromAddr.byte
getReferenceLevel(Address toAddr)
Returns the reference level for the references to the given addressReference[]
getReferencesFrom(Address addr)
Get all references "from" the specified addr.Reference[]
getReferencesFrom(Address fromAddr, int opIndex)
Returns all references "from" the given fromAddr and operand (specified by opIndex).int
getReferenceSourceCount()
Return the number of references for "from" addresses.AddressIterator
getReferenceSourceIterator(Address startAddr, boolean forward)
Returns an iterator over addresses that are the "From" address in a referenceAddressIterator
getReferenceSourceIterator(AddressSetView addrSet, boolean forward)
Returns an iterator over all addresses that are the "From" address in a reference, restricted by the given address set.ReferenceIterator
getReferencesTo(Address addr)
Get an iterator over all references that have the given address as their "To" address.Reference[]
getReferencesTo(Variable var)
Returns all references to the given variable.boolean
hasFlowReferencesFrom(Address addr)
Return whether the given address has flow references from this address.boolean
hasReferencesFrom(Address fromAddr)
Returns true if there are any memory references at the given address.boolean
hasReferencesFrom(Address fromAddr, int opIndex)
Returns true if there are any memory references at the given address/opIndex.boolean
hasReferencesTo(Address toAddr)
Return true if a memory reference exists with the given "to" address.void
removeAllReferencesFrom(Address fromAddr)
Remove all stack, external, and memory references for the given from address.void
removeAllReferencesFrom(Address beginAddr, Address endAddr)
Removes all references where "From address" is in the given range.void
removeAssociation(Reference ref)
Removes any symbol associations with the given reference.void
setAssociation(Symbol s, Reference ref)
Associates the given reference with the given symbol.void
setPrimary(Reference ref, boolean isPrimary)
Set the given reference's primary attributeReference
updateRefType(Reference ref, RefType refType)
Uodate the reference type on a memory reference.
-
-
-
Method Detail
-
addReference
public Reference addReference(Reference reference)
Description copied from interface:ReferenceManager
Add a memory, stack, register or external reference- Specified by:
addReference
in interfaceReferenceManager
-
addStackReference
public Reference addStackReference(Address fromAddr, int opIndex, int stackOffset, RefType type, SourceType source)
Description copied from interface:ReferenceManager
Add a reference to a stack location. If a reference already exists for the fromAddr and opIndex, the existing reference is replaced with the new reference.- Specified by:
addStackReference
in interfaceReferenceManager
- Parameters:
fromAddr
- "from" address within a functionopIndex
- operand indexstackOffset
- stack offset of the referencetype
- reference type - how the location is being referenced.source
- the source of this reference
-
addRegisterReference
public Reference addRegisterReference(Address fromAddr, int opIndex, Register register, RefType type, SourceType source)
Description copied from interface:ReferenceManager
Add a reference to a register. If a reference already exists for the fromAddr and opIndex, the existing reference is replaced with the new reference.- Specified by:
addRegisterReference
in interfaceReferenceManager
- Parameters:
fromAddr
- "from" addressopIndex
- operand indexregister
- register to add the reference totype
- reference type - how the location is being referenced.source
- the source of this reference
-
addMemoryReference
public Reference addMemoryReference(Address fromAddr, Address toAddr, RefType type, SourceType source, int opIndex)
Description copied from interface:ReferenceManager
Adds a memory reference.- Specified by:
addMemoryReference
in interfaceReferenceManager
- Parameters:
fromAddr
- address of the codeunit where the reference occurstoAddr
- address of the location being referenced. Memory, stack, and register addresses are all permitted.type
- reference type - how the location is being referenced.source
- the source of this referenceopIndex
- the operand index display of the operand making this reference
-
addOffsetMemReference
public Reference addOffsetMemReference(Address fromAddr, Address toAddr, long offset, RefType type, SourceType source, int opIndex)
Description copied from interface:ReferenceManager
Add an offset memory reference.- Specified by:
addOffsetMemReference
in interfaceReferenceManager
- Parameters:
fromAddr
- address for the "from"toAddr
- address of the "to"offset
- value added to a base address to get the toAddrtype
- reference type - how the location is being referencedsource
- the source of this referenceopIndex
- the operand index
-
addShiftedMemReference
public Reference addShiftedMemReference(Address fromAddr, Address toAddr, int shiftValue, RefType type, SourceType source, int opIndex)
Description copied from interface:ReferenceManager
Add a shifted memory reference; the "to" address is computed as the value at the operand at opIndex shifted by some number of bits, specified in the shiftValue parameter.- Specified by:
addShiftedMemReference
in interfaceReferenceManager
- Parameters:
fromAddr
- address for the "from"toAddr
- computed as the value of the operand at opIndex shifted by the number of bits specified by shiftValuetype
- reference type - how the location is being referencedsource
- the source of this referenceopIndex
- the operand index
-
addExternalReference
public Reference addExternalReference(Address fromAddr, java.lang.String libraryName, java.lang.String extLabel, Address extAddr, SourceType source, int opIndex, RefType type) throws InvalidInputException, DuplicateNameException
Description copied from interface:ReferenceManager
Adds an external reference.- Specified by:
addExternalReference
in interfaceReferenceManager
- Parameters:
fromAddr
- from address (source of the reference)libraryName
- name of external programextLabel
- label within the external program, may be null if extAddr is not nullextAddr
- address within the external program, may be nullsource
- the source of this referenceopIndex
- operand indextype
- reference type - how the location is being referenced- Throws:
InvalidInputException
DuplicateNameException
-
addExternalReference
public Reference addExternalReference(Address fromAddr, Namespace extNamespace, java.lang.String extLabel, Address extAddr, SourceType source, int opIndex, RefType type) throws InvalidInputException, DuplicateNameException
Description copied from interface:ReferenceManager
Adds an external reference.- Specified by:
addExternalReference
in interfaceReferenceManager
- Parameters:
fromAddr
- from address (source of the reference)extNamespace
- external namespace containing the named external label.extLabel
- label within the external program, may be null if extAddr is not nullextAddr
- address within the external program, may be nullsource
- the source of this referenceopIndex
- operand indextype
- reference type - how the location is being referenced- Throws:
InvalidInputException
DuplicateNameException
-
addExternalReference
public Reference addExternalReference(Address fromAddr, int opIndex, ExternalLocation location, SourceType source, RefType type) throws InvalidInputException
Description copied from interface:ReferenceManager
Adds an external reference.- Specified by:
addExternalReference
in interfaceReferenceManager
- Parameters:
fromAddr
- from address (source of the reference)opIndex
- operand indexlocation
- external locationsource
- the source of this referencetype
- reference type - how the location is being referenced- Returns:
- external reference
- Throws:
InvalidInputException
-
removeAllReferencesFrom
public void removeAllReferencesFrom(Address beginAddr, Address endAddr)
Description copied from interface:ReferenceManager
Removes all references where "From address" is in the given range.- Specified by:
removeAllReferencesFrom
in interfaceReferenceManager
- Parameters:
beginAddr
- the first address in the range.endAddr
- the last address in the range.
-
removeAllReferencesFrom
public void removeAllReferencesFrom(Address fromAddr)
Description copied from interface:ReferenceManager
Remove all stack, external, and memory references for the given from address.- Specified by:
removeAllReferencesFrom
in interfaceReferenceManager
- Parameters:
fromAddr
- the address of the codeunit from which to remove all references.
-
getReferencesTo
public Reference[] getReferencesTo(Variable var)
Description copied from interface:ReferenceManager
Returns all references to the given variable. Only data references to storage are considered.- Specified by:
getReferencesTo
in interfaceReferenceManager
- Parameters:
var
- variable to retrieve references to- Returns:
- array of variable references, or zero length array if no references exist
-
getReferencedVariable
public Variable getReferencedVariable(Reference reference)
Description copied from interface:ReferenceManager
Returns the referenced function variable.- Specified by:
getReferencedVariable
in interfaceReferenceManager
- Returns:
- function variable or null if variable not found
-
setPrimary
public void setPrimary(Reference ref, boolean isPrimary)
Description copied from interface:ReferenceManager
Set the given reference's primary attribute- Specified by:
setPrimary
in interfaceReferenceManager
- Parameters:
ref
- the reference to make primary.isPrimary
- true to make the reference primary, false to make it non-primary
-
hasFlowReferencesFrom
public boolean hasFlowReferencesFrom(Address addr)
Description copied from interface:ReferenceManager
Return whether the given address has flow references from this address.- Specified by:
hasFlowReferencesFrom
in interfaceReferenceManager
- Parameters:
addr
- the address to test for flow references.
-
getFlowReferencesFrom
public Reference[] getFlowReferencesFrom(Address addr)
Description copied from interface:ReferenceManager
Get the flow references from the given address.- Specified by:
getFlowReferencesFrom
in interfaceReferenceManager
- Parameters:
addr
- the address of the codeunit to get all flows from.
-
getExternalReferences
public ReferenceIterator getExternalReferences()
Description copied from interface:ReferenceManager
Returns an iterator over all external references- Specified by:
getExternalReferences
in interfaceReferenceManager
-
getReferencesTo
public ReferenceIterator getReferencesTo(Address addr)
Description copied from interface:ReferenceManager
Get an iterator over all references that have the given address as their "To" address.- Specified by:
getReferencesTo
in interfaceReferenceManager
- Parameters:
addr
- the address that all references in the iterator refer to.
-
getReferenceIterator
public ReferenceIterator getReferenceIterator(Address startAddr)
Description copied from interface:ReferenceManager
Get an iterator over references starting with the specified fromAddr. A forward iterator is returned with references sorted on the from address.- Specified by:
getReferenceIterator
in interfaceReferenceManager
- Parameters:
startAddr
- the first from address to consider.- Returns:
- a forward memory reference iterator.
-
getReference
public Reference getReference(Address fromAddr, Address toAddr, int opIndex)
Description copied from interface:ReferenceManager
Get the reference that has the given from and to address, and operand index.- Specified by:
getReference
in interfaceReferenceManager
- Parameters:
fromAddr
- the address of the codeunit making the reference.toAddr
- the address being referred to.opIndex
- the operand index.
-
getReferencesFrom
public Reference[] getReferencesFrom(Address addr)
Description copied from interface:ReferenceManager
Get all references "from" the specified addr.- Specified by:
getReferencesFrom
in interfaceReferenceManager
- Parameters:
addr
- address of code-unit making the references.- Returns:
- array of all references "from" the specified addr.
-
getReferencesFrom
public Reference[] getReferencesFrom(Address fromAddr, int opIndex)
Description copied from interface:ReferenceManager
Returns all references "from" the given fromAddr and operand (specified by opIndex).- Specified by:
getReferencesFrom
in interfaceReferenceManager
- Parameters:
fromAddr
- the from which to get referencesopIndex
- the operand from which to get references- Returns:
- all references "from" the given fromAddr and operand.
-
hasReferencesFrom
public boolean hasReferencesFrom(Address fromAddr)
Description copied from interface:ReferenceManager
Returns true if there are any memory references at the given address.- Specified by:
hasReferencesFrom
in interfaceReferenceManager
- Parameters:
fromAddr
- the address of the codeunit being tested
-
hasReferencesFrom
public boolean hasReferencesFrom(Address fromAddr, int opIndex)
Description copied from interface:ReferenceManager
Returns true if there are any memory references at the given address/opIndex. Keep in mind this is a rather inefficient method as it must examine all references from the specified fromAddr.- Specified by:
hasReferencesFrom
in interfaceReferenceManager
- Parameters:
fromAddr
- the address of the codeunit being testedopIndex
- the index of the operand being tested.
-
getPrimaryReferenceFrom
public Reference getPrimaryReferenceFrom(Address addr, int opIndex)
Description copied from interface:ReferenceManager
Get the primary reference from the given address.- Specified by:
getPrimaryReferenceFrom
in interfaceReferenceManager
- Parameters:
addr
- from addressopIndex
- operand index
-
getReferenceSourceIterator
public AddressIterator getReferenceSourceIterator(Address startAddr, boolean forward)
Description copied from interface:ReferenceManager
Returns an iterator over addresses that are the "From" address in a reference- Specified by:
getReferenceSourceIterator
in interfaceReferenceManager
- Parameters:
startAddr
- address to position iterator.forward
- true means to iterate in the forward direction
-
getReferenceSourceIterator
public AddressIterator getReferenceSourceIterator(AddressSetView addrSet, boolean forward)
Description copied from interface:ReferenceManager
Returns an iterator over all addresses that are the "From" address in a reference, restricted by the given address set.- Specified by:
getReferenceSourceIterator
in interfaceReferenceManager
- Parameters:
addrSet
- the set of address to restrict the iterator.forward
- true means to iterate in the forward direction
-
getReferenceDestinationIterator
public AddressIterator getReferenceDestinationIterator(Address startAddr, boolean forward)
Description copied from interface:ReferenceManager
Returns an iterator over all addresses that are the "To" address in a reference.- Specified by:
getReferenceDestinationIterator
in interfaceReferenceManager
- Parameters:
startAddr
- start of iteratorforward
- true means to iterate in the forward direction
-
getReferenceDestinationIterator
public AddressIterator getReferenceDestinationIterator(AddressSetView addrSet, boolean forward)
Description copied from interface:ReferenceManager
Returns an iterator over all addresses that are the "To" address in a memory reference, restricted by the given address set.- Specified by:
getReferenceDestinationIterator
in interfaceReferenceManager
- Parameters:
addrSet
- the set of address to restrict the iterator.forward
- true means to iterate in the forward direction
-
getReferenceCountTo
public int getReferenceCountTo(Address toAddr)
Description copied from interface:ReferenceManager
Returns the number of memory References to the specifiedtoAddr
- Specified by:
getReferenceCountTo
in interfaceReferenceManager
- Parameters:
toAddr
- the address being referenced
-
getReferenceCountFrom
public int getReferenceCountFrom(Address fromAddr)
Description copied from interface:ReferenceManager
Returns the number of memory References from the specifiedfromAddr
- Specified by:
getReferenceCountFrom
in interfaceReferenceManager
- Parameters:
fromAddr
- the address of the codeunit making the reference.
-
getReferenceDestinationCount
public int getReferenceDestinationCount()
Description copied from interface:ReferenceManager
Return the number of references for "to" addresses.- Specified by:
getReferenceDestinationCount
in interfaceReferenceManager
-
getReferenceSourceCount
public int getReferenceSourceCount()
Description copied from interface:ReferenceManager
Return the number of references for "from" addresses.- Specified by:
getReferenceSourceCount
in interfaceReferenceManager
-
hasReferencesTo
public boolean hasReferencesTo(Address toAddr)
Description copied from interface:ReferenceManager
Return true if a memory reference exists with the given "to" address.- Specified by:
hasReferencesTo
in interfaceReferenceManager
- Parameters:
toAddr
- address being refered to.
-
updateRefType
public Reference updateRefType(Reference ref, RefType refType)
Description copied from interface:ReferenceManager
Uodate the reference type on a memory reference.- Specified by:
updateRefType
in interfaceReferenceManager
- Parameters:
ref
- reference to be updatedrefType
- new reference type
-
setAssociation
public void setAssociation(Symbol s, Reference ref)
Description copied from interface:ReferenceManager
Associates the given reference with the given symbol.- Specified by:
setAssociation
in interfaceReferenceManager
- Parameters:
s
- the symbol to associate with the given reference.ref
- the reference to associate with the given symbol
-
removeAssociation
public void removeAssociation(Reference ref)
Description copied from interface:ReferenceManager
Removes any symbol associations with the given reference.- Specified by:
removeAssociation
in interfaceReferenceManager
- Parameters:
ref
- the reference for which any symbol association is to be removed.
-
delete
public void delete(Reference ref)
Description copied from interface:ReferenceManager
Deletes the given reference object- Specified by:
delete
in interfaceReferenceManager
- Parameters:
ref
- the reference to be deleted.
-
getReferenceLevel
public byte getReferenceLevel(Address toAddr)
Description copied from interface:ReferenceManager
Returns the reference level for the references to the given address- Specified by:
getReferenceLevel
in interfaceReferenceManager
- Parameters:
toAddr
- the address at which to find the highest reference level
-
-