[Soot-list] Help!!! Spark: PointsToAnalysis.java
hxj
hxj163 at gmail.com
Fri Mar 2 14:21:39 EST 2012
Hi Eric,
I am learning how to use the points-to analysis of Spark now.
I am using Eclipse to set up a new project and loading the codes from
the source example.
When I ran the PointsToAnalysis.java, it throws following exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at dk.brics.paddle.PointsToAnalysis.main(PointsToAnalysis.java:43)
and I found the line 43 in PointsToAnalysis is SootClass c =
loadClass(args[1],true); And similar exceptions appear for args[0], and
args[2]. So I was wandering what are these values and how can I assign
the values for args[0], args[1] and args[2] in eclipse?
Then I found online [Soot-list] Spark Points-to analysis:
http://www.sable.mcgill.ca/pipermail/soot-list/2007-July/001354.html, I
followed the suggestion to add something in the main class in
PointsToAnalysis.java, and changed args[1] to "Test1" which is another
java file provided in the source example.
There is the modified code:
public static void main(String[] args) {
List<String> sootArgs = new LinkedList(Arrays.asList(args));
//enable whole program mode
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) {
//set the PointsToAnalysis with phase options
options.put("verbose", "true");
options.put("propagator", "worklist");
options.put("simple-edges-bidirectional", "false");
options.put("on-fly-cg", "true");
options.put("set-impl", "hybrid");
options.put("double-set-old", "hybrid");
options.put("double-set-new", "hybrid");
SparkTransformer.v().transform("",options);
}
}));
String[] argsArray = sootArgs.toArray(new String[0]);
loadClass("Item",false);
loadClass("Container",false);
SootClass c = loadClass("Test1",true);
soot.Scene.v().loadNecessaryClasses();
soot.Scene.v().setEntryPoints(EntryPoints.v().all());
// I delete them because args[0] throws exception and
setPaddlePointsToAnalysis() does not //work. Because I fail to
configurate Paddle in eclipse.
// if (args[0].equals("paddle"))
// setPaddlePointsToAnalysis();
// else if (args[0].equals("spark"))
setSparkPointsToAnalysis();
SootField f = getField("Container","item");
Map/*<Local>*/ ls = getLocals(c,args[2],"Container");
printLocalIntersects(ls);
printFieldIntersects(ls,f);
soot.Main.main(argsArray);
}
After I ran the modified code, I got:
[spark] Starting analysis ...
Total methods: 23359
Initially reachable methods: 141
Classes with at least one reachable method: 60
[Spark] Pointer Assignment Graph in 0.8 seconds.
Total types: 2963
[Spark] Type masks in 0.3 seconds.
VarNodes: 1164
FieldRefNodes: 133
AllocNodes: 491
Cleaning up graph for merged nodes
Done cleaning up graph for merged nodes
[Spark] Pointer Graph simplified in 0.0 seconds.
Worklist has 504 nodes.
Warning: Method <java.net.URL: java.net.URLStreamHandler
getURLStreamHandler(java.lang.String)> is reachable, and calls
Class.newInstance; graph will be incomplete! Use safe-newinstance option
for a conservative result.
Warning: Method <java.lang.Class: java.lang.Object newInstance0()> is
reachable, and calls Constructor.newInstance; graph will be incomplete!
Use safe-newinstance option for a conservative result.
Warning: Method <java.net.URL: java.net.URLStreamHandler
getURLStreamHandler(java.lang.String)> is reachable, and calls
Class.forName on a non-constant String; graph will be incomplete! Use
safe-forname option for a conservative
result.......................................and thousands of similar
warnings.
At last, after the warnings, I got the exception:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at
soot.toolkits.graph.PseudoTopologicalOrderer.computeOrder(PseudoTopologicalOrderer.java:79)
at
soot.toolkits.graph.PseudoTopologicalOrderer.newList(PseudoTopologicalOrderer.java:66)
at
soot.jimple.toolkits.base.Aggregator.internalAggregate(Aggregator.java:118)
at
soot.jimple.toolkits.base.Aggregator.internalTransform(Aggregator.java:95)
at soot.BodyTransformer.transform(BodyTransformer.java:51)
at soot.Transform.apply(Transform.java:104)
at soot.JimpleBodyPack.applyPhaseOptions(JimpleBodyPack.java:61)
at soot.JimpleBodyPack.internalApply(JimpleBodyPack.java:89)
at soot.Pack.apply(Pack.java:124)
at soot.coffi.CoffiMethodSource.getBody(CoffiMethodSource.java:117)
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:82)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:315)
at
soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder.processNewMethod(OnFlyCallGraphBuilder.java:526)
at
soot.jimple.toolkits.callgraph.OnFlyCallGraphBuilder.processReachables(OnFlyCallGraphBuilder.java:426)
at
soot.jimple.spark.solver.OnFlyCallGraph.build(OnFlyCallGraph.java:55)
at
soot.jimple.spark.solver.PropWorklist.handleVarNode(PropWorklist.java:123)
at
soot.jimple.spark.solver.PropWorklist.propagate(PropWorklist.java:53)
at
soot.jimple.spark.SparkTransformer.internalTransform(SparkTransformer.java:151)
at soot.SceneTransformer.transform(SceneTransformer.java:39)
at
dk.brics.paddle.PointsToAnalysis1.setSparkPointsToAnalysis(PointsToAnalysis1.java:152)
at dk.brics.paddle.PointsToAnalysis1.main(PointsToAnalysis1.java:106)
I think the exception is because I did not increase the VM memory.
In the survivor's guide: "When setting up a run configuration you should
add the following parameters to the JVM -Xmx512m -Xss256m to increase
the VM memory", but I don't know how to do it when I use the eclipse to
set up a run configuration.
So could you advice me how to increase the VM memory in eclipse?
Last, I try to delete some options to solve the memory problem.
Following is the change to the setParkPointsToAnalysis():
static void setSparkPointsToAnalysis() {
System.out.println("[spark] Starting analysis ...");
HashMap opt = new HashMap();
opt.put("enabled","true");
opt.put("verbose","true");
opt.put("ignore-types","false");
/* opt.put("force-gc","false");
opt.put("pre-jimplify","false");
opt.put("vta","false");
opt.put("rta","false");
opt.put("field-based","false");
opt.put("types-for-sites","false");
opt.put("merge-stringbuffer","true");
opt.put("string-constants","false");
opt.put("simulate-natives","true");
opt.put("simple-edges-bidirectional","false");
opt.put("on-fly-cg","true");
opt.put("simplify-offline","false");
opt.put("simplify-sccs","false");
opt.put("ignore-types-for-sccs","false");
opt.put("propagator","worklist");
opt.put("set-impl","double");
opt.put("double-set-old","hybrid");
opt.put("double-set-new","hybrid");
opt.put("dump-html","false");
opt.put("dump-pag","false");
opt.put("dump-solution","false");
opt.put("topo-sort","false");
opt.put("dump-types","true");
opt.put("class-method-var","true");
opt.put("dump-answer","false");
opt.put("add-tags","false");
opt.put("set-mass","false"); */
SparkTransformer.v().transform("",opt);
System.out.println("[spark] Done!");
}
But I got another exception when I ran it:
[spark] Starting analysis ...
Exception in thread "main" java.lang.RuntimeException: Invalid value of
phase option set-impl
at soot.options.SparkOptions.set_impl(SparkOptions.java:513)
at soot.jimple.spark.pag.PAG.<init>(PAG.java:50)
at
soot.jimple.spark.builder.ContextInsensitiveBuilder.setup(ContextInsensitiveBuilder.java:58)
at
soot.jimple.spark.SparkTransformer.internalTransform(SparkTransformer.java:82)
at soot.SceneTransformer.transform(SceneTransformer.java:39)
at
dk.brics.paddle.PointsToAnalysis1.setSparkPointsToAnalysis(PointsToAnalysis1.java:152)
at dk.brics.paddle.PointsToAnalysis1.main(PointsToAnalysis1.java:106)
And it show this statement: SparkTransformer.v().transform("",opt);
throws the exception.
So now I am very confused and exhausted to run this analysis.
Could you help me solve these problems? Or provide a complete example
for the PointsToAnalysis.java, and suggest me how to increase the memory
in Eclipse?
Thanks very much and Best regards,
Eve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120302/e23e1f9d/attachment.html
More information about the Soot-list
mailing list