add utility methods for creating n-CFA call graph builders
This commit is contained in:
parent
89e90cd44e
commit
16a0e02fa0
@ -58,6 +58,7 @@ public class ScopeFileCallGraph {
|
||||
*/
|
||||
public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException,
|
||||
CallGraphBuilderCancelException {
|
||||
long start = System.currentTimeMillis();
|
||||
Properties p = CommandLine.parse(args);
|
||||
String scopeFile = p.getProperty("scopeFile");
|
||||
String entryClass = p.getProperty("entryClass");
|
||||
@ -76,13 +77,17 @@ public class ScopeFileCallGraph {
|
||||
Iterable<Entrypoint> entrypoints = entryClass != null ? makePublicEntrypoints(scope, cha, entryClass) : Util.makeMainEntrypoints(scope, cha, mainClass);
|
||||
options.setEntrypoints(entrypoints);
|
||||
// you can dial down reflection handling if you like
|
||||
// options.setReflectionOptions(ReflectionOptions.NONE);
|
||||
// options.setReflectionOptions(ReflectionOptions.NONE);
|
||||
AnalysisCache cache = new AnalysisCache();
|
||||
// other builders can be constructed with different Util methods
|
||||
CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
|
||||
// CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
|
||||
// CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
|
||||
System.out.println("building call graph...");
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("done");
|
||||
System.out.println("took " + (end-start) + "ms");
|
||||
System.out.println(CallGraphStats.getStats(cg));
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXCFABuilder;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXContainerCFABuilder;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ZeroXInstanceKeys;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.nCFABuilder;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.rta.BasicRTABuilder;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ipa.summaries.BypassClassTargetSelector;
|
||||
@ -429,6 +430,50 @@ public class Util {
|
||||
return new ZeroXContainerCFABuilder(cha, options, cache, appSelector, appInterpreter, ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS
|
||||
| ZeroXInstanceKeys.SMUSH_STRINGS | ZeroXInstanceKeys.SMUSH_THROWABLES);
|
||||
}
|
||||
|
||||
/**
|
||||
* make a {@link CallGraphBuilder} that uses call-string context sensitivity,
|
||||
* with call-string length limited to n, and a context-sensitive
|
||||
* allocation-site-based heap abstraction.
|
||||
*/
|
||||
public static SSAPropagationCallGraphBuilder makeNCFABuilder(int n, AnalysisOptions options, AnalysisCache cache,
|
||||
IClassHierarchy cha, AnalysisScope scope) {
|
||||
if (options == null) {
|
||||
throw new IllegalArgumentException("options is null");
|
||||
}
|
||||
addDefaultSelectors(options, cha);
|
||||
addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha);
|
||||
ContextSelector appSelector = null;
|
||||
SSAContextInterpreter appInterpreter = null;
|
||||
SSAPropagationCallGraphBuilder result = new nCFABuilder(n, cha, options, cache, appSelector, appInterpreter);
|
||||
// nCFABuilder uses type-based heap abstraction by default, but we want allocation sites
|
||||
result.setInstanceKeys(new ZeroXInstanceKeys(options, cha, result.getContextInterpreter(), ZeroXInstanceKeys.ALLOCATIONS
|
||||
| ZeroXInstanceKeys.SMUSH_MANY | ZeroXInstanceKeys.SMUSH_PRIMITIVE_HOLDERS | ZeroXInstanceKeys.SMUSH_STRINGS
|
||||
| ZeroXInstanceKeys.SMUSH_THROWABLES));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* make a {@link CallGraphBuilder} that uses call-string context sensitivity,
|
||||
* with call-string length limited to n, and a context-sensitive
|
||||
* allocation-site-based heap abstraction. Standard optimizations in the heap
|
||||
* abstraction like smushing of strings are disabled.
|
||||
*/
|
||||
public static SSAPropagationCallGraphBuilder makeVanillaNCFABuilder(int n, AnalysisOptions options, AnalysisCache cache,
|
||||
IClassHierarchy cha, AnalysisScope scope) {
|
||||
if (options == null) {
|
||||
throw new IllegalArgumentException("options is null");
|
||||
}
|
||||
addDefaultSelectors(options, cha);
|
||||
addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha);
|
||||
ContextSelector appSelector = null;
|
||||
SSAContextInterpreter appInterpreter = null;
|
||||
SSAPropagationCallGraphBuilder result = new nCFABuilder(n, cha, options, cache, appSelector, appInterpreter);
|
||||
// nCFABuilder uses type-based heap abstraction by default, but we want allocation sites
|
||||
result.setInstanceKeys(new ZeroXInstanceKeys(options, cha, result.getContextInterpreter(), ZeroXInstanceKeys.ALLOCATIONS | ZeroXInstanceKeys.CONSTANT_SPECIFIC));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param options options that govern call graph construction
|
||||
|
||||
@ -23,7 +23,8 @@ import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
||||
/**
|
||||
* nCFA Call graph builder
|
||||
* nCFA Call graph builder. Note that by default, this builder uses a
|
||||
* {@link ClassBasedInstanceKeys} heap model.
|
||||
*/
|
||||
public class nCFABuilder extends SSAPropagationCallGraphBuilder {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user