[Soot-list] Whole program analysis

Bodden, Eric eric.bodden at sit.fraunhofer.de
Mon Feb 17 03:42:26 EST 2014


Hello.

> I am very new to using Soot. I am using Eclipse to run a simple live variables analysis using Soot on the following test program.
> 
> public class Input {
> 
> 	private Lock lock = new ReentrantLock();
> 	private int count = 0;
> 	
> 	private class Thread1 extends Thread {
> 		public void run() {
> 	            lock.lock();
> 		    count++;
> 		    lock.unlock();
> 	    }
> 	}
> 	
> 	public static void main(String[] args) {
> 		Input ip = new Input();
> 		
> 		Thread t1 = new Thread(ip.new Thread1());
>                 t1.start();
> 	}
> }
> 
> Even on using the -w option, the run() method is not reached during the analysis. How can I enable Soot to enter the run() method when t1.start() is called?

You have to enable Spark: -p cg.spark on

> Also, how can I extract the call graph for the program?
> I have tried the following for obtaining the call graph (read this in a beginner's tutorial on using Soot). But, it produces a out of memory error.
> 
> public class Livemain {
> 
> 	public static void main(String[] args) {
> 	    if(args.length == 0) System.exit(-1);
> 	    PackManager.v().getPack("wjtp").
> 	    add(new Transform("wjtp.liveVariables", new SceneTransformer() {
> 			@Override
> 			protected void internalTransform (String phaseName, Map options) {
> 		  		CallGraph cg = Scene.v().getCallGraph();
> 		  		System.out.println("call graph: " + cg);
> 		  	}
> 		}));
> 	    
> 	    soot.Main.main(args);
>         }
> }

This is the right way to do it. Just give it more memory. 512m should suffice for the little program.

Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20140217/81d74bed/attachment.bin 


More information about the Soot-list mailing list