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

vasrivastava@hssworld.com srivastava varun0007 at gmail.com
Wed Sep 2 12:43:16 EDT 2009


Hi Eric ,  So finally I feel following set of commands will be ideal for me
.

HashMap opt = new HashMap();
opt.put("verbose","true");
opt.put("all-reachable","true");
CHATransformer.v().transform("",opt); // This call right now throwing
exception "couldn't find method main(*)"
StaticInliner.v().trasform();

Now get each method and perform intra process Data Analysis on each method
as all the inter procedure calls are inlined.
Please let me know how to achieve this using soot.
Thanks
Varun

On Mon, Aug 31, 2009 at 4:52 AM, Eric Bodden <
bodden at st.informatik.tu-darmstadt.de> wrote:

> I agree with Khilan.
>
> There's no such thing as "a call graph for a single method" - by
> definition a call graph is a graph that connects *multiple* methods.
> So what you probably want is the whole-program call graph but
> restricted to a single method, which is what Khilan suggested. I am
> still not sure if a call graph is really what you want. Depending on
> your exact analysis goal, you could be better off with just inspecting
> the invoke expressions in each of the methods.
>
> Eric
>
> 2009/8/31 Khilan Gudka <khilan at doc.ic.ac.uk>:
> > 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>
> >
>
>
>
> --
> Eric Bodden
> Software Technology Group
> Technical University Darmstadt, Germany
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090902/8efa2531/attachment-0001.html 


More information about the Soot-list mailing list