Search in sources :

Example 11 with CallGraph

use of soot.jimple.toolkits.callgraph.CallGraph in project soot by Sable.

the class TypeBasedReflectionModelTest method genericLocalVsStringConstantTest.

private void genericLocalVsStringConstantTest(boolean useConstantBase) {
    resetSoot();
    Options.v().set_allow_phantom_refs(true);
    Options.v().set_whole_program(true);
    Options.v().set_no_bodies_for_excluded(true);
    Scene.v().loadBasicClasses();
    SootClass tc = setUpTestClass(useConstantBase);
    Scene.v().addClass(tc);
    tc.setApplicationClass();
    Scene.v().setMainClass(tc);
    Scene.v().forceResolve(tc.getName(), BODIES);
    Scene.v().loadNecessaryClasses();
    Options.v().setPhaseOption("cg.spark", "on");
    Options.v().setPhaseOption("cg", "types-for-invoke:true");
    // this option is necessary to get constant bases working
    Options.v().setPhaseOption("wjpp.cimbt", "enabled:true");
    Options.v().setPhaseOption("wjpp.cimbt", "verbose:true");
    PackManager.v().getPack("wjpp").apply();
    PackManager.v().getPack("cg").apply();
    CallGraph callGraph = Scene.v().getCallGraph();
    boolean found = false;
    for (Edge edge : callGraph) {
        if (edge.getSrc().method().getSignature().contains("main") && edge.getTgt().method().getSignature().contains("concat")) {
            found = true;
            break;
        }
    }
    Assert.assertTrue("There should be an edge from main to String.concat after resolution of the target of Method.invoke, but none found", found);
}
Also used : CallGraph(soot.jimple.toolkits.callgraph.CallGraph) Edge(soot.jimple.toolkits.callgraph.Edge)

Aggregations

CallGraph (soot.jimple.toolkits.callgraph.CallGraph)11 SootMethod (soot.SootMethod)7 Edge (soot.jimple.toolkits.callgraph.Edge)7 Stmt (soot.jimple.Stmt)5 MethodOrMethodContext (soot.MethodOrMethodContext)3 CgEdge (soot.jimple.spark.geom.dataRep.CgEdge)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 SootClass (soot.SootClass)2 Unit (soot.Unit)2 Value (soot.Value)2 ValueBox (soot.ValueBox)2 InstanceInvokeExpr (soot.jimple.InstanceInvokeExpr)2 InvokeExpr (soot.jimple.InvokeExpr)2 PlainConstraint (soot.jimple.spark.geom.dataRep.PlainConstraint)2 LocalVarNode (soot.jimple.spark.pag.LocalVarNode)2 Targets (soot.jimple.toolkits.callgraph.Targets)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1