java.lang.Object | |
↳ | com.pnfsoftware.jeb.core.units.code.DFA4<InsnType extends com.pnfsoftware.jeb.core.units.code.IInstruction> |
Lean Data Flow Analysis (DFA) object implementation.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | CACHE_DUI | Cache basic def/use information at the instruction level | |||||||||
int | CACHE_DUI_UDC_DUC | CACHE_DUI + cache standard ud-chains and du-chains |
|||||||||
int | CACHE_NONE | Nothing is cached |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.pnfsoftware.jeb.core.units.code.IDFA
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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.
| |||||||||||
DFA4(IControlFlowGraph<InsnType, ? extends IBasicBlock<InsnType>> cfg, int collectionFlags, int cacheConfig)
Create a DFA object.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
boolean | checkInput(int varid) | ||||||||||
Collection<Long> | checkInputWithUses(int varid) | ||||||||||
int |
checkNoUse(long insnAddress, int varId, boolean reachOutIsUse, int maxBlocks)
Check whether a variable, defined at the provided instruction, is not used.
| ||||||||||
boolean |
checkNoUse(long addr, int varid)
Check whether a variable, defined at the provided instruction, is not used.
| ||||||||||
boolean |
checkNoUse(long insnAddress, int varId, boolean reachOutIsUse)
Check whether a variable, defined at the provided instruction, is not used.
| ||||||||||
boolean | checkOutput(int varid) | ||||||||||
boolean | checkOutput(IBasicBlock<InsnType> blk, int varid) | ||||||||||
Collection<Long> | checkOutputsWithDefs(int varid) | ||||||||||
Collection<Long> | checkOutputsWithDefs(IBasicBlock<InsnType> blk, int varid) | ||||||||||
Long |
checkSingleDef(long addr, int varid)
Check whether a used variable has a single definition point.
| ||||||||||
Long |
checkSingleDef(long addr, int varid, boolean liveInIsDef)
Check whether a used variable has a single explicit definition point (i.e.
| ||||||||||
Long |
checkSingleDefNoInput(long addr, int varid)
Check whether a used variable has a single explicit definition point.
| ||||||||||
Long | checkSingleSource(long addr, int varid, boolean liveInIsDef) | ||||||||||
Long | checkSingleSource(long addr, int varid) | ||||||||||
Long | checkSingleUse(long addr, int varid) | ||||||||||
Long | checkSingleUse(long addr, int varid, boolean reachOutIsUse) | ||||||||||
void | collectInstructionAllDefs(long addr, Collection<Integer> r) | ||||||||||
void | collectInstructionAllUses(long addr, Collection<Integer> r) | ||||||||||
Collection<Integer> | filterInputs(Collection<Integer> varids) | ||||||||||
Map<Integer, Collection<Long>> | filterInputsWithUses(Collection<Integer> varids) | ||||||||||
Collection<Integer> | filterOutputs(IBasicBlock<InsnType> blk, Collection<Integer> varids) | ||||||||||
Collection<Integer> | filterOutputs(Collection<Integer> varids) | ||||||||||
Map<Integer, Collection<Long>> | filterOutputsWithDefs(Collection<Integer> varids) | ||||||||||
Map<Integer, Collection<Long>> | filterOutputsWithDefs(IBasicBlock<InsnType> blk, Collection<Integer> varids) | ||||||||||
String | formatDUI(DUI o) | ||||||||||
Collection<Long> | getBlockDefUses(long addr, int varid) | ||||||||||
int |
getCacheConfiguration()
Retrieve the cache configuration.
| ||||||||||
IControlFlowGraph<InsnType, IBasicBlock<InsnType>> |
getCfg()
Retrieve a reference to the CFG object that will be accessed and modified when performing an
analysis.
| ||||||||||
DUI | getDUI(AddressableInstruction<InsnType> a) | ||||||||||
DUI | getDUI(long addr) | ||||||||||
DUI | getDUI(long addr, InsnType insn) | ||||||||||
Map<Integer, Collection<Long>> | getDefUseChains(long addr, boolean recordReachOut) | ||||||||||
Map<Integer, Collection<Long>> | getDefUseChains(long addr) | ||||||||||
Collection<Long> | getDefUses(long addr, int varid, int stopCount, boolean recordReachOut) | ||||||||||
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.
| ||||||||||
Collection<Long> | getDefUses(long addr, int varid, int stopCount) | ||||||||||
Collection<Long> | getDefUses(long addr, int varid) | ||||||||||
Collection<Long> | getInputMap(int varid) | ||||||||||
Map<Integer, Collection<Long>> | getInputMap() | ||||||||||
Collection<Integer> | getInputs() | ||||||||||
Map<Integer, Collection<Long>> | getInputsWithUses() | ||||||||||
Set<Integer> | getInstructionAllDefs(long addr) | ||||||||||
Set<Integer> | getInstructionAllUses(long addr) | ||||||||||
Set<Integer> | getInstructionDefs(long addr) | ||||||||||
Set<Integer> | getInstructionPotentialDefs(long addr) | ||||||||||
Set<Integer> | getInstructionPotentialUses(long addr) | ||||||||||
Set<Integer> | getInstructionSpoiledDefs(long addr) | ||||||||||
Set<Integer> | getInstructionUses(long addr) | ||||||||||
Map<Integer, Collection<Long>> | getLiveChains(IBasicBlock<InsnType> b, int idx) | ||||||||||
Map<Integer, Collection<Long>> | getLiveChains(IBasicBlock<InsnType> b, int idx, Collection<Integer> varids) | ||||||||||
Collection<Long> | getLiveChains(IBasicBlock<InsnType> b, int idx, int varid) | ||||||||||
int |
getMaxBlocks()
Retrieve the maximum block count used for common DFA operations.
| ||||||||||
Map<Integer, Collection<Long>> | getOutputMap() | ||||||||||
Collection<Long> | getOutputMap(IBasicBlock<InsnType> blk, int varid) | ||||||||||
Collection<Long> | getOutputMap(int varid) | ||||||||||
Map<Integer, Collection<Long>> | getOutputMap(IBasicBlock<InsnType> blk) | ||||||||||
Collection<Integer> | getOutputs(IBasicBlock<InsnType> blk) | ||||||||||
Collection<Integer> | getOutputs() | ||||||||||
Map<Integer, Collection<Long>> | getOutputsWithDefs() | ||||||||||
Map<Integer, Collection<Long>> | getOutputsWithDefs(IBasicBlock<InsnType> blk) | ||||||||||
Map<Integer, Collection<Long>> | getReachChains(IBasicBlock<InsnType> b, int idx, Collection<Integer> varids) | ||||||||||
Collection<Long> | getReachChains(IBasicBlock<InsnType> b, int idx, int varid) | ||||||||||
Map<Integer, Collection<Long>> | getReachChains(IBasicBlock<InsnType> b, int idx) | ||||||||||
Map<Integer, Collection<Long>> | getUseDefChains(long addr) | ||||||||||
Map<Integer, Collection<Long>> | getUseDefChains(long addr, boolean recordLiveIn) | ||||||||||
Collection<Long> | getUseDefs(long addr, int varid, int stopCount) | ||||||||||
Collection<Long> | getUseDefs(long addr, int varid) | ||||||||||
Collection<Long> |
getUseDefs(long addr, int varid, int stopcount, boolean verifyStartOnUsePoint, boolean recordLiveIn, IBasicBlock<InsnType> blkForReachChains, int idxForReachChains, boolean[] aDetectedUseDiscrepancy, boolean treatSpoiledAsDefs, int maxBlocks)
Find the list of definition points for a used variable.
| ||||||||||
Collection<Integer> |
getUseDiscrepancies(long addr)
Retrieve the list of use-discrepancies at the provided instruction address.
| ||||||||||
int |
getVariableCollectionFlags()
Retrieve the variable collection flags.
| ||||||||||
ICFGOwnerContext | getVariableInformationProvider() | ||||||||||
void |
invalidate()
Invalidate the analysis.
| ||||||||||
boolean | isAlive(IBasicBlock<InsnType> b, int idx, int varid) | ||||||||||
boolean | isAlwaysExamineIrregularFlows() | ||||||||||
boolean | isIntegrateCalculatedInputRegisters() | ||||||||||
boolean |
isNotRedefined(int varid, long addr0, long addr1)
Determine if a variable reaching a start instruction has not been redefined when it reaches a
final instruction.
| ||||||||||
boolean |
isNotRedefined(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1)
Determine if a variable reaching a start instruction has not been redefined when it reaches a
final instruction.
| ||||||||||
boolean | isReaching(IBasicBlock<InsnType> b, int idx, int varid) | ||||||||||
boolean |
isTerminator(IBasicBlock<InsnType> blk)
Determine whether the provided block is a terminator.
| ||||||||||
boolean | isUseDiscrepancy(long addr, int varid) | ||||||||||
boolean |
isValid()
Determine whether the current analysis was performed and is valid.
| ||||||||||
Boolean |
isVarReachingFromTo(int varid, IBasicBlock<InsnType> b0, int i0, IBasicBlock<InsnType> b1, int i1)
Determine if a variable used by the start instruction reaches the final instruction with the
same value.
| ||||||||||
Boolean |
isVarReachingFromTo(int varid, long addr0, long addr1)
Determine if a variable used by the start instruction reaches the final instruction with the
same value.
| ||||||||||
void | notifyInstructionUpdate(long addr) | ||||||||||
void |
perform()
Perform data flow analysis on the CFG.
| ||||||||||
void | setAlwaysExamineIrregularFlows(boolean alwaysExamineIrregularFlows) | ||||||||||
void |
setCacheConfiguration(int value)
Set or update the cache configuration of this object.
| ||||||||||
void | setIntegrateCalculatedInputRegisters(boolean integrateCalculatedInputRegisters) | ||||||||||
int |
setMaxBlocks(int maxBlocks)
Set an exploration threshold for most DFA operations.
| ||||||||||
void |
setVariableCollectionFlags(int flags)
Set the variable collection flags.
| ||||||||||
void | setVariableInformationProvider(ICFGOwnerContext varInfoProvider) | ||||||||||
String | toString() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.pnfsoftware.jeb.core.units.code.IDFA
|
Cache basic def/use information at the instruction level
CACHE_DUI
+ cache standard ud-chains and du-chains
Nothing is cached
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.
Create a DFA object. This object can be further configured by invoking its various setters.
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 |
Check whether a variable, defined at the provided instruction, is not used.
insnAddress | initial instruction address |
---|---|
varId | defined variable at the initial instruction |
Check whether a variable, defined at the provided instruction, is not used.
addr | initial instruction address |
---|---|
varid | defined variable at the initial instruction |
Check whether a variable, defined at the provided instruction, is not used.
insnAddress | initial instruction address |
---|---|
varId | defined variable at the initial instruction |
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).
addr | initial instruction address |
---|---|
varid | used variable at the initial instruction |
Check whether a used variable has a single explicit definition point (i.e. it is a non-input defined at a unique address).
addr | initial instruction address |
---|---|
varid | used variable at the initial instruction |
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).
addr | initial instruction address |
---|---|
varid | used variable at the initial instruction |
varids | optional collection of potential argument variables for which we want to verify uses; leave null to retrieve all potential arguments |
---|
Retrieve the cache configuration.
CACHE_xxx
attribute
Retrieve a reference to the CFG object that will be accessed and modified when performing an analysis.
Find the list of usage points for a defined variable.
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 |
Retrieve the maximum block count used for common DFA operations. See
setMaxBlocks(int)
for details.
Find the list of definition points for a used variable.
addr | initial instruction address |
---|---|
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 |
Retrieve the list of use-discrepancies at the provided instruction address.
addr | instruction address |
---|
Retrieve the variable collection flags.
DefUseInfo
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.
Determine if a variable reaching a start instruction has not been redefined when it reaches a 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.)
varid | variable id |
---|---|
addr0 | start address, exclusive |
addr1 | final address, also exclusive |
Determine if a variable reaching a start instruction has not been redefined when it reaches a 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.)
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 exclusive |
Determine whether the provided block is a terminator. A terminator has no output and its final instruction is a clean routine terminator.
blk | block to test |
---|
Determine whether the current analysis was performed and is valid.
Determine if a variable used by the start instruction reaches the final instruction with the same value. This method provides a must-reach result: if a multiple paths exist from start to end, where the variable reaches the end via some paths, but not on others (it is overwritten), the method returns false.
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 exclusive |
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 start to
end, where the variable reaches the end via some paths, but not on others (it is
overwritten), the method returns false.
- This method works from the start point to an end point, and provides the guarantee that the
variable was not overwritten when it reached the end-point. There is no guarantee provided at
the end-point itself.
varid | variable id |
---|---|
addr0 | start address, exclusive |
addr1 | final address, also exclusive |
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.
Set or update the cache configuration of this object.
value | one of CACHE_xxx attribute
|
---|
integrateCalculatedInputRegisters | if true, the live registers determined after analysis will be integrated in the use-def chains |
---|
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.
maxBlocks | -1 means no limit |
---|
Set the variable collection flags.
flags | flags, see DefUseInfo
|
---|