com.ibm.wala.ipa.callgraph.impl.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(15.3k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中com.ibm.wala.ipa.callgraph.impl.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:com.ibm.wala.ipa.callgraph.impl.Util
类名称:Util

Util介绍

[英]Call graph utilities
[中]调用图实用程序

代码示例

代码示例来源:origin: wala/WALA

  1. /**
  2. * @return Entrypoints object for a Main J2SE class
  3. */
  4. public static Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope, final IClassHierarchy cha, String className) {
  5. return makeMainEntrypoints(scope, cha, new String[] { className });
  6. }

代码示例来源:origin: wala/WALA

  1. public CallGraphBuilder<InstanceKey> make(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, AnalysisScope scope) {
  2. Util.addDefaultSelectors(options, cha);
  3. Util.addDefaultBypassLogic(options, scope, Util.class.getClassLoader(), cha);
  4. return new AstJavaZeroOneContainerCFABuilder(cha, options, cache, null, null);
  5. }
  6. }

代码示例来源:origin: wala/WALA

  1. /**
  2. * @param options options that govern call graph construction
  3. * @param cha governing class hierarchy
  4. * @param scope representation of the analysis scope
  5. * @return a 0-CFA Call Graph Builder.
  6. */
  7. public static SSAPropagationCallGraphBuilder makeZeroCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView cache,
  8. IClassHierarchy cha, AnalysisScope scope) {
  9. return makeZeroCFABuilder(l, options, cache, cha, scope, null, null);
  10. }

代码示例来源:origin: com.ibm.wala/com.ibm.wala.cast.java

  1. /**
  2. * @param options options that govern call graph construction
  3. * @param cha governing class hierarchy
  4. * @param cl classloader that can find DOMO resources
  5. * @param scope representation of the analysis scope
  6. * @param xmlFiles set of Strings that are names of XML files holding bypass logic specifications.
  7. * @return a 0-1-Opt-CFA Call Graph Builder.
  8. */
  9. public static AstJavaCFABuilder make(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, ClassLoader cl,
  10. AnalysisScope scope, String[] xmlFiles, byte instancePolicy) {
  11. com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
  12. for (String xmlFile : xmlFiles) {
  13. com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFile, cha);
  14. }
  15. return new AstJavaZeroXCFABuilder(cha, options, cache, null, null, instancePolicy);
  16. }

代码示例来源:origin: wala/WALA

  1. /**
  2. * test for bug reported on mailing list by Joshua Garcia, 5/16/2010
  3. */
  4. @Test
  5. public void testTestInetAddr() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException, UnsoundGraphException {
  6. AnalysisScope scope = findOrCreateAnalysisScope();
  7. IClassHierarchy cha = findOrCreateCHA(scope);
  8. Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
  9. TestConstants.SLICE_TESTINETADDR);
  10. AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
  11. CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
  12. CallGraph cg = builder.makeCallGraph(options, null);
  13. SDG<?> sdg = new SDG<>(cg, builder.getPointerAnalysis(), DataDependenceOptions.NO_BASE_NO_HEAP, ControlDependenceOptions.FULL);
  14. GraphIntegrity.check(sdg);
  15. }

代码示例来源:origin: wala/WALA

  1. private static Pair<CallGraph,PointerAnalysis<InstanceKey>> makeJavaBuilder(String scopeFile, String mainClass) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
  2. AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
  3. ClassHierarchy cha = ClassHierarchyFactory.make(scope);
  4. Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
  5. AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
  6. SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
  7. CallGraph CG = builder.makeCallGraph(options);
  8. return Pair.make(CG, builder.getPointerAnalysis());
  9. }

代码示例来源:origin: SAP/vulnerability-assessment-tool

  1. builder = Util.makeRTABuilder(options, cache, this.cha, this.scope);
  2. } else if (cg_algorithm.equals("0-CFA")) {
  3. builder = Util.makeZeroCFABuilder(options, cache, this.cha, this.scope);
  4. } else if (cg_algorithm.equals("0-ctn-CFA")) {
  5. builder = Util.makeZeroContainerCFABuilder(options, cache, this.cha, this.scope);
  6. } else if (cg_algorithm.equals("vanilla-0-1-CFA")) {
  7. builder = Util.makeVanillaZeroOneCFABuilder(options, cache, this.cha, this.scope);
  8. } else if (cg_algorithm.equals("0-1-CFA")) {
  9. builder = Util.makeZeroOneCFABuilder(options, cache, this.cha, this.scope);
  10. } else if (cg_algorithm.equals("0-1-ctn-CFA")) {
  11. builder = Util.makeZeroOneContainerCFABuilder(options, cache, this.cha, this.scope);
  12. } else {
  13. builder = Util.makeZeroOneCFABuilder(options, cache, this.cha, this.scope);

代码示例来源:origin: wala/WALA

  1. public static Graph<Object> buildPointsTo(String appJar) throws WalaException, IllegalArgumentException, CancelException, IOException {
  2. AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, (new FileProvider()).getFile(CallGraphTestUtil.REGRESSION_EXCLUSIONS));
  3. ClassHierarchy cha = ClassHierarchyFactory.make(scope);
  4. Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha);
  5. AnalysisOptions options = new AnalysisOptions(scope, entrypoints);
  6. // //
  7. // build the call graph
  8. // //
  9. com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(),cha, scope, null, null);
  10. CallGraph cg = builder.makeCallGraph(options,null);
  11. PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis();
  12. System.err.println(pointerAnalysis);
  13. return new BasicHeapGraph<>(pointerAnalysis, cg);
  14. }
  15. }

代码示例来源:origin: wala/WALA

  1. protected DemandRefinementPointsTo makeDemandPointerAnalysis(String mainClass) throws ClassHierarchyException,
  2. IllegalArgumentException, CancelException, IOException {
  3. AnalysisScope scope = findOrCreateAnalysisScope();
  4. // build a type hierarchy
  5. IClassHierarchy cha = findOrCreateCHA(scope);
  6. // set up call graph construction options; mainly what should be considered
  7. // entrypoints?
  8. Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, mainClass);
  9. AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
  10. final IAnalysisCacheView analysisCache = new AnalysisCacheImpl();
  11. CallGraphBuilder<InstanceKey> cgBuilder = Util.makeZeroCFABuilder(Language.JAVA, options, analysisCache, cha, scope);
  12. final CallGraph cg = cgBuilder.makeCallGraph(options, null);
  13. // System.err.println(cg.toString());
  14. // MemoryAccessMap mam = new SimpleMemoryAccessMap(cg,
  15. // cgBuilder.getPointerAnalysis().getHeapModel(), false);
  16. MemoryAccessMap mam = new PABasedMemoryAccessMap(cg, cgBuilder.getPointerAnalysis());
  17. SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, analysisCache, cha, scope);
  18. DemandRefinementPointsTo fullDemandPointsTo = DemandRefinementPointsTo.makeWithDefaultFlowGraph(cg, builder, mam, cha, options,
  19. getStateMachineFactory());
  20. // always refine array fields; otherwise, can be very sensitive to differences
  21. // in library versions. otherwise, no refinement by default
  22. fullDemandPointsTo.setRefinementPolicyFactory(new SinglePassRefinementPolicy.Factory(new OnlyArraysPolicy(), new NeverRefineCGPolicy()));
  23. return fullDemandPointsTo;
  24. }

代码示例来源:origin: wala/WALA

  1. Warnings.clear();
  2. AnalysisOptions options = new AnalysisOptions();
  3. Iterable<Entrypoint> entrypoints = entryClass != null ? makePublicEntrypoints(cha, entryClass) : Util.makeMainEntrypoints(scope, cha, mainClass);
  4. options.setEntrypoints(entrypoints);
  5. IAnalysisCacheView cache = new AnalysisCacheImpl();
  6. CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);

代码示例来源:origin: wala/WALA

  1. public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(
  2. AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha,
  3. AnalysisScope scope, ContextSelector customSelector,
  4. SSAContextInterpreter customInterpreter,
  5. InputStream summariesStream, MethodSummary extraSummary) {
  6. if (options == null) {
  7. throw new IllegalArgumentException("options is null");
  8. }
  9. Util.addDefaultSelectors(options, cha);
  10. // addDefaultBypassLogic(options, scope, Util.class.getClassLoader(),
  11. // cha);
  12. // addBypassLogic(options, scope,
  13. // AndroidAppLoader.class.getClassLoader(), methodSpec, cha);
  14. addBypassLogic(options, scope, summariesStream, cha, extraSummary);
  15. return ZeroXCFABuilder.make(Language.JAVA, cha, options, cache, customSelector,
  16. customInterpreter, ZeroXInstanceKeys.ALLOCATIONS
  17. | ZeroXInstanceKeys.CONSTANT_SPECIFIC);
  18. }

代码示例来源:origin: wala/WALA

  1. /**
  2. * builds a call graph, and sets the corresponding heap model for analysis
  3. */
  4. private static Pair<CallGraph, PointerAnalysis<InstanceKey>> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options)
  5. throws IllegalArgumentException, CancelException {
  6. CallGraph retCG = null;
  7. PointerAnalysis<InstanceKey> retPA = null;
  8. final IAnalysisCacheView cache = new AnalysisCacheImpl();
  9. CallGraphBuilder<InstanceKey> builder;
  10. if (CHEAP_CG) {
  11. builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
  12. // we want vanilla 0-1 CFA, which has one abstract loc per allocation
  13. heapModel = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope);
  14. } else {
  15. builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
  16. heapModel = (HeapModel) builder;
  17. }
  18. ProgressMaster master = ProgressMaster.make(new NullProgressMonitor(), 360000, false);
  19. master.beginTask("runSolver", 1);
  20. try {
  21. retCG = builder.makeCallGraph(options, master);
  22. retPA = builder.getPointerAnalysis();
  23. } catch (CallGraphBuilderCancelException e) {
  24. System.err.println("TIMED OUT!!");
  25. retCG = e.getPartialCallGraph();
  26. retPA = e.getPartialPointerAnalysis();
  27. }
  28. return Pair.make(retCG, retPA);
  29. }

代码示例来源:origin: wala/WALA

  1. /**
  2. * @return a 0-1-CFA Call Graph Builder.
  3. *
  4. * @param options options that govern call graph construction
  5. * @param cha governing class hierarchy
  6. * @param scope representation of the analysis scope
  7. */
  8. public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView analysisCache,
  9. IClassHierarchy cha, AnalysisScope scope) {
  10. return makeVanillaZeroOneCFABuilder(l, options, analysisCache, cha, scope, null, null);
  11. }

代码示例来源:origin: wala/WALA

  1. public static void addDefaultBypassLogic(AnalysisOptions options, AnalysisScope scope, ClassLoader cl, IClassHierarchy cha) {
  2. if (nativeSpec == null) return;
  3. if (cl.getResourceAsStream(nativeSpec) != null) {
  4. addBypassLogic(options, scope, cl, nativeSpec, cha);
  5. } else {
  6. // try to load from filesystem
  7. try (final BufferedInputStream bIn = new BufferedInputStream(new FileInputStream(nativeSpec))) {
  8. XMLMethodSummaryReader reader = new XMLMethodSummaryReader(bIn, scope);
  9. addBypassLogic(options, scope, cl, reader, cha);
  10. } catch (FileNotFoundException e) {
  11. System.err.println("Could not load natives xml file from: " + nativeSpec);
  12. e.printStackTrace();
  13. } catch (IOException e) {
  14. System.err.println("Could not close natives xml file " + nativeSpec);
  15. e.printStackTrace();
  16. }
  17. }
  18. }

代码示例来源:origin: wala/WALA

  1. private static void doTests(AnalysisScope scope, final ClassHierarchy cha, AnalysisOptions options) throws IllegalArgumentException, CancelException {
  2. final SSAPropagationCallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
  3. final CallGraph oldCG = builder.makeCallGraph(options,null);
  4. final PointerAnalysis<InstanceKey> pa = builder.getPointerAnalysis();
  5. CallGraphBuilder<InstanceKey> rtaBuilder = Util.makeRTABuilder(options, new AnalysisCacheImpl(), cha, scope);
  6. final CallGraph cg = rtaBuilder.makeCallGraph(options, null);

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

  1. /**
  2. * @return a 0-1-CFA Call Graph Builder.
  3. *
  4. * @param options options that govern call graph construction
  5. * @param cha governing class hierarchy
  6. * @param scope representation of the analysis scope
  7. */
  8. public static SSAPropagationCallGraphBuilder makeZeroOneCFABuilder(Language l, AnalysisOptions options, IAnalysisCacheView cache,
  9. IClassHierarchy cha, AnalysisScope scope) {
  10. return makeZeroOneCFABuilder(l, options, cache, cha, scope, null, null);
  11. }

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

  1. /**
  2. * @param options options that govern call graph construction
  3. * @param cha governing class hierarchy
  4. * @param scope representation of the analysis scope
  5. * @return a 0-1-CFA Call Graph Builder augmented with extra logic for containers
  6. * @throws IllegalArgumentException if options is null
  7. */
  8. public static SSAPropagationCallGraphBuilder makeZeroOneContainerCFABuilder(AnalysisOptions options, IAnalysisCacheView cache,
  9. IClassHierarchy cha, AnalysisScope scope) {
  10. return makeZeroOneContainerCFABuilder(options, cache, cha, scope, null, null);
  11. }

代码示例来源:origin: wala/WALA

  1. @Test
  2. public void testSlice4() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
  3. AnalysisScope scope = findOrCreateAnalysisScope();
  4. IClassHierarchy cha = findOrCreateCHA(scope);
  5. Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
  6. TestConstants.SLICE4_MAIN);
  7. AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
  8. CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
  9. CallGraph cg = builder.makeCallGraph(options, null);
  10. CGNode main = findMainMethod(cg);
  11. Statement s = findCallTo(main, "foo");
  12. s = PDFSlice.getReturnStatementForCall(s);
  13. System.err.println("Statement: " + s);
  14. // compute a data slice
  15. final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis();
  16. Collection<Statement> slice = Slicer.computeForwardSlice(s, cg, pointerAnalysis, DataDependenceOptions.FULL,
  17. ControlDependenceOptions.NONE);
  18. dumpSlice(slice);
  19. Assert.assertEquals(slice.toString(), 4, slice.size());
  20. }

代码示例来源:origin: wala/WALA

  1. private void testOCamlJar(String jarFile, String... args) throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException, ClassNotFoundException, InvalidClassFileException, FailureException, SecurityException, InterruptedException {
  2. File F = TemporaryFile.urlToFile(jarFile.replace('.', '_') + ".jar", getClass().getClassLoader().getResource(jarFile));
  3. F.deleteOnExit();
  4. AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope("base.txt", CallGraphTestUtil.REGRESSION_EXCLUSIONS);
  5. scope.addToScope(ClassLoaderReference.Application, new JarFile(F, false));
  6. ClassHierarchy cha = ClassHierarchyFactory.make(scope);
  7. Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha, "Lpack/ocamljavaMain");
  8. AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
  9. options.setUseConstantSpecificKeys(true);
  10. IAnalysisCacheView cache = new AnalysisCacheImpl();
  11. SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
  12. MethodHandles.analyzeMethodHandles(options, builder);
  13. CallGraph cg = builder.makeCallGraph(options, null);
  14. System.err.println(cg);
  15. instrument(F.getAbsolutePath());
  16. run("pack.ocamljavaMain", null, args);
  17. checkNodes(cg, t -> {
  18. String s = t.toString();
  19. return s.contains("Lpack/") || s.contains("Locaml/stdlib/");
  20. });
  21. }

代码示例来源:origin: wala/WALA

  1. /**
  2. * @param options options that govern call graph construction
  3. * @param cha governing class hierarchy
  4. * @param cl classloader that can find DOMO resources
  5. * @param scope representation of the analysis scope
  6. * @param xmlFiles set of Strings that are names of XML files holding bypass logic specifications.
  7. * @return a 0-1-Opt-CFA Call Graph Builder.
  8. */
  9. public static AstJavaCFABuilder make(AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, ClassLoader cl,
  10. AnalysisScope scope, String[] xmlFiles, byte instancePolicy) {
  11. com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
  12. for (String xmlFile : xmlFiles) {
  13. com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFile, cha);
  14. }
  15. return new AstJavaZeroXCFABuilder(cha, options, cache, null, null, instancePolicy);
  16. }

相关文章