[Soot-list] Type inference in Soot for Java polymorphism?

Richard Xiao richardxx at cse.ust.hk
Tue Jan 22 13:11:06 EST 2013


1. Use "-f" option to avoid the output. You cannot completely eliminate all
the transformations because points-to analysis depends on.

2. It's not clear from your description, maybe you can send me your code
and I will see.


On Tue, Jan 22, 2013 at 7:20 PM, Yi Lin <qinsoon at gmail.com> wrote:

>  Thank you. I removed unnecessary options.
>
> But still those problems exist.
>
> 1. Even if I only want points-to analysis result, I have to run
> soot.Main.main(), which involves other transforms and optimizations on the
> class bytecodes I feed into it. Is there a way to run the points-to
> analysis only (the class bytecode will not be transformed)?
>
> 2. Why after this Soot run (soot.Main.main()), when I tried to get any
> method body from a class I have resolved, I got null pointer exception? If
> I comment out the soot run, everything is fine.
>
> Can anyone give an idea? Thanks very much.
>
> Regards,
> Yi
>
>
> On 22/01/13 19:45 , Richard Xiao wrote:
>
> 1. Don't add a new transformer to soot. That's needed only when you write
> a new optimization or analysis pass. Here, what you need is only setting up
> the parameters and running soot.
>
>  2. Every phase option (e.g. the option for SPARK) should be preceded by
> "-p cg.spark". You don't need to repeat the default options;
>
>  3. Please specify the locations of your files that you want to analyze,
> especially the main class file, on the parameter list.
>
>
>  Try the code below:
>
> List<String> sootArgs = new ArrayList<String>();
>
>          sootArgs.add("-W");
>         sootArgs.add("-p");
>         sootArgs.add("wjop");
>         sootArgs.add("enabled:true");
>
>          //enable points-to analysis
>         sootArgs.add("-p");
>         sootArgs.add("cg");
>         sootArgs.add("enabled:true");
>
>         //enable Spark
>         sootArgs.add("-p cg.spark enabled:true");
>         sootArgs.add("-p cg.spark verbose:true");
>
>         // Specify the main class file of the program you want to analyze
>         // Here I exemplify the analysis of compress in SPECJVM benchmark
> with JDK 1.3
>
>          sootArgs.add( "-cp
> /home/xiao/workspace/SPECJVM_runnable/bin:/opt/jdk1.3.1_20/jre/lib/rt.jar
> spec.benchmarks._201_compress.Main" );
>
>         soot.Main.main(sootArgs.toArray(new String[0]));
>
>
>
>
> On Tue, Jan 22, 2013 at 4:05 PM, Yi Lin <qinsoon at gmail.com> wrote:
>
>>  Thanks very much. That is very helpful.
>>
>> I read some documents about SPARK. However I am having some problems
>> using SPARK with my code.
>>
>> 1. I used to only use Soot to resolve classes, and I didn't run any
>> transformation or optimizations by Soot. However, it seems if I want
>> points-to analysis result from SPARK, I would have to run soot.Main.main(),
>> which involves all transformations and optimizations. This not only takes a
>> quite long time, but also is undesirable. How can I very 'cleanly' get the
>> points-to analysis from SPARK? (I will attach the code I am running with at
>> the end of this email, which was found from the mail-list archives)
>>
>> 2. After I added those code to run SPARK, I am not able to retrieve any
>> method body. The pseudo-code for my program is like,
>>
>>     (1)initSootOptions();
>>     (2)resolveClassesThatINeed();
>>     (3)walkThroughThoseClasses();
>>
>> But after I add 'runSPARK()' after (1) or (2), in (3) it failed to get
>> method body.
>>
>> java.lang.NullPointerException
>>     at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:89)
>>     at soot.SootMethod.retrieveActiveBody(SootMethod.java:322)
>>
>> Sorry if those questions sound naive. I quickly went through Ondrej's
>> SPARK thesis, I got Soot survivor guide with me, I searched through mail
>> list. But I am still quite lost.
>>
>> Thank you very much.
>>
>> Regards,
>> Yi
>>
>>  the code that I am running SPARK with:
>>
>> runSPARK() {
>>         List<String> sootArgs = new ArrayList<String>();
>>         sootArgs.add("-W");
>>         sootArgs.add("-p");
>>         sootArgs.add("wjop");
>>         sootArgs.add("enabled:true");
>>
>>         //enable points-to analysis
>>         sootArgs.add("-p");
>>         sootArgs.add("cg");
>>         sootArgs.add("enabled:true");
>>
>>         //enable Spark
>>         sootArgs.add("-p");
>>         sootArgs.add("cg.spark");
>>         sootArgs.add("enabled:true");
>>
>>         PackManager.v().getPack("wjop").add(new
>> Transform("wjop.mytrans",new SceneTransformer() {
>>              protected void internalTransform(String phaseName, Map
>> options) {
>>                  System.out.println("SPARK pointer-to analysis...");
>>                  HashMap map = new HashMap(options);
>>                  //set the PointsToAnalysis with phase options
>>                  map.put("verbose", "true");
>>                  map.put("propagator", "worklist");
>>                  map.put("simple-edges-bidirectional", "false");
>>                  map.put("on-fly-cg", "true");
>>                  map.put("set-impl", "hybrid");
>>                  map.put("double-set-old", "hybrid");
>>                  map.put("double-set-new", "hybrid");
>>                  SparkTransformer.v().transform("",map);
>>              }
>>            }));
>>
>>         soot.Main.main(sootArgs.toArray(new String[0]));
>> }
>>
>>
>> On 22/01/13 16:09 , Richard Xiao wrote:
>>
>> Of course, try SPARK, the points-to analysis in soot. You will obtain a
>> list of objects "cat" can point to. Compute the lowest common ancestor of
>> the types of these pointed to objects, that's the answer.
>>
>>
>> On Tue, Jan 22, 2013 at 10:56 AM, Yi Lin <qinsoon at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> For example.
>>>
>>> For Java code,
>>>      Animal cat = new Cat();
>>>      cat.speak();
>>>
>>> Jimple code is like,
>>> Locals:
>>>      [Animal]cat
>>>      [Cat]temp$0
>>> Code:
>>>      temp$0 = new Cat
>>>      specialinvoke temp$0.<Cat: void <init>()>()
>>>      cat = temp$0
>>>      virtualinvoke cat.<Animal: void speak()>()
>>>
>>> Is it possible for Soot to tell that the variable 'cat' actually holds a
>>> 'Cat' object instead of an 'Animal'?
>>>
>>> If not, is it possible for me to implement such analysis on Soot
>>> framework (especially for inter-procedure cases)? Without using dynamic
>>> loading in the Java code, and with whole program analysis turned on in
>>> Soot, I assume it should be possible to do such type inference.
>>>
>>> Any idea would be appreciated. Thank you very much.
>>>
>>> Regards,
>>> Yi
>>> _______________________________________________
>>> Soot-list mailing list
>>> Soot-list at sable.mcgill.ca
>>> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>>>
>>
>>
>>
>> --
>> Richard Xiao Xiao
>> PhD Student @ CSE @ Hong Kong University of Science and Technology
>>  www.cse.ust.hk/~richardxx <http://www.cse.ust.hk/%7Erichardxx>
>>
>>
>>
>
>
> --
> Richard Xiao Xiao
> PhD Student @ CSE @ Hong Kong University of Science and Technology
>  www.cse.ust.hk/~richardxx <http://www.cse.ust.hk/%7Erichardxx>
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
>


-- 
Richard Xiao Xiao
PhD Student @ CSE @ Hong Kong University of Science and Technology
www.cse.ust.hk/~richardxx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130123/4a74712a/attachment.html 


More information about the Soot-list mailing list