Search in sources :

Example 46 with VarNode

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

the class SootUtil method dumpVarNodeInfo.

public static void dumpVarNodeInfo(final PAG pag) {
    PrintWriter varNodeWriter = null;
    try {
        varNodeWriter = new PrintWriter(new BufferedWriter(new FileWriter("varNodeInfo")));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    for (Iterator iter = pag.getVarNodeNumberer().iterator(); iter.hasNext(); ) {
        VarNode varNode = (VarNode) iter.next();
        varNodeWriter.println(varNode.getNumber() + " " + varNode);
    }
    varNodeWriter.flush();
    varNodeWriter.close();
}
Also used : GlobalVarNode(soot.jimple.spark.pag.GlobalVarNode) LocalVarNode(soot.jimple.spark.pag.LocalVarNode) VarNode(soot.jimple.spark.pag.VarNode) FileWriter(java.io.FileWriter) Iterator(java.util.Iterator) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter)

Example 47 with VarNode

use of soot.jimple.spark.pag.VarNode 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

VarNode (soot.jimple.spark.pag.VarNode)47 AllocNode (soot.jimple.spark.pag.AllocNode)37 Node (soot.jimple.spark.pag.Node)29 FieldRefNode (soot.jimple.spark.pag.FieldRefNode)24 LocalVarNode (soot.jimple.spark.pag.LocalVarNode)23 PointsToSetInternal (soot.jimple.spark.sets.PointsToSetInternal)22 GlobalVarNode (soot.jimple.spark.pag.GlobalVarNode)17 SparkField (soot.jimple.spark.pag.SparkField)15 HashSet (java.util.HashSet)11 NewInstanceNode (soot.jimple.spark.pag.NewInstanceNode)11 SootMethod (soot.SootMethod)10 ClassConstantNode (soot.jimple.spark.pag.ClassConstantNode)10 RefType (soot.RefType)8 Type (soot.Type)8 P2SetVisitor (soot.jimple.spark.sets.P2SetVisitor)8 AssignEdge (soot.jimple.spark.ondemand.pautil.AssignEdge)7 Iterator (java.util.Iterator)6 ImmutableStack (soot.jimple.spark.ondemand.genericutil.ImmutableStack)6 Stack (soot.jimple.spark.ondemand.genericutil.Stack)6 AllocDotField (soot.jimple.spark.pag.AllocDotField)6