[Soot-list] Type inference in Soot for Java polymorphism?
Yi Lin
qinsoon at gmail.com
Tue Jan 22 03:05:55 EST 2013
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
> <mailto: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 <mailto: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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130122/377960fc/attachment-0001.html
More information about the Soot-list
mailing list