[Soot-list] Re: Regd call graph - soot
Ondrej Lhotak
olhotak at sable.mcgill.ca
Sat Oct 16 20:42:35 EDT 2004
I use the attached code to produce a dump of a Soot call graph. It takes
Soot parameters on the command line. In particular, -w is required to
put Soot into whole-program mode so it constructs a call graph, and so
it even runs this phase.
Ondrej
On Sat, Oct 16, 2004 at 05:09:19AM -0700, keerthana m wrote:
> Sir,
>
> I want to construct the call graph for a sample java program. I am unable
> to do so because I am not findiong a way to create the Soot Methods. Can
> you please give me a sample program which will be generating a call graph
> for a sample program, and retrieve the graph for specific method.
>
> Thanks in anticipation
> Keerthana
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
-------------- next part --------------
package olhotak;
import soot.*;
import java.util.*;
import java.io.*;
import soot.jimple.*;
import soot.util.queue.*;
import soot.jimple.toolkits.callgraph.*;
public class CallGraphDumper extends SceneTransformer {
public static void main(String[] args)
{
PackManager.v().getPack("wjtp").add(
new Transform("wjtp.dumpcg", new CallGraphDumper()));
soot.Main.main(args);
}
protected void internalTransform(String phaseName, Map options)
{
CallGraph cg = Scene.v().getCallGraph();
Iterator it = cg.listener();
while( it.hasNext() ) {
soot.jimple.toolkits.callgraph.Edge e =
(soot.jimple.toolkits.callgraph.Edge) it.next();
System.out.println(""+e.src()+e.srcStmt()+" ="+e.kind()+"=> "+e.tgt());
}
}
}
More information about the Soot-list
mailing list