Class 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 first maxNumber 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 first maxNumber direct XREF addresses to the specified code unit.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XReferenceUtil

        public XReferenceUtil()
    • 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 first maxNumber direct XREF addresses to the specified code unit.
        Parameters:
        cu - the code unit to generate the XREFs
        maxNumber - 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 first maxNumber direct XREF references to the specified code unit.
        Parameters:
        cu - the code unit to generate the XREFs
        maxNumber - 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 XREFs
        maxXRefs - 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 XREFs
        maxXRefs - 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 references
        xrefs - list to put direct references on
        offcuts - 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