[Soot-list] Get Callsites of each method from callgraph

Steven Arzt Steven.Arzt at cased.de
Mon Jul 28 04:26:10 EDT 2014


Hi Stefan,

 

The callgraph connects every call site with all possible callees. I
therefore do not understand why you should not be able to find out where a
method is called. You might want to look at the
JimpleBasedInterproceduralCFG class which already implements a lot of
queries on the callgraph such as getCalleesOfCallAt() and getCallersOf().

 

Best regards,

  Steven

 

Von: Stefan Gommer [mailto:gommeriphone at googlemail.com] 
Gesendet: Samstag, 26. Juli 2014 22:37
An: soot-list at CS.McGill.CA
Cc: Steven Arzt
Betreff: Get Callsites of each method from callgraph

 

Hello,

 

I'm trying to visualize something like a call graph but with grouped methods
for each component. For example instead of having a normal call graph like



 

I want to know in which component each method is called like :

 



 

But I don't know how to get the information, where a method is called. First
I tried using the call graph, traversing it by recursively looking for the
outgoing edges of each node. But it seems that for each node I can only get
the information in which class it is declared, its name, etc. but not the
call sites( where the methods are called for example "method_2 called in
Activity1: onClick()" )

 

Then, instead of using the call graph, I examined the active body of the
entry method (dummyMainMethod) and started looking for all invoke
expressions in there. Then I wanted to use each SootMethod from
InvokeExpr.getMethod() and examine the body of these methods (code below),
but unfortunately it turns out, that there is no active body for these
methods. Can anyone give me an advice how I can achieve my goal?

 

Regards, 

Stefan

 

private static void checkMethod(SootMethod m)

       {

             // don't know if used correctly

             Scene.v().forceResolve(m.getDeclaringClass().getName(),
SootClass.BODIES);

 

             try{

                    if(m.hasActiveBody()){

 

                           Body b = m.getActiveBody();

             

                           for(Unit u : b.getUnits()) {

                                  

                                  Stmt s = (Stmt)u;

                                  if(s.containsInvokeExpr()) {

                                        

                                        InvokeExpr expr = s.getInvokeExpr();

                                        

                                        System.out.println("Found invoke
expression " + expr);

                                        checkMethod(expr.getMethod());

                                  }

                           }

                    } else { System.out.println("Method " + m + " has no
active body");}

             } finally{}

       }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140728/7af8a5ba/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 38101 bytes
Desc: not available
Url : http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140728/7af8a5ba/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 53137 bytes
Desc: not available
Url : http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140728/7af8a5ba/attachment-0003.png 


More information about the Soot-list mailing list