[Soot-list] Trouble Implementing Interprocedural Analysis
Armand Navabi
anavabi at purdue.edu
Thu May 3 16:46:59 EDT 2007
I am trying to write a simple interprocedural analysis, but I keep
running into different issues. The analysis determines all global
accesses (read or write) for each method in the application classes. A
global access is simply a FieldRef of a class, so I look for the use of
a field ref for reads and def for writes. If there is a method call, I
go into the called method and try to determine what it reads and
writes. I am using CHATransformer to determine which methods may be called.
The analysis works fine as long as the argument class does not call a
library class. As soon as I put a System.out.println in the class, I
get the following error:
Exception in thread "main" java.lang.RuntimeException:
Aborting: can't find classfile sun.misc.Version
at soot.Scene.getSootClass(Scene.java:374)
at soot.coffi.CFG.generateJimple(CFG.java:4647)
....
My original code to get the callgraph looks like this. (The reason I
need the callgraph is because upon a method call, I want to go into that
method to see what global fields are accessed by that method).
SootClass c = Scene.v().loadClassAndSupport(args[0]);
System.out.println("first class loaded: " + c);
c.setApplicationClass();
Scene.v().setMainClass(c);
CHATransformer.v().transform();
//Build the CallGraph and run analysis
CallGraph cg = Scene.v().getCallGraph();
GlobalAccessesAnalysis an = new GlobalAccesses(cg,
GlobalAccessesAnalysis.WRITE);
I'm pretty sure that I need whole code analysis, but when I try to do
that I get another error. So, here is what I tried to do whole program
analysis:
String [] opts = {"-W", "-app", "-keep-line-number", args[0]};
System.out.println("Set options to the static main class");
Main.main(opts);
SootClass c = Scene.v().loadClassAndSupport(args[0]);
System.out.println("first class loaded: " + c);
c.setApplicationClass();
Scene.v().setMainClass(c);
CHATransformer.v().transform();
//Build the CallGraph and run analysis
CallGraph cg = Scene.v().getCallGraph();
GlobalAccessesAnalysis an = new GlobalAccesses(cg,
GlobalAccessesAnalysis.WRITE);
Then I get the following error. Plus now I get the exception below also
for analyzing applications that only call
methods inside the application (which worked before). It seems the
methods do not have active bodies. I have tried to setApplicationClass
to make them have active bodies, but that did not work either.
Exception in thread "main" java.lang.NullPointerException
at soot.SootMethod.getBodyFromMethodSource(SootMethod.java:80)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:304)
...
Any help would be greatly appreciated. I was also wondering if there
was any good examples of a simple interprocedural analyses. I've read
the survivor's guide tutorial and it was very useful in explaining
intraprocedural analysis and walked through a VeryBusyExpression analysis.
Please let me know if more code would be useful in finding the problem here.
Thanks,
Armand
More information about the Soot-list
mailing list