Reputation: 1
I am a beginner in learning soot and I was tormented by this strange problem: I create a instance of a class and I cannot find its methodcalls.
Here is the source code that I want to analyze:
package com.example.hello;
public class TestInputMain {
public static void main(String[] args) {
Calculator calc = new Calculator(); // another class in same package, written by me.
int result = calc.add(10, 20); // I CANNOT FIND IT!!!
System.out.println("The result of adding 10 and 20 is " + result);
}
}
Here is part of soot codes that I use:
……
//SET UP CALL GRAPH
String[] sootArgs = {
"-pp",
"-process-dir", jarFilePath, //I put them in a jar. The result is same without a jar
"-allow-phantom-refs",
"-no-bodies-for-excluded",
"-whole-program",
"-verbose",
"-p", "cg.cha", "enabled:true",
"-dynamic-dir", jarFilePath,
};
Options.v().parse(sootArgs);
String sootClassPath = jarFilePath;
Options.v().set_soot_classpath(sootClassPath);
Scene.v().loadNecessaryClasses();
PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTransform", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map<String, String> options) {
CallGraph cg = Scene.v().getCallGraph();
……
//PRINT EVERY EDGE IN CALLGRAPH
CallGraph callgraph = Scene.v().getCallGraph();
Iterator<Edge> edgesdebug = callgraph.iterator();
while (edgesdebug.hasNext()) {
Edge it = edgesdebug.next();
System.out.println("??????" + it.src() + " =>> " + it.tgt());
}
The situation is, even if I print every edge in callgraph, including all kinds of lib functions, I still cannot find "add". I am crazy. I am dying.
Upvotes: 0
Views: 180
Reputation: 1393
You are using Soot incorrectly. Where did you get your code from? You are supposed to call soot.Main.main(..) after you have registered your transformer with Soot.
Upvotes: 0