fixes to Dalvik support, and work on running Dalvik tests on Travis
This commit is contained in:
parent
4676c4f4d4
commit
5cc870dd77
|
@ -59,6 +59,8 @@ import com.ibm.wala.util.strings.Atom;
|
|||
|
||||
public abstract class IRTests {
|
||||
|
||||
protected boolean dump = false;
|
||||
|
||||
protected IRTests(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
|
@ -356,8 +358,10 @@ public abstract class IRTests {
|
|||
//System.err.println(callGraph.toString());
|
||||
|
||||
// If we've gotten this far, IR has been produced.
|
||||
//dumpIR(callGraph, sources, assertReachable);
|
||||
|
||||
if (dump) {
|
||||
dumpIR(callGraph, sources, assertReachable);
|
||||
}
|
||||
|
||||
// Now check any assertions as to source mapping
|
||||
for (IRAssertion IRAssertion : ca) {
|
||||
IRAssertion.check(callGraph);
|
||||
|
|
|
@ -100,7 +100,9 @@ public class TestFieldBasedCG extends AbstractFieldBasedTest {
|
|||
}
|
||||
|
||||
private static final Object[][] assertionsForReflectiveCall = new Object[][] {
|
||||
new Object[] { "suffix:h", new String[] { "suffix:Function_prototype_call" } },
|
||||
new Object[] { "suffix:h", new String[] { "suffix:Function_prototype_call", "suffix:Function_prototype_apply" } },
|
||||
new Object[] { "suffix:Function_prototype_call", new String[] { "suffix:f" } },
|
||||
new Object[] { "suffix:Function_prototype_apply", new String[] { "suffix:x" } },
|
||||
new Object[] { "suffix:f", new String[] { "suffix:k" } }
|
||||
};
|
||||
|
||||
|
|
|
@ -88,21 +88,21 @@ public class JSCallGraphBuilderUtil extends com.ibm.wala.cast.js.ipa.callgraph.J
|
|||
/**
|
||||
* 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);
|
||||
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);
|
||||
AnalysisScope scope = makeScriptScope(dir, name, loaders, loader);
|
||||
|
||||
return makeCG(loaders, scope, builderType, AstIRFactory.makeDefaultFactory());
|
||||
}
|
||||
|
||||
public static URL getURLforFile(String dir, String name) throws IOException {
|
||||
public static URL getURLforFile(String dir, String name, ClassLoader loader) throws IOException {
|
||||
File f = null;
|
||||
FileProvider provider = new FileProvider();
|
||||
try {
|
||||
f = provider.getFile(dir + File.separator + name, JSCallGraphBuilderUtil.class.getClassLoader());
|
||||
f = provider.getFile(dir + File.separator + name, loader);
|
||||
} catch (FileNotFoundException e) {
|
||||
// I guess we need to do this on Windows sometimes? --MS
|
||||
// if this fails, we won't catch the exception
|
||||
|
@ -120,12 +120,20 @@ public class JSCallGraphBuilderUtil extends com.ibm.wala.cast.js.ipa.callgraph.J
|
|||
};
|
||||
}
|
||||
|
||||
public static AnalysisScope makeScriptScope(String dir, String name, JavaScriptLoaderFactory loaders, ClassLoader loader) throws IOException {
|
||||
return makeScope(makeSourceModules(dir, name, loader), loaders, JavaScriptLoader.JS);
|
||||
}
|
||||
|
||||
public static AnalysisScope makeScriptScope(String dir, String name, JavaScriptLoaderFactory loaders) throws IOException {
|
||||
return makeScope(makeSourceModules(dir, name), loaders, JavaScriptLoader.JS);
|
||||
return makeScope(makeSourceModules(dir, name, JSCallGraphBuilderUtil.class.getClassLoader()), loaders, JavaScriptLoader.JS);
|
||||
}
|
||||
|
||||
public static SourceModule[] makeSourceModules(String dir, String name) throws IOException {
|
||||
URL script = getURLforFile(dir, name);
|
||||
return makeSourceModules(dir, name, JSCallGraphBuilderUtil.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static SourceModule[] makeSourceModules(String dir, String name, ClassLoader loader) throws IOException {
|
||||
URL script = getURLforFile(dir, name, loader);
|
||||
SourceModule[] modules = new SourceModule[] {
|
||||
(script.openConnection() instanceof JarURLConnection)? new SourceURLModule(script): makeSourceModule(script, dir, name),
|
||||
getPrologueFile("prologue.js")
|
||||
|
@ -133,17 +141,25 @@ public class JSCallGraphBuilderUtil extends com.ibm.wala.cast.js.ipa.callgraph.J
|
|||
return modules;
|
||||
}
|
||||
|
||||
public static JSCFABuilder makeScriptCGBuilder(String dir, String name, ClassLoader loader) throws IOException, WalaException {
|
||||
return makeScriptCGBuilder(dir, name, CGBuilderType.ZERO_ONE_CFA, loader);
|
||||
}
|
||||
|
||||
public static JSCFABuilder makeScriptCGBuilder(String dir, String name) throws IOException, WalaException {
|
||||
return makeScriptCGBuilder(dir, name, CGBuilderType.ZERO_ONE_CFA);
|
||||
return makeScriptCGBuilder(dir, name, CGBuilderType.ZERO_ONE_CFA, JSCallGraphBuilderUtil.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static CallGraph makeScriptCG(String dir, String name) throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
return makeScriptCG(dir, name, CGBuilderType.ZERO_ONE_CFA);
|
||||
return makeScriptCG(dir, name, CGBuilderType.ZERO_ONE_CFA, JSCallGraphBuilderUtil.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static CallGraph makeScriptCG(String dir, String name, ClassLoader loader) throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
return makeScriptCG(dir, name, CGBuilderType.ZERO_ONE_CFA, loader);
|
||||
}
|
||||
|
||||
public static CallGraph makeScriptCG(String dir, String name, CGBuilderType builderType) throws IOException,
|
||||
public static CallGraph makeScriptCG(String dir, String name, CGBuilderType builderType, ClassLoader loader) throws IOException,
|
||||
IllegalArgumentException, CancelException, WalaException {
|
||||
PropagationCallGraphBuilder b = makeScriptCGBuilder(dir, name, builderType);
|
||||
PropagationCallGraphBuilder b = makeScriptCGBuilder(dir, name, builderType, loader);
|
||||
CallGraph CG = b.makeCallGraph(b.getOptions());
|
||||
// dumpCG(b.getPointerAnalysis(), CG);
|
||||
return CG;
|
||||
|
|
|
@ -291,12 +291,21 @@ public abstract class TestPointerAnalyses {
|
|||
|
||||
for(InstanceKey k : fbPA.getInstanceKeys()) {
|
||||
k.getCreationSites(fbCG);
|
||||
if (! hg.containsNode(fbPA.getHeapModel().getPointerKeyForInstanceField(k, new AstDynamicField(false, k.getConcreteType(), Atom.findOrCreateUnicodeAtom("__proto__"), JavaScriptTypes.Root)))) {
|
||||
System.err.println("object " + k + "(" + k.getConcreteType() + ")");
|
||||
for(Iterator<Pair<CGNode, NewSiteReference>> css = k.getCreationSites(fbCG); css.hasNext(); ) {
|
||||
System.err.println(css.next());
|
||||
for(String f : new String[]{ "__proto__", "prototype" }) {
|
||||
boolean dump = false;
|
||||
PointerKey pointerKeyForInstanceField = fbPA.getHeapModel().getPointerKeyForInstanceField(k, new AstDynamicField(false, k.getConcreteType(), Atom.findOrCreateUnicodeAtom(f), JavaScriptTypes.Root));
|
||||
if (! hg.containsNode(pointerKeyForInstanceField)) {
|
||||
dump = true;
|
||||
System.err.println("no " + f + " for " + k + "(" + k.getConcreteType() + ")");
|
||||
} else if (! hg.getSuccNodes(pointerKeyForInstanceField).hasNext()){
|
||||
dump = true;
|
||||
System.err.println("empty " + f + " for " + k + "(" + k.getConcreteType() + ")");
|
||||
}
|
||||
if (dump) {
|
||||
for(Iterator<Pair<CGNode, NewSiteReference>> css = k.getCreationSites(fbCG); css.hasNext(); ) {
|
||||
System.err.println(css.next());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class JSAstTranslator extends AstTranslator {
|
|||
protected int doGlobalRead(CAstNode n, WalkContext context, String name, TypeReference type) {
|
||||
int readVn = super.doGlobalRead(n, context, name, type);
|
||||
// add a check if name is undefined, unless we're reading the value 'undefined'
|
||||
if (!("undefined".equals(name) || "$$undefined".equals(name))) {
|
||||
if (n != null && !("undefined".equals(name) || "$$undefined".equals(name))) {
|
||||
addDefinedCheck(n, context, readVn);
|
||||
}
|
||||
return readVn;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
=======================================================================
|
||||
CAPA Domo build file
|
||||
WALA CAst build file
|
||||
=======================================================================
|
||||
-->
|
||||
<project name="com.ibm.wala.cast" default="getJars" basedir=".">
|
||||
|
@ -19,7 +19,6 @@
|
|||
<property name="javacDebugInfo" value="on" />
|
||||
<property name="javacVerbose" value="false" />
|
||||
|
||||
|
||||
<!-- Set global properties for this build -->
|
||||
<property name="src" value="source/java" />
|
||||
<property name="nativesourcedir" value="source/c" />
|
||||
|
|
|
@ -3767,8 +3767,9 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
|
||||
context.cfg().addPreNode(n, context.getUnwindState());
|
||||
context.cfg().newBlock(true);
|
||||
context.cfg().addPreEdge(n, context.getControlFlow().getTarget(n, Boolean.TRUE), false);
|
||||
|
||||
context.cfg().newBlock(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -216,4 +216,8 @@ abstract public class AstFunctionClass implements IClass, ClassConstants {
|
|||
public boolean isReferenceType() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public IMethod getCodeBody() {
|
||||
return functionBody;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public abstract class DynamicCallGraphTestBase extends WalaTestCase {
|
|||
}
|
||||
|
||||
private MethodReference callee(String calleeClass, String calleeMethod) {
|
||||
return MethodReference.findOrCreate(TypeReference.findOrCreate(ClassLoaderReference.Application, "L" + calleeClass), Selector.make(calleeMethod));
|
||||
return MethodReference.findOrCreate(TypeReference.findOrCreate(ClassLoaderReference.Application, "L" + calleeClass), Selector.make(calleeMethod));
|
||||
}
|
||||
|
||||
protected void checkEdges(CallGraph staticCG) throws IOException {
|
||||
|
|
|
@ -33,7 +33,7 @@ public class NestedJarFileModule extends AbstractNestedJarFileModule {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected InputStream getNestedContents() {
|
||||
public InputStream getNestedContents() {
|
||||
return new ByteArrayInputStream(parent.getContents(entry));
|
||||
}
|
||||
|
||||
|
|
|
@ -71,10 +71,9 @@ public class AnalysisScopeReader {
|
|||
r = new BufferedReader(new InputStreamReader(new FileInputStream(scopeFile), "UTF-8"));
|
||||
} else {
|
||||
// try to read from jar
|
||||
InputStream inFromJar = scope.getClass().getClassLoader().getResourceAsStream(scopeFileName);
|
||||
InputStream inFromJar = javaLoader.getResourceAsStream(scopeFileName);
|
||||
if (inFromJar == null) {
|
||||
throw new IllegalArgumentException("Unable to retreive " + scopeFileName + " from the jar using the loader of " +
|
||||
scope.getClass());
|
||||
throw new IllegalArgumentException("Unable to retreive " + scopeFileName + " from the jar using " + javaLoader);
|
||||
}
|
||||
r = new BufferedReader(new InputStreamReader(inFromJar));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="source"/>
|
||||
<classpathentry kind="src" path="data"/>
|
||||
<classpathentry kind="lib" path="lib/dx-1.7.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
|
||||
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
|
||||
org.eclipse.jdt.core.builder.invalidClasspath=abort
|
||||
org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore
|
||||
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=,*.g
|
||||
org.eclipse.jdt.core.circularClasspath=error
|
||||
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
|
||||
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
|
||||
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
|
||||
org.eclipse.jdt.core.incompleteClasspath=error
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: WalaDalvikBytecodeTests
|
||||
Bundle-SymbolicName: com.ibm.wala.dalvik.test
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Version: 1.3.4.qualifier
|
||||
Bundle-Activator: com.ibm.wala.dalvik.test.Activator
|
||||
Bundle-Vendor: IBM
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
|
@ -14,3 +14,5 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
org.junit;bundle-version="4.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ClassPath: .,
|
||||
lib/dx-1.7.jar
|
||||
|
|
|
@ -2,4 +2,5 @@ source.. = source/,\
|
|||
data/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
lib/dx-1.7.jar
|
||||
jars.extra.classpath = lib/dx-1.7.jar
|
||||
|
|
|
@ -51,8 +51,15 @@
|
|||
<available file="${plugin.destination}/data/troff2html.cup" property="sample.cup.present"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchSampleLex,fetchSampleCup" />
|
||||
<target name="fetchDx" depends="dxPresent" unless="dx.present">
|
||||
<get src="http://central.maven.org/maven2/com/google/android/tools/dx/1.7/dx-1.7.jar" dest="${plugin.destination}/lib/dx-1.7.jar" />
|
||||
</target>
|
||||
|
||||
<target name="dxPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/dx-1.7.jar" property="dx.present"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchSampleLex,fetchSampleCup,fetchDx" />
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.ibm.wala</groupId>
|
||||
<artifactId>WALA</artifactId>
|
||||
<version>1.3.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.ibm.wala.dalvik.test</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>com.google.android.tools</groupId>
|
||||
<artifactId>dx</artifactId>
|
||||
<version>1.7</version>
|
||||
<type>jar</type>
|
||||
<overWrite>false</overWrite>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<outputDirectory>${basedir}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>test</phase>
|
||||
<configuration>
|
||||
<testClassesDirectory>${project.build.outputDirectory}</testClassesDirectory>
|
||||
<argLine>-Xmx800M -ea</argLine>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,8 +1,6 @@
|
|||
package com.ibm.wala.dalvik.drivers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
|
@ -10,107 +8,102 @@ import com.ibm.wala.dalvik.test.callGraph.DalvikCallGraphTestBase;
|
|||
import com.ibm.wala.ipa.callgraph.AnalysisOptions.ReflectionOptions;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
|
||||
import com.ibm.wala.util.Predicate;
|
||||
import com.ibm.wala.util.collections.HashSetFactory;
|
||||
import com.ibm.wala.util.functions.VoidFunction;
|
||||
import com.ibm.wala.util.io.FileUtil;
|
||||
|
||||
public class APKCallGraphDriver {
|
||||
private static int timeout = -1;
|
||||
|
||||
public static void main(String[] args) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException {
|
||||
File apk = new File(args[0]);
|
||||
try {
|
||||
public static void main(String[] args) {
|
||||
File apk = new File(args[0]);
|
||||
try {
|
||||
timeout = Integer.parseInt(args[1]);
|
||||
System.err.println("timeout is " + timeout);
|
||||
} catch (Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
// no timeout specified
|
||||
}
|
||||
recurseApks(apk);
|
||||
}
|
||||
}
|
||||
FileUtil.recurseFiles(new VoidFunction<File>() {
|
||||
|
||||
protected static void recurseApks(File apk) throws IOException,
|
||||
ClassHierarchyException, CancelException {
|
||||
if (apk.isDirectory()) {
|
||||
for(File f : apk.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith("apk") || new File(dir, name).isDirectory();
|
||||
}
|
||||
})) {
|
||||
recurseApks(f);
|
||||
}
|
||||
} else {
|
||||
doApk(apk);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void apply(File apk) {
|
||||
System.gc();
|
||||
System.err.println("Analyzing " + apk + "...");
|
||||
try {
|
||||
long time = System.currentTimeMillis();
|
||||
CallGraph CG;
|
||||
if (timeout == -1) {
|
||||
CG = DalvikCallGraphTestBase.makeAPKCallGraph(apk.getAbsolutePath()).fst;
|
||||
} else {
|
||||
final long startTime = System.currentTimeMillis();
|
||||
IProgressMonitor pm = new IProgressMonitor() {
|
||||
private boolean cancelled = false;
|
||||
|
||||
protected static void doApk(File apk) throws IOException,
|
||||
ClassHierarchyException, CancelException {
|
||||
System.gc();
|
||||
System.err.println("Analyzing " + apk + "...");
|
||||
try {
|
||||
long time = System.currentTimeMillis();
|
||||
CallGraph CG;
|
||||
if (timeout == -1) {
|
||||
CG = DalvikCallGraphTestBase.makeAPKCallGraph(apk.getAbsolutePath()).fst;
|
||||
} else {
|
||||
final long startTime = System.currentTimeMillis();
|
||||
IProgressMonitor pm = new IProgressMonitor() {
|
||||
private boolean cancelled = false;
|
||||
|
||||
@Override
|
||||
public void beginTask(String task, int totalWork) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void beginTask(String task, int totalWork) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subTask(String subTask) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void subTask(String subTask) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
}
|
||||
@Override
|
||||
public void cancel() {
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
if (System.currentTimeMillis() - startTime > timeout) {
|
||||
cancelled = true;
|
||||
}
|
||||
return cancelled;
|
||||
}
|
||||
@Override
|
||||
public boolean isCanceled() {
|
||||
if (System.currentTimeMillis() - startTime > timeout) {
|
||||
cancelled = true;
|
||||
}
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void done() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void worked(int units) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public void worked(int units) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelMessage() {
|
||||
return "timeout";
|
||||
}
|
||||
};
|
||||
CG = DalvikCallGraphTestBase.makeAPKCallGraph(apk.getAbsolutePath(), pm, ReflectionOptions.NONE).fst;
|
||||
}
|
||||
System.err.println("Analyzed " + apk + " in " + (System.currentTimeMillis() - time));
|
||||
|
||||
Set<IMethod> code = HashSetFactory.make();
|
||||
for(CGNode n : CG) {
|
||||
code.add(n.getMethod());
|
||||
}
|
||||
for(IMethod m : code) {
|
||||
System.err.println(m);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelMessage() {
|
||||
return "timeout";
|
||||
}
|
||||
};
|
||||
CG = DalvikCallGraphTestBase.makeAPKCallGraph(apk.getAbsolutePath(), pm, ReflectionOptions.NONE).fst;
|
||||
}
|
||||
System.err.println("Analyzed " + apk + " in " + (System.currentTimeMillis() - time));
|
||||
|
||||
Set<IMethod> code = HashSetFactory.make();
|
||||
for(CGNode n : CG) {
|
||||
code.add(n.getMethod());
|
||||
}
|
||||
System.err.println("reachable methods for " + apk);
|
||||
for(IMethod m : code) {
|
||||
System.err.println("" + m.getDeclaringClass().getName() + " " + m.getName() + m.getDescriptor());
|
||||
}
|
||||
System.err.println("end of methods");
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
},
|
||||
new Predicate<File>() {
|
||||
@Override
|
||||
public boolean test(File file) {
|
||||
return file.getName().endsWith("apk");
|
||||
}
|
||||
},
|
||||
apk);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -29,6 +32,7 @@ import java.util.Set;
|
|||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.JarFileModule;
|
||||
import com.ibm.wala.classLoader.Module;
|
||||
import com.ibm.wala.classLoader.NestedJarFileModule;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.shrike.DynamicCallGraphTestBase;
|
||||
|
@ -111,18 +115,26 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase {
|
|||
}
|
||||
|
||||
|
||||
protected static String getJavaJar(AnalysisScope javaScope) {
|
||||
protected static String getJavaJar(AnalysisScope javaScope) throws IOException {
|
||||
Module javaJar = javaScope.getModules(javaScope.getApplicationLoader()).iterator().next();
|
||||
assert javaJar instanceof JarFileModule;
|
||||
String javaJarPath = ((JarFileModule)javaJar).getAbsolutePath();
|
||||
return javaJarPath;
|
||||
if (javaJar instanceof JarFileModule) {
|
||||
String javaJarPath = ((JarFileModule)javaJar).getAbsolutePath();
|
||||
return javaJarPath;
|
||||
} else {
|
||||
assert javaJar instanceof NestedJarFileModule : javaJar;
|
||||
File F = File.createTempFile("android", ".jar");
|
||||
//F.deleteOnExit();
|
||||
System.err.println(F.getAbsolutePath());
|
||||
TemporaryFile.streamToFile(F, ((NestedJarFileModule)javaJar).getNestedContents());
|
||||
return F.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
public static File convertJarToDex(File jarFile) throws IOException, InterruptedException {
|
||||
public static File convertJarToDex(String jarFile) throws IOException, InterruptedException {
|
||||
File f = File.createTempFile("convert", ".dex");
|
||||
f.deleteOnExit();
|
||||
Process p = Runtime.getRuntime().exec(walaProperties.getProperty(ANDROID_DEX_TOOL) + " --dex --output=" + f.getAbsolutePath() + " " + jarFile.getAbsolutePath());
|
||||
p.waitFor();
|
||||
//f.deleteOnExit();
|
||||
System.err.println(f);
|
||||
com.android.dx.command.Main.main(new String[]{"--dex", "--output=" + f.getAbsolutePath(), jarFile});
|
||||
return f;
|
||||
}
|
||||
|
||||
|
@ -137,8 +149,12 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase {
|
|||
return makeAPKCallGraph(apkFileName, new NullProgressMonitor());
|
||||
}
|
||||
|
||||
public static Pair<CallGraph, PointerAnalysis<InstanceKey>> makeAPKCallGraph(String apkFileName, ReflectionOptions options) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
return makeAPKCallGraph(apkFileName, new NullProgressMonitor(), options);
|
||||
}
|
||||
|
||||
public static Pair<CallGraph, PointerAnalysis<InstanceKey>> makeAPKCallGraph(String apkFileName, IProgressMonitor monitor) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
return makeAPKCallGraph(apkFileName, monitor, ReflectionOptions.ONE_FLOW_TO_CASTS_APPLICATION_GET_METHOD);
|
||||
return makeAPKCallGraph(apkFileName, monitor, ReflectionOptions.NONE);
|
||||
}
|
||||
|
||||
private static SSAContextInterpreter makeDefaultInterpreter(AnalysisOptions options, AnalysisCache cache) {
|
||||
|
@ -171,6 +187,7 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase {
|
|||
AndroidAnalysisScope.setUpAndroidAnalysisScope(
|
||||
new File(apkFileName).toURI(),
|
||||
"AndroidRegressionExclusions.txt",
|
||||
CallGraphTestUtil.class.getClassLoader(),
|
||||
androidLibs());
|
||||
|
||||
final IClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
@ -200,16 +217,33 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase {
|
|||
}
|
||||
|
||||
public static URI[] androidLibs() {
|
||||
List<URI> libs = new ArrayList<URI>();
|
||||
for(File lib : new File(walaProperties.getProperty(ANDROID_RT_JAR)).listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith("dex");
|
||||
}
|
||||
})) {
|
||||
libs.add(lib.toURI());
|
||||
if ("Dalvik".equals(System.getProperty("java.vm.name"))) {
|
||||
try {
|
||||
return new URI[]{
|
||||
new URL("file:///system/framework/core.jar").toURI(),
|
||||
new URL("file:///system/framework/framework.jar").toURI(),
|
||||
new URL("file:///system/framework/framework2.jar").toURI(),
|
||||
new URL("file:///system/framework/framework3.jar").toURI()
|
||||
};
|
||||
} catch (MalformedURLException e) {
|
||||
assert false : e;
|
||||
return null;
|
||||
} catch (URISyntaxException e) {
|
||||
assert false : e;
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
List<URI> libs = new ArrayList<URI>();
|
||||
for(File lib : new File(walaProperties.getProperty(ANDROID_RT_JAR)).listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith("dex") || name.endsWith("jar");
|
||||
}
|
||||
})) {
|
||||
libs.add(lib.toURI());
|
||||
}
|
||||
return libs.toArray(new URI[ libs.size() ]);
|
||||
}
|
||||
return libs.toArray(new URI[ libs.size() ]);
|
||||
}
|
||||
|
||||
public static Pair<CallGraph, PointerAnalysis<InstanceKey>> makeDalvikCallGraph(boolean useAndroidLib, String mainClassName, String dexFileName) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
|
@ -218,10 +252,12 @@ public class DalvikCallGraphTestBase extends DynamicCallGraphTestBase {
|
|||
AndroidAnalysisScope.setUpAndroidAnalysisScope(
|
||||
new File(dexFileName).toURI(),
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS,
|
||||
CallGraphTestUtil.class.getClassLoader(),
|
||||
androidLibs()):
|
||||
AndroidAnalysisScope.setUpAndroidAnalysisScope(
|
||||
new File(dexFileName).toURI(),
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS,
|
||||
CallGraphTestUtil.class.getClassLoader());
|
||||
|
||||
final IClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ package com.ibm.wala.dalvik.test.callGraph;
|
|||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
@ -29,6 +30,7 @@ import org.junit.runners.Parameterized.Parameters;
|
|||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions.ReflectionOptions;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
|
@ -73,7 +75,7 @@ public class DroidBenchCGTest extends DalvikCallGraphTestBase {
|
|||
uncalledFunctions.put("Reflection_Reflection1.apk", x);
|
||||
}
|
||||
|
||||
private static final String droidBenchRoot = walaProperties.getProperty("droidbench.root");
|
||||
public static final String droidBenchRoot = walaProperties.getProperty("droidbench.root");
|
||||
|
||||
private void assertUserCodeReachable(CallGraph cg) throws InvalidClassFileException {
|
||||
for(Iterator<IClass> clss = cg.getClassHierarchy().getLoader(ClassLoaderReference.Application).iterateAllClasses();
|
||||
|
@ -104,9 +106,9 @@ public class DroidBenchCGTest extends DalvikCallGraphTestBase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test() throws IOException, ClassHierarchyException, CancelException, InvalidClassFileException {
|
||||
public void test() throws IOException, ClassHierarchyException, CancelException, InvalidClassFileException, IllegalArgumentException, URISyntaxException {
|
||||
System.err.println("testing " + apkFile + "...");
|
||||
Pair<CallGraph,PointerAnalysis<InstanceKey>> x = makeAPKCallGraph(apkFile);
|
||||
Pair<CallGraph,PointerAnalysis<InstanceKey>> x = makeAPKCallGraph(apkFile, ReflectionOptions.ONE_FLOW_TO_CASTS_APPLICATION_GET_METHOD);
|
||||
System.err.println(x.fst);
|
||||
assertUserCodeReachable(x.fst);
|
||||
System.err.println("...success testing " + apkFile);
|
||||
|
|
|
@ -32,12 +32,12 @@ import com.ibm.wala.util.Predicate;
|
|||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.io.TemporaryFile;
|
||||
|
||||
public class DynamicDalvikComparison extends DalvikCallGraphTestBase {
|
||||
public class DynamicDalvikComparisonTest extends DalvikCallGraphTestBase {
|
||||
|
||||
private void test(boolean useAndroidLib, String mainClass, String javaScopeFile, String... args) throws ClassHierarchyException, IllegalArgumentException, IOException, CancelException, InterruptedException, ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InvalidClassFileException, FailureException {
|
||||
AnalysisScope javaScope = CallGraphTestUtil.makeJ2SEAnalysisScope(javaScopeFile, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
String javaJarPath = getJavaJar(javaScope);
|
||||
File androidDex = convertJarToDex(new File(javaJarPath));
|
||||
File androidDex = convertJarToDex(javaJarPath);
|
||||
Pair<CallGraph,PointerAnalysis<InstanceKey>> android = makeDalvikCallGraph(useAndroidLib, mainClass, androidDex.getAbsolutePath());
|
||||
|
||||
dynamicCG(new File(javaJarPath), mainClass, args);
|
||||
|
|
|
@ -45,7 +45,7 @@ import com.ibm.wala.util.collections.Iterator2Collection;
|
|||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.intset.OrdinalSet;
|
||||
|
||||
public class JVMLDalvikComparison extends DalvikCallGraphTestBase {
|
||||
public class JVMLDalvikComparisonTest extends DalvikCallGraphTestBase {
|
||||
|
||||
private static Pair<CallGraph,PointerAnalysis<InstanceKey>> makeJavaBuilder(String scopeFile, String mainClass) throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(scopeFile, CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
|
@ -85,7 +85,7 @@ public class JVMLDalvikComparison extends DalvikCallGraphTestBase {
|
|||
|
||||
AnalysisScope javaScope = java.fst.getClassHierarchy().getScope();
|
||||
String javaJarPath = getJavaJar(javaScope);
|
||||
File androidDex = convertJarToDex(new File(javaJarPath));
|
||||
File androidDex = convertJarToDex(javaJarPath);
|
||||
Pair<CallGraph,PointerAnalysis<InstanceKey>> android = makeDalvikCallGraph(useAndroidLib, mainClass, androidDex.getAbsolutePath());
|
||||
|
||||
Set<MethodReference> androidMethods = applicationMethods(android.fst);
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project default="create_run_jar" name="Create Runnable Jar for Project com.ibm.wala.dalvik.test">
|
||||
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
|
||||
<!--ANT 1.7 is required -->
|
||||
<target name="create_run_jar">
|
||||
<jar destfile="/tmp/cgs.jar" filesetmanifest="mergewithoutmain">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="com.ibm.wala.dalvik.drivers.APKCallGraphDriver"/>
|
||||
<attribute name="Class-Path" value="."/>
|
||||
</manifest>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.core.runtime_3.10.0.v20140318-2214.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/javax.annotation_1.2.0.v201401042248.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/javax.inject_1.0.0.v20091030.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.osgi_3.10.0.v20140606-1445.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.osgi.compatibility.state_1.0.0.v20140403-1907.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.core.jobs_3.6.0.v20140424-0053.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.core.runtime.compatibility.registry_3.5.300.v20140128-0851/runtime_registry_compatibility.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.equinox.registry_3.5.400.v20140428-1507.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.equinox.preferences_3.5.200.v20140224-1527.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.core.contenttype_3.4.200.v20140207-1251.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.equinox.app_1.3.200.v20130910-1609.jar"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.core.testdata/bin"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.util/bin"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.shrike/bin"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.core/bin"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.junit_4.11.0.v201303080030/junit.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-antlr.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-bcel.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-bsf.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-log4j.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-oro.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-regexp.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-resolver.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-apache-xalan2.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-commons-logging.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-commons-net.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-jai.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-javamail.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-jdepend.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-jmf.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-jsch.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-junit.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-junit4.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-launcher.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-netrexx.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-swing.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant-testutil.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.apache.ant_1.9.2.v201404171502/lib/ant.jar"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.core.tests/bin"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.dalvik/bin"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.cast/bin"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.cast/lib/commons-io-2.4.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.pde.core_3.10.1.v20140902-1534.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.jface_3.10.0.v20140604-0740.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.swt_3.103.0.v20140605-2008.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.swt.cocoa.macosx.x86_64_3.103.0.v20140605-2012.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.core.commands_3.6.100.v20140528-1422.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.ui_3.106.0.v20140519-0906.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.ui.workbench_3.106.0.v20140530-0732.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.e4.ui.workbench3_0.12.0.v20140227-2118.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.core.resources_3.9.0.v20140514-1307.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.jdt.core_3.10.0.v20140902-0626.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.jdt.compiler.apt_1.1.0.v20140509-1235.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.jdt.compiler.tool_1.0.300.v20140311-1758.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.ui.ide_3.10.0.v20140521-1937.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.ui.views_3.7.0.v20140408-0703.jar"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.ide/bin"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/commons-cli-1.2.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/commons-io-2.4.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/logback-classic-1.0.9.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/logback-core-1.0.9.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/slf4j-api-1.7.2.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/guava-13.0.1.jar"/>
|
||||
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/dexlib-1.3.4-dev.jar"/>
|
||||
<fileset dir="/Users/dolby/git/WALA/com.ibm.wala.dalvik.test/bin"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
|
@ -71,6 +71,7 @@ import org.jf.dexlib.FieldIdItem;
|
|||
import org.jf.dexlib.MethodIdItem;
|
||||
import org.jf.dexlib.StringIdItem;
|
||||
import org.jf.dexlib.TypeIdItem;
|
||||
import org.jf.dexlib.Code.InstructionWithReference;
|
||||
import org.jf.dexlib.Code.Opcode;
|
||||
import org.jf.dexlib.Code.TwoRegisterInstruction;
|
||||
import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction;
|
||||
|
@ -1431,10 +1432,10 @@ public class DexIMethod implements IBytecodeMethod {
|
|||
case IPUT_BYTE:
|
||||
case IPUT_CHAR:
|
||||
case IPUT_SHORT: {
|
||||
logger.debug(inst.opcode.toString() + " class: "+((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", field name: " + ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getFieldName().getStringValue() + ", field type: " + ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getFieldType().getTypeDescriptor());
|
||||
String cname = ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
|
||||
String fname = ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getFieldName().getStringValue();
|
||||
String ftname = ((FieldIdItem)((Instruction22c)inst).getReferencedItem()).getFieldType().getTypeDescriptor();
|
||||
logger.debug(inst.opcode.toString() + " class: "+((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", field name: " + ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getFieldName().getStringValue() + ", field type: " + ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getFieldType().getTypeDescriptor());
|
||||
String cname = ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
|
||||
String fname = ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getFieldName().getStringValue();
|
||||
String ftname = ((FieldIdItem)((InstructionWithReference)inst).getReferencedItem()).getFieldType().getTypeDescriptor();
|
||||
|
||||
if (cname.endsWith(";"))
|
||||
cname = cname.substring(0,cname.length()-1);
|
||||
|
@ -1444,7 +1445,7 @@ public class DexIMethod implements IBytecodeMethod {
|
|||
ftname = ftname.substring(0,ftname.length()-1);
|
||||
|
||||
instructions.add(new PutField.PutInstanceField(
|
||||
instLoc, ((Instruction22c)inst).getRegisterA(), ((Instruction22c)inst).getRegisterB(),
|
||||
instLoc, ((TwoRegisterInstruction)inst).getRegisterA(), ((TwoRegisterInstruction)inst).getRegisterB(),
|
||||
cname, fname, ftname, inst.opcode, this));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -987,6 +987,9 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
|
|||
emitInstruction(insts.NewInstruction(getCurrentInstructionIndex(), result, instruction.newSiteRef, sizes));
|
||||
setLocal(dest, result);
|
||||
|
||||
/*
|
||||
* we need to emit these instructions somehow, but for now this clobbers the emitInstruction mechanism
|
||||
*
|
||||
for (int i = 0; i < instruction.args.length; i++)
|
||||
{
|
||||
int value = workingState.getLocal(instruction.args[i]);
|
||||
|
@ -995,7 +998,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
|
|||
TypeReference t = instruction.myType;
|
||||
emitInstruction(insts.ArrayStoreInstruction(getCurrentInstructionIndex(), arrayRef, index, value, t));
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,14 +28,12 @@ import com.ibm.wala.util.io.FileProvider;
|
|||
|
||||
public class AndroidAnalysisScope {
|
||||
|
||||
private static final ClassLoader WALA_CLASSLOADER = AnalysisScopeReader.class.getClassLoader();
|
||||
private static final String BASIC_FILE = "primordial.txt";
|
||||
|
||||
private static final String BASIC_FILE = "./primordial.txt";
|
||||
|
||||
public static AnalysisScope setUpAndroidAnalysisScope(URI classpath, String exclusions, URI... androidLib) throws IOException {
|
||||
public static AnalysisScope setUpAndroidAnalysisScope(URI classpath, String exclusions, ClassLoader loader, URI... androidLib) throws IOException {
|
||||
AnalysisScope scope;
|
||||
if (androidLib == null || androidLib.length == 0) {
|
||||
scope = AnalysisScopeReader.readJavaScope(BASIC_FILE, new File(exclusions), WALA_CLASSLOADER);
|
||||
scope = AnalysisScopeReader.readJavaScope(BASIC_FILE, new File(exclusions), loader);
|
||||
} else {
|
||||
scope = AnalysisScope.createJavaAnalysisScope();
|
||||
|
||||
|
|
|
@ -61,7 +61,8 @@ public class JDTJavaIRTests extends JavaIRTests {
|
|||
private JDTJavaIRTests(ZippedProjectData project) {
|
||||
super(project.projectName);
|
||||
this.project = project;
|
||||
}
|
||||
this.dump = Boolean.parseBoolean(System.getProperty("wala.cast.dump", "false"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractAnalysisEngine getAnalysisEngine(final String[] mainClassDescriptors, Collection<String> sources, List<String> libs) {
|
||||
|
|
|
@ -41,6 +41,7 @@ public abstract class JDTJavaTest extends IRTests {
|
|||
public JDTJavaTest(ZippedProjectData project) {
|
||||
super(project.projectName);
|
||||
this.project = project;
|
||||
this.dump = Boolean.parseBoolean(System.getProperty("wala.cast.dump", "false"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +53,10 @@ public abstract class JDTJavaTest extends IRTests {
|
|||
AbstractAnalysisEngine engine;
|
||||
try {
|
||||
engine = new JDTJavaSourceAnalysisEngine(project.projectName) {
|
||||
{
|
||||
setDump(Boolean.parseBoolean(System.getProperty("wala.cast.dump", "false")));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Entrypoint> makeDefaultEntrypoints(AnalysisScope scope, IClassHierarchy cha) {
|
||||
return Util.makeMainEntrypoints(JavaSourceAnalysisScope.SOURCE, cha, mainClassDescriptors);
|
||||
|
|
|
@ -62,7 +62,8 @@ import com.ibm.wala.types.ClassLoaderReference;
|
|||
import com.ibm.wala.util.config.SetOfClasses;
|
||||
|
||||
public class JDTJavaSourceAnalysisEngine extends EclipseProjectSourceAnalysisEngine<IJavaProject> {
|
||||
|
||||
private boolean dump;
|
||||
|
||||
public JDTJavaSourceAnalysisEngine(IJavaProject project) throws IOException, CoreException {
|
||||
super(project);
|
||||
}
|
||||
|
@ -71,9 +72,13 @@ public class JDTJavaSourceAnalysisEngine extends EclipseProjectSourceAnalysisEng
|
|||
this(JdtUtil.getNamedProject(projectName));
|
||||
}
|
||||
|
||||
public void setDump(boolean dump) {
|
||||
this.dump = dump;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassLoaderFactory makeClassLoaderFactory(SetOfClasses exclusions) {
|
||||
return new JDTClassLoaderFactory(exclusions);
|
||||
return new JDTClassLoaderFactory(exclusions, dump);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,8 @@ import com.ibm.wala.types.ClassLoaderReference;
|
|||
import com.ibm.wala.util.config.SetOfClasses;
|
||||
|
||||
public class JDTClassLoaderFactory extends ClassLoaderFactoryImpl {
|
||||
|
||||
private boolean dump;
|
||||
|
||||
// /**
|
||||
// * A map from ClassLoaderReference to IRTranslatorExtension, so that source files
|
||||
// * in different languages are processed by the right kind of IRTranslatorExtension.
|
||||
|
@ -57,7 +58,12 @@ public class JDTClassLoaderFactory extends ClassLoaderFactoryImpl {
|
|||
// that's nice, but there's only one kind of IRTransatorExtension.
|
||||
|
||||
public JDTClassLoaderFactory(SetOfClasses exclusions) {
|
||||
this(exclusions, false);
|
||||
}
|
||||
|
||||
public JDTClassLoaderFactory(SetOfClasses exclusions, boolean dump) {
|
||||
super(exclusions);
|
||||
this.dump = dump;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,6 +80,6 @@ public class JDTClassLoaderFactory extends ClassLoaderFactoryImpl {
|
|||
|
||||
protected JDTSourceLoaderImpl makeSourceLoader(ClassLoaderReference classLoaderReference, IClassHierarchy cha, IClassLoader parent)
|
||||
throws IOException {
|
||||
return new JDTSourceLoaderImpl(classLoaderReference, parent, getExclusions(), cha);
|
||||
return new JDTSourceLoaderImpl(classLoaderReference, parent, getExclusions(), cha, dump);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
*/
|
||||
package com.ibm.wala.cast.java.translator.jdt;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -150,6 +151,7 @@ import com.ibm.wala.cast.tree.impl.CAstNodeTypeMapRecorder;
|
|||
import com.ibm.wala.cast.tree.impl.CAstOperator;
|
||||
import com.ibm.wala.cast.tree.impl.CAstSourcePositionRecorder;
|
||||
import com.ibm.wala.cast.tree.impl.CAstSymbolImpl;
|
||||
import com.ibm.wala.cast.util.CAstPrinter;
|
||||
import com.ibm.wala.classLoader.CallSiteReference;
|
||||
import com.ibm.wala.ide.util.JdtPosition;
|
||||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||
|
@ -181,6 +183,8 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class JDTJava2CAstTranslator {
|
||||
protected boolean dump = false;
|
||||
|
||||
protected final CAst fFactory = new CAstImpl();
|
||||
|
||||
// ///////////////////////////////////////////
|
||||
|
@ -221,6 +225,10 @@ public class JDTJava2CAstTranslator {
|
|||
//
|
||||
|
||||
public JDTJava2CAstTranslator(JavaSourceLoaderImpl sourceLoader, CompilationUnit astRoot, IFile sourceFile, String fullPath, boolean replicateForDoLoops) {
|
||||
this(sourceLoader, astRoot, sourceFile, fullPath, replicateForDoLoops, false);
|
||||
}
|
||||
|
||||
public JDTJava2CAstTranslator(JavaSourceLoaderImpl sourceLoader, CompilationUnit astRoot, IFile sourceFile, String fullPath, boolean replicateForDoLoops, boolean dump) {
|
||||
fDivByZeroExcType = FakeExceptionTypeBinding.arithmetic;
|
||||
fNullPointerExcType = FakeExceptionTypeBinding.nullPointer;
|
||||
fClassCastExcType = FakeExceptionTypeBinding.classCast;
|
||||
|
@ -236,6 +244,8 @@ public class JDTJava2CAstTranslator {
|
|||
ast = cu.getAST();
|
||||
|
||||
this.doLoopTranslator = new DoLoopTranslator(replicateForDoLoops, fFactory);
|
||||
|
||||
this.dump = dump;
|
||||
|
||||
// FIXME: we might need one AST (-> "Object" class) for all files.
|
||||
fIdentityMapper = new JDTIdentityMapper(fSourceLoader.getReference(), ast);
|
||||
|
@ -255,6 +265,12 @@ public class JDTJava2CAstTranslator {
|
|||
declEntities.add(visit(decl, new RootContext()));
|
||||
}
|
||||
|
||||
if (dump) {
|
||||
for(CAstEntity d : declEntities) {
|
||||
CAstPrinter.printTo(d, new PrintWriter(System.err));
|
||||
}
|
||||
}
|
||||
|
||||
return new CompilationUnitEntity(cu.getPackage(), declEntities);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,14 +47,19 @@ import com.ibm.wala.types.ClassLoaderReference;
|
|||
import com.ibm.wala.util.config.SetOfClasses;
|
||||
|
||||
public class JDTSourceLoaderImpl extends JavaSourceLoaderImpl {
|
||||
private final boolean dump;
|
||||
|
||||
public JDTSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha)
|
||||
throws IOException {
|
||||
public JDTSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha) throws IOException {
|
||||
this(loaderRef, parent, exclusions, cha, false);
|
||||
}
|
||||
|
||||
public JDTSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, SetOfClasses exclusions, IClassHierarchy cha, boolean dump) throws IOException {
|
||||
super(loaderRef, parent, exclusions, cha);
|
||||
this.dump = dump;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SourceModuleTranslator getTranslator() {
|
||||
return new JDTSourceModuleTranslator(cha.getScope(), this);
|
||||
return new JDTSourceModuleTranslator(cha.getScope(), this, dump);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,11 +74,17 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
*/
|
||||
// remove me comment: Jdt little-case = not OK, upper case = OK
|
||||
public class JDTSourceModuleTranslator implements SourceModuleTranslator {
|
||||
protected boolean dump;
|
||||
protected JDTSourceLoaderImpl sourceLoader;
|
||||
|
||||
public JDTSourceModuleTranslator(AnalysisScope scope, JDTSourceLoaderImpl sourceLoader) {
|
||||
this(scope, sourceLoader, false);
|
||||
}
|
||||
|
||||
public JDTSourceModuleTranslator(AnalysisScope scope, JDTSourceLoaderImpl sourceLoader, boolean dump) {
|
||||
computeClassPath(scope);
|
||||
this.sourceLoader = sourceLoader;
|
||||
this.dump = dump;
|
||||
}
|
||||
|
||||
private void computeClassPath(AnalysisScope scope) {
|
||||
|
@ -173,7 +179,7 @@ public class JDTSourceModuleTranslator implements SourceModuleTranslator {
|
|||
}
|
||||
|
||||
protected JDTJava2CAstTranslator makeCAstTranslator(CompilationUnit cu, IFile sourceFile, String fullPath) {
|
||||
return new JDTJava2CAstTranslator(sourceLoader, cu, sourceFile, fullPath, false);
|
||||
return new JDTJava2CAstTranslator(sourceLoader, cu, sourceFile, fullPath, false, dump);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class AndroidAnalysisContext {
|
|||
ClassHierarchyException, URISyntaxException {
|
||||
logger.debug(DefaultSCanDroidOptions.dumpString(options));
|
||||
this.options = options;
|
||||
scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(options.getClasspath(), exclusions, options.getAndroidLibrary());
|
||||
scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(options.getClasspath(), exclusions, getClass().getClassLoader(), options.getAndroidLibrary());
|
||||
|
||||
cha = ClassHierarchy.make(scope);
|
||||
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -18,7 +18,6 @@
|
|||
<modules>
|
||||
<module>targets</module>
|
||||
|
||||
|
||||
<module>com.ibm.wala-feature</module>
|
||||
<module>com.ibm.wala.core</module>
|
||||
<module>com.ibm.wala.shrike</module>
|
||||
|
@ -27,6 +26,10 @@
|
|||
<module>com.ibm.wala.core.testdata</module>
|
||||
<module>com.ibm.wala.core.tests</module>
|
||||
|
||||
<module>com.ibm.wala.dalvik</module>
|
||||
<module>com.ibm.wala.dalvik.test</module>
|
||||
<module>com.ibm.wala.scandroid</module>
|
||||
|
||||
<module>com.ibm.wala.cast</module>
|
||||
<module>com.ibm.wala.cast.test</module>
|
||||
<module>com.ibm.wala.cast.java</module>
|
||||
|
@ -49,9 +52,6 @@
|
|||
<module>com.ibm.wala.ide.jsdt.tests</module>
|
||||
<module>com.ibm.wala.ide.jdt.test</module>
|
||||
|
||||
<module>com.ibm.wala.dalvik</module>
|
||||
<module>com.ibm.wala.scandroid</module>
|
||||
|
||||
<module>com.ibm.wala-repository</module>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue