[Soot-list] Create CFG problem

Gias Uddin gias98 at gmail.com
Mon Aug 26 18:09:42 EDT 2013


I am trying to create Call Graph of a given method (code below).

I get error:
-------------------------
[Call Graph] For information on where the call graph may be
incomplete, use the verbose option to the cg phase.
Exception in thread "main" java.lang.RuntimeException: This operation
requires resolving level BODIES but java.lang.Object is at resolving
level SIGNATURES
If you are extending Soot, try to add the following call before
calling soot.Main.main(..):
Scene.v().addBasicClass(java.lang.Object,BODIES);
Otherwise, try whole-program mode (-w).
...

My code:
---------------------------
public void createCallGraph(String className, String methodName)
{
Scene scene = Scene.v();
String classPaths = "/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:"
+"/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:"
+ "/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:"
+ "/temp/jars/joda-time-2.3.jar";
scene.setSootClassPath(classPaths);
SootClass sootClass = scene.loadClassAndSupport(className);
//sootClass.setLibraryClass();
scene.loadBasicClasses();
scene.loadNecessaryClasses();
soot.options.Options.v().set_whole_program(true);

Scene.v().setEntryPoints(sootClass.getMethods());
HashMap<String,String> sparkOptions = new HashMap<String,String>();
sparkOptions.put("enabled", "true");
sparkOptions.put("on-fly-cg", "true");
sparkOptions.put("set-impl", "hybrid");
sparkOptions.put("propagator", "worklist");
sparkOptions.put("verbose", "true");
SparkTransformer.v().transform("cg", sparkOptions);

SootMethod sMethod = sootClass.getMethod(methodName);
CallGraph callGraph = scene.getCallGraph();
Iterator iter = callGraph.edgesOutOf((MethodOrMethodContext)sMethod);

while (iter.hasNext()) {
System.out.println(iter.next());
}
}

public static void main(String[] args)
{
String className = "org.joda.time.chrono.CopticChronology";
String methodName = "public int getMinimumDaysInFirstWeek()";
MethodCallGraph methodCallGraph = new MethodCallGraph();
methodCallGraph.createCallGraph(className, methodName);
}

Am I doing anything wrong?

-Gias


More information about the Soot-list mailing list