Search in sources :

Example 36 with PointsToSetInternal

use of soot.jimple.spark.sets.PointsToSetInternal in project soot by Sable.

the class SootUtil method checkSetsEqual.

@SuppressWarnings("unused")
private static void checkSetsEqual(final HybridPointsToSet intersection, final PointsToSetInternal set1, final PointsToSetInternal set2, PAG pag) {
    final PointsToSetInternal ret = new HybridPointsToSet(Scene.v().getObjectType(), pag);
    set1.forall(new P2SetVisitor() {

        @Override
        public void visit(Node n) {
            if (set2.contains(n))
                ret.add(n);
        }
    });
    ret.forall(new P2SetVisitor() {

        @Override
        public void visit(Node n) {
            // TODO Auto-generated method stub
            if (!intersection.contains(n)) {
                logger.debug("" + n + " missing from intersection");
                logger.debug("" + set1);
                logger.debug("" + set2);
                logger.debug("" + intersection);
                logger.debug("" + ret);
                throw new RuntimeException("intersection too small");
            }
        }
    });
    intersection.forall(new P2SetVisitor() {

        @Override
        public void visit(Node n) {
            // TODO Auto-generated method stub
            if (!ret.contains(n)) {
                logger.debug("" + n + " missing from ret");
                logger.debug("" + set1);
                logger.debug("" + set2);
                logger.debug("" + intersection);
                logger.debug("" + ret);
                throw new RuntimeException("old way too small???");
            }
        }
    });
}
Also used : PointsToSetInternal(soot.jimple.spark.sets.PointsToSetInternal) FieldRefNode(soot.jimple.spark.pag.FieldRefNode) GlobalVarNode(soot.jimple.spark.pag.GlobalVarNode) StringConstantNode(soot.jimple.spark.pag.StringConstantNode) LocalVarNode(soot.jimple.spark.pag.LocalVarNode) Node(soot.jimple.spark.pag.Node) VarNode(soot.jimple.spark.pag.VarNode) AllocNode(soot.jimple.spark.pag.AllocNode) HybridPointsToSet(soot.jimple.spark.sets.HybridPointsToSet) P2SetVisitor(soot.jimple.spark.sets.P2SetVisitor)

Example 37 with PointsToSetInternal

use of soot.jimple.spark.sets.PointsToSetInternal 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

PointsToSetInternal (soot.jimple.spark.sets.PointsToSetInternal)37 AllocNode (soot.jimple.spark.pag.AllocNode)32 VarNode (soot.jimple.spark.pag.VarNode)28 Node (soot.jimple.spark.pag.Node)25 FieldRefNode (soot.jimple.spark.pag.FieldRefNode)22 LocalVarNode (soot.jimple.spark.pag.LocalVarNode)15 P2SetVisitor (soot.jimple.spark.sets.P2SetVisitor)15 SparkField (soot.jimple.spark.pag.SparkField)12 ClassConstantNode (soot.jimple.spark.pag.ClassConstantNode)9 GlobalVarNode (soot.jimple.spark.pag.GlobalVarNode)9 NewInstanceNode (soot.jimple.spark.pag.NewInstanceNode)9 HashSet (java.util.HashSet)8 AllocDotField (soot.jimple.spark.pag.AllocDotField)8 SootMethod (soot.SootMethod)7 AssignEdge (soot.jimple.spark.ondemand.pautil.AssignEdge)7 Type (soot.Type)5 ImmutableStack (soot.jimple.spark.ondemand.genericutil.ImmutableStack)5 Stack (soot.jimple.spark.ondemand.genericutil.Stack)5 ContextVarNode (soot.jimple.spark.pag.ContextVarNode)5 Propagator (soot.jimple.spark.ondemand.genericutil.Propagator)4