Class DFA4<InsnType extends IInstruction>

java.lang.Object
com.pnfsoftware.jeb.core.units.code.DFA4<InsnType>
Type Parameters:
InsnType - instruction type
All Implemented Interfaces:
IDFA<InsnType>

public class DFA4<InsnType extends IInstruction> extends Object implements IDFA<InsnType>
Lean Data Flow Analysis (DFA) object implementation.
  • Field Details

    • CACHE_NONE

      public static final int CACHE_NONE
      Nothing is cached
      See Also:
    • CACHE_DUI

      public static final int CACHE_DUI
      Cache basic def/use information at the instruction level
      See Also:
    • CACHE_DUI_CHAINS

      public static final int CACHE_DUI_CHAINS
      CACHE_DUI + cache standard ud-chains and du-chains
      See Also:
    • CACHE_DUI_UDC_DUC

      @Deprecated public static final int CACHE_DUI_UDC_DUC
      Deprecated.
      use CACHE_DUI_CHAINS instead
      See Also:
    • dbgDuCacheTotalQueryCount

      public static final AtomicLong dbgDuCacheTotalQueryCount
    • dbgDuCacheTotalHitCount

      public static final AtomicLong dbgDuCacheTotalHitCount
    • dbgDuCalculationTotalExectimeNs

      public static final AtomicLong dbgDuCalculationTotalExectimeNs
    • dbgUdCacheTotalQueryCount

      public static final AtomicLong dbgUdCacheTotalQueryCount
    • dbgUdCacheTotalHitCount

      public static final AtomicLong dbgUdCacheTotalHitCount
    • dbgUdCalculationTotalExectimeNs

      public static final AtomicLong dbgUdCalculationTotalExectimeNs
    • dbgVrCacheTotalQueryCount

      public static final AtomicLong dbgVrCacheTotalQueryCount
    • dbgVrCacheTotalHitCount

      public static final AtomicLong dbgVrCacheTotalHitCount
    • dbgVrCalculationTotalExectimeNs

      public static final AtomicLong dbgVrCalculationTotalExectimeNs
  • Constructor Details

    • DFA4

      public DFA4(IControlFlowGraph<InsnType,? extends IBasicBlock<InsnType>> cfg)
      Create a DFA object with CFG-provided default collection flags and basic caching for instruction-level def-use information. This object can be further configured by invoking its various setters.
      Parameters:
      cfg - control flow graph
    • DFA4

      public DFA4(IControlFlowGraph<InsnType,? extends IBasicBlock<InsnType>> cfg, int collectionFlags, int cacheConfig)
      Create a DFA object. This object can be further configured by invoking its various setters.
      Parameters:
      cfg - control flow graph
      collectionFlags - collection flags, see constants in DefUseInfo
      cacheConfig - 0= no cache, 1= cached for instruction-level def-use information; 2= 1 + cache for ud-chains and du-chains
  • Method Details

    • perform

      public void perform()
      Description copied from interface: IDFA
      Perform data flow analysis on the CFG. Upon return, basic blocks will have their data chains (ud and du, full and simple) set up and accessible.
      Specified by:
      perform in interface IDFA<InsnType extends IInstruction>
    • isValid

      public boolean isValid()
      Description copied from interface: IDFA
      Determine whether the current analysis was performed and is valid.
      Specified by:
      isValid in interface IDFA<InsnType extends IInstruction>
      Returns:
      true if the analysis is valid
    • invalidate

      public void invalidate()
      Description copied from interface: IDFA
      Invalidate the analysis. Clients have the responsibility to invalidate an analysis if the CFG was modified in such a way that data flow should be recalculated.
      Specified by:
      invalidate in interface IDFA<InsnType extends IInstruction>
    • notifyInstructionUpdate

      public void notifyInstructionUpdate(long addr)
      Description copied from interface: IDFA
      Notify the DFA that an instruction was updated.
      Specified by:
      notifyInstructionUpdate in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
    • resetChainCaches

      public void resetChainCaches()
      Reset cached chain information.
    • invalidateForRemoval

      public void invalidateForRemoval(long addr0)
      Description copied from interface: IDFA
      Selectively invalidate the cache in preparation for an instruction pseudo-removal (neutering). This method should be called before neutering takes place.
      Specified by:
      invalidateForRemoval in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr0 - address of the start instruction; it is assumed that this instruction is no-throw
    • invalidateForSubstitution

      public void invalidateForSubstitution(long addr0, Collection<Long> addr1coll, Collection<Long> srccoll)
      Description copied from interface: IDFA
      Selectively invalidate the cache in preparation for an expression-substitution. This method should be called before the substitution by an immediate took place.
      Specified by:
      invalidateForSubstitution in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr0 - address of the start instruction, which defines the variable being substituted; it is assumed that this instruction is no-throw
      addr1coll - mandatory collection of addresses where the substitutions will take place place
      srccoll - optional collection of source instructions; if not provided, all instructions defining some of the substituted variables will be invalidated from the cache
    • invalidatePostSimpleSubstitutionWithMultiDefs

      public void invalidatePostSimpleSubstitutionWithMultiDefs(Collection<Long> addr0coll, long addr1, int varid)
      Description copied from interface: IDFA
      Selectively invalidate DFA cache after the substitution of a variable X by an immediate. This method should be called after the substitution by an immediate took place.
      Specified by:
      invalidatePostSimpleSubstitutionWithMultiDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr0coll - collection of equivalent source instructions defining a target var X (e.g. X=3); these instructions must be left as-is when calling this method; it is assumed that these instructions are no-throw
      addr1 - destination instruction, whose target variable X was replaced by a constant
      varid - the variable that was propagated (X)
    • getCfg

      Description copied from interface: IDFA
      Retrieve a reference to the CFG object that will be accessed and modified when performing an analysis.
      Specified by:
      getCfg in interface IDFA<InsnType extends IInstruction>
      Returns:
      control flow graph
    • setVariableCollectionFlags

      public void setVariableCollectionFlags(int flags)
      Description copied from interface: IDFA
      Set the variable collection flags.
      Specified by:
      setVariableCollectionFlags in interface IDFA<InsnType extends IInstruction>
      Parameters:
      flags - flags, see DefUseInfo
    • getVariableCollectionFlags

      public int getVariableCollectionFlags()
      Description copied from interface: IDFA
      Retrieve the variable collection flags.
      Specified by:
      getVariableCollectionFlags in interface IDFA<InsnType extends IInstruction>
      Returns:
      flags, see DefUseInfo
    • setCacheConfiguration

      public void setCacheConfiguration(int value)
      Set or update the cache configuration of this object.
      Parameters:
      value - one of CACHE_xxx attribute
    • getCacheConfiguration

      public int getCacheConfiguration()
      Retrieve the cache configuration.
      Returns:
      value one of CACHE_xxx attribute
    • setIntegrateCalculatedInputRegisters

      public boolean setIntegrateCalculatedInputRegisters(boolean enabled)
      Description copied from interface: IDFA
      Set whether calculated input registers should be integrated.
      Specified by:
      setIntegrateCalculatedInputRegisters in interface IDFA<InsnType extends IInstruction>
      Parameters:
      enabled - if true, the live registers determined after analysis will be integrated in the use-def chains
      Returns:
      the previous value for this setting
    • isIntegrateCalculatedInputRegisters

      public boolean isIntegrateCalculatedInputRegisters()
      Description copied from interface: IDFA
      Determine whether calculated input registers are integrated.
      Specified by:
      isIntegrateCalculatedInputRegisters in interface IDFA<InsnType extends IInstruction>
      Returns:
      true if calculated input registers are integrated
    • setAlwaysExamineIrregularFlows

      public boolean setAlwaysExamineIrregularFlows(boolean enabled)
      Description copied from interface: IDFA
      Set whether irregular flows should always be examined.
      Specified by:
      setAlwaysExamineIrregularFlows in interface IDFA<InsnType extends IInstruction>
      Parameters:
      enabled - true to always examine irregular flows
      Returns:
      the previous value for this setting
    • isAlwaysExamineIrregularFlows

      public boolean isAlwaysExamineIrregularFlows()
      Description copied from interface: IDFA
      Determine whether irregular flows are always examined.
      Specified by:
      isAlwaysExamineIrregularFlows in interface IDFA<InsnType extends IInstruction>
      Returns:
      true if irregular flows are always examined
    • setVariableInformationProvider

      public ICFGOwnerContext setVariableInformationProvider(ICFGOwnerContext provider)
      Description copied from interface: IDFA
      Set the variable information provider.
      Specified by:
      setVariableInformationProvider in interface IDFA<InsnType extends IInstruction>
      Parameters:
      provider - variable information provider
      Returns:
      the previously set provider
    • getVariableInformationProvider

      public ICFGOwnerContext getVariableInformationProvider()
      Description copied from interface: IDFA
      Get the variable information provider.
      Specified by:
      getVariableInformationProvider in interface IDFA<InsnType extends IInstruction>
      Returns:
      variable information provider
    • setMaxBlocks

      public int setMaxBlocks(int maxBlocks)
      Description copied from interface: IDFA
      Set an exploration threshold for most DFA operations. By default, there is no threshold. The threshold is a block count; if a block count is reached, a chain may contain a reference to the invalid address -2 in order to indicate an incomplete result.
      Specified by:
      setMaxBlocks in interface IDFA<InsnType extends IInstruction>
      Parameters:
      maxBlocks - -1 means no limit
      Returns:
      the previous value for this setting
    • getMaxBlocks

      public int getMaxBlocks()
      Description copied from interface: IDFA
      Retrieve the maximum block count used for common DFA operations. See IDFA.setMaxBlocks(int) for details.
      Specified by:
      getMaxBlocks in interface IDFA<InsnType extends IInstruction>
      Returns:
      maximum block count
    • formatDUI

      public String formatDUI(DUI o)
      Format def-use information.
      Parameters:
      o - def-use information
      Returns:
      formatted def-use information
    • getDUI

      public DUI getDUI(long addr)
      Description copied from interface: IDFA
      Get def-use information for an instruction.
      Specified by:
      getDUI in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      def-use information
    • getDUI

      public DUI getDUI(AddressableInstruction<InsnType> a)
      Description copied from interface: IDFA
      Get def-use information for an addressable instruction.
      Specified by:
      getDUI in interface IDFA<InsnType extends IInstruction>
      Parameters:
      a - addressable instruction
      Returns:
      def-use information
    • getDUI

      public DUI getDUI(long addr, InsnType insn)
      Description copied from interface: IDFA
      Get def-use information for an instruction.
      Specified by:
      getDUI in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      insn - instruction
      Returns:
      def-use information
    • getUseDefs

      public Collection<Long> getUseDefs(long addr, int varid, int stopcount, boolean verifyStartOnUsePoint, boolean recordLiveIn, IBasicBlock<InsnType> blkForReachChains, int idxForReachChains, boolean[] aDetectedUseDiscrepancy, boolean treatSpoiledAsDefs, int maxBlocks, boolean limitToStartBlock)
      Find the list of definition points for a used variable.
      Parameters:
      addr - initial instruction address (disregarded if computing reachability, in which case, blkForReachChains must be provided)
      varid - used variable, for which definitions are to be collected
      stopcount - the search will stop if the def-count reaches that threshold; use <=0 to mean no stopcount
      verifyStartOnUsePoint - if true, the variable must be used at the provided instruction (else the method will return null)
      recordLiveIn - if true, a candidate argument-definition is recorded as -1 in the returned list
      blkForReachChains - optional basic block used to record reaching variables
      idxForReachChains - optional block index used to record reaching variables
      aDetectedUseDiscrepancy - optional one-element array, if provided, any use discrepancy (using a potentially undefined variable) will interrupt the search, and this flag will be set to true
      treatSpoiledAsDefs - if true, spoiled information for variables will be treated as a regular definition
      maxBlocks - maximum number of basic blocks to be examined; use -1 to mean all; if a positive value is provided, the returned list of addresses may contain -2 to indicate that a definition may be located in an unexplored block
      limitToStartBlock - true to limit the search to the start block
      Returns:
      a read-only collection of addresses where the variable was defined; the list may contain -1 to indicate a candidate argument-definition; never return null unless verifyStartOnUsePoint was true
    • getUseDefs

      public Collection<Long> getUseDefs(long addr, int varid)
      Description copied from interface: IDFA
      Get definition locations for a variable use.
      Specified by:
      getUseDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - a variable, which must be used by the provided instruction
      Returns:
      a collection (possibly empty) or null if the variable is not used by the instruction
    • getUseDefs

      public Collection<Long> getUseDefs(long addr, int varid, int stopCount)
      Description copied from interface: IDFA
      Get definition locations for a variable use.
      Specified by:
      getUseDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - a variable, which must be used by the provided instruction
      stopCount - optional stop count
      Returns:
      a collection (possibly empty) or null if the variable is not used by the instruction
    • getBlockUseDefs

      public Collection<Long> getBlockUseDefs(long addr, int varid)
      Description copied from interface: IDFA
      Get block-local definition locations for a variable use.
      Specified by:
      getBlockUseDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      Returns:
      definition locations
    • isTerminator

      public boolean isTerminator(IBasicBlock<InsnType> blk)
      Description copied from interface: IDFA
      Determine whether the provided block is a terminator. A terminator has no output and its final instruction is a clean routine terminator.
      Specified by:
      isTerminator in interface IDFA<InsnType extends IInstruction>
      Parameters:
      blk - block to test
      Returns:
      true if the block is a clean terminator
    • getDefUses

      public Collection<Long> getDefUses(long addr, int varid, int stopcount, boolean verifyStartOnDefPoint, boolean recordReachOut, IBasicBlock<InsnType> blkForLiveChains, int idxForLiveChains, int maxBlocks, boolean limitToStartBlock)
      Find the list of usage points for a defined variable.
      Parameters:
      addr - initial instruction address (disregarded if computing liveness, in which case, blkForLiveChains must be provided)
      varid - defined variable
      stopcount - the search will stop if the use-count reaches that threshold; use <= 0 to mean no stopcount
      verifyStartOnDefPoint - if true, the variable must be defined by the provided initial instruction (else the method will return null)
      recordReachOut - if true, if the variable reaches the CFG output, a pseudo usage will be recorded as -1
      blkForLiveChains - optional basic block used to record live variables
      idxForLiveChains - optional block index used to record live variables
      maxBlocks - maximum number of basic blocks to be examined; use -1 to mean all; if a positive value is provided, the returned list of addresses may contain -2 to indicate that a usage may be located in an unexplored block
      limitToStartBlock - if true, the exploration will stop as soon as a use is detected outside the provided starting block, where the def took place, and -2 will be added to the returned list (if true, blkForLiveChains should be null); note: unlike what maxBlocks intends to do, a -2 in the resulting collection will indicate a definite out-of-block use
      Returns:
      a read-only collection of addresses where the variable is used; the list may contain -1 to indicate the the variable reached an output; never returns null unless verifyStartOnDefPoint was true
    • getDefUses

      public Collection<Long> getDefUses(long addr, int varid)
      Description copied from interface: IDFA
      Get use locations for a variable definition.
      Specified by:
      getDefUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - a variable, which must be defined by the provided instruction
      Returns:
      a collection (possibly empty) or null if the variable is not defined by the instruction
    • getDefUses

      public Collection<Long> getDefUses(long addr, int varid, int stopCount)
      Description copied from interface: IDFA
      Get use locations for a variable definition.
      Specified by:
      getDefUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - a variable, which must be defined by the provided instruction
      stopCount - optional stop count (-1 to collect as many uses as possible)
      Returns:
      a collection (possibly empty) or null if the variable is not defined by the instruction
    • getDefUses

      public Collection<Long> getDefUses(long addr, int varid, int stopCount, boolean recordReachOut)
      Description copied from interface: IDFA
      Get use locations for a variable definition.
      Specified by:
      getDefUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - a variable, which must be defined by the provided instruction
      stopCount - optional stop count (-1 to collect as many uses as possible)
      recordReachOut - if true, a variable reaching is considered used (if so, the output list will contain -1)
      Returns:
      a collection (possibly empty) or null if the variable is not defined by the instruction
    • getBlockDefUses

      public Collection<Long> getBlockDefUses(long addr, int varid)
      Description copied from interface: IDFA
      Get block-local use locations for a variable definition.
      Specified by:
      getBlockDefUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      Returns:
      use locations
    • getBlockDefUses

      public Collection<Long> getBlockDefUses(long addr, int varid, int stopCount)
      Description copied from interface: IDFA
      Get block-local use locations for a variable definition.
      Specified by:
      getBlockDefUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      stopCount - optional stop count
      Returns:
      use locations
    • checkNoUse

      public int checkNoUse(long addr, int varid, boolean reachOutIsUse, int maxBlocks)
      Description copied from interface: IDFA
      Check whether a variable, defined at the provided instruction, is not used.
      Specified by:
      checkNoUse in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - initial instruction address
      varid - defined variable at the initial instruction
      reachOutIsUse - true if reaching out is considered a use
      maxBlocks - optional maximum block count
      Returns:
      1: some uses; 0: no use; -1: no use, but may be a meaningful output; -2: unknown (may be returned only if maxBlocks is positive); -3: error
    • checkNoUse

      public boolean checkNoUse(long insnAddress, int varId, boolean reachOutIsUse)
      Description copied from interface: IDFA
      Check whether a variable, defined at the provided instruction, is not used.
      Specified by:
      checkNoUse in interface IDFA<InsnType extends IInstruction>
      Parameters:
      insnAddress - initial instruction address
      varId - defined variable at the initial instruction
      reachOutIsUse - true if reaching out is considered a use
      Returns:
      true if the variable is not used, and optionally (if reachOutIsUse is true), is overwritten before reaching possible end-blocks
    • checkNoUse

      public boolean checkNoUse(long addr, int varid)
      Description copied from interface: IDFA
      Check whether a variable, defined at the provided instruction, is not used.
      Specified by:
      checkNoUse in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - initial instruction address
      varid - defined variable at the initial instruction
      Returns:
      true if the variable is not used; reaching-out is not considered a use
    • checkSingleUse

      public Long checkSingleUse(long addr, int varid, boolean reachOutIsUse)
      Check whether a defined variable has a single use.
      Parameters:
      addr - instruction address
      varid - variable id
      reachOutIsUse - true if reaching out is considered a use
      Returns:
      single use address, or null
    • checkSingleUse

      public Long checkSingleUse(long addr, int varid)
      Description copied from interface: IDFA
      Check whether a defined variable has a single use.
      Specified by:
      checkSingleUse in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      Returns:
      single use address, or null
    • checkSingleDef

      public Long checkSingleDef(long addr, int varid, boolean liveInIsDef)
      Check whether a used variable has a single explicit definition point (i.e. it is a non-input defined at a unique address).
      Parameters:
      addr - initial instruction address
      varid - used variable at the initial instruction
      liveInIsDef - true if live-in variables are treated as definitions
      Returns:
      the instruction address, if the variable used at the provided instruction has a single def-point; -1 is returned if the variable has no explicit def-point (as would be the case for method arguments); on error, or if multiple def-points are detected, null is returned
    • checkSingleDefNoInput

      public Long checkSingleDefNoInput(long addr, int varid)
      Description copied from interface: IDFA
      Check whether a used variable has a single explicit definition point. The def point cannot be a routine input (i.e. the definition must be explicit).
      Specified by:
      checkSingleDefNoInput in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - initial instruction address
      varid - used variable at the initial instruction
      Returns:
      single definition address, or null
    • checkSingleDef

      public Long checkSingleDef(long addr, int varid)
      Description copied from interface: IDFA
      Check whether a used variable has a single definition point. The def point may be explicit (e.g. resulting from an assignment) or implicit (e.g. provided as a parameter to the routine, which is always represented as the address -1).
      Specified by:
      checkSingleDef in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - initial instruction address
      varid - used variable at the initial instruction (it must be used at the provided address; else, refer to checkSingleSource)
      Returns:
      single definition address, or null
    • checkSingleSource

      public Long checkSingleSource(long addr, int varid, boolean liveInIsDef)
      Description copied from interface: IDFA
      Check whether a variable has a single source.
      Specified by:
      checkSingleSource in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      liveInIsDef - true if live-in variables are treated as definitions
      Returns:
      single source address, or null
    • checkSingleSource

      public Long checkSingleSource(long addr, int varid)
      Description copied from interface: IDFA
      Check whether a variable has a single source.
      Specified by:
      checkSingleSource in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      Returns:
      single source address, or null
    • collectInstructionAllDefs

      public void collectInstructionAllDefs(long addr, Collection<Integer> r)
      Description copied from interface: IDFA
      Collect all variables defined by an instruction.
      Specified by:
      collectInstructionAllDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      r - output collection
    • collectInstructionAllUses

      public void collectInstructionAllUses(long addr, Collection<Integer> r)
      Description copied from interface: IDFA
      Collect all variables used by an instruction.
      Specified by:
      collectInstructionAllUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      r - output collection
    • getInstructionAllDefs

      public Set<Integer> getInstructionAllDefs(long addr)
      Description copied from interface: IDFA
      Get all variables defined by an instruction.
      Specified by:
      getInstructionAllDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      defined variables
    • getInstructionAllUses

      public Set<Integer> getInstructionAllUses(long addr)
      Description copied from interface: IDFA
      Get all variables used by an instruction.
      Specified by:
      getInstructionAllUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      used variables
    • getInstructionDefs

      public Set<Integer> getInstructionDefs(long addr)
      Description copied from interface: IDFA
      Get the variables defined by an instruction.
      Specified by:
      getInstructionDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      a list of variables defined by the instruction at index in the block
    • getInstructionUses

      public Set<Integer> getInstructionUses(long addr)
      Description copied from interface: IDFA
      Get the variables used by an instruction.
      Specified by:
      getInstructionUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      a list of variables used by the instruction at index in the block
    • getInstructionPotentialDefs

      public Set<Integer> getInstructionPotentialDefs(long addr)
      Description copied from interface: IDFA
      Get variables potentially defined by an instruction.
      Specified by:
      getInstructionPotentialDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      a list of variables potentially defined by the instruction at index in the block; note that this data may not be present (empty lists) depending on DFA settings
    • getInstructionPotentialUses

      public Set<Integer> getInstructionPotentialUses(long addr)
      Description copied from interface: IDFA
      Get variables potentially used by an instruction.
      Specified by:
      getInstructionPotentialUses in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      a list of variables potentially used by the instruction at index in the block; note that this data may not be present (empty lists) depending on DFA settings
    • getInstructionSpoiledDefs

      public Set<Integer> getInstructionSpoiledDefs(long addr)
      Description copied from interface: IDFA
      Get variables potentially spoiled by an instruction.
      Specified by:
      getInstructionSpoiledDefs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      a list of variables potentially spoiled by the instruction at index in the block; note that this data may not be present (empty lists) depending on DFA settings
    • getUseDefChains

      public Map<Integer,Collection<Long>> getUseDefChains(long addr, boolean recordLiveIn)
      Get use-def chains at an instruction.
      Parameters:
      addr - instruction address
      recordLiveIn - true to record live-in definitions
      Returns:
      use-def chains
    • getUseDefChains

      public Map<Integer,Collection<Long>> getUseDefChains(long addr)
      Description copied from interface: IDFA
      Get use-def chains at an instruction.
      Specified by:
      getUseDefChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      use-def chains
    • getDefUseChains

      public Map<Integer,Collection<Long>> getDefUseChains(long addr, boolean recordReachOut)
      Get def-use chains at an instruction.
      Parameters:
      addr - instruction address
      recordReachOut - true to record reaching outputs
      Returns:
      def-use chains
    • getDefUseChains

      public Map<Integer,Collection<Long>> getDefUseChains(long addr)
      Description copied from interface: IDFA
      Get def-use chains at an instruction.
      Specified by:
      getDefUseChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      def-use chains
    • getLiveChains

      public Map<Integer,Collection<Long>> getLiveChains(IBasicBlock<InsnType> b, int idx, Collection<Integer> varids, int stopcount)
      Get live chains at a block location.
      Parameters:
      b - basic block
      idx - instruction index
      varids - optional variable filter
      stopcount - optional stop count
      Returns:
      live chains
    • getLiveChains

      public Collection<Long> getLiveChains(IBasicBlock<InsnType> b, int idx, int varid)
      Description copied from interface: IDFA
      Get live chains for a variable at a block location.
      Specified by:
      getLiveChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      varid - variable id
      Returns:
      live chains
    • getLiveChains

      public Collection<Long> getLiveChains(IBasicBlock<InsnType> b, int idx, int varid, int stopcount)
      Description copied from interface: IDFA
      Get live chains for a variable at a block location.
      Specified by:
      getLiveChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      varid - variable id
      stopcount - optional stop count
      Returns:
      live chains
    • getLiveChains

      public Map<Integer,Collection<Long>> getLiveChains(IBasicBlock<InsnType> b, int idx)
      Description copied from interface: IDFA
      Get live chains at a block location.
      Specified by:
      getLiveChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      Returns:
      live chains
    • isAlive

      public boolean isAlive(IBasicBlock<InsnType> b, int idx, int varid)
      Description copied from interface: IDFA
      Determine whether a variable is alive at a block location.
      Specified by:
      isAlive in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      varid - variable id
      Returns:
      true if the variable is alive
    • getReachChains

      public Map<Integer,Collection<Long>> getReachChains(IBasicBlock<InsnType> b, int idx, Collection<Integer> varids, int stopcount)
      Get reach chains at a block location.
      Parameters:
      b - basic block
      idx - instruction index
      varids - optional variable filter
      stopcount - optional stop count
      Returns:
      reach chains
    • getReachChains

      public Collection<Long> getReachChains(IBasicBlock<InsnType> b, int idx, int varid)
      Description copied from interface: IDFA
      Get reach chains for a variable at a block location.
      Specified by:
      getReachChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      varid - variable id
      Returns:
      reach chains
    • getReachChains

      public Collection<Long> getReachChains(IBasicBlock<InsnType> b, int idx, int varid, int stopcount)
      Description copied from interface: IDFA
      Get reach chains for a variable at a block location.
      Specified by:
      getReachChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      varid - variable id
      stopcount - optional stop count
      Returns:
      reach chains
    • getReachChains

      public Map<Integer,Collection<Long>> getReachChains(IBasicBlock<InsnType> b, int idx)
      Description copied from interface: IDFA
      Get reach chains at a block location.
      Specified by:
      getReachChains in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      Returns:
      reach chains
    • isReaching

      public boolean isReaching(IBasicBlock<InsnType> b, int idx, int varid)
      Description copied from interface: IDFA
      Determine whether a variable reaches a block location.
      Specified by:
      isReaching in interface IDFA<InsnType extends IInstruction>
      Parameters:
      b - basic block
      idx - instruction index
      varid - variable id
      Returns:
      true if the variable is reaching
    • getUseDiscrepancies

      public Collection<Integer> getUseDiscrepancies(long addr)
      Description copied from interface: IDFA
      Retrieve the list of use-discrepancies at the provided instruction address.
      Specified by:
      getUseDiscrepancies in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      Returns:
      a list of variables whose usage at the provided location appears to be incorrect (i.e. not all paths to this usage carry a definition if the variable)
    • isUseDiscrepancy

      public boolean isUseDiscrepancy(long addr, int varid)
      Description copied from interface: IDFA
      Determine whether a use discrepancy exists for a variable.
      Specified by:
      isUseDiscrepancy in interface IDFA<InsnType extends IInstruction>
      Parameters:
      addr - instruction address
      varid - variable id
      Returns:
      true if a use discrepancy exists
    • checkInput

      public boolean checkInput(int varid)
      Determine whether a variable is an input.
      Parameters:
      varid - variable id
      Returns:
      true if the variable is an input
    • getInputs

      public Collection<Integer> getInputs()
      Description copied from interface: IDFA
      Get input variables.
      Specified by:
      getInputs in interface IDFA<InsnType extends IInstruction>
      Returns:
      input variables
    • filterInputs

      public Collection<Integer> filterInputs(Collection<Integer> varids)
      Filter input variables.
      Parameters:
      varids - optional collection of potential argument variables for which we want to verify uses; leave null to retrieve all potential arguments
      Returns:
      a collection of variables that are used in the routine, that look like they have definitions outside the routine (if `varids` was provided, this output collection is a subset of it)
    • getInputsWithUses

      public Map<Integer,Collection<Long>> getInputsWithUses()
      Get input variables with their uses.
      Returns:
      input use map
    • checkInputWithUses

      public Collection<Long> checkInputWithUses(int varid)
      Get uses of an input variable.
      Parameters:
      varid - variable id
      Returns:
      use addresses
    • filterInputsWithUses

      public Map<Integer,Collection<Long>> filterInputsWithUses(Collection<Integer> varids)
      Filter input variables with their uses.
      Parameters:
      varids - optional variable filter
      Returns:
      input read-only use map (there may be more varid keys than requested)
    • getInputMap

      public Map<Integer,Collection<Long>> getInputMap()
      Description copied from interface: IDFA
      Get the input map.
      Specified by:
      getInputMap in interface IDFA<InsnType extends IInstruction>
      Returns:
      input map
    • getInputMap

      public Collection<Long> getInputMap(int varid)
      Description copied from interface: IDFA
      Get input locations for a variable.
      Specified by:
      getInputMap in interface IDFA<InsnType extends IInstruction>
      Parameters:
      varid - variable id
      Returns:
      input locations
    • checkOutput

      public boolean checkOutput(IBasicBlock<InsnType> blk, int varid)
      Determine whether a variable is an output of a block.
      Parameters:
      blk - basic block
      varid - variable id
      Returns:
      true if the variable is an output
    • getOutputs

      public Collection<Integer> getOutputs(IBasicBlock<InsnType> blk)
      Description copied from interface: IDFA
      Get output variables for a block.
      Specified by:
      getOutputs in interface IDFA<InsnType extends IInstruction>
      Parameters:
      blk - basic block
      Returns:
      output variables
    • filterOutputs

      public Collection<Integer> filterOutputs(IBasicBlock<InsnType> blk, Collection<Integer> varids)
      Filter output variables of a block.
      Parameters:
      blk - basic block
      varids - optional variable filter
      Returns:
      output variables
    • getOutputsWithDefs

      public Map<Integer,Collection<Long>> getOutputsWithDefs(IBasicBlock<InsnType> blk)
      Get block output variables with their definitions.
      Parameters:
      blk - basic block
      Returns:
      output definition map
    • checkOutputsWithDefs

      public Collection<Long> checkOutputsWithDefs(IBasicBlock<InsnType> blk, int varid)
      Get definitions for a block output variable.
      Parameters:
      blk - basic block
      varid - variable id
      Returns:
      definition addresses
    • filterOutputsWithDefs

      public Map<Integer,Collection<Long>> filterOutputsWithDefs(IBasicBlock<InsnType> blk, Collection<Integer> varids)
      Filter block output variables with their definitions.
      Parameters:
      blk - basic block
      varids - optional variable filter
      Returns:
      output definition map
    • getOutputMap

      public Map<Integer,Collection<Long>> getOutputMap(IBasicBlock<InsnType> blk)
      Description copied from interface: IDFA
      Get the output map for a block.
      Specified by:
      getOutputMap in interface IDFA<InsnType extends IInstruction>
      Parameters:
      blk - basic block
      Returns:
      output map
    • getOutputMap

      public Collection<Long> getOutputMap(IBasicBlock<InsnType> blk, int varid)
      Description copied from interface: IDFA
      Get output locations for a block and variable.
      Specified by:
      getOutputMap in interface IDFA<InsnType extends IInstruction>
      Parameters:
      blk - basic block
      varid - variable id
      Returns:
      output locations
    • checkOutput

      public boolean checkOutput(int varid)
      Determine whether a variable is an output of the CFG.
      Parameters:
      varid - variable id
      Returns:
      true if the variable is an output
    • getOutputs

      public Collection<Integer> getOutputs()
      Description copied from interface: IDFA
      Get output variables.
      Specified by:
      getOutputs in interface IDFA<InsnType extends IInstruction>
      Returns:
      output variables
    • filterOutputs

      public Collection<Integer> filterOutputs(Collection<Integer> varids)
      Filter output variables of the CFG.
      Parameters:
      varids - optional variable filter
      Returns:
      output variables
    • getOutputsWithDefs

      public Map<Integer,Collection<Long>> getOutputsWithDefs()
      Get CFG output variables with their definitions.
      Returns:
      output definition map
    • checkOutputsWithDefs

      public Collection<Long> checkOutputsWithDefs(int varid)
      Get definitions for a CFG output variable.
      Parameters:
      varid - variable id
      Returns:
      definition addresses
    • filterOutputsWithDefs

      public Map<Integer,Collection<Long>> filterOutputsWithDefs(Collection<Integer> varids)
      Filter CFG output variables with their definitions.
      Parameters:
      varids - optional variable filter
      Returns:
      output read-only def map (there may be more varid keys than requested)
    • getOutputMap

      public Map<Integer,Collection<Long>> getOutputMap()
      Description copied from interface: IDFA
      Get the output map.
      Specified by:
      getOutputMap in interface IDFA<InsnType extends IInstruction>
      Returns:
      output map
    • getOutputMap

      public Collection<Long> getOutputMap(int varid)
      Description copied from interface: IDFA
      Get output locations for a variable.
      Specified by:
      getOutputMap in interface IDFA<InsnType extends IInstruction>
      Parameters:
      varid - variable id
      Returns:
      output locations
    • isNotRedefined

      public boolean isNotRedefined(int varid, long addr0, long addr1)
      Determine whether a variable is not redefined between two addresses.
      Parameters:
      varid - variable id
      addr0 - start address
      addr1 - end address
      Returns:
      true if the variable is not redefined
    • isNotRedefined

      public boolean isNotRedefined(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1)
      Determine whether a variable is not redefined between two block locations.
      Parameters:
      varid - variable id
      b0 - start block
      i0 - start instruction index
      b1 - end block
      i1 - end instruction index
      Returns:
      true if the variable is not redefined
    • isVarReachingFromTo

      public Boolean isVarReachingFromTo(int varid, long addr0, long addr1)
      Description copied from interface: IDFA
      Determine if a variable used by the start instruction reaches the final instruction with the same value.

      Important notes:
      - This method provides a must-reach result: if a multiple paths exist from source to sink, where the variable reaches the sink via some paths, but not on others (it is overwritten), the method returns false.
      - This method works from the source to the sink, and provides the guarantee that the variable was not overwritten when it reached the sink. There is no guarantee provided at the sink itself regarding other paths that may exist from different sources to the same sink.
      - This method also checks that the paths from the sink back that may connect back to the sink do not overwrite the variable defined at the source.

      Specified by:
      isVarReachingFromTo in interface IDFA<InsnType extends IInstruction>
      Parameters:
      varid - variable id
      addr0 - source: start address, exclusive
      addr1 - sink: final address, also exclusive
      Returns:
      success indicator; null means unknown
    • isVarReachingFromTo

      public Boolean isVarReachingFromTo(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1)
      Description copied from interface: IDFA
      Determine if a variable used by the start instruction reaches the final instruction with the same value.

      Important notes:
      - This method provides a must-reach result: if a multiple paths exist from source to sink, where the variable reaches the sink via some paths, but not on others (it is overwritten), the method returns false.
      - This method works from the source to the sink, and provides the guarantee that the variable was not overwritten when it reached the sink. There is no guarantee provided at the sink itself regarding other paths that may exist from different sources to the same sink.
      - This method also checks that the paths from the sink back that may connect back to the sink do not overwrite the variable defined at the source.

      Specified by:
      isVarReachingFromTo in interface IDFA<InsnType extends IInstruction>
      Parameters:
      varid - variable id
      b0 - start block (source)
      i0 - final block (sink)
      b1 - index of the start instruction in the start block, exclusive
      i1 - index of the final instruction in the final block, also exclusive
      Returns:
      success indicator; null means unknown
    • isVarReachingFromTo

      public Boolean isVarReachingFromTo(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1, boolean performExtendedChecks, int maxBlocks)
      Description copied from interface: IDFA
      Determine if a variable used by the start instruction reaches the final instruction with the same value.

      Important notes:
      - This method provides a must-reach result: if a multiple paths exist from source to sink, where the variable reaches the sink via some paths, but not on others (it is overwritten), the method returns false.
      - This method works from the source to the sink, and provides the guarantee that the variable was not overwritten when it reached the sink. There is no guarantee provided at the sink itself regarding other paths that may exist from different sources to the same sink.
      - if `performExtendedChecks` is true, this method also checks that the paths from the sink back that may connect back to the sink do not overwrite the variable defined at the source.

      Specified by:
      isVarReachingFromTo in interface IDFA<InsnType extends IInstruction>
      Parameters:
      varid - variable id
      b0 - start block (source)
      i0 - final block (sink)
      b1 - index of the start instruction in the start block, exclusive
      i1 - index of the final instruction in the final block, also exclusive
      performExtendedChecks - true to perform extended reachability checks
      maxBlocks - optional maximum count of blocks to be explored before failing
      Returns:
      success indicator; null means unknown
    • isVarReachingFromTo

      public Boolean isVarReachingFromTo(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1, boolean allowRedef, boolean performExtendedChecks, int maxBlocks)
      Determine whether a variable reaches one block location from another.
      Parameters:
      varid - variable id
      b0 - start block
      i0 - start instruction index
      b1 - end block
      i1 - end instruction index
      allowRedef - true to allow redefinitions
      performExtendedChecks - true to perform extended checks
      maxBlocks - optional maximum block count
      Returns:
      success indicator; null means unknown
    • verifyNoRedefAfterSink

      public Boolean verifyNoRedefAfterSink(int varid, long addr0, long addr1)
      Verify that a variable is not redefined after a sink address.
      Parameters:
      varid - variable id
      addr0 - source address
      addr1 - sink address
      Returns:
      success indicator; null means unknown
    • verifyNoRedefAfterSink

      public Boolean verifyNoRedefAfterSink(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1, int maxBlocks)
      Verify that a variable is not redefined after a sink location.
      Parameters:
      varid - variable id
      b0 - source block
      i0 - source instruction index
      b1 - sink block
      i1 - sink instruction index
      maxBlocks - optional maximum block count
      Returns:
      success indicator; null means unknown
    • toString

      public String toString()
      Overrides:
      toString in class Object