[Soot-list] soot can not output call graph
Alexandre Bartel
alexandre.bartel at cased.de
Tue May 26 04:38:02 EDT 2015
Hi ConlyXia,
You need to create a Scene transformer and run Soot in whole-program
mode to retrieve the call graph.
See http://www.bodden.de/2008/11/26/soot-packs/
Below is a code snippet to print the methods called in the main method:
public class MyPack {
public static void main(String[] args) {
PackManager.v().getPack("wjtp").add(
new Transform("wjtp.myTransform", new SceneTransformer() {
protected void internalTransform(String phaseName,
Map options) {
System.out.println("--- start");
CallGraph cg = Scene.v().getCallGraph();
SootMethod entryPoint = Scene.v().getEntryPoints().get(0); // main by default
Iterator<Edge> it = cg.edgesOutOf(entryPoint);
while(it.hasNext()) {
Edge e = it.next();
System.out.println("edge out of main: "+ e.getTgt());
}
System.out.println("--- end");
}
}));
soot.Main.main(args);
}
}
Running the above code on the following small example
public class Main {
public static void main(String[] args) {
foo();
}
public static void foo() {
bar();
}
public static void bar() {
}
}
should give the following output:
[...]
--- start
edge out of main: <java.lang.Object: void <clinit>()>
edge out of main: <Main: void foo()>
--- end
[...]
Best Regards,
Alexandre
On Thu, 2015-05-21 at 10:01 +0800, conlyxia wrote:
> Hi List,
> I want to use soot to generate a call graph by command line.But I can
> not obtain the call graph.My command line is as follow:
> java -Xmx1g -cp soot-trunk.jar soot.Main -w -time -v -debug
> -debug-resolver -p cg
> enabled:true,verbose:true,jdkver:7,all-reachable:true,implicit-entry:false -p jb enabled:true -p wjtp enabled:true -d out1 -allow-phantom-refs -ire -src-prec java Station
> where the Station is a java file.
> I do not know how to use the method Scene.v().getCallGraph() in the
> command line.Could you help me?Thanks so much!
>
>
> Best wishes!
> ConlyXia
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
More information about the Soot-list
mailing list