[Soot-list] custom entry points on a CallGraph
Moritz Tiedje
moritztiedje at gmail.com
Wed Feb 5 05:37:06 EST 2014
Hello,
I need a complete callGraph of all the method calls in a library. The
problem is, that upon calling soot.Main.main(), a main Method in the
library to analyse is searched, found and used to derive a very incomplete
call path. Using the following piece of code, I can overwrite this
incomplete CallGraph with the complete CallGraph that I need:
ArrayList<SootMethod> entryPoints = new ArrayList<SootMethod>();
for (SootClass currentClass : Scene.v().getClasses())
for (SootMethod method : currentClass.getMethods())
if(method.hasActiveBody())
entryPoints.add(method);
Scene.v().setEntryPoints(entryPoints);
CHATransformer.v().transform();
Here, I set every single method that has an active Body as an entry Point
for the call graph and proceed to calculating it.
Could you help me find a way calculate the CallGraph only once? So far I
have looked for ways to either suppress the calculation of the callGraph in
soot.Main.main() or to set custom entry points for it but have been
unsuccessful. You can find an abbreviated Version of my code below:
public static void main(String[] args)
{
PackManager
.v()
.getPack("wjtp")
.add(new Transform("wjtp.permissionAnalysis",
new SceneTransformer() {
@Override
protected void internalTransform(String arg0, Map
arg1)
{
ArrayList<SootMethod> entryPoints = new
ArrayList<SootMethod>();
for (SootClass currentClass :
Scene.v().getClasses())
for (SootMethod method :
currentClass.getMethods())
if(method.hasActiveBody())
entryPoints.add(method);
Scene.v().setEntryPoints(entryPoints);
CHATransformer.v().transform();
//customAnalysis is an instance of a class that
implements CallGraphAnalysis
customAnalysis.performAnalysis(Scene.v().getCallGraph())
}
}));
//createDefaultArgs is defined below
ArrayList<String> argList = createDefaultArgs(args);
soot.Main.main(argList.toArray(new String[0]))
}
private static ArrayList<String> createDefaultArgs(String[] args) {
ArrayList<String> argList = new ArrayList<String>(Arrays.asList(args));
argList.add("-no-bodies-for-excluded");
argList.add("-allow-phantom-refs");
argList.add("-w");
argList.add("-f");
argList.add("none");
argList.add("-pp");
argList.add("-p");
argList.add("jb");
argList.add("use-original-names:true");
argList.add("-p");
argList.add("cg.spark");
argList.add("enabled:true");
argList.add("-p");
argList.add("cg.spark");
argList.add("pre-jimplify"); argList.add("-cp");
//LIBRARY_JAR is a String that contains the path to the library we
wish to analyze
argList.add(fileToItsPath(LIBRARY_JAR));
argList.add("-process-path");
argList.add(LIBRARY_JAR);
return argList;
}
Thank you for your time, Moritz Tiedje
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20140205/aabce167/attachment.html
More information about the Soot-list
mailing list