public CallGraph buildDefaultCallGraph() throws IllegalArgumentException, CancelException, IOException { return defaultCallGraphBuilder().makeCallGraph(options, null); }
public CallGraph buildDefaultCallGraph() throws IllegalArgumentException, CancelException, IOException { return defaultCallGraphBuilder().makeCallGraph(options, null); }
protected CallGraphBuilder<? super I> buildCallGraph(IClassHierarchy cha, AnalysisOptions options, boolean savePointerAnalysis, IProgressMonitor monitor) throws IllegalArgumentException, CancelException { CallGraphBuilder<? super I> builder = getCallGraphBuilder(cha, options, cache); cg = builder.makeCallGraph(options, monitor); if (savePointerAnalysis) { pointerAnalysis = builder.getPointerAnalysis(); } return builder; }
protected CallGraphBuilder<? super I> buildCallGraph(IClassHierarchy cha, AnalysisOptions options, boolean savePointerAnalysis, IProgressMonitor monitor) throws IllegalArgumentException, CancelException { CallGraphBuilder<? super I> builder = getCallGraphBuilder(cha, options, cache); cg = builder.makeCallGraph(options, monitor); if (savePointerAnalysis) { pointerAnalysis = builder.getPointerAnalysis(); } return builder; }
public static CallGraph buildRTA(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { StopwatchGC S = null; if (CHECK_FOOTPRINT) { S = new StopwatchGC("build RTA graph"); S.start(); } CallGraphBuilder<InstanceKey> builder = Util.makeRTABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (CHECK_FOOTPRINT) { S.stop(); System.err.println(S.report()); } return cg; }
public static CallGraph buildVanillaZeroOneCFA(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { StopwatchGC S = null; if (CHECK_FOOTPRINT) { S = new StopwatchGC("build RTA graph"); S.start(); } CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (CHECK_FOOTPRINT) { S.stop(); System.err.println(S.report()); } return cg; }
public static CallGraph buildZeroContainerCFA(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { StopwatchGC S = null; if (CHECK_FOOTPRINT) { S = new StopwatchGC("build RTA graph"); S.start(); } CallGraphBuilder<InstanceKey> builder = Util.makeZeroContainerCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (CHECK_FOOTPRINT) { S.stop(); System.err.println(S.report()); } return cg; }
public static CallGraph buildZeroOneContainerCFA(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) throws IllegalArgumentException, CancelException { StopwatchGC S = null; if (CHECK_FOOTPRINT) { S = new StopwatchGC("build RTA graph"); S.start(); } CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (CHECK_FOOTPRINT) { S.stop(); System.err.println(S.report()); } return cg; }
public static CallGraph buildZeroOneCFA(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope, boolean testPAtoString) throws IllegalArgumentException, CancelException { StopwatchGC S = null; if (CHECK_FOOTPRINT) { S = new StopwatchGC("build RTA graph"); S.start(); } CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); if (testPAtoString) { builder.getPointerAnalysis().toString(); } if (CHECK_FOOTPRINT) { S.stop(); System.err.println(S.report()); } return cg; }
@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); } }
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); } }
private static void run(String classPath, String exclusionFilePath) throws IOException, ClassHierarchyException, CallGraphBuilderCancelException{ File exclusionFile = (new FileProvider()).getFile(exclusionFilePath); AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classPath, exclusionFile != null ? exclusionFile : new File(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.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); @SuppressWarnings("unused") WalaViewer walaViewer = new WalaViewer(cg, pa); } }
@Test public void testTestCD1() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = findOrCreateAnalysisScope(); IClassHierarchy cha = findOrCreateCHA(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTCD1); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); Statement s = findCallToDoNothing(main); System.err.println("Statement: " + s); // compute a data slice final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis(); Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, pointerAnalysis, DataDependenceOptions.NONE, ControlDependenceOptions.FULL); dumpSlice(slice); Assert.assertEquals(slice.toString(), 2, countConditionals(slice)); }
@Test public void testTestCD3() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = findOrCreateAnalysisScope(); IClassHierarchy cha = findOrCreateCHA(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTCD3); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); Statement s = findCallToDoNothing(main); System.err.println("Statement: " + s); // compute a data slice final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis(); Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, pointerAnalysis, DataDependenceOptions.NONE, ControlDependenceOptions.FULL); dumpSlice(slice); Assert.assertEquals(slice.toString(), 0, countConditionals(slice)); }
@Test public void testTestMultiTarget() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = findOrCreateAnalysisScope(); IClassHierarchy cha = findOrCreateCHA(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTMULTITARGET); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); Statement s = findCallToDoNothing(main); System.err.println("Statement: " + s); // compute a data slice final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis(); Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, pointerAnalysis, DataDependenceOptions.FULL, ControlDependenceOptions.NONE); dumpSlice(slice); Assert.assertEquals(slice.toString(), 2, countAllocations(slice)); }
@Test public void testJustThrow() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = findOrCreateAnalysisScope(); IClassHierarchy cha = findOrCreateCHA(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_JUSTTHROW); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); Statement s = findCallToDoNothing(main); System.err.println("Statement: " + s); final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis(); Collection<Statement> slice = Slicer.computeBackwardSlice(s, cg, pointerAnalysis, DataDependenceOptions.FULL, ControlDependenceOptions.NO_EXCEPTIONAL_EDGES); dumpSlice(slice); }
@Test public void testTestMessageFormat() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = findOrCreateAnalysisScope(); IClassHierarchy cha = findOrCreateCHA(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTMESSAGEFORMAT); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); CGNode main = findMainMethod(cg); Statement seed = new NormalStatement(main, 2); System.err.println("Statement: " + seed); // compute a backwards thin slice ThinSlicer ts = new ThinSlicer(cg, builder.getPointerAnalysis()); Collection<Statement> slice = ts.computeBackwardThinSlice(seed); dumpSlice(slice); }
/** * test for bug reported on mailing list by Joshua Garcia, 5/16/2010 */ @Test public void testTestInetAddr() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException, UnsoundGraphException { AnalysisScope scope = findOrCreateAnalysisScope(); IClassHierarchy cha = findOrCreateCHA(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, TestConstants.SLICE_TESTINETADDR); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope); CallGraph cg = builder.makeCallGraph(options, null); SDG<?> sdg = new SDG<>(cg, builder.getPointerAnalysis(), DataDependenceOptions.NO_BASE_NO_HEAP, ControlDependenceOptions.FULL); GraphIntegrity.check(sdg); }
@Test public void testMultiDim() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util .makeMainEntrypoints(scope, cha, TestConstants.MULTI_DIM_MAIN); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); CGNode node = findDoNothingNode(cg); PointerKey pk = pa.getHeapModel().getPointerKeyForLocal(node, 1); OrdinalSet<InstanceKey> ptsTo = pa.getPointsToSet(pk); Assert.assertEquals(1, ptsTo.size()); }
@Test public void testZeroOneContainerCopyOf() throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException { AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA, CallGraphTestUtil.REGRESSION_EXCLUSIONS); ClassHierarchy cha = ClassHierarchyFactory.make(scope); Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, "Ldemandpa/TestArraysCopyOf"); AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints); IAnalysisCacheView cache = new AnalysisCacheImpl(); CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope); CallGraph cg = builder.makeCallGraph(options, null); PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis(); CGNode mainMethod = AbstractPtrTest.findMainMethod(cg); PointerKey keyToQuery = AbstractPtrTest.getParam(mainMethod, "testThisVar", pa.getHeapModel()); OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(keyToQuery); Assert.assertEquals(1, pointsToSet.size()); } /**