Package ghidra.app.util
Class XReferenceUtil
- java.lang.Object
-
- ghidra.app.util.XReferenceUtil
-
public class XReferenceUtil extends java.lang.Object
A utility class to handle the generation of direct and offcut cross-reference (XREF) lists on code units and stack variables.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ALL_REFS
-
Constructor Summary
Constructors Constructor Description XReferenceUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
getOffcutXRefCount(CodeUnit cu)
Returns the count of all offcut XREF addresses to the specified code unit.static Reference[]
getOffcutXReferences(CodeUnit cu, int maxXRefs)
Returns an array containing all offcut XREF references to the specified code unit.static Address[]
getOffcutXRefList(CodeUnit cu)
Returns an array containing all offcut XREF addresses to the specified code unit.static Address[]
getOffcutXRefList(CodeUnit cu, int maxXRefs)
Returns an array containing all offcut XREF addresses to the specified code unit.static int
getReferenceCount(CodeUnit cu)
Get the reference count to the min address of the given code unit.static void
getVariableRefs(Variable var, java.util.List<Reference> xrefs, java.util.List<Reference> offcuts)
Populates the provided array lists with the direct and offcut XREFs to the specified variable.static Reference[]
getXReferences(CodeUnit cu, int maxNumber)
Returns an array containing the firstmaxNumber
direct XREF references to the specified code unit.static Address[]
getXRefList(CodeUnit cu)
Returns an array containing all direct XREF addresses to the specified code unit.static Address[]
getXRefList(CodeUnit cu, int maxNumber)
Returns an array containing the firstmaxNumber
direct XREF addresses to the specified code unit.
-
-
-
Field Detail
-
ALL_REFS
public static final int ALL_REFS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getXRefList
public static final Address[] getXRefList(CodeUnit cu)
Returns an array containing all direct XREF addresses to the specified code unit.- Parameters:
cu
- the code unit to generate the XREFs- Returns:
- array of all XREFs to the code unit
-
getXRefList
public static final Address[] getXRefList(CodeUnit cu, int maxNumber)
Returns an array containing the firstmaxNumber
direct XREF addresses to the specified code unit.- Parameters:
cu
- the code unit to generate the XREFsmaxNumber
- max number of XREFs to get, or -1 to get all references- Returns:
- array first
maxNumber
XREFs to the code unit
-
getXReferences
public static final Reference[] getXReferences(CodeUnit cu, int maxNumber)
Returns an array containing the firstmaxNumber
direct XREF references to the specified code unit.- Parameters:
cu
- the code unit to generate the XREFsmaxNumber
- max number of XREFs to get, or -1 to get all references- Returns:
- array first
maxNumber
XREFs to the code unit
-
getOffcutXRefList
public static final Address[] getOffcutXRefList(CodeUnit cu)
Returns an array containing all offcut XREF addresses to the specified code unit.- Parameters:
cu
- the code unit to generate the offcut XREFs- Returns:
- array of all offcut XREFs to the code unit
-
getOffcutXRefList
public static final Address[] getOffcutXRefList(CodeUnit cu, int maxXRefs)
Returns an array containing all offcut XREF addresses to the specified code unit.- Parameters:
cu
- the code unit to generate the offcut XREFsmaxXRefs
- max number of offcut XREFs to get, or -1 to get all offcut references- Returns:
- array of all offcut XREFs to the code unit
-
getOffcutXReferences
public static final Reference[] getOffcutXReferences(CodeUnit cu, int maxXRefs)
Returns an array containing all offcut XREF references to the specified code unit.- Parameters:
cu
- the code unit to generate the offcut XREFsmaxXRefs
- max number of offcut XREFs to get, or -1 to get all offcut references- Returns:
- array of all offcut XREFs to the code unit
-
getOffcutXRefCount
public static int getOffcutXRefCount(CodeUnit cu)
Returns the count of all offcut XREF addresses to the specified code unit.- Parameters:
cu
- the code unit to generate the offcut XREFs- Returns:
- count of all offcut XREFs to the code unit
-
getVariableRefs
public static void getVariableRefs(Variable var, java.util.List<Reference> xrefs, java.util.List<Reference> offcuts)
Populates the provided array lists with the direct and offcut XREFs to the specified variable.- Parameters:
var
- variable to get referencesxrefs
- list to put direct references onoffcuts
- list to put offcut references on
-
getReferenceCount
public static int getReferenceCount(CodeUnit cu)
Get the reference count to the min address of the given code unit. If an external entry exists there, then subtract one from the count.- Parameters:
cu
- code unit- Returns:
- reference count, excluding an external entry reference
-
-