[Soot-list] Cannot reach transitive methods in Call Graph

John Dee jdsoot at hotmail.com
Wed Jul 27 08:50:22 EDT 2011


Hi there.
I the following 2 classes, which will be used for generating a call graph.
public class CallGraphs{	public static void main(String[] args) {		doStuff();	}		@Criteria(profile = "med")	public static void doStuff() {		StringBuilder b = new StringBuilder("Blah");		b.append(" Blah");		new A().foo();	}}
class A{
	public void foo() {		bar();	}		public void bar() {	}}
My call graph code looks like
public class CallGraphExample{		public static void main(String[] args) {		// create a list from args	   List<String> argsList = new ArrayList<String>(Arrays.asList(args));	   	   // add on the following arguments	   argsList.addAll(Arrays.asList(new String[]{			   "-w",			   "-main-class",			   "testers.CallGraphs",			   "testers.CallGraphs",//argument classes			   "testers.A"				   	   }));	   	   // PackManager manages the packs containing the various phases and their options	   PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new SceneTransformer() {		@Override		protected void internalTransform(String phaseName, Map options) {		       CHATransformer.v().transform();               SootClass a = Scene.v().getSootClass("testers.CallGraphs");
		       SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");		       CallGraph cg = Scene.v().getCallGraph();				       Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));		       while (targets.hasNext()) {		           SootMethod tgt = (SootMethod)targets.next();		           System.out.println(src + " may call " + tgt);		       }		       ReachableMethods reachableMethods = new ReachableMethods(cg, targets);		       QueueReader<MethodOrMethodContext> transitiveMethods = 		    	   reachableMethods.listener();		       reachableMethods.update();		       System.out.println("Num transitive methods " + reachableMethods.size());		       while (transitiveMethods.hasNext()) {		    	   System.out.println(src + " may reach " + ((SootMethod)transitiveMethods.next()).getName());		       }		}	   }));           args = argsList.toArray(new String[0]);           soot.Main.main(args);	}}
The issue is that I can only see the reachable methods based on the edges out of method 'doStuff' in class 'CallGraphs'.I can't see the methods that are reachable transitively, which would be method 'bar' in class A. I have added in a 'ReachableMethods'instance based on the call graph and edges from method 'doStuff'. I then create a QueueReader based on the reachable methods.However, the queue is empty and also, when I print out 'reachableMethods.size()', it is 0 for some reason. Any ideas why?
ThanksJD
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20110727/40a3c52c/attachment.html 


More information about the Soot-list mailing list