public class

DFA

extends Object
implements IDataFlowAnalysis<InsnType extends IInstruction>
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.asm.cfg.DFA<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction>

Class Overview

Data Flow Analysis (DFA) object for a CFG.

DFA objects can be configured and performed using CFG.doDataFlowAnalysis() methods.

Important: The provided chains are ordered by key (variable) appearance in processing.

Summary

Nested Classes
class DFA.BI<InsnType extends IInstruction>  
Public Methods
<T extends Number> String formatChain(Map<Integer, Set<T>> chains)
Format a data chain as: (regId)={pos0, pos1, ...} ...
String formatStats()
BI<InsnType> getBlockInfo(BasicBlock<InsnType> b)
CFG<InsnType> getCfg()
Retrieve a reference to the CFG object that will be accessed and modified when performing an analysis.
Map<Integer, Set<Integer>> getDefUseChains(BasicBlock<InsnType> b, int index)
Map<Integer, Set<Long>> getDefUseChains(long address)
Retrieve the du-chains for the instruction at the provided address.
long getExecutionTime()
Map<Integer, Set<Long>> getFullDefUseChains(BasicBlock<InsnType> b, int index)
Map<Integer, Set<Long>> getFullUseDefChains(BasicBlock<InsnType> b, int index)
Map<Integer, Set<Long>> getInputMap()
Retrieve the du-chain of live registers at the entry block.
Map<Integer, Set<Long>> getOutputMap()
Retrieve a coalesced ud-chain of reaching registers for all the exit blocks of the CFG.
Map<Integer, Set<Long>> getOutputMap(BasicBlock<InsnType> b)
Map<Integer, Set<Long>> getOutputMap(long lastAddress)
Retrieve the ud-chain of reaching registers for the provided exit block.
Map<Integer, Set<Long>> getReachingVariables(long address)
Retrieve the list of variables reaching the instruction at the provided address.
Map<Integer, Set<Integer>> getUseDefChains(BasicBlock<InsnType> b, int index)
Map<Integer, Set<Long>> getUseDefChains(long address)
Retrieve the ud-chains for the instruction at the provided address.
List<Integer> getUseDiscrepancies(long address)
Retrieve the list of use-discrepancies at the provided address.
int getVariableCollectionFlags()
Retrieve the variable collection flags.
IVariableInformationProvider getVariableInformationProvider()
void invalidate()
Invalidate the analysis.
boolean isCleanCopies()
boolean isConservative()
Convenience method used to determine whether the variable collection flags are CONSERVATIVE.
boolean isIntegrateCalculatedInputRegisters()
boolean isNotRedefined(int varid, BasicBlock<InsnType> b0, int i0, BasicBlock<InsnType> b1, int i1)
Determine if a variable reaching an instruction at a start instruction has not been redefined when it reaches an final instruction.
boolean isNotRedefined(int varid, long addr0, long addr1)
Determine if a variable reaching an instruction at a start instruction has not been redefined when it reaches an final instruction.
boolean isSanitizePotentialLists()
boolean isValid()
Determine whether the current analysis was performed and is valid.
void perform()
Perform data flow analysis on the CFG.
void removeEntries(BasicBlock<InsnType> b, int index, boolean hardRemoval)
void setCleanCopies(boolean cleanCopies)
void setConservative(boolean conservative)
Convenience method used to set or remove CONSERVATIVE variable collection flags.
void setIntegrateCalculatedInputRegisters(boolean integrateCalculatedInputRegisters)
void setSanitizePotentialLists(boolean sanitizePotentialLists)
void setVariableCollectionFlags(int flags)
Set the variable collection flags.
void setVariableInformationProvider(IVariableInformationProvider varInfoProvider)
String toString()
void verifyDFA()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.IDataFlowAnalysis

Public Methods

public String formatChain (Map<Integer, Set<T>> chains)

Format a data chain as: (regId)={pos0, pos1, ...} .... The ids are naturally ordered. Positions for each id are also naturally ordered. Consequently, performing chain comparison using string comparison on the rendered chain is a viable solution.

Parameters
chains chain
Returns
  • formatted chain

public String formatStats ()

public BI<InsnType> getBlockInfo (BasicBlock<InsnType> b)

public CFG<InsnType> getCfg ()

Retrieve a reference to the CFG object that will be accessed and modified when performing an analysis.

public Map<Integer, Set<Integer>> getDefUseChains (BasicBlock<InsnType> b, int index)

public Map<Integer, Set<Long>> getDefUseChains (long address)

Retrieve the du-chains for the instruction at the provided address.

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
address instruction address; the special address -1 can be used retrieve the routine's input chains (live registers at entry)
Returns
  • a def-use chain: key= input variable id, value= list of addresses for uses

public long getExecutionTime ()

public Map<Integer, Set<Long>> getFullDefUseChains (BasicBlock<InsnType> b, int index)

public Map<Integer, Set<Long>> getFullUseDefChains (BasicBlock<InsnType> b, int index)

public Map<Integer, Set<Long>> getInputMap ()

Retrieve the du-chain of live registers at the entry block.

Data flow analysis must have been #doDataFlowAnalysis() performed else this method will throw an IllegalStateException.

Returns
  • a def-use chain: key= input variable id, value= list of addresses for uses

public Map<Integer, Set<Long>> getOutputMap ()

Retrieve a coalesced ud-chain of reaching registers for all the exit blocks of the CFG.

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Returns
  • a use-def chain: key= output variable id, value= list of addresses for definitions

public Map<Integer, Set<Long>> getOutputMap (BasicBlock<InsnType> b)

public Map<Integer, Set<Long>> getOutputMap (long lastAddress)

Retrieve the ud-chain of reaching registers for the provided exit block.

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
lastAddress address of the last instruction of the wanted output block
Returns
  • a use-def chain: key= output variable id, value= list of addresses for definitions

public Map<Integer, Set<Long>> getReachingVariables (long address)

Retrieve the list of variables reaching the instruction at the provided address.

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
address exact instruction address; the special address -1 can be used retrieve the routine's input chains (live registers at entry)
Returns
  • a map of var_ids reaching the instruction, whose values are the the lists of addresses where those vars were defined

public Map<Integer, Set<Integer>> getUseDefChains (BasicBlock<InsnType> b, int index)

public Map<Integer, Set<Long>> getUseDefChains (long address)

Retrieve the ud-chains for the instruction at the provided address.

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
address instruction address; the special address -1 can be used retrieve the routine's output chains (reaching registers at all exits)
Returns
  • a use-def chain: key= output variable id, value= list of addresses for definitions

public List<Integer> getUseDiscrepancies (long address)

Retrieve the list of use-discrepancies at the provided address.

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
address (-1L is not a valid address for this method)
Returns
  • a list of registers whose usage at the provided location appears to be incorrect

public int getVariableCollectionFlags ()

Retrieve the variable collection flags.

Returns

public IVariableInformationProvider getVariableInformationProvider ()

public void invalidate ()

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.

public boolean isCleanCopies ()

public boolean isConservative ()

Convenience method used to determine whether the variable collection flags are CONSERVATIVE.

public boolean isIntegrateCalculatedInputRegisters ()

public boolean isNotRedefined (int varid, BasicBlock<InsnType> b0, int i0, BasicBlock<InsnType> b1, int i1)

Determine if a variable reaching an instruction at a start instruction has not been redefined when it reaches an final instruction. (Note that this method does not verify that varid actually has definitions reaching the start or final instruction; it is up to the caller to verify that.)

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
varid variable id
b0 start block
i0 final block
b1 index of the start instruction in the start block, exclusive
i1 index of the final instruction in the final block, also exlusive
Returns
  • true if the variable was not redefined

public boolean isNotRedefined (int varid, long addr0, long addr1)

Determine if a variable reaching an instruction at a start instruction has not been redefined when it reaches an final instruction. (Note that this method does not verify that varid actually has definitions reaching the start or final instruction; it is up to the caller to verify that.)

Data flow analysis must have been #doDataFlowAnalysis() performed done else this method will throw an IllegalStateException.

Parameters
varid variable id
addr0 start address, exclusive
addr1 final address, also exclusive
Returns
  • true if the variable was not redefined

public boolean isSanitizePotentialLists ()

public boolean isValid ()

Determine whether the current analysis was performed and is valid.

public void perform ()

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.

public void removeEntries (BasicBlock<InsnType> b, int index, boolean hardRemoval)

public void setCleanCopies (boolean cleanCopies)

public void setConservative (boolean conservative)

Convenience method used to set or remove CONSERVATIVE variable collection flags.

public void setIntegrateCalculatedInputRegisters (boolean integrateCalculatedInputRegisters)

Parameters
integrateCalculatedInputRegisters if true, the live registers determined after analysis will be integrated in the use-def chains

public void setSanitizePotentialLists (boolean sanitizePotentialLists)

public void setVariableCollectionFlags (int flags)

Set the variable collection flags.

Parameters
flags flags, see DefUseInfo

public void setVariableInformationProvider (IVariableInformationProvider varInfoProvider)

public String toString ()

public void verifyDFA ()

Throws
IllegalStateException