[Soot-list] Trying to build call graph from with a java program

Khilan Gudka khilan at doc.ic.ac.uk
Mon Aug 31 05:22:58 EDT 2009


Hi Varun,

 From what I understand, you can get the "call graph" for a method by  
using the CallGraph.edgesOutOf(Unit) and  
CallGraph.edgesOutOf(MethodOrMethodContext) methods. These allow you  
to traverse the call graph, from a particular statement or method  
respectively. Furthermore, the class TransitiveTargets can be used to  
get all methods reachable from a method or statement. So, for what you  
are trying to do, you could potentially iterate through all the  
methods in a class using SootClass.getMethods() and then use the  
CallGraph.edgesOutOf methods or TransitiveTargets class to traverse  
the "call graph" from that specific method.

Alternatively, you could use the all-reachable:true flag to the cg  
phase (i.e. -p cg all-reachable:true). From the phase options  
documentation:

"Setting this option to true makes Soot consider all methods of  
application classes to be reachable, so call edges are generated for  
all of them."

Then you could iterate through the entry points  
(EntryPoints.v().all()) and then use the edgesOutOf methods or  
TransitiveTargets class as mentioned above).

Hope that helps

--
Khilan Gudka
PhD Student
Department of Computing
Imperial College
http://www.doc.ic.ac.uk/~khilan/

On 31 Aug 2009, at 03:38, vasrivastava at hssworld.com srivastava wrote:

> Hi Eric,
>   I want to perform some analysis on different set of classes and  
> then compare the results. The ideal thing for me to do is , create  
> some application specific datastructure for each of the sets and  
> then compare them inside my program.
>  To achieve this, on the high level I am trying to follow the given  
> algorithm
> 1) Load a class from set A into soot using loadandsupport api
> 2) Perform interprocess data flow analysis for each of the methods  
> individually
> 3) Perform same operation for a class of set B
> 4) Compare results of set A and set B and then print out final  
> results.
>
> Now for this analysis I need to analyse all the public methods  
> individually in interprocedural fashion [ as all the public methods  
> can be called by any application outside the class]
>   But right now I am not able to construct a call graph for each  
> method individually, so that i can run my inter procedural dataflow  
> analysis on that call graph.
>  Please suggest me the right way to do this , as I guess I am on the  
> wrong way :(.
> Thanks
> Varun
>
>
> On Sun, Aug 30, 2009 at 2:36 AM, Eric Bodden <bodden at st.informatik.tu-darmstadt.de 
> > wrote:
> Hi.
>
> >  I am trying to build call graph for a class from a java program.  
> I need to
> > take each method the class and build a call graph as if that  
> method is the
> > main method. I haven't got any way of declaring any arbitrary  
> method as
> > reachableMethod and continue call graph construction.
>
> From what you write, it seems like you would want to play around with
> the class EntryPoints. I don't understand why you are adding "main"
> methods to every class. How would that solve your problem? What
> exactly is the problem that your analysis should solve anyway?
>
> Eric
>
> --
> Eric Bodden
> Software Technology Group
> Technical University Darmstadt, Germany
>
> <ATT00002.txt>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090831/471672c4/attachment.html 


More information about the Soot-list mailing list