com.ibm.wala.ipa.callgraph.impl.Util.makeZeroCFABuilder()方法的使用及代码示例

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

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

Util.makeZeroCFABuilder介绍

暂无

代码示例

代码示例来源: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.core

/**
 * @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: wala/WALA

@Override
protected CallGraphBuilder<InstanceKey> getCallGraphBuilder(IClassHierarchy cha, AnalysisOptions options, IAnalysisCacheView cache) {
 return Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
}

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

public static CallGraph buildZeroCFA(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();
 }
 SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(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;
}

代码示例来源: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);

代码示例来源: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 appJar something like "c:/temp/testdata/java_cup.jar"
 * @return a call graph
 */
public static Graph<CGNode> buildPrunedCallGraph(String appJar, File exclusionFile) throws WalaException,
  IllegalArgumentException, CancelException, IOException {
 AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(appJar, 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);
 System.err.println(CallGraphStats.getStats(cg));
 Graph<CGNode> g = pruneForAppLoader(cg);
 return g;
}

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

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

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

com.ibm.wala.ipa.callgraph.CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope, null,
  null);
CallGraph cg = builder.makeCallGraph(options,null);

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

@Test public void testSystemProperties() 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,
   "LstaticInit/TestSystemProperties");
 AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
 SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);    
 CallGraph cg = builder.makeCallGraph(options);
 for (CGNode n : cg) {
  if (n.toString().equals("Node: < Application, LstaticInit/TestSystemProperties, main([Ljava/lang/String;)V > Context: Everywhere")) {
   boolean foundToCharArray = false;
   for (CGNode callee : Iterator2Iterable.make(cg.getSuccNodes(n))) {
    if (callee.getMethod().getName().toString().equals("toCharArray")) {
     foundToCharArray = true;
     break;
    }
   }
   Assert.assertTrue(foundToCharArray);
   break;
  }
 }
}

代码示例来源: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: wala/WALA

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

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

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

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

private static void doCPATest(String testClass, String testIdSignature) 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, testClass);
  AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);

  SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, new AnalysisCacheImpl(), cha, scope);
  builder.setContextSelector(new CPAContextSelector(builder.getContextSelector()));
  CallGraph cg = builder.makeCallGraph(options, null);
  
  // Find id
  TypeReference str = TypeReference.findOrCreate(ClassLoaderReference.Application, testClass);
  MethodReference ct = MethodReference.findOrCreate(str, Atom.findOrCreateUnicodeAtom("id"), Descriptor.findOrCreateUTF8(testIdSignature));
  Set<CGNode> idNodes = cg.getNodes(ct);
 
  System.err.println(cg);

  Assert.assertEquals(2, idNodes.size());
 }
}

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

options.setUseConstantSpecificKeys(true);
SSAPropagationCallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);

代码示例来源: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

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

代码示例来源: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

@BeforeClass
public static void init() throws IOException, ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException {
 AnalysisOptions options;
 AnalysisScope scope;
 scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, new File(REGRESSION_EXCLUSIONS), CLASS_LOADER);
 cha = ClassHierarchyFactory.make(scope);
 Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, "Lexceptionpruning/TestPruning");
 options = new AnalysisOptions(scope, entrypoints);
 options.getSSAOptions().setPiNodePolicy(new AllIntegerDueToBranchePiPolicy());
 ReferenceCleanser.registerClassHierarchy(cha);
 IAnalysisCacheView cache = new AnalysisCacheImpl();
 ReferenceCleanser.registerCache(cache);
 CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
 cg = builder.makeCallGraph(options, null);
 pointerAnalysis = builder.getPointerAnalysis();
 /*
  * We will ignore some exceptions to focus on the exceptions we want to
  * raise (OwnException, ArrayIndexOutOfBoundException)
  */
 filter = new CombinedInterproceduralExceptionFilter<>();
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(TypeReference.JavaLangOutOfMemoryError)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangNullPointerException)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangExceptionInInitializerError)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangNegativeArraySizeException)));
}

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

@BeforeClass
public static void init() throws IOException, ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException {
 AnalysisOptions options;
 AnalysisScope scope;
 scope = AnalysisScopeReader.readJavaScope(TestConstants.WALA_TESTDATA, new File(REGRESSION_EXCLUSIONS), CLASS_LOADER);
 cha = ClassHierarchyFactory.make(scope);
 Iterable<Entrypoint> entrypoints = Util.makeMainEntrypoints(scope, cha, "Lexceptionpruning/TestPruning");
 options = new AnalysisOptions(scope, entrypoints);
 options.getSSAOptions().setPiNodePolicy(new AllIntegerDueToBranchePiPolicy());
 ReferenceCleanser.registerClassHierarchy(cha);
 IAnalysisCacheView cache = new AnalysisCacheImpl();
 ReferenceCleanser.registerCache(cache);
 CallGraphBuilder<InstanceKey> builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha, scope);
 cg = builder.makeCallGraph(options, null);
 pointerAnalysis = builder.getPointerAnalysis();
 /*
  * We will ignore some exceptions to focus on the exceptions we want to
  * raise (OwnException, ArrayIndexOutOfBoundException)
  */
 filter = new CombinedInterproceduralExceptionFilter<>();
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(TypeReference.JavaLangOutOfMemoryError)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangNullPointerException)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangExceptionInInitializerError)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangExceptionInInitializerError)));
 filter.add(new IgnoreExceptionsInterFilter<>(new IgnoreExceptionsFilter(
   TypeReference.JavaLangNegativeArraySizeException)));
}

相关文章