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

Stefan Gommer gommeriphone at googlemail.com
Sat Jul 26 16:37:21 EDT 2014


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/20140726/1fbbc9d0/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bildschirmfoto 2014-07-26 um 22.25.41.png
Type: image/png
Size: 38101 bytes
Desc: not available
Url : http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140726/1fbbc9d0/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Bildschirmfoto 2014-07-26 um 22.26.09.png
Type: image/png
Size: 53137 bytes
Desc: not available
Url : http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140726/1fbbc9d0/attachment-0003.png 


More information about the Soot-list mailing list