[Soot-list] Why Spark can't obtain the call graph on this snippet? But CHA can work.
liuyuan at fastmail.com
liuyuan at fastmail.com
Thu Jun 18 18:16:50 EDT 2020
Hi all,
I customizd an entry point for a library (i.e. JCommander, a command interface tool for java) and used the Spark to build its CG. But The callgraph is empty. If I use the CHA, it works.
The code snippet is as follows and the parseWithoutValidation is selected as the entry point.
public void parseWithoutValidation(String... args) { // the customized entry point
parse(false /* no validation */, args); // I think this method could be found easily by Spark~
}
private void parse(boolean validate, String... args) {
StringBuilder sb = new StringBuilder("Parsing \"");
sb.append(join(args).append("\"\n with:").append(join(objects.toArray())));
p(sb.toString());
if (descriptions == null) createDescriptions();
initializeDefaultValues();
parseValues(expandArgs(args), validate);
if (validate) validateOptions();
}
private StringBuilder join(Object[] args) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < args.length; i++) {
if (i > 0) result.append(" ");
result.append(args[i]);
}
return result;
}
...
My core code is as follows.
Options.v().set_process_dir(Arrays.asList(classesDir));
Options.v().set_whole_program(true);
Options.v().set_no_bodies_for_excluded(true);
Options.v().set_allow_phantom_refs(true);
// set an entry point
SootClass c = Scene.v().forceResolve(entryClass, SootClass.BODIES);
c.setApplicationClass();
Scene.v().loadNecessaryClasses();
SootMethod method = c.getMethodByName(entryMethod);
List entryPoints = new ArrayList();
entryPoints.add(method);
Scene.v().setEntryPoints(entryPoints);
//set Spark
HashMap<String, String> opt = new HashMap<String, String>();
opt.put("on-fly-cg", "true");
SparkTransformer.v().transform("", opt);
PhaseOptions.v().setPhaseOption("cg.spark", "enabled:true");
PackManager.v().runPacks();
The target java file is attached.
Any suggestions are welcome.
Best regards,
Yuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20200618/dc0b004b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JCommander.java
Type: application/octet-stream
Size: 61687 bytes
Desc: not available
URL: <https://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20200618/dc0b004b/attachment-0001.obj>
More information about the Soot-list
mailing list