[Soot-list] Spark missing prinln ?

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Tue Dec 28 06:41:50 EST 2010


Molnar,

the problem has to do with an insufficient initialization of Spark. If
in your code I change this line...

HashMap<String, String> optionsMap = new HashMap<String, String>();

to this line...

Map<String,String> optionsMap = new
HashMap<String,String>(PhaseOptions.v().getPhaseOptions("cg.spark"));

... then it works.

By the way, you can make your life a lot easier by using a
transformer, like this:

	public static void main(String[] args) {
		List<String> argsList = new LinkedList<String>(Arrays.asList(args));
		
		PackManager.v().getPack("wjtp").add(
				new Transform("wjtp.myTransform", new SceneTransformer() {

					protected void internalTransform(String phase, Map options) {
						CallGraph cg = Scene.v().getCallGraph();

						SootMethod main= Scene.v().getMainMethod();
						Iterator<MethodOrMethodContext> targets = new
Targets(cg.edgesOutOf(main));
						while (targets.hasNext()) {
							SootMethod tgt = (SootMethod) targets.next();
							System.out.println(main + " may call " + tgt);
						}
					}
					
				}));
		
		argsList.add("-w");
		
		argsList.add("-p");
		argsList.add("cg.spark");
		argsList.add("enabled");
		
				
		args = argsList.toArray(new String[0]);		
		soot.Main.main(args);
	}

Eric


--
Dr. Eric Bodden
Software Technology Group, Technische Universität Darmstadt, Germany
Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt



On 28 December 2010 12:07, Molnar Arthur <arthur486 at yahoo.com> wrote:
> Hello Eric,
> here is the driver class, and below the tested class (i'm using Sun's 1.5
> JDK btw):
> //imports here ...
> public class SPARKTest {
> public static String BASE = "c:\\Applications\\test\\";
> public static String SOOT_PATH = BASE + "jce.jar;" + BASE + "rt.jar;" + BASE
> + "test.jar";
> public static void main(String[] args) {
> Options.v().set_whole_program(true);
> Scene.v().loadBasicClasses();
> Scene.v().setSootClassPath(SOOT_PATH);
> Scene.v().setMainClass(Scene.v().loadClassAndSupport("Test"));
> Scene.v().loadNecessaryClasses();
> HashMap<String, String> optionsMap = new HashMap<String, String>();
> optionsMap.put("enabled", "true");
> optionsMap.put("verbose", "true");
> optionsMap.put("propagator", "worklist");
> optionsMap.put("simple-edges-bidirectional", "false");
> optionsMap.put("set-impl", "double");
> optionsMap.put("double-set-old", "hybrid");
> optionsMap.put("double-set-new", "hybrid");
> SparkTransformer.v().transform("", optionsMap);
> CallGraph cg = Scene.v().getCallGraph();
> SootMethod main2= Scene.v().getMainMethod();
> Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(main2));
> while (targets.hasNext()) {
> SootMethod tgt = (SootMethod) targets.next();
> System.out.println(main2 + " may call " + tgt);
> }
> }
> }
>
> Here's the tested class (it's the only class included in the test.jar file
> on the Soot classpath and is set as main class for the JAR):
> import java.io.PrintStream;
> public class Test
> {
>   public static void main(String[] args)
>   {
>     System.out.println("Test!!");
>   }
> }
> Many thanks,
> Arthur.
> ________________________________
> From: Eric Bodden <bodden at st.informatik.tu-darmstadt.de>
> To: Molnar Arthur <arthur486 at yahoo.com>
> Cc: soot-list at sable.mcgill.ca
> Sent: Tue, 28 December, 2010 12:37:30
> Subject: Re: [Soot-list] Spark missing prinln ?
>
> Molnar, could you attach the source of your driver class and the test
> class that you analyze?
>
> Often, the devil is in the details, I am afraid...
>
> Eric
> --
> Dr. Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
>
>
> On 28 December 2010 11:12, Molnar Arthur <arthur486 at yahoo.com> wrote:
>> Hello everyone,
>> I'm using Soot to get call graphs for certain programs. I recently noticed
>> that by generating the call graph using SPARK, it misses the println(...)
>> call. The program I'm analyzing is a "Hello World" type, with only:
>> "System.out.println("bla")" in the main method. However, it appears the
>> only
>> call edges coming from main are:
>> <testers.CallGraphs: void main(java.lang.String[])> may call
>> <java.lang.System: void <clinit>()>
>> <testers.CallGraphs: void main(java.lang.String[])> may call
>> <java.lang.Object: void <clinit>()>
>> As far as I know, everything is set up properly (I took guidance from the
>> Soot tutorials). Also, if I'm using the CHATransformer I get my missing
>> edge
>> and everything seems alright. Also, reflection can be ruled out as it's a
>> direct call from my main method.
>> What could be wrong here ? Many thanks,
>> Arthur.
>>
>> _______________________________________________
>> Soot-list mailing list
>> Soot-list at sable.mcgill.ca
>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>
>>
>
>


More information about the Soot-list mailing list