use of soot.jimple.spark.pag.AllocDotField in project soot by Sable.
the class PropWorklist method handleVarNode.
/**
* Propagates new points-to information of node src to all its successors.
*/
protected final boolean handleVarNode(final VarNode src) {
boolean ret = false;
boolean flush = true;
if (src.getReplacement() != src)
throw new RuntimeException("Got bad node " + src + " with rep " + src.getReplacement());
final PointsToSetInternal newP2Set = src.getP2Set().getNewSet();
if (newP2Set.isEmpty())
return false;
if (ofcg != null) {
QueueReader<Node> addedEdges = pag.edgeReader();
ofcg.updatedNode(src);
ofcg.build();
while (addedEdges.hasNext()) {
Node addedSrc = (Node) addedEdges.next();
Node addedTgt = (Node) addedEdges.next();
ret = true;
if (addedSrc instanceof VarNode) {
VarNode edgeSrc = (VarNode) addedSrc.getReplacement();
if (addedTgt instanceof VarNode) {
VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
if (edgeTgt.makeP2Set().addAll(edgeSrc.getP2Set(), null)) {
varNodeWorkList.add(edgeTgt);
if (edgeTgt == src)
flush = false;
}
} else if (addedTgt instanceof NewInstanceNode) {
NewInstanceNode edgeTgt = (NewInstanceNode) addedTgt.getReplacement();
if (edgeTgt.makeP2Set().addAll(edgeSrc.getP2Set(), null)) {
for (Node element : pag.assignInstanceLookup(edgeTgt)) {
varNodeWorkList.add((VarNode) element);
if (element == src)
flush = false;
}
}
}
} else if (addedSrc instanceof AllocNode) {
VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
if (edgeTgt.makeP2Set().add(addedSrc)) {
varNodeWorkList.add(edgeTgt);
if (edgeTgt == src)
flush = false;
}
} else if (addedSrc instanceof NewInstanceNode && addedTgt instanceof VarNode) {
final NewInstanceNode edgeSrc = (NewInstanceNode) addedSrc.getReplacement();
final VarNode edgeTgt = (VarNode) addedTgt.getReplacement();
addedSrc.getP2Set().forall(new P2SetVisitor() {
@Override
public void visit(Node n) {
if (n instanceof ClassConstantNode) {
ClassConstantNode ccn = (ClassConstantNode) n;
Type ccnType = ccn.getClassConstant().toSootType();
// If the referenced class has not been loaded,
// we do this now
SootClass targetClass = ((RefType) ccnType).getSootClass();
if (targetClass.resolvingLevel() == SootClass.DANGLING)
Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES);
// We can only create alloc nodes for types that
// we know
edgeTgt.makeP2Set().add(pag.makeAllocNode(edgeSrc.getValue(), ccnType, ccn.getMethod()));
varNodeWorkList.add(edgeTgt);
}
}
});
if (edgeTgt.makeP2Set().add(addedSrc)) {
if (edgeTgt == src)
flush = false;
}
}
}
}
Node[] simpleTargets = pag.simpleLookup(src);
for (Node element : simpleTargets) {
if (element.makeP2Set().addAll(newP2Set, null)) {
varNodeWorkList.add((VarNode) element);
if (element == src)
flush = false;
ret = true;
}
}
Node[] storeTargets = pag.storeLookup(src);
for (Node element : storeTargets) {
final FieldRefNode fr = (FieldRefNode) element;
final SparkField f = fr.getField();
ret = fr.getBase().getP2Set().forall(new P2SetVisitor() {
public final void visit(Node n) {
AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, f);
if (nDotF.makeP2Set().addAll(newP2Set, null)) {
returnValue = true;
}
}
}) | ret;
}
final HashSet<Node[]> storesToPropagate = new HashSet<Node[]>();
final HashSet<Node[]> loadsToPropagate = new HashSet<Node[]>();
for (final FieldRefNode fr : src.getAllFieldRefs()) {
final SparkField field = fr.getField();
final Node[] storeSources = pag.storeInvLookup(fr);
if (storeSources.length > 0) {
newP2Set.forall(new P2SetVisitor() {
public final void visit(Node n) {
AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, field);
for (Node element : storeSources) {
Node[] pair = { element, nDotF.getReplacement() };
storesToPropagate.add(pair);
}
}
});
}
final Node[] loadTargets = pag.loadLookup(fr);
if (loadTargets.length > 0) {
newP2Set.forall(new P2SetVisitor() {
public final void visit(Node n) {
AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, field);
if (nDotF != null) {
for (Node element : loadTargets) {
Node[] pair = { nDotF.getReplacement(), element };
loadsToPropagate.add(pair);
}
}
}
});
}
}
if (flush)
src.getP2Set().flushNew();
for (Node[] p : storesToPropagate) {
VarNode storeSource = (VarNode) p[0];
AllocDotField nDotF = (AllocDotField) p[1];
if (nDotF.makeP2Set().addAll(storeSource.getP2Set(), null)) {
ret = true;
}
}
for (Node[] p : loadsToPropagate) {
AllocDotField nDotF = (AllocDotField) p[0];
VarNode loadTarget = (VarNode) p[1];
if (loadTarget.makeP2Set().addAll(nDotF.getP2Set(), null)) {
varNodeWorkList.add(loadTarget);
ret = true;
}
}
return ret;
}
use of soot.jimple.spark.pag.AllocDotField in project soot by Sable.
the class PropIter method handleStores.
protected final boolean handleStores(VarNode src) {
boolean ret = false;
final PointsToSetInternal srcSet = src.getP2Set();
if (srcSet.isEmpty())
return false;
Node[] storeTargets = pag.storeLookup(src);
for (Node element : storeTargets) {
final FieldRefNode fr = (FieldRefNode) element;
final SparkField f = fr.getField();
ret = fr.getBase().getP2Set().forall(new P2SetVisitor() {
public final void visit(Node n) {
AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, f);
if (nDotF.makeP2Set().addAll(srcSet, null)) {
returnValue = true;
}
}
}) | ret;
}
return ret;
}
use of soot.jimple.spark.pag.AllocDotField in project soot by Sable.
the class PropIter method handleLoads.
protected final boolean handleLoads(FieldRefNode src) {
boolean ret = false;
final Node[] loadTargets = pag.loadLookup(src);
final SparkField f = src.getField();
ret = src.getBase().getP2Set().forall(new P2SetVisitor() {
public final void visit(Node n) {
AllocDotField nDotF = ((AllocNode) n).dot(f);
if (nDotF == null)
return;
PointsToSetInternal set = nDotF.getP2Set();
if (set.isEmpty())
return;
for (Node element : loadTargets) {
VarNode target = (VarNode) element;
if (target.makeP2Set().addAll(set, null)) {
returnValue = true;
}
}
}
}) | ret;
return ret;
}
use of soot.jimple.spark.pag.AllocDotField in project soot by Sable.
the class PropWorklist method handleFieldRefNode.
/**
* Propagates new points-to information of node src to all its successors.
*/
protected final void handleFieldRefNode(FieldRefNode src, final HashSet<Object[]> edgesToPropagate) {
final Node[] loadTargets = pag.loadLookup(src);
if (loadTargets.length == 0)
return;
final SparkField field = src.getField();
src.getBase().getP2Set().forall(new P2SetVisitor() {
public final void visit(Node n) {
AllocDotField nDotF = pag.makeAllocDotField((AllocNode) n, field);
if (nDotF != null) {
PointsToSetInternal p2Set = nDotF.getP2Set();
if (!p2Set.getNewSet().isEmpty()) {
for (Node element : loadTargets) {
Object[] pair = { p2Set, element };
edgesToPropagate.add(pair);
}
}
}
}
});
}
use of soot.jimple.spark.pag.AllocDotField in project soot by Sable.
the class GeomPointsTo method reachingObjects.
// An extra query interfaces not provided by SPARK
public PointsToSet reachingObjects(AllocNode an, SootField f) {
AllocDotField adf = an.dot(f);
IVarAbstraction pn = consG.get(adf);
// No such pointer seen by SPARK
if (adf == null)
return EmptyPointsToSet.v();
// Not seen by geomPTA
if (pn == null)
return adf.getP2Set();
if (hasTransformed || adf.getP2Set() != EmptyPointsToSet.v())
return adf.getP2Set();
// We transform and cache the result for the next query
pn = pn.getRepresentative();
PointsToSetInternal ptSet = adf.makeP2Set();
for (AllocNode obj : pn.getRepresentative().get_all_points_to_objects()) {
ptSet.add(obj);
}
return ptSet;
}
Aggregations