forked from kadirayk/SparseIDEClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
497 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/analysis/edgefunctions/CPANormalEdgeFunctionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package analysis.edgefunctions; | ||
|
||
import analysis.data.DFF; | ||
import analysis.edgefunctions.normal.IntegerAssign; | ||
import analysis.edgefunctions.normal.IntegerBinop; | ||
import heros.EdgeFunction; | ||
import heros.edgefunc.AllBottom; | ||
import heros.edgefunc.EdgeIdentity; | ||
import soot.Unit; | ||
import soot.Value; | ||
import soot.jimple.BinopExpr; | ||
import soot.jimple.DefinitionStmt; | ||
import soot.jimple.IntConstant; | ||
|
||
public class CPANormalEdgeFunctionProvider { | ||
|
||
private final static EdgeFunction<Integer> ALL_BOTTOM = new AllBottom<>(Integer.MAX_VALUE); | ||
|
||
private EdgeFunction<Integer> edgeFunction; | ||
|
||
public CPANormalEdgeFunctionProvider(Unit src, DFF srcNode, DFF tgtNode, DFF zeroValue){ | ||
edgeFunction = EdgeIdentity.v(); | ||
if (srcNode == zeroValue && tgtNode == zeroValue) { | ||
edgeFunction = ALL_BOTTOM; | ||
} else if (src instanceof DefinitionStmt) { | ||
DefinitionStmt assignment = (DefinitionStmt) src; | ||
Value lhs = assignment.getLeftOp(); | ||
Value rhs = assignment.getRightOp(); | ||
if(lhs == tgtNode.getValue()){ | ||
// check if lhs is the tgtNode we are looking at and if rhs is a constant integer | ||
if (rhs instanceof IntConstant) { | ||
IntConstant iconst = (IntConstant) rhs; | ||
edgeFunction = new IntegerAssign(iconst.value); | ||
} | ||
// check if rhs is a binary expression with known values | ||
else if (rhs instanceof BinopExpr) { | ||
BinopExpr binop = (BinopExpr) rhs; | ||
edgeFunction = new IntegerBinop(binop, srcNode); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
public EdgeFunction<Integer> getEdgeFunction(){ | ||
return edgeFunction; | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...analysis/edgefunctions/IntegerAssign.java → ...s/edgefunctions/normal/IntegerAssign.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../analysis/edgefunctions/IntegerBinop.java → ...is/edgefunctions/normal/IntegerBinop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...va/analysis/edgefunctions/IntegerTop.java → ...ysis/edgefunctions/normal/IntegerTop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/analysis/flowfunctions/CPACallFlowFunctionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package analysis.flowfunctions; | ||
|
||
|
||
import analysis.data.DFF; | ||
import analysis.flowfunctions.call.CallFF; | ||
import heros.FlowFunction; | ||
import soot.Local; | ||
import soot.SootMethod; | ||
import soot.Unit; | ||
import soot.Value; | ||
import soot.jimple.InvokeExpr; | ||
import soot.jimple.Stmt; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public class CPACallFlowFunctionProvider implements FlowFunctionProvider<DFF>{ | ||
|
||
private FlowFunction<DFF> flowFunction; | ||
|
||
public CPACallFlowFunctionProvider(Unit callStmt, SootMethod dest, DFF zeroValue){ | ||
// we want to pass only the mapped parameters and effectively kill everything else. So no identity.v() | ||
Stmt s = (Stmt) callStmt; | ||
InvokeExpr ie = s.getInvokeExpr(); | ||
final List<Value> callArgs = ie.getArgs(); | ||
final List<Local> paramLocals = new ArrayList<>(callArgs.size()); | ||
for (int i = 0; i < dest.getParameterCount(); i++) { | ||
paramLocals.add(dest.getActiveBody().getParameterLocal(i)); | ||
} | ||
flowFunction = new CallFF(callArgs, dest, zeroValue, paramLocals); | ||
} | ||
|
||
public FlowFunction<DFF> getFlowFunction(){ | ||
return flowFunction; | ||
} | ||
|
||
} |
Oops, something went wrong.