当前位置: 首页>>代码示例>>Java>>正文


Java AnalysisScope.getApplicationLoader方法代码示例

本文整理汇总了Java中com.ibm.wala.ipa.callgraph.AnalysisScope.getApplicationLoader方法的典型用法代码示例。如果您正苦于以下问题:Java AnalysisScope.getApplicationLoader方法的具体用法?Java AnalysisScope.getApplicationLoader怎么用?Java AnalysisScope.getApplicationLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.wala.ipa.callgraph.AnalysisScope的用法示例。


在下文中一共展示了AnalysisScope.getApplicationLoader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadCoreClass

import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入方法依赖的package包/类
/**
   * @param cha
   * @param coreName The name of the core to be analyzed. Should be something of the form
   *                 `-Lorg/paninij/soter/FooCore`.
   */
  public static IClass loadCoreClass(String coreName, IClassHierarchy cha)
  {
      AnalysisScope scope = cha.getScope();
      ClassLoaderReference appLoaderRef = scope.getApplicationLoader();
TypeReference typeRef = TypeReference.findOrCreate(appLoaderRef, coreName);

      IClass coreClass = cha.lookupClass(typeRef);
      if (coreClass == null)
      {
          String msg = "Failed to load a core's `IClass`: " + coreName;
          throw new IllegalArgumentException(msg);
      }
      return coreClass;
  }
 
开发者ID:paninij,项目名称:paninij,代码行数:20,代码来源:WalaUtil.java

示例2: getCallGraph

import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入方法依赖的package包/类
/**
 * Gets callgraph for given parameters (binary analysis only)
 * @param exclusionFilePath
 * @param classPath
 * @param entryClass
 * @param entryMethod
 * @return
 */
public static CallGraph getCallGraph(String exclusionFilePath, String classPath, String entryClass, String entryMethod) {
    AnalysisScope scope = null;
    ClassHierarchy cha = null;
    HashSet<Entrypoint> entryPoints = null;
    try {
        File exclusionFile = new File(exclusionFilePath);
        scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classPath, exclusionFile); // works with class and jar files
        cha = ClassHierarchyFactory.make(scope);

        ClassLoaderReference clr = scope.getApplicationLoader();
        entryPoints = HashSetFactory.make();
        for(IClass class1 : cha) {
            if(class1.getClassLoader().getReference().equals(clr)) {
                Collection<IMethod> allMethods = class1.getDeclaredMethods();
                for(IMethod m : allMethods) {
                    if(m.isPrivate()) {
                        continue;
                    }
                    TypeName tn = m.getDeclaringClass().getName();//MainApplication
                    if(tn.toString().contains("/" + entryClass) && m.getName().toString().contains(entryMethod)) { // TODO: too weak
                        entryPoints.add(new DefaultEntrypoint(m, cha));
                    }
                }
            }
        }
        //	    Iterable<Entrypoint> result1 = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha); // uses the static main methods as entry methods
        if(entryPoints.size() == 0) {
            log.error("Could not find specified entry point for analysis.\n" +
                      " path: " + classPath + "\n" +
                      " class: " + entryClass + "\n" +
                      " method: " + entryMethod);
            System.exit(1);
        }
        AnalysisOptions options = new AnalysisOptions(scope, entryPoints);

        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeRTABuilder(options, new AnalysisCacheImpl(), cha, scope); // Rapid Type Analysis
        SSAPropagationCallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-CFA = context-insensitive, class-based heap
        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-1-CFA = context-insensitive, allocation-site-based heap
        //		CallGraphBuilder builder = com.ibm.wala.ipa.callgraph.impl.Util.makeZeroOneContainerCFABuilder(options, new AnalysisCacheImpl(), cha, scope); // 0-1-Container-CFA = object-sensitive container

        return builder.makeCallGraph(options);
    } catch (Exception e) {
        log.error("Error while building the call graph");
        e.printStackTrace();
        System.exit(1);
        return null;
    }
}
 
开发者ID:logicalhacking,项目名称:DASCA,代码行数:57,代码来源:AnalysisUtil.java


注:本文中的com.ibm.wala.ipa.callgraph.AnalysisScope.getApplicationLoader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。