if (jarIS != null) scope.addInputStreamForJarToScope(ClassLoaderReference.Application, jarIS); else AnalysisScopeReader.addClassPathToScope(inPath, scope, ClassLoaderReference.Application); AnalysisOptions options = new AnalysisOptions(scope, null); AnalysisCache cache = new AnalysisCacheImpl(); IClassHierarchy cha = ClassHierarchyFactory.makeWithPhantom(scope);
public static AnalysisOptions makeAnalysisOptions(AnalysisScope scope, Iterable<Entrypoint> entrypoints) { AnalysisOptions options = new AnalysisOptions(scope, entrypoints); return options; }
@Override public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) { return new AnalysisOptions(getScope(), entrypoints); }
@Override public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) { return new AnalysisOptions(getScope(), entrypoints); }
public AnalysisCacheImpl(IRFactory<IMethod> irFactory) { this(irFactory, new AnalysisOptions().getSSAOptions()); }
public AnalysisCacheImpl(IRFactory<IMethod> irFactory) { this(irFactory, new AnalysisOptions().getSSAOptions()); }
public CHACallGraph(IClassHierarchy cha, boolean applicationOnly) { this.cha = cha; this.options = new AnalysisOptions(); this.cache = new AnalysisCacheImpl(); this.applicationOnly = applicationOnly; setInterpreter(new ContextInsensitiveCHAContextInterpreter()); }
public CHACallGraph(IClassHierarchy cha, boolean applicationOnly) { this.cha = cha; this.options = new AnalysisOptions(); this.cache = new AnalysisCacheImpl(); this.applicationOnly = applicationOnly; setInterpreter(new ContextInsensitiveCHAContextInterpreter()); }
@Override public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) { AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints); SSAOptions ssaOptions = new SSAOptions(); ssaOptions.setDefaultValues(SymbolTable::getDefaultValue); options.setSSAOptions(ssaOptions); return options; } }
@Override public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) { AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints); SSAOptions ssaOptions = new SSAOptions(); ssaOptions.setDefaultValues(SymbolTable::getDefaultValue); options.setSSAOptions(ssaOptions); return options; }
@Override public AnalysisOptions getDefaultOptions(Iterable<Entrypoint> entrypoints) { AnalysisOptions options = new AnalysisOptions(getScope(), entrypoints); SSAOptions ssaOptions = new SSAOptions(); ssaOptions.setDefaultValues(SymbolTable::getDefaultValue); options.setSSAOptions(ssaOptions); return options; }
@BeforeClass public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); options = new AnalysisOptions(scope, null); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions()); try { cha = ClassHierarchyFactory.make(scope, factory); } catch (ClassHierarchyException e) { throw new Exception(e); } }
@BeforeClass public static void beforeClass() throws Exception { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); options = new AnalysisOptions(scope, null); cache = new AnalysisCacheImpl(); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions()); try { cha = ClassHierarchyFactory.make(scope, factory); } catch (ClassHierarchyException e) { throw new Exception(e); } }
@BeforeClass public static void init() throws IOException, ClassHierarchyException { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, null, CLASS_LOADER); cha = ClassHierarchyFactory.make(scope); irFactory = new DefaultIRFactory(); options = new AnalysisOptions(); options.getSSAOptions().setPiNodePolicy(new AllIntegerDueToBranchePiPolicy()); }
@BeforeClass public static void beforeClass() throws Exception { cache = new AnalysisCacheImpl(); scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS), NullPointerExceptionInterTest.class.getClassLoader()); ClassLoaderFactory factory = new ClassLoaderFactoryImpl(scope.getExclusions()); try { cha = ClassHierarchyFactory.make(scope, factory); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Lcfg/exc/inter/CallFieldAccess"); AnalysisOptions options = new AnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeNCFABuilder(1, options, cache, cha, scope); cg = builder.makeCallGraph(options, null); } catch (ClassHierarchyException e) { throw new Exception(e); } }
@BeforeClass public static void init() throws IOException, ClassHierarchyException { scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, null, CLASS_LOADER); cha = ClassHierarchyFactory.make(scope); irFactory = new DefaultIRFactory(); options = new AnalysisOptions(); options.getSSAOptions().setPiNodePolicy(new AllIntegerDueToBranchePiPolicy()); }
public static Pair<CallGraph, PointerAnalysis<InstanceKey>> makeDalvikCallGraph(URI[] androidLibs, File androidAPIJar, String mainClassName, String dexFileName) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException { AnalysisScope scope = makeDalvikScope(androidLibs, androidAPIJar, dexFileName); final IClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference mainClassRef = TypeReference.findOrCreate(ClassLoaderReference.Application, mainClassName); IClass mainClass = cha.lookupClass(mainClassRef); assert mainClass != null; System.err.println("building call graph for " + mainClass + ":" + mainClass.getClass()); Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, mainClassName); IAnalysisCacheView cache = new AnalysisCacheImpl(new DexIRFactory()); AnalysisOptions options = new AnalysisOptions(scope, entrypoints); SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph callGraph = cgb.makeCallGraph(options); MethodReference mmr = MethodReference.findOrCreate(mainClassRef, "main", "([Ljava/lang/String;)V"); assert !callGraph.getNodes(mmr).isEmpty(); PointerAnalysis<InstanceKey> ptrAnalysis = cgb.getPointerAnalysis(); return Pair.make(callGraph, ptrAnalysis); }
public static Graph<Object> buildPointsTo(String appJar) throws WalaException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS)); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha); AnalysisOptions options = new AnalysisOptions(scope, entrypoints); // // // build the call graph // // com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope, null, null); CallGraph cg = builder.makeCallGraph(options,null); PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis(); System.err.println(pointerAnalysis); return new BasicHeapGraph<>(pointerAnalysis, cg); } }
public static Pair<CallGraph, PointerAnalysis<InstanceKey>> makeAPKCallGraph(URI[] androidLibs, File androidAPIJar, String apkFileName, IProgressMonitor monitor, ReflectionOptions policy) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException { AnalysisScope scope = makeDalvikScope(androidLibs, androidAPIJar, apkFileName); final IClassHierarchy cha = ClassHierarchyFactory.make(scope); IAnalysisCacheView cache = new AnalysisCacheImpl(new DexIRFactory()); List<? extends Entrypoint> es = getEntrypoints(cha); assert ! es.isEmpty(); AnalysisOptions options = new AnalysisOptions(scope, es); options.setReflectionOptions(policy); // SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(options, cache, cha, scope, null, makeDefaultInterpreter(options, cache)); SSAPropagationCallGraphBuilder cgb = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph callGraph = cgb.makeCallGraph(options, monitor); PointerAnalysis<InstanceKey> ptrAnalysis = cgb.getPointerAnalysis(); return Pair.make(callGraph, ptrAnalysis); }
/** * test that type inference works in the presence of a getfield where the * field's declared type cannot be loaded */ @Test public void testBug38540() throws ClassHierarchyException, IOException { AnalysisScope scope = null; scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, (new FileProvider()).getFile("J2SEClassHierarchyExclusions.txt"), MY_CLASSLOADER); AnalysisOptions options = new AnalysisOptions(); ClassHierarchy cha = ClassHierarchyFactory.make(scope); TypeReference t = TypeReference.findOrCreateClass(scope.getApplicationLoader(), "cornerCases", "Main"); IClass klass = cha.lookupClass(t); Assert.assertTrue(klass != null); ShrikeCTMethod m = (ShrikeCTMethod) klass.getMethod(new Selector(Atom.findOrCreateAsciiAtom("foo"), Descriptor .findOrCreateUTF8("()Ljava/lang/Object;"))); Assert.assertTrue(m != null); IR ir = new AnalysisCacheImpl().getSSACache().findOrCreateIR(m, Everywhere.EVERYWHERE, options.getSSAOptions()); TypeInference.make(ir, false); }