[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: old to new soot questions



On Wed, Aug 06, 2003 at 05:16:58PM -0500, Oksana I Tkachuk wrote:
> Ondrej,
> I am updating my tool to use the latest version of Soot. It was originally
> written on top of Soot 1.2.2 (quite old, time to catch up with you guys
> :-)
> 
> A few things came up as I was updating the code.
> I can't seem to find the equivalent for method
> 
> JimpleBody.printTo(java.io.PrintWriter out, int printBodyOptions)
>
> I used to print Jimple bodies for debugging purposes. How can I do this in
> the new Soot?

All the printing code from SootClass and Body was moved out to
soot.Printer. The method you want is:
    soot.Printer: void printTo(Body b, PrintWriter out) 

Unfortunately, as part of the refactoring, it was erroneously made private. 
It will be public in future releases of Soot. You can make it public in
your own copy of Soot, or you can print the whole class with
    void printTo(SootClass cl, PrintWriter out)
which is public.

> I used InvokeGraph to build a method call graph. I did my own call graph
> construction as I needed a customized call graph. I used methods like
> 
> 
> public void addTarget(Stmt site,
>                       SootMethod target)
> 
> 
> public void addSite(Stmt site,
>                     SootMethod container)
> 
> public java.util.List getSitesOf(SootMethod container)
> 
> public java.util.List getTargetsOf(SootMethod m)
> 
> to build and query the graph.  I was wondering what the equivalent of
> this functionality is in the new Soot and what is the best way to build a
> customized call graph on top of new Soot.

The replacement for the InvokeGraph (as well as for MethodCallGraph) is
soot.jimple.toolkits.callgraph.CallGraph. The interface is a bit
different: you don't add call sites to it; you just add call edges,
in the form of soot.jimple.toolkits.callgraph.Edge objects. Each of
these has a source method, source statement, and target method. You can
get all the Edges out of a particular source statement or source method
by calling edgesOutOf(Unit) or edgesOutOf(SootMethod). Some more
documentation about it is in the PLDI tutorial slides available with the
rest of the Soot tutorials, as well as in Javadoc comments.

Out of curiosity, how are you customizing the call graph?

Note that some of the Edge code will be changing in upcoming versions of
Soot to support context-sensitivity in the call graph. However, these
changes should be backward compatible with existing code.

Ondrej

> 
> 
> Thank you,
> Oksana.
>