本文整理汇总了Java中com.ibm.wala.ipa.callgraph.AnalysisScope类的典型用法代码示例。如果您正苦于以下问题:Java AnalysisScope类的具体用法?Java AnalysisScope怎么用?Java AnalysisScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnalysisScope类属于com.ibm.wala.ipa.callgraph包,在下文中一共展示了AnalysisScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createClassHierarchy
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
private void createClassHierarchy() throws IOException, ClassHierarchyException {
long s = System.currentTimeMillis();
// check if we have a multi-dex file
stats.isMultiDex = ApkUtils.isMultiDexApk(stats.appFile);
if (stats.isMultiDex)
logger.info("Multi-dex apk detected - Code is merged to single class hierarchy!");
// create analysis scope and generate class hierarchy
// we do not need additional libraries like support libraries,
// as they are statically linked in the app code.
final AnalysisScope scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(new File(stats.appFile.getAbsolutePath()).toURI(), null /* no exclusions */, null /* we always pass an android lib */, CliOptions.pathToAndroidJar.toURI());
cha = ClassHierarchy.make(scope);
logger.info("generated class hierarchy (in " + Utils.millisecondsToFormattedTime(System.currentTimeMillis() - s) + ")");
LibraryProfiler.getChaStats(cha);
}
示例2: makeCG
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
try {
IClassHierarchy cha = makeHierarchy(scope, loaders);
com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
Iterable<Entrypoint> roots = makeScriptRoots(cha);
JSAnalysisOptions options = makeOptions(scope, cha, roots);
options.setHandleCallApply(builderType.handleCallApply());
IAnalysisCacheView cache = makeCache(irFactory);
JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
builderType.useOneCFA());
if(builderType.extractCorrelatedPairs())
builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));
return builder;
} catch (ClassHierarchyException e) {
assert false : "internal error building class hierarchy";
return null;
}
}
示例3: makeCG
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
try {
IClassHierarchy cha = makeHierarchy(scope, loaders);
com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
Iterable<Entrypoint> roots = makeScriptRoots(cha);
JSAnalysisOptions options = makeOptions(scope, cha, roots);
options.setHandleCallApply(builderType.handleCallApply());
AnalysisCache cache = makeCache(irFactory);
JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
builderType.useOneCFA());
if(builderType.extractCorrelatedPairs())
builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));
return builder;
} catch (ClassHierarchyException e) {
return null;
}
}
示例4: makeAnalysisOptions
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
/**
* Note that the resulting `AnalysisOptions` object does not have any entrypoints.
*
* @param cha
* @param scope
* @return
*/
public static AnalysisOptions makeAnalysisOptions(IClassHierarchy cha)
{
AnalysisScope scope = cha.getScope();
AnalysisOptions options = new AnalysisOptions(scope, null);
ClassLoader classLoader = WalaUtil.class.getClassLoader();
InputStream nativesSpec = classLoader.getResourceAsStream(NATIVE_SPEC_RESOURCE_NAME);
XMLMethodSummaryReader nativeSpecSummary = new XMLMethodSummaryReader(nativesSpec, scope);
// Add default selectors then custom ones. The defaults will serve as the parents of the
// custom children. The children delegate to their parents when they do not definitively
// target a class/method.
Util.addDefaultSelectors(options, cha);
setToSynthesizeNativeMethods(cha, options, nativeSpecSummary);
setToSynthesizeNativeClasses(cha, options, nativeSpecSummary);
return options;
}
示例5: createECJJavaEngine
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
public static JavaSourceAnalysisEngine
createECJJavaEngine(Collection<String> sources, List<String> libs, final String [] entryPoints) {
JavaSourceAnalysisEngine engine=null;
if(null == entryPoints) {
engine = new ECJJavaSourceAnalysisEngine();
} else {
engine = new ECJJavaSourceAnalysisEngine() {
@Override
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE,cha, entryPoints);
}
};
}
engine.setExclusionsFile(REGRESSION_EXCLUSIONS);
populateScope(engine, sources, libs);
return engine;
}
示例6: makeCG
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders,
AnalysisScope scope, CGBuilderType builderType,
IRFactory<IMethod> irFactory) throws IOException, WalaException {
try {
IClassHierarchy cha = makeHierarchy(scope, loaders);
com.ibm.wala.cast.util.Util.checkForFrontEndErrors(cha);
Iterable<Entrypoint> roots = makeScriptRoots(cha);
JSAnalysisOptions options = makeOptions(scope, cha, roots);
options.setHandleCallApply(builderType.handleCallApply());
IAnalysisCacheView cache = makeCache(irFactory);
JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options,
cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
builderType.useOneCFA());
if (builderType.extractCorrelatedPairs())
builder.setContextSelector(new PropertyNameContextSelector(
builder.getAnalysisCache(), 2, builder
.getContextSelector()));
return builder;
} catch (ClassHierarchyException e) {
// Assert.assertTrue("internal error building class hierarchy",
// false);
return null;
}
}
示例7: makeCG
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
protected static JSCFABuilder makeCG(JavaScriptLoaderFactory loaders, AnalysisScope scope, CGBuilderType builderType, IRFactory<IMethod> irFactory) throws IOException, WalaException {
try {
IClassHierarchy cha = makeHierarchy(scope, loaders);
com.ibm.wala.cast.js.util.Util.checkForFrontEndErrors(cha);
Iterable<Entrypoint> roots = makeScriptRoots(cha);
JSAnalysisOptions options = makeOptions(scope, cha, roots);
options.setHandleCallApply(builderType.handleCallApply());
AnalysisCache cache = makeCache(irFactory);
JSCFABuilder builder = new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, ZeroXInstanceKeys.ALLOCATIONS,
builderType.useOneCFA());
if(builderType.extractCorrelatedPairs())
builder.setContextSelector(new PropertyNameContextSelector(builder.getAnalysisCache(), 2, builder.getContextSelector()));
return builder;
} catch (ClassHierarchyException e) {
Assert.assertTrue("internal error building class hierarchy", false);
return null;
}
}
示例8: main
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
/**
* Usage: ScopeFileCallGraph -scopeFile file_path [-entryClass class_name |
* -mainClass class_name]
*
* If given -mainClass, uses main() method of class_name as entrypoint. If
* given -entryClass, uses all public methods of class_name.
*
* @throws IOException
* @throws ClassHierarchyException
* @throws CallGraphBuilderCancelException
* @throws IllegalArgumentException
*/
public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException,
CallGraphBuilderCancelException {
long start = System.currentTimeMillis();
Properties p = CommandLine.parse(args);
String scopeFile = p.getProperty("scopeFile");
String entryClass = p.getProperty("entryClass");
String mainClass = p.getProperty("mainClass");
if (mainClass != null && entryClass != null) {
throw new IllegalArgumentException("only specify one of mainClass or entryClass");
}
AnalysisScope scope = AnalysisScopeReader.readJavaScope(scopeFile, null, ScopeFileCallGraph.class.getClassLoader());
// set exclusions. we use these exclusions as standard for handling JDK 8
ExampleUtil.addDefaultExclusions(scope);
IClassHierarchy cha = ClassHierarchyFactory.make(scope);
System.out.println(cha.getNumberOfClasses() + " classes");
System.out.println(Warnings.asString());
Warnings.clear();
AnalysisOptions options = new AnalysisOptions();
Iterable<Entrypoint> entrypoints = entryClass != null ? makePublicEntrypoints(scope, cha, entryClass) : Util.makeMainEntrypoints(scope, cha, mainClass);
options.setEntrypoints(entrypoints);
// you can dial down reflection handling if you like
// options.setReflectionOptions(ReflectionOptions.NONE);
AnalysisCache cache = new AnalysisCacheImpl();
// other builders can be constructed with different Util methods
CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);
// CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
// CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
System.out.println("building call graph...");
CallGraph cg = builder.makeCallGraph(options, null);
long end = System.currentTimeMillis();
System.out.println("done");
System.out.println("took " + (end-start) + "ms");
System.out.println(CallGraphStats.getStats(cg));
}
示例9: makePublicEntrypoints
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
private static Iterable<Entrypoint> makePublicEntrypoints(AnalysisScope scope, IClassHierarchy cha, String entryClass) {
Collection<Entrypoint> result = new ArrayList<Entrypoint>();
IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application,
StringStuff.deployment2CanonicalTypeString(entryClass)));
for (IMethod m : klass.getDeclaredMethods()) {
if (m.isPublic()) {
result.add(new DefaultEntrypoint(m, cha));
}
}
return result;
}
示例10: run
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
public static Process run(String[] args) throws IOException {
try {
validateCommandLine(args);
String classpath = args[CLASSPATH_INDEX];
AnalysisScope scope = AnalysisScopeReader.makeJavaBinaryAnalysisScope(classpath, null);
ExampleUtil.addDefaultExclusions(scope);
// invoke WALA to build a class hierarchy
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
Graph<IClass> g = typeHierarchy2Graph(cha);
g = pruneForAppLoader(g);
//String dotFile = "/tmp" + File.separatorChar + DOT_FILE;
String dotFile = File.createTempFile("out", ".dt").getAbsolutePath();
String pdfFile = File.createTempFile("out", ".pdf").getAbsolutePath();
String dotExe = "dot";
String gvExe = "open";
DotUtil.dotify(g, null, dotFile, pdfFile, dotExe);
return PDFViewUtil.launchPDFView(pdfFile, gvExe);
} catch (WalaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
示例11: makeScriptCGBuilder
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
/**
* create a CG builder for script. Note that the script at dir/name is loaded via the classloader, not from the filesystem.
*/
public static JSCFABuilder makeScriptCGBuilder(String dir, String name, CGBuilderType builderType, ClassLoader loader) throws IOException, WalaException {
URL script = getURLforFile(dir, name, loader);
CAstRewriterFactory preprocessor = builderType.extractCorrelatedPairs ? new CorrelatedPairExtractorFactory(translatorFactory, script) : null;
JavaScriptLoaderFactory loaders = JSCallGraphUtil.makeLoaders(preprocessor);
AnalysisScope scope = makeScriptScope(dir, name, loaders, loader);
return makeCG(loaders, scope, builderType, AstIRFactory.makeDefaultFactory());
}
示例12: removeErrorModules
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
private SourceModule[] removeErrorModules(SourceModule[] scriptsArray, JavaScriptLoaderFactory loaders)
throws IOException, ClassHierarchyException {
AnalysisScope scope = CAstCallGraphUtil.makeScope(scriptsArray, loaders, JavaScriptLoader.JS);
IClassHierarchy cha = ClassHierarchy.make(scope, loaders, JavaScriptLoader.JS);
Set<ModuleEntry> errorModules = new HashSet<>();
for (IClassLoader loader : cha.getLoaders()) {
if(loader instanceof CAstAbstractLoader) {
Iterator errors = ((CAstAbstractLoader)loader).getModulesWithParseErrors();
while(errors.hasNext()) {
ModuleEntry errorModule = (ModuleEntry)errors.next();
errorModules.add(errorModule);
}
((CAstAbstractLoader)loader).clearMessages();
}
}
Set<SourceModule> newSourceModules = new HashSet<>();
for (SourceModule sourceModule : scriptsArray) {
boolean isErrorModule = false;
Iterator<? extends ModuleEntry> moduleEntries = sourceModule.getEntries();
while (moduleEntries.hasNext()) {
ModuleEntry moduleEntry = moduleEntries.next();
if (errorModules.contains(moduleEntry)) {
isErrorModule = true;
break;
}
}
if (isErrorModule) {
continue;
}
newSourceModules.add(sourceModule);
}
return newSourceModules.toArray(new SourceModule[newSourceModules.size()]);
}
示例13: 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;
}
示例14: makeScriptCGBuilder
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
/**
* create a CG builder for script. Note that the script at dir/name is
* loaded via the classloader, not from the filesystem.
*/
public static JSCFABuilder makeScriptCGBuilder(String dir, String name,
CGBuilderType builderType) throws IOException, WalaException {
URL script = getURLforFile(dir, name);
CAstRewriterFactory preprocessor = builderType.extractCorrelatedPairs
? new CorrelatedPairExtractorFactory(translatorFactory, script)
: null;
JavaScriptLoaderFactory loaders = JSCallGraphUtil
.makeLoaders(preprocessor);
AnalysisScope scope = makeScriptScope(script, dir, name, loaders);
return makeCG(loaders, scope, builderType,
AstIRFactory.makeDefaultFactory());
}
示例15: makeScriptScope
import com.ibm.wala.ipa.callgraph.AnalysisScope; //导入依赖的package包/类
static AnalysisScope makeScriptScope(URL script, String dir, String name,
JavaScriptLoaderFactory loaders) throws IOException {
return makeScope(new SourceModule[] {
(script.openConnection() instanceof JarURLConnection)
? new SourceURLModule(script)
: makeSourceModule(script, dir, name),
getPrologueFile("prologue.js")
}, loaders, JavaScriptLoader.JS);
}