Search in sources :

Example 66 with AllocNode

use of soot.jimple.spark.pag.AllocNode in project soot by Sable.

the class GeomQueries method kCFA.

/**
 * Standard K-CFA querying for field expression.
 *
 * @param callEdgeChain: callEdgeChain[0] is the farthest call edge in the chain.
 * @param l
 * @param field
 * @param visitor
 * @return
 */
@SuppressWarnings("rawtypes")
public boolean kCFA(Edge[] callEdgeChain, Local l, SparkField field, PtSensVisitor visitor) {
    // We first obtain the points-to information for l
    Obj_full_extractor pts_l = new Obj_full_extractor();
    if (kCFA(callEdgeChain, l, pts_l) == false)
        return false;
    // We compute the points-to information for l.field
    visitor.prepare();
    for (IntervalContextVar icv : pts_l.outList) {
        AllocNode obj = (AllocNode) icv.var;
        AllocDotField obj_f = geomPTA.findAllocDotField(obj, field);
        if (obj_f == null)
            continue;
        IVarAbstraction objField = geomPTA.findInternalNode(obj_f);
        if (objField == null)
            continue;
        long L = icv.L;
        long R = icv.R;
        assert L < R;
        objField.get_all_context_sensitive_objects(L, R, visitor);
    }
    pts_l = null;
    visitor.finish();
    return visitor.numOfDiffObjects() != 0;
}
Also used : AllocDotField(soot.jimple.spark.pag.AllocDotField) AllocNode(soot.jimple.spark.pag.AllocNode) Obj_full_extractor(soot.jimple.spark.geom.dataMgr.Obj_full_extractor) IntervalContextVar(soot.jimple.spark.geom.dataRep.IntervalContextVar)

Example 67 with AllocNode

use of soot.jimple.spark.pag.AllocNode in project soot by Sable.

the class OnFlyCallGraph method updatedNode.

public void updatedNode(VarNode vn) {
    Object r = vn.getVariable();
    if (!(r instanceof Local))
        return;
    final Local receiver = (Local) r;
    final Context context = vn.context();
    PointsToSetInternal p2set = vn.getP2Set().getNewSet();
    if (ofcgb.wantTypes(receiver)) {
        p2set.forall(new P2SetVisitor() {

            public final void visit(Node n) {
                if (n instanceof AllocNode)
                    ofcgb.addType(receiver, context, n.getType(), (AllocNode) n);
            }
        });
    }
    if (ofcgb.wantStringConstants(receiver)) {
        p2set.forall(new P2SetVisitor() {

            public final void visit(Node n) {
                if (n instanceof StringConstantNode) {
                    String constant = ((StringConstantNode) n).getString();
                    ofcgb.addStringConstant(receiver, context, constant);
                } else {
                    ofcgb.addStringConstant(receiver, context, null);
                }
            }
        });
    }
    if (ofcgb.wantInvokeArg(receiver)) {
        p2set.forall(new P2SetVisitor() {

            @Override
            public void visit(Node n) {
                if (n instanceof AllocNode) {
                    AllocNode an = ((AllocNode) n);
                    ofcgb.addInvokeArgDotField(receiver, an.dot(ArrayElement.v()));
                    assert an.getNewExpr() instanceof NewArrayExpr;
                    NewArrayExpr nae = (NewArrayExpr) an.getNewExpr();
                    if (!(nae.getSize() instanceof IntConstant)) {
                        ofcgb.setArgArrayNonDetSize(receiver, context);
                    } else {
                        IntConstant sizeConstant = (IntConstant) nae.getSize();
                        ofcgb.addPossibleArgArraySize(receiver, sizeConstant.value, context);
                    }
                }
            }
        });
        for (Type ty : pag.reachingObjectsOfArrayElement(p2set).possibleTypes()) {
            ofcgb.addInvokeArgType(receiver, context, ty);
        }
    }
}
Also used : MethodOrMethodContext(soot.MethodOrMethodContext) Context(soot.Context) StringConstantNode(soot.jimple.spark.pag.StringConstantNode) PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) Node(soot.jimple.spark.pag.Node) StringConstantNode(soot.jimple.spark.pag.StringConstantNode) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) Local(soot.Local) Type(soot.Type) AllocNode(soot.jimple.spark.pag.AllocNode) NewArrayExpr(soot.jimple.NewArrayExpr) IntConstant(soot.jimple.IntConstant) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Aggregations

AllocNode (soot.jimple.spark.pag.AllocNode)67 Node (soot.jimple.spark.pag.Node)37 VarNode (soot.jimple.spark.pag.VarNode)36 LocalVarNode (soot.jimple.spark.pag.LocalVarNode)28 PointsToSetInternal (soot.jimple.spark.sets.PointsToSetInternal)25 FieldRefNode (soot.jimple.spark.pag.FieldRefNode)22 P2SetVisitor (soot.jimple.spark.sets.P2SetVisitor)19 PlainConstraint (soot.jimple.spark.geom.dataRep.PlainConstraint)18 SegmentNode (soot.jimple.spark.geom.dataRep.SegmentNode)18 SootMethod (soot.SootMethod)17 ClassConstantNode (soot.jimple.spark.pag.ClassConstantNode)17 SparkField (soot.jimple.spark.pag.SparkField)16 RefType (soot.RefType)14 Type (soot.Type)13 AllocDotField (soot.jimple.spark.pag.AllocDotField)13 NewInstanceNode (soot.jimple.spark.pag.NewInstanceNode)11 HashSet (java.util.HashSet)10 GlobalVarNode (soot.jimple.spark.pag.GlobalVarNode)10 StringConstantNode (soot.jimple.spark.pag.StringConstantNode)10 SootClass (soot.SootClass)9