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

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

本文整理了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

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

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

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

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

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

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

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

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

/**
 * 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);
}

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

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

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

builder = Util.makeRTABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-CFA")) {
  builder = Util.makeZeroCFABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-ctn-CFA")) {
  builder = Util.makeZeroContainerCFABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("vanilla-0-1-CFA")) {
  builder = Util.makeVanillaZeroOneCFABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-1-CFA")) {
  builder = Util.makeZeroOneCFABuilder(options, cache, this.cha, this.scope);
} else if (cg_algorithm.equals("0-1-ctn-CFA")) {
  builder = Util.makeZeroOneContainerCFABuilder(options, cache, this.cha, this.scope);
} else {
  builder = Util.makeZeroOneCFABuilder(options, cache, this.cha, this.scope);

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

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);
 }
}

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

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

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

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

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

public static SSAPropagationCallGraphBuilder makeVanillaZeroOneCFABuilder(
    AnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha,
    AnalysisScope scope, ContextSelector customSelector,
    SSAContextInterpreter customInterpreter,
    InputStream summariesStream, MethodSummary extraSummary) {
  if (options == null) {
    throw new IllegalArgumentException("options is null");
  }
  Util.addDefaultSelectors(options, cha);
  // addDefaultBypassLogic(options, scope, Util.class.getClassLoader(),
  // cha);
  // addBypassLogic(options, scope,
  // AndroidAppLoader.class.getClassLoader(), methodSpec, cha);
  addBypassLogic(options, scope, summariesStream, cha, extraSummary);
  return ZeroXCFABuilder.make(Language.JAVA, cha, options, cache, customSelector,
      customInterpreter, ZeroXInstanceKeys.ALLOCATIONS
          | ZeroXInstanceKeys.CONSTANT_SPECIFIC);
}

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

/**
 * builds a call graph, and sets the corresponding heap model for analysis
 */
private static Pair<CallGraph, PointerAnalysis<InstanceKey>> buildCallGraph(AnalysisScope scope, ClassHierarchy cha, AnalysisOptions options)
  throws IllegalArgumentException, CancelException {
 CallGraph retCG = null;
 PointerAnalysis<InstanceKey> retPA = null;
 final IAnalysisCacheView cache = new AnalysisCacheImpl();
 CallGraphBuilder<InstanceKey> builder;
 if (CHEAP_CG) {
  builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
  // we want vanilla 0-1 CFA, which has one abstract loc per allocation
  heapModel = Util.makeVanillaZeroOneCFABuilder(Language.JAVA, options, cache, cha, scope);
 } else {
  builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
  heapModel = (HeapModel) builder;
 }
 ProgressMaster master = ProgressMaster.make(new NullProgressMonitor(), 360000, false);
 master.beginTask("runSolver", 1);
 try {
  retCG = builder.makeCallGraph(options, master);
  retPA = builder.getPointerAnalysis();
 } catch (CallGraphBuilderCancelException e) {
  System.err.println("TIMED OUT!!");
  retCG = e.getPartialCallGraph();
  retPA = e.getPartialPointerAnalysis();
 }
 return Pair.make(retCG, retPA);
}

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

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

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

public static void addDefaultBypassLogic(AnalysisOptions options, AnalysisScope scope, ClassLoader cl, IClassHierarchy cha) {
 if (nativeSpec == null) return;
 if (cl.getResourceAsStream(nativeSpec) != null) {
  addBypassLogic(options, scope, cl, nativeSpec, cha);
 } else {
  // try to load from filesystem
  try (final BufferedInputStream bIn = new BufferedInputStream(new FileInputStream(nativeSpec))) {
   XMLMethodSummaryReader reader = new XMLMethodSummaryReader(bIn, scope);
   addBypassLogic(options, scope, cl, reader, cha);
  } catch (FileNotFoundException e) {
   System.err.println("Could not load natives xml file from: " + nativeSpec);
   e.printStackTrace();
  } catch (IOException e) {
   System.err.println("Could not close natives xml file " + nativeSpec);
   e.printStackTrace();
  }
 }
}

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

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

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

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

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

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

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

@Test
public void testSlice4() 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.SLICE4_MAIN);
 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 = findCallTo(main, "foo");
 s = PDFSlice.getReturnStatementForCall(s);
 System.err.println("Statement: " + s);
 // compute a data slice
 final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis();
 Collection<Statement> slice = Slicer.computeForwardSlice(s, cg, pointerAnalysis, DataDependenceOptions.FULL,
   ControlDependenceOptions.NONE);
 dumpSlice(slice);
 Assert.assertEquals(slice.toString(), 4, slice.size());
}

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

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

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

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

相关文章