1) changes for mobile

a) serializable added for use by Android services
  b) test classes refactored to allow Android variants to use JUnit 3
2) shrike instrumentation now uses java.lang.instrument
  a) refactoring
  b) online variants of call graph tracing
This commit is contained in:
Julian Dolby 2015-05-25 19:00:51 -04:00
parent 125c8fa684
commit 63ec46f67d
117 changed files with 853 additions and 1444 deletions

View File

@ -15,7 +15,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
import com.ibm.wala.classLoader.BytecodeClass;
@ -39,6 +38,12 @@ import com.ibm.wala.util.strings.Atom;
public abstract class AnnotationTest extends WalaTestCase {
protected abstract void assertEquals(Object findOrCreate, Object type);
protected abstract void assertNotNull(String string, Object classUnderTest);
protected abstract void assertTrue(String x, boolean b);
private final IClassHierarchy cha;
protected AnnotationTest(IClassHierarchy cha) {
@ -85,8 +90,8 @@ public abstract class AnnotationTest extends WalaTestCase {
Collection<Annotation> expectedRuntimeVisibleAnnotations) throws IOException, ClassHierarchyException,
InvalidClassFileException {
IClass classUnderTest = cha.lookupClass(typeUnderTest);
Assert.assertNotNull(typeUnderTest.toString() + " not found", classUnderTest);
Assert.assertTrue(classUnderTest instanceof BytecodeClass);
assertNotNull(typeUnderTest.toString() + " not found", classUnderTest);
assertTrue(classUnderTest + " must be BytecodeClass", classUnderTest instanceof BytecodeClass);
BytecodeClass<?> bcClassUnderTest = (BytecodeClass<?>) classUnderTest;
Collection<Annotation> runtimeInvisibleAnnotations = bcClassUnderTest.getAnnotations(true);
@ -105,10 +110,10 @@ public abstract class AnnotationTest extends WalaTestCase {
}
if (expected.size() != actual.size()) {
Assert.assertTrue("expected=" + expected + " actual=" + actual, false);
assertTrue("expected=" + expected + " actual=" + actual, false);
}
for (T a : expected) {
Assert.assertTrue("missing " + a.toString(), actual.contains(a));
assertTrue("missing " + a.toString(), actual.contains(a));
}
}
@ -118,34 +123,34 @@ public abstract class AnnotationTest extends WalaTestCase {
TypeReference typeRef = TypeReference.findOrCreate(ClassLoaderReference.Application, "Lannotations/AnnotatedClass3");
IClass klass = cha.lookupClass(typeRef);
Assert.assertNotNull(klass);
assertNotNull(typeRef + " must exist", klass);
BytecodeClass<?> shrikeClass = (BytecodeClass<?>) klass;
Collection<Annotation> classAnnotations = shrikeClass.getAnnotations(true);
Assert.assertEquals("[Annotation type <Application,Lannotations/AnnotationWithParams> {strParam=classStrParam}]",
assertEquals("[Annotation type <Application,Lannotations/AnnotationWithParams> {strParam=classStrParam}]",
classAnnotations.toString());
MethodReference methodRefUnderTest = MethodReference.findOrCreate(typeRef, Selector.make("foo()V"));
IMethod methodUnderTest = cha.resolveMethod(methodRefUnderTest);
Assert.assertNotNull(methodRefUnderTest.toString() + " not found", methodUnderTest);
Assert.assertTrue(methodUnderTest instanceof IBytecodeMethod);
assertNotNull(methodRefUnderTest.toString() + " not found", methodUnderTest);
assertTrue(methodUnderTest + " must be IBytecodeMethod", methodUnderTest instanceof IBytecodeMethod);
IBytecodeMethod bcMethodUnderTest = (IBytecodeMethod) methodUnderTest;
Collection<Annotation> runtimeInvisibleAnnotations = bcMethodUnderTest.getAnnotations(true);
Assert.assertEquals(1, runtimeInvisibleAnnotations.size());
assertEquals(1, runtimeInvisibleAnnotations.size());
Annotation x = runtimeInvisibleAnnotations.iterator().next();
Assert.assertEquals(TypeReference.findOrCreate(ClassLoaderReference.Application, "Lannotations/AnnotationWithParams"), x.getType());
assertEquals(TypeReference.findOrCreate(ClassLoaderReference.Application, "Lannotations/AnnotationWithParams"), x.getType());
for(Pair<String,String> n : new Pair[]{Pair.make("enumParam", "EnumElementValue [type=Lannotations/AnnotationEnum;, val=VAL1]"),
Pair.make("strArrParam", "ArrayElementValue [vals=[biz, boz]]"),
Pair.make("annotParam", "AnnotationElementValue [type=Lannotations/AnnotationWithSingleParam;, elementValues={value=sdfevs}]"),
Pair.make("strParam", "sdfsevs"),
Pair.make("intParam", "25"),
Pair.make("klassParam", "Ljava/lang/Integer;")}) {
Assert.assertEquals(n.snd, x.getNamedArguments().get(n.fst).toString());
assertEquals(n.snd, x.getNamedArguments().get(n.fst).toString());
}
}
@Test
public void testClassAnnotations4() throws Exception {
@ -153,11 +158,10 @@ public abstract class AnnotationTest extends WalaTestCase {
FieldReference fieldRefUnderTest = FieldReference.findOrCreate(typeRef, Atom.findOrCreateUnicodeAtom("foo"), TypeReference.Int);
IField fieldUnderTest = cha.resolveField(fieldRefUnderTest);
Assert.assertNotNull(fieldRefUnderTest.toString() + " not found", fieldUnderTest);
assertNotNull(fieldRefUnderTest.toString() + " not found", fieldUnderTest);
Collection<Annotation> annots = fieldUnderTest.getAnnotations();
Assert
.assertEquals(
assertEquals(
"[Annotation type <Application,Lannotations/RuntimeInvisableAnnotation>, Annotation type <Application,Lannotations/RuntimeVisableAnnotation>]",
annots.toString());
@ -185,17 +189,17 @@ public abstract class AnnotationTest extends WalaTestCase {
new String[0]);
}
protected void checkParameterAnnots(TypeReference typeRef, String selector, String[]... expected) {
MethodReference methodRefUnderTest = MethodReference.findOrCreate(typeRef, Selector.make(selector));
IMethod methodUnderTest = cha.resolveMethod(methodRefUnderTest);
Assert.assertNotNull(methodRefUnderTest.toString() + " not found", methodUnderTest);
Assert.assertTrue(methodUnderTest instanceof IBytecodeMethod);
assertTrue(methodRefUnderTest.toString() + " not found", methodUnderTest != null);
assertTrue(methodUnderTest + " must be bytecode method", methodUnderTest instanceof IBytecodeMethod);
IBytecodeMethod IBytecodeMethodUnderTest = (IBytecodeMethod) methodUnderTest;
Collection<Annotation>[] parameterAnnotations = IBytecodeMethodUnderTest.getParameterAnnotations();
Assert.assertEquals(expected.length, parameterAnnotations.length);
assertEquals(expected.length, parameterAnnotations.length);
for (int i = 0; i < expected.length; i++) {
Set<String> e = HashSetFactory.make();
for(String s : expected[i]) {
@ -209,7 +213,7 @@ public abstract class AnnotationTest extends WalaTestCase {
}
}
Assert.assertEquals(e, a);
assertTrue(e + " must be " + a, e.equals(a));
}
}

View File

@ -2,6 +2,8 @@ package com.ibm.wala.core.tests.ir;
import java.io.IOException;
import org.junit.Assert;
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
import com.ibm.wala.core.tests.util.TestConstants;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
@ -26,4 +28,19 @@ public class JVMLAnnotationTest extends AnnotationTest {
public JVMLAnnotationTest() throws ClassHierarchyException, IOException {
super(makeCHA());
}
@Override
protected void assertEquals(Object a, Object b) {
Assert.assertEquals(a, b);
}
@Override
protected void assertNotNull(String msg, Object obj) {
Assert.assertNotNull(msg, obj);
}
@Override
protected void assertTrue(String x, boolean b) {
Assert.assertTrue(x, b);
}
}

View File

@ -30,7 +30,7 @@ import com.ibm.wala.core.tests.util.WalaTestCase;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.properties.WalaProperties;
import com.ibm.wala.shrike.cg.DynamicCallGraph;
import com.ibm.wala.shrike.cg.OfflineDynamicCallGraph;
import com.ibm.wala.shrikeBT.analysis.Analyzer.FailureException;
import com.ibm.wala.shrikeCT.InvalidClassFileException;
import com.ibm.wala.types.ClassLoaderReference;
@ -80,7 +80,7 @@ public abstract class DynamicCallGraphTestBase extends WalaTestCase {
}
}
DynamicCallGraph.main(
OfflineDynamicCallGraph.main(
rtJar == null?
new String[]{testJarLocation, "-o", instrumentedJarLocation}:
new String[]{testJarLocation, "-o", instrumentedJarLocation, "--rt-jar", rtJar});

View File

@ -1,22 +1,13 @@
eclipse.preferences.version=1
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
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.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
@ -72,7 +63,6 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0

View File

@ -4,3 +4,4 @@ output.. = bin/
bin.includes = META-INF/,\
lib/dx.jar
jars.extra.classpath = lib/dx.jar
jre.compilation.profile = JavaSE-1.7

View File

@ -1,8 +1,11 @@
package com.ibm.wala.dalvik.drivers;
import java.io.File;
import java.net.URI;
import java.util.Collections;
import java.util.Set;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.dalvik.test.DalvikTestBase;
import com.ibm.wala.dalvik.test.callGraph.DalvikCallGraphTestBase;
@ -18,6 +21,23 @@ import com.ibm.wala.util.io.FileUtil;
public class APKCallGraphDriver {
private static int timeout = -1;
private static URI[] libs() {
File f = new File("libs");
if (f.exists() && f.isDirectory()) {
Set<URI> libs = HashSetFactory.make();
for(File l : f.listFiles()) {
String name = l.getName();
if (name.endsWith("jar") || name.endsWith("dex")) {
libs.add(l.toURI());
}
}
return libs.toArray(new URI[ libs.size() ]);
}
return DalvikTestBase.androidLibs();
}
public static void main(String[] args) {
File apk = new File(args[0]);
try {
@ -77,18 +97,26 @@ public class APKCallGraphDriver {
return "timeout";
}
};
CG = DalvikCallGraphTestBase.makeAPKCallGraph(DalvikTestBase.androidLibs(), null, apk.getAbsolutePath(), pm, ReflectionOptions.NONE).fst;
CG = DalvikCallGraphTestBase.makeAPKCallGraph(libs(), null, 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());
for(IClass cls : CG.getClassHierarchy()) {
for(IMethod m : cls.getDeclaredMethods()) {
if (m.isAbstract() && !Collections.disjoint(CG.getClassHierarchy().getPossibleTargets(m.getReference()), code)) {
code.add(m);
}
}
}
System.err.println("end of methods");
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);

View File

@ -11,9 +11,7 @@
package com.ibm.wala.dalvik.test.callGraph;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@ -31,12 +29,10 @@ 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;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.shrikeCT.InvalidClassFileException;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.NullProgressMonitor;
import com.ibm.wala.util.Predicate;
import com.ibm.wala.util.collections.HashMapFactory;
@ -127,10 +123,10 @@ public abstract class DroidBenchCGTest extends DalvikCallGraphTestBase {
}
@Test
public void runTest() throws IOException, ClassHierarchyException, CancelException, InvalidClassFileException, IllegalArgumentException, URISyntaxException {
public void runTest() throws Exception {
System.err.println("testing " + apkFile + "...");
Pair<CallGraph,PointerAnalysis<InstanceKey>> x = makeAPKCallGraph(androidLibs, androidJavaJar, apkFile, new NullProgressMonitor(), ReflectionOptions.ONE_FLOW_TO_CASTS_APPLICATION_GET_METHOD);
//System.err.println(x.fst);
// System.err.println(x.fst);
Set<IMethod> bad = assertUserCodeReachable(x.fst, uncalled);
assertion(bad + " should be empty", bad.isEmpty());
System.err.println("...success testing " + apkFile);
@ -174,7 +170,7 @@ public abstract class DroidBenchCGTest extends DalvikCallGraphTestBase {
}, new Predicate<File>() {
@Override
public boolean test(File t) {
return t.getAbsolutePath().contains(filter) && t.getName().endsWith("apk") && ! skipTests.contains(t.getName().toString());
return (filter == null || t.getAbsolutePath().contains(filter)) && t.getName().endsWith("apk") && ! skipTests.contains(t.getName().toString());
} }, new File(droidBenchRoot + "/apk/"));
return files;
}

View File

@ -5,8 +5,9 @@ import static com.ibm.wala.dalvik.test.DalvikTestBase.convertJarToDex;
import java.io.File;
import java.io.IOException;
import org.junit.Assert;
import com.ibm.wala.core.tests.ir.AnnotationTest;
import com.ibm.wala.core.tests.ir.JVMLAnnotationTest;
import com.ibm.wala.dalvik.test.DalvikTestBase;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.cha.ClassHierarchy;
@ -18,7 +19,7 @@ import com.ibm.wala.util.io.TemporaryFile;
public class DalvikAnnotationsTest extends AnnotationTest {
public static void main(String[] args) {
justThisTest(JVMLAnnotationTest.class);
justThisTest(DalvikAnnotationsTest.class);
}
private static IClassHierarchy makeCHA() throws IOException, ClassHierarchyException {
@ -33,4 +34,20 @@ public class DalvikAnnotationsTest extends AnnotationTest {
public DalvikAnnotationsTest() throws ClassHierarchyException, IOException {
super(makeCHA());
}
@Override
protected void assertEquals(Object a, Object b) {
Assert.assertEquals(a, b);
}
@Override
protected void assertNotNull(String msg, Object obj) {
Assert.assertNotNull(msg, obj);
}
@Override
protected void assertTrue(String x, boolean b) {
Assert.assertTrue(x, b);
}
}

View File

@ -5,9 +5,6 @@
<classpathentry exported="true" kind="lib" path="lib/guava-13.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-cli-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-io-2.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/logback-classic-1.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/logback-core-1.0.9.jar"/>
<classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.7.2.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>

View File

@ -9,60 +9,7 @@ Require-Bundle: com.ibm.wala.cast;bundle-version="1.0.0",
com.ibm.wala.shrike;bundle-version="1.3.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: ch.qos.logback.classic,
ch.qos.logback.classic.boolex,
ch.qos.logback.classic.db,
ch.qos.logback.classic.db.names,
ch.qos.logback.classic.encoder,
ch.qos.logback.classic.filter,
ch.qos.logback.classic.gaffer,
ch.qos.logback.classic.helpers,
ch.qos.logback.classic.html,
ch.qos.logback.classic.jmx,
ch.qos.logback.classic.joran,
ch.qos.logback.classic.joran.action,
ch.qos.logback.classic.jul,
ch.qos.logback.classic.log4j,
ch.qos.logback.classic.net,
ch.qos.logback.classic.pattern,
ch.qos.logback.classic.pattern.color,
ch.qos.logback.classic.selector,
ch.qos.logback.classic.selector.servlet,
ch.qos.logback.classic.sift,
ch.qos.logback.classic.spi,
ch.qos.logback.classic.turbo,
ch.qos.logback.classic.util,
ch.qos.logback.core,
ch.qos.logback.core.boolex,
ch.qos.logback.core.db,
ch.qos.logback.core.db.dialect,
ch.qos.logback.core.encoder,
ch.qos.logback.core.filter,
ch.qos.logback.core.helpers,
ch.qos.logback.core.html,
ch.qos.logback.core.joran,
ch.qos.logback.core.joran.action,
ch.qos.logback.core.joran.conditional,
ch.qos.logback.core.joran.event,
ch.qos.logback.core.joran.spi,
ch.qos.logback.core.joran.util,
ch.qos.logback.core.layout,
ch.qos.logback.core.net,
ch.qos.logback.core.pattern,
ch.qos.logback.core.pattern.color,
ch.qos.logback.core.pattern.parser,
ch.qos.logback.core.pattern.util,
ch.qos.logback.core.property,
ch.qos.logback.core.read,
ch.qos.logback.core.recovery,
ch.qos.logback.core.rolling,
ch.qos.logback.core.rolling.helper,
ch.qos.logback.core.sift,
ch.qos.logback.core.spi,
ch.qos.logback.core.status,
ch.qos.logback.core.subst,
ch.qos.logback.core.util,
com.google.common.annotations,
Export-Package: com.google.common.annotations,
com.google.common.base,
com.google.common.base.internal,
com.google.common.cache,
@ -100,18 +47,11 @@ Export-Package: ch.qos.logback.classic,
org.jf.dexlib.Code.Format,
org.jf.dexlib.Debug,
org.jf.dexlib.EncodedValue,
org.jf.dexlib.Util,
org.slf4j,
org.slf4j.helpers,
org.slf4j.impl,
org.slf4j.spi
org.jf.dexlib.Util
Bundle-ClassPath: dalvik.jar,
lib/commons-cli-1.2.jar,
lib/commons-io-2.4.jar,
lib/commons-lang3-3.1.jar,
lib/dexlib-1.3.4.jar,
lib/logback-classic-1.0.9.jar,
lib/logback-core-1.0.9.jar,
lib/slf4j-api-1.7.2.jar,
lib/guava-13.0.1.jar

View File

@ -52,6 +52,13 @@
<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"/>
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/git/WALA/com.ibm.wala.dalvik/lib/dexlib-1.3.4.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/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"/>
<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.2.v20150127-1015.jar"/>
@ -71,13 +78,6 @@
<zipfileset excludes="META-INF/*.SF" src="/Users/dolby/eclipse-luna/plugins/org.eclipse.jdt.launching_3.7.102.v20141111-0953.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/dexlib-1.3.4.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/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"/>
</jar>
</target>
</project>

View File

@ -55,8 +55,6 @@ import org.jf.dexlib.ClassDefItem;
import org.jf.dexlib.DexFile;
import org.jf.dexlib.Section;
import org.jf.dexlib.Code.Opcode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dalvik.dex.instructions.Invoke;
import com.ibm.wala.util.io.FileProvider;
@ -66,8 +64,6 @@ import com.ibm.wala.util.io.FileProvider;
*/
@Deprecated
public class ActivityModelMethod extends DexIMethod {
private static final Logger logger = LoggerFactory
.getLogger(ActivityModelMethod.class);
private static EncodedMethod ActivityModelM;
public ActivityModelMethod(EncodedMethod encodedMethod, DexIClass klass) {
@ -244,9 +240,6 @@ public class ActivityModelMethod extends DexIMethod {
}
instructions.add(new Invoke.InvokeVirtual(instLoc, cname, mname, pname,
args, opcode, this));
logger.debug("\tActivityModelMethod " + opcode.toString() + " class: "
+ cname + ", method name: " + mname + ", prototype string: "
+ pname);
}
}

View File

@ -18,9 +18,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.cfg.AbstractCFG;
import com.ibm.wala.cfg.BytecodeCFG;
import com.ibm.wala.cfg.IBasicBlock;
@ -50,8 +47,6 @@ import com.ibm.wala.util.warnings.Warning;
import com.ibm.wala.util.warnings.Warnings;
public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implements BytecodeCFG {
private static final Logger logger = LoggerFactory.getLogger(DexCFG.class);
private static final boolean DEBUG = false;
private int[] instruction2Block;
@ -60,9 +55,6 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
private final Context context;
private static int totalEdges = 0;
private int tempTE;
/**
* Cache this here for efficiency
@ -82,16 +74,10 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
this.dexMethod = method;
this.context = context;
this.hashBase = method.hashCode() * 9967;
tempTE = 0;
makeBasicBlocks();
init();
computeI2BMapping();
computeEdges();
logger.debug("Method: " + method.getSignature() + " edges: " +tempTE);
if (DEBUG) {
logger.debug(this.toString());
}
}
public DexIMethod getDexMethod() {
@ -252,7 +238,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
private void computeOutgoingEdges() {
if (DEBUG) {
logger.debug("Block " + this + ": computeOutgoingEdges()");
System.err.println("Block " + this + ": computeOutgoingEdges()");
}
Instruction last = getInstructions()[getLastInstructionIndex()];
@ -325,16 +311,16 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
for (int j = 0; j < hs.length; j++) {
if (DEBUG) {
logger.debug(" handler " + hs[j]);
System.err.println(" handler " + hs[j]);
}
BasicBlock b = getBlockForInstruction(hs[j].getHandler());
if (DEBUG) {
logger.debug(" target " + b);
System.err.println(" target " + b);
}
if (goToAllHandlers) {
// add an edge to the catch block.
if (DEBUG) {
logger.debug(" gotoAllHandlers " + b);
System.err.println(" gotoAllHandlers " + b);
}
addExceptionalEdgeTo(b);
} else {
@ -343,7 +329,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
ClassLoaderReference loader = DexCFG.this.getMethod().getDeclaringClass().getReference().getClassLoader();
caughtException = ShrikeUtil.makeTypeReference(loader, hs[j].getCatchClass());
if (DEBUG) {
logger.debug(" caughtException " + caughtException);
System.err.println(" caughtException " + caughtException);
}
IClass caughtClass = cha.lookupClass(caughtException);
if (caughtClass == null) {
@ -355,7 +341,7 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
}
} else {
if (DEBUG) {
logger.debug(" catchClass() == null");
System.err.println(" catchClass() == null");
}
// hs[j].getCatchClass() == null.
// this means that the handler catches all exceptions.
@ -584,13 +570,11 @@ public class DexCFG extends AbstractCFG<Instruction, DexCFG.BasicBlock> implemen
private void addNormalEdgeTo(BasicBlock b) {
totalEdges++;
tempTE++;
addNormalEdge(this, b);
}
private void addExceptionalEdgeTo(BasicBlock b) {
totalEdges++;
tempTE++;
addExceptionalEdge(this, b);
}

View File

@ -57,8 +57,6 @@ import java.util.jar.JarFile;
import org.jf.dexlib.ClassDefItem;
import org.jf.dexlib.DexFile;
import org.jf.dexlib.Section;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.Module;
import com.ibm.wala.classLoader.ModuleEntry;
@ -70,8 +68,6 @@ import com.ibm.wala.util.io.TemporaryFile;
* @author barjo
*/
public class DexFileModule implements Module {
private static final Logger logger = LoggerFactory.getLogger(DexFileModule.class);
private final DexFile dexfile;
private final Collection<ModuleEntry> entries;
@ -115,7 +111,6 @@ public class DexFileModule implements Module {
Section<ClassDefItem> cldeff = dexfile.ClassDefsSection;
for (ClassDefItem cdefitems : cldeff.getItems()) {
logger.debug("DexFileModule adding class: " + cdefitems.getConciseIdentity());
entries.add(new DexModuleEntry(cdefitems));
}
}

View File

@ -70,8 +70,6 @@ import org.jf.dexlib.FieldIdItem;
import org.jf.dexlib.MethodIdItem;
import org.jf.dexlib.TypeIdItem;
import org.jf.dexlib.TypeListItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.BytecodeClass;
import com.ibm.wala.classLoader.IClassLoader;
@ -87,9 +85,8 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.strings.ImmutableByteArray;
public class DexIClass extends BytecodeClass<IClassLoader> {
private static final Logger logger = LoggerFactory.getLogger(DexIClass.class);
/**
/**
* Item which contains the class definitions.
* (compute by DexFile, from the dexLib)
*/
@ -349,12 +346,7 @@ public class DexIClass extends BytecodeClass<IClassLoader> {
@Override
protected IMethod[] computeDeclaredMethods() throws InvalidClassFileException {
ArrayList<IMethod> methodsAL = new ArrayList<IMethod>();
logger.debug("class: " + classDef.getClassType().getTypeDescriptor());
if (classDef.getSuperclass() != null){
logger.debug("superclass: " + classDef.getSuperclass().getTypeDescriptor());
}
if (methods == null && classDef.getClassData() == null)
methods = new IMethod[0];
@ -369,8 +361,6 @@ public class DexIClass extends BytecodeClass<IClassLoader> {
// Create Direct methods (static, private, constructor)
for (int i = 0; i < directMethods.size(); i++) {
EncodedMethod dMethod = directMethods.get(i);
logger.debug("direct method info: " + dMethod.method.getMethodString());
logger.debug("direct method name: " + dMethod.method.getMethodName().getStringValue());
//methods[i] = new DexIMethod(dMethod,this);
methodsAL.add(new DexIMethod(dMethod,this));
@ -382,16 +372,11 @@ public class DexIClass extends BytecodeClass<IClassLoader> {
//if (methods[i].isClinit())
if (methodsAL.get(i).isClinit()) {
clinitId = i;
logger.debug("Clinit id: " + i);
}
}
// Create virtual methods (other methods)
for (int i = 0; i < virtualMethods.size(); i++) {
logger.debug("virtual method info: " + virtualMethods.get(i).method.getMethodString());
logger.debug("virtual method name: " + virtualMethods.get(i).method.getMethodName().getStringValue());
logger.debug("virtual method prototype name: " + virtualMethods.get(i).method.getPrototype().getPrototypeString());
logger.debug("virtual method return type: " + virtualMethods.get(i).method.getPrototype().getReturnType().getTypeDescriptor());
//methods[dSize+i] = new DexIMethod(virtualMethods[i],this);
methodsAL.add(new DexIMethod(virtualMethods.get(i),this));
//is this enough to determine if the class is an activity?

View File

@ -104,8 +104,6 @@ import org.jf.dexlib.Code.Format.PackedSwitchDataPseudoInstruction;
import org.jf.dexlib.Code.Format.SparseSwitchDataPseudoInstruction;
import org.jf.dexlib.EncodedValue.ArrayEncodedValue;
import org.jf.dexlib.EncodedValue.TypeEncodedValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IBytecodeMethod;
@ -158,7 +156,6 @@ import com.ibm.wala.util.strings.ImmutableByteArray;
* A wrapper around a EncodedMethod object (from dexlib) that represents a method.
*/
public class DexIMethod implements IBytecodeMethod {
private static final Logger logger = LoggerFactory.getLogger(DexIMethod.class);
/**
* The EncodedMethod object for which this DexIMethod is a wrapper.
@ -220,7 +217,6 @@ public class DexIMethod implements IBytecodeMethod {
/** BEGIN Custom change: Variable Names in synth. methods */
assert (eMethod.method != null);
if (myClass.getClassDefItem().getAnnotations() == null) {
logger.error("Get Annotations is null for method " + eMethod + " in getDeclaredExceptions");
return null;
}
ArrayList<String> strings = new ArrayList<String>();
@ -230,7 +226,6 @@ public class DexIMethod implements IBytecodeMethod {
if (annotationSet != null) {
for (AnnotationItem annotationItem: annotationSet.getAnnotations())
{
logger.debug("getDeclaredExceptions() AnnotationItem: " + annotationItem.getEncodedAnnotation().annotationType.getTypeDescriptor());
if (annotationItem.getEncodedAnnotation().annotationType.getTypeDescriptor().contentEquals("Ldalvik/annotation/Throws;")) {
for (int i = 0; i < annotationItem.getEncodedAnnotation().values.length; i++) {
for (int j = 0; j < ((ArrayEncodedValue)annotationItem.getEncodedAnnotation().values[i]).values.length; j++) {
@ -252,7 +247,6 @@ public class DexIMethod implements IBytecodeMethod {
TypeReference[] result = new TypeReference[strings.size()];
for (int i = 0; i < result.length; i++) {
result[i] = TypeReference.findOrCreate(loader, TypeName.findOrCreate(ImmutableByteArray.make(strings.get(i))));
logger.debug("getDeclaredExceptions() result["+i+"]: " + result[i] );
}
return result;
}
@ -268,7 +262,6 @@ public class DexIMethod implements IBytecodeMethod {
* @see com.ibm.wala.classLoader.IMethod#getMaxLocals()
*/
public int getMaxLocals() {
logger.debug("Max Local Register Count: " + eMethod.codeItem.getRegisterCount() + " + 2");
return eMethod.codeItem.getRegisterCount() + 2;
}
@ -703,12 +696,6 @@ public class DexIMethod implements IBytecodeMethod {
if (instructions == null)
parseBytecode();
logger.debug("Got " + instructions.size()
+ " instructions for method " + myClass.toString() + "."
+ eMethod.toString() + ":");
for (Instruction inst : instructions()) {
logger.debug("\t" + inst.getClass());
}
throw new UnsupportedOperationException(
"DexMethod doesn't use IInstruction - try getDexInstructions instead");
}
@ -716,8 +703,6 @@ public class DexIMethod implements IBytecodeMethod {
protected void parseBytecode() {
logger.debug("DexIMethod: parseByteCode() : " + eMethod.getClass().getSimpleName() + ":" + eMethod.method.getMethodString());
org.jf.dexlib.Code.Instruction[] instrucs = eMethod.codeItem.getInstructions();
// for (org.jf.dexlib.Code.Instruction inst: instrucs)
@ -825,8 +810,6 @@ public class DexIMethod implements IBytecodeMethod {
// }
// }
logger.debug("Total DexLib instructions for Method: " + eMethod.method.getMethodString() + " : " + instrucs.length);
//if (eMethod.method.getMethodString().contentEquals("Lorg/xbill/DNS/Name;-><init>([B)V") && instrucs.length == 4)
// System.out.println("debug here");
@ -844,7 +827,6 @@ public class DexIMethod implements IBytecodeMethod {
// instLoc = pc - instCounter;
instLoc = currentCodeAddress;
//pc += inst.getFormat().size;
logger.debug("Instruction: " + instCounter + ", Address: " + instLoc + ", OpCode: " + inst.opcode.name() + ", Format: " + inst.getFormat());
switch(inst.opcode)
{
case NOP:
@ -1007,19 +989,15 @@ public class DexIMethod implements IBytecodeMethod {
case CONST_4: {
instructions.add(new Constant.IntConstant(instLoc,
(int)((Instruction11n)inst).getLiteral(),((Instruction11n)inst).getRegisterA(), inst.opcode, this));
logger.debug("\tRegister: " + ((Instruction11n)inst).getRegisterA() + ", Value: " + ((Instruction11n)inst).getLiteral());
break;
}
case CONST_16:
instructions.add(new Constant.IntConstant(instLoc,
(int)((Instruction21s)inst).getLiteral(), ((Instruction21s)inst).getRegisterA(), inst.opcode, this));
logger.debug("\tRegister: " + ((Instruction21s)inst).getRegisterA() + ", Value: " + ((Instruction21s)inst).getLiteral());
break;
case CONST:
instructions.add(new Constant.IntConstant(instLoc,
(int)((Instruction31i)inst).getLiteral(), ((Instruction31i)inst).getRegisterA(), inst.opcode, this));
logger.debug("\tRegister: " + ((Instruction31i)inst).getRegisterA() + ", Value: " + ((Instruction31i)inst).getLiteral());
break;
case CONST_HIGH16:
instructions.add(new Constant.IntConstant(instLoc,
@ -1028,8 +1006,6 @@ public class DexIMethod implements IBytecodeMethod {
case CONST_WIDE_16:
instructions.add(new Constant.LongConstant(instLoc,
((Instruction21s)inst).getLiteral(), ((Instruction21s)inst).getRegisterA(), inst.opcode, this));
logger.debug("\tRegister: " + ((Instruction21s)inst).getRegisterA() + ", Value: " + ((Instruction21s)inst).getLiteral());
break;
case CONST_WIDE_32:
instructions.add(new Constant.LongConstant(instLoc,
@ -1042,22 +1018,17 @@ public class DexIMethod implements IBytecodeMethod {
case CONST_WIDE_HIGH16:
instructions.add(new Constant.LongConstant(instLoc,
((Instruction21h)inst).getLiteral() << 16, ((Instruction21h)inst).getRegisterA(), inst.opcode, this));
logger.debug("\tRegister: " + ((Instruction21h)inst).getRegisterA() + ", Value: " + ((Instruction21h)inst).getLiteral());
break;
case CONST_STRING:
instructions.add(new Constant.StringConstant(instLoc,
((StringIdItem)((Instruction21c)inst).getReferencedItem()).getStringValue(),
((Instruction21c)inst).getRegisterA(), inst.opcode, this));
logger.debug(inst.opcode.toString() + " value: "+
((StringIdItem)((Instruction21c)inst).getReferencedItem()).getStringValue());
break;
case CONST_STRING_JUMBO:
instructions.add(new Constant.StringConstant(instLoc,
((StringIdItem)((Instruction31c)inst).getReferencedItem()).getStringValue(),
((Instruction31c)inst).getRegisterA(), inst.opcode, this));
logger.debug(inst.opcode.toString() + " value: "+
((StringIdItem)((Instruction31c)inst).getReferencedItem()).getStringValue());
break;
case CONST_CLASS: {
String cname = ((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor();
@ -1069,7 +1040,6 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new Constant.ClassConstant(instLoc,
typeRef, ((Instruction21c)inst).getRegisterA(), inst.opcode, this));
logger.debug(inst.opcode.toString() + " classname: "+cname+ " value: "+this.myClass.getClassLoader().lookupClass(TypeName.findOrCreate(cname)));
//logger.debug("myClass found name: " + this.myClass.loader.lookupClass(TypeName.findOrCreate(cname)).toString());
break;
}
@ -1080,7 +1050,6 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new Monitor(instLoc, false, ((Instruction11x)inst).getRegisterA(), inst.opcode, this));
break;
case CHECK_CAST: {
logger.debug(inst.opcode.toString() + " value: "+((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor());
String cname = ((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor();
if (cname.endsWith(";"))
cname = cname.substring(0,cname.length()-1);
@ -1093,7 +1062,6 @@ public class DexIMethod implements IBytecodeMethod {
break;
}
case INSTANCE_OF: {
logger.debug(inst.opcode.toString() + " value: "+((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor());
String cname = ((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor();
if (cname.endsWith(";"))
cname = cname.substring(0,cname.length()-1);
@ -1111,12 +1079,10 @@ public class DexIMethod implements IBytecodeMethod {
break;
case NEW_INSTANCE: {
//newsitereference use instLoc or pc?
logger.debug(inst.opcode.toString() + " value: "+((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor());
String cname = ((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor();
if (cname.endsWith(";"))
cname = cname.substring(0,cname.length()-1);
logger.info("Type: " +((TypeIdItem)((Instruction21c)inst).getReferencedItem()).getTypeDescriptor());
instructions.add(new New(instLoc,
((Instruction21c)inst).getRegisterA(),
NewSiteReference.make(instLoc, TypeReference.findOrCreate(myClass.getClassLoader().getReference(),
@ -1129,7 +1095,6 @@ public class DexIMethod implements IBytecodeMethod {
params[0] = ((Instruction22c)inst).getRegisterB();
// MyLogger.log(LogLevel.INFO, "Type: " +((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor());
logger.debug(inst.opcode.toString() + " value: "+((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor());
String cname = ((TypeIdItem)((Instruction22c)inst).getReferencedItem()).getTypeDescriptor();
if (cname.endsWith(";"))
cname = cname.substring(0,cname.length()-1);
@ -1172,7 +1137,6 @@ public class DexIMethod implements IBytecodeMethod {
}
}
logger.debug(inst.opcode.toString() + " value: "+((TypeIdItem)((Instruction35c)inst).getReferencedItem()).getTypeDescriptor());
String cname = ((TypeIdItem)((Instruction35c)inst).getReferencedItem()).getTypeDescriptor();
if (cname.endsWith(";"))
cname = cname.substring(0,cname.length()-1);
@ -1183,16 +1147,6 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new NewArrayFilled(instLoc, getReturnReg(),
newSiteRef, myTypeRef, params, args, inst.opcode, this));
logger.debug("Type: " + ((TypeIdItem)((Instruction35c)inst).getReferencedItem()).getTypeDescriptor() +
", Register Count: "+ ((Instruction35c)inst).getRegCount());
logger.debug(registerCount + " registers");
for (int temp_i = 0; temp_i < registerCount; temp_i++)
logger.debug(" " + args[temp_i]);
break;
}
case FILLED_NEW_ARRAY_RANGE: {
@ -1204,7 +1158,6 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < registerCount; i++)
args[i] = ((Instruction3rc)inst).getStartRegister() + i;
logger.debug(inst.opcode.toString() + " value: "+((TypeIdItem)((Instruction3rc)inst).getReferencedItem()).getTypeDescriptor());
String cname = ((TypeIdItem)((Instruction3rc)inst).getReferencedItem()).getTypeDescriptor();
if (cname.endsWith(";"))
cname = cname.substring(0,cname.length()-1);
@ -1231,7 +1184,6 @@ public class DexIMethod implements IBytecodeMethod {
break;
case GOTO:
instructions.add(new Goto(instLoc, ((Instruction10t)inst).getTargetAddressOffset(), inst.opcode, this));
logger.debug("Offset: " + ((Instruction10t)inst).getTargetAddressOffset());
break;
case GOTO_16:
instructions.add(new Goto(instLoc, ((Instruction20t)inst).getTargetAddressOffset(), inst.opcode, this));
@ -1243,7 +1195,6 @@ public class DexIMethod implements IBytecodeMethod {
case PACKED_SWITCH:
case SPARSE_SWITCH:
instructions.add(new Switch(instLoc, ((Instruction31t)inst).getRegisterA(), ((Instruction31t)inst).getTargetAddressOffset(), inst.opcode, this));
logger.debug(inst.opcode.toString() + ", format: " + inst.getFormat());
break;
case CMPL_FLOAT:
@ -1275,74 +1226,61 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(),
Branch.BinaryBranch.CompareOp.EQ, ((Instruction22t)inst).getRegisterA(),
((Instruction22t)inst).getRegisterB(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction22t)inst).getRegisterA() + ", Register2: " + ((Instruction22t)inst).getRegisterB() + ", Offset: " + ((Instruction22t)inst).getTargetAddressOffset());
break;
case IF_NE:
instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(),
Branch.BinaryBranch.CompareOp.NE, ((Instruction22t)inst).getRegisterA(),
((Instruction22t)inst).getRegisterB(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction22t)inst).getRegisterA() + ", Register2: " + ((Instruction22t)inst).getRegisterB() + ", Offset: " + ((Instruction22t)inst).getTargetAddressOffset());
break;
case IF_LT:
instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(),
Branch.BinaryBranch.CompareOp.LT, ((Instruction22t)inst).getRegisterA(),
((Instruction22t)inst).getRegisterB(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction22t)inst).getRegisterA() + ", Register2: " + ((Instruction22t)inst).getRegisterB() + ", Offset: " + ((Instruction22t)inst).getTargetAddressOffset());
// logger.debug("Offset: " + ((Instruction22t)inst).getTargetAddressOffset() + ", Value: " + ((Instruction22t)inst).getLiteral());
break;
case IF_GE:
instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(),
Branch.BinaryBranch.CompareOp.GE, ((Instruction22t)inst).getRegisterA(),
((Instruction22t)inst).getRegisterB(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction22t)inst).getRegisterA() + ", Register2: " + ((Instruction22t)inst).getRegisterB() + ", Offset: " + ((Instruction22t)inst).getTargetAddressOffset());
break;
case IF_GT:
instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(),
Branch.BinaryBranch.CompareOp.GT, ((Instruction22t)inst).getRegisterA(),
((Instruction22t)inst).getRegisterB(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction22t)inst).getRegisterA() + ", Register2: " + ((Instruction22t)inst).getRegisterB() + ", Offset: " + ((Instruction22t)inst).getTargetAddressOffset());
break;
case IF_LE:
instructions.add(new Branch.BinaryBranch(instLoc, ((Instruction22t)inst).getTargetAddressOffset(),
Branch.BinaryBranch.CompareOp.LE, ((Instruction22t)inst).getRegisterA(),
((Instruction22t)inst).getRegisterB(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction22t)inst).getRegisterA() + ", Register2: " + ((Instruction22t)inst).getRegisterB() + ", Offset: " + ((Instruction22t)inst).getTargetAddressOffset());
break;
case IF_EQZ:
instructions.add(new Branch.UnaryBranch(instLoc,
((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.EQZ,
((Instruction21t)inst).getRegisterA(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction21t)inst).getRegisterA() + ", Offset: " + ((Instruction21t)inst).getTargetAddressOffset());
break;
case IF_NEZ:
instructions.add(new Branch.UnaryBranch(instLoc,
((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.NEZ,
((Instruction21t)inst).getRegisterA(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction21t)inst).getRegisterA() + ", Offset: " + ((Instruction21t)inst).getTargetAddressOffset());
break;
case IF_LTZ:
instructions.add(new Branch.UnaryBranch(instLoc,
((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.LTZ,
((Instruction21t)inst).getRegisterA(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction21t)inst).getRegisterA() + ", Offset: " + ((Instruction21t)inst).getTargetAddressOffset());
break;
case IF_GEZ:
instructions.add(new Branch.UnaryBranch(instLoc,
((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.GEZ,
((Instruction21t)inst).getRegisterA(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction21t)inst).getRegisterA() + ", Offset: " + ((Instruction21t)inst).getTargetAddressOffset());
break;
case IF_GTZ:
instructions.add(new Branch.UnaryBranch(instLoc,
((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.GTZ,
((Instruction21t)inst).getRegisterA(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction21t)inst).getRegisterA() + ", Offset: " + ((Instruction21t)inst).getTargetAddressOffset());
break;
case IF_LEZ:
instructions.add(new Branch.UnaryBranch(instLoc,
((Instruction21t)inst).getTargetAddressOffset(), Branch.UnaryBranch.CompareOp.LEZ,
((Instruction21t)inst).getRegisterA(), inst.opcode, this));
logger.debug("Register1: " + ((Instruction21t)inst).getRegisterA() + ", Offset: " + ((Instruction21t)inst).getTargetAddressOffset());
break;
case AGET:
instructions.add(new ArrayGet(instLoc, ((Instruction23x)inst).getRegisterA(),
@ -1407,7 +1345,6 @@ public class DexIMethod implements IBytecodeMethod {
case IGET_BYTE:
case IGET_CHAR:
case IGET_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();
@ -1431,7 +1368,6 @@ public class DexIMethod implements IBytecodeMethod {
case IPUT_BYTE:
case IPUT_CHAR:
case IPUT_SHORT: {
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();
@ -1455,7 +1391,6 @@ public class DexIMethod implements IBytecodeMethod {
case SGET_BYTE:
case SGET_CHAR:
case SGET_SHORT: {
logger.debug(inst.opcode.toString() + " class: "+((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", field name: " + ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldName().getStringValue() + ", field type: " + ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldType().getTypeDescriptor());
String cname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String fname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldName().getStringValue();
String ftname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldType().getTypeDescriptor();
@ -1478,7 +1413,6 @@ public class DexIMethod implements IBytecodeMethod {
case SPUT_BYTE:
case SPUT_CHAR:
case SPUT_SHORT: {
logger.debug(inst.opcode.toString() + " class: "+((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", field name: " + ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldName().getStringValue() + ", field type: " + ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldType().getTypeDescriptor());
String cname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String fname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldName().getStringValue();
String ftname = ((FieldIdItem)((Instruction21c)inst).getReferencedItem()).getFieldType().getTypeDescriptor();
@ -1570,7 +1504,6 @@ public class DexIMethod implements IBytecodeMethod {
}
}
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -1581,7 +1514,6 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new Invoke.InvokeSuper(instLoc,
cname, mname, pname, args, inst.opcode, this));
logger.debug("Super class name: " + cname + ", Method name: " + mname + ", Prototype String" + pname);
break;
}
case INVOKE_DIRECT: {
@ -1624,15 +1556,6 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new Invoke.InvokeDirect(instLoc,
cname, mname, pname, args, inst.opcode, this));
logger.debug("Class: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() +
", Method: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue() +
", Descriptor: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString() +
", Register Count: "+ ((Instruction35c)inst).getRegCount());
//System.out.print(registerCount + " registers");
//for (int temp_i = 0; temp_i < registerCount; temp_i++)
// System.out.print(", " + args[temp_i]);
//System.out.println();
break;
}
case INVOKE_STATIC: {
@ -1675,11 +1598,6 @@ public class DexIMethod implements IBytecodeMethod {
instructions.add(new Invoke.InvokeStatic(instLoc, cname, mname, pname, args, inst.opcode, this));
logger.debug("Class: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() +
", Method: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue() +
", Descriptor: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString() +
", Register Count: "+ ((Instruction35c)inst).getRegCount());
break;
}
case INVOKE_INTERFACE: {
@ -1710,7 +1628,6 @@ public class DexIMethod implements IBytecodeMethod {
}
}
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction35c)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -1730,7 +1647,6 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < registerCount; i++)
args[i] = ((Instruction3rc)inst).getStartRegister() + i;
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -1750,7 +1666,6 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < registerCount; i++)
args[i] = ((Instruction3rc)inst).getStartRegister() + i;
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -1769,7 +1684,6 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < registerCount; i++)
args[i] = ((Instruction3rc)inst).getStartRegister() + i;
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -1788,7 +1702,6 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < registerCount; i++)
args[i] = ((Instruction3rc)inst).getStartRegister() + i;
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -1808,7 +1721,6 @@ public class DexIMethod implements IBytecodeMethod {
for (int i = 0; i < registerCount; i++)
args[i] = ((Instruction3rc)inst).getStartRegister() + i;
logger.debug(inst.opcode.toString() + " class: "+((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor() + ", method name: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue() + ", prototype string: " + ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString());
String cname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getContainingClass().getTypeDescriptor();
String mname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getMethodName().getStringValue();
String pname = ((MethodIdItem)((Instruction3rc)inst).getReferencedItem()).getPrototype().getPrototypeString();
@ -2395,7 +2307,7 @@ public class DexIMethod implements IBytecodeMethod {
// UnresolvedOdexInstruction(null, -1, false),
//*/
// case Format10t: { //goto
// logger.debug(instruction.opcode.name + " - 10t");
//
//
// Instruction10t dInst = (Instruction10t)instruction;
//
@ -2405,7 +2317,7 @@ public class DexIMethod implements IBytecodeMethod {
// break;
// }
// case Format10x: {
// logger.debug(instruction.opcode.name + " - 10x");
//
// switch(instruction.opcode) {
// case RETURN_VOID: {
// instructions.add(new Return.ReturnVoid(i));
@ -2419,7 +2331,7 @@ public class DexIMethod implements IBytecodeMethod {
// }
//
// case Format11n: {
// logger.debug(instruction.opcode.name + " - 11n");
//
// Instruction11n dInst = (Instruction11n) instruction;
//
// System.out.println("here1");
@ -2450,7 +2362,7 @@ public class DexIMethod implements IBytecodeMethod {
// MONITOR_EXIT((byte)0x1e, "monitor-exit", ReferenceType.none, Format.Format11x, Opcode.CAN_THROW | Opcode.CAN_CONTINUE),
// THROW((byte)0x27, "throw", ReferenceType.none, Format.Format11x, Opcode.CAN_THROW),
// */
// logger.debug(instruction.opcode.name + " - 11x");
//
// Instruction11x dInst = (Instruction11x) instruction;
//
// switch (dInst.opcode) {
@ -2515,7 +2427,7 @@ public class DexIMethod implements IBytecodeMethod {
// }
//
// case Format12x: {
// logger.debug(instruction.opcode.name + " - 12x");
//
// Instruction12x dInst = (Instruction12x) instruction;
// int destination = dInst.getRegisterA();
// int source = dInst.getRegisterB();
@ -2957,7 +2869,7 @@ public class DexIMethod implements IBytecodeMethod {
// }
//
// case Format20t: { //goto/16
// logger.debug(instruction.opcode.name + " - 20t");
//
//
// Instruction20t dInst = (Instruction20t)instruction;
//
@ -2966,7 +2878,7 @@ public class DexIMethod implements IBytecodeMethod {
// break;
// }
// case Format30t: { //goto/32
// logger.debug(instruction.opcode.name + " - 30t");
//
//
// Instruction30t dInst = (Instruction30t)instruction;
//
@ -2977,7 +2889,7 @@ public class DexIMethod implements IBytecodeMethod {
//
// case Format21c: {
// Instruction21c dInst = (Instruction21c) instruction;
// logger.debug(instruction.opcode.name + " - 21c");
//
//
// switch (dInst.opcode) {
// //CONST_STRING((byte)0x1a, "const-string", ReferenceType.string, Format.Format21c, Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
@ -3174,7 +3086,7 @@ public class DexIMethod implements IBytecodeMethod {
//
//
// case Format35c: {
// logger.debug(instruction.opcode.name + " - 11c");
//
// // = invoke virtual
// //iinstructions[i] = new IInstruction35c((Instruction35c)instruction, this);
// break;
@ -3190,12 +3102,6 @@ public class DexIMethod implements IBytecodeMethod {
// }
//
// //comment out stop
logger.debug("DexIMethod: " + this.toString() + "parseByteCode() done");
// TODO Auto-generated method stub
//return iinstructions;
//return instrucs;
}
private TypeReference findOutArrayElementType(
@ -3236,7 +3142,6 @@ public class DexIMethod implements IBytecodeMethod {
protected void handleINVOKE_VIRTUAL(int instLoc, String cname, String mname, String pname, int[] args, Opcode opcode ) {
instructions.add(new Invoke.InvokeVirtual(instLoc, cname, mname, pname, args, opcode, this));
logger.debug("\tDexIMethod " + opcode.toString() + " class: "+ cname + ", method name: " + mname + ", prototype string: " + pname);
}
public Instruction[] getDexInstructions() {
@ -3296,7 +3201,7 @@ public class DexIMethod implements IBytecodeMethod {
// if ( mIdItem.equals(eMethod.method) ){
// AnnotationItem[] items = anoSet.getAnnotations();
// for (AnnotationItem item : items) {
// logger.debug("ANNOTATION"+item.toString());
//
// }
//
// }
@ -3336,9 +3241,6 @@ public class DexIMethod implements IBytecodeMethod {
target, // declaredTarget
((Invoke)inst).getInvocationCode() // invocationCode
));
logger.info("\tClass Name:\t" + ((Invoke)inst).clazzName);
logger.info("\tMethod Name:\t" + ((Invoke)inst).methodName);
logger.info("\tSignature:\t" + ((Invoke)inst).descriptor );
}
}
return Collections.unmodifiableCollection(csites);

View File

@ -12,9 +12,6 @@
package com.ibm.wala.dalvik.classLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.cfg.ControlFlowGraph;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.dalvik.ssa.DexSSABuilder;
@ -30,8 +27,6 @@ import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.ssa.analysis.DeadAssignmentElimination;
public class DexIRFactory extends DefaultIRFactory {
private static final Logger logger = LoggerFactory.getLogger(DexIRFactory.class);
public final static boolean buildLocalMap = false;
@SuppressWarnings("rawtypes")
@ -132,7 +127,6 @@ public class DexIRFactory extends DefaultIRFactory {
@SuppressWarnings("unchecked")
@Override
protected ShrikeIndirectionData getIndirectionData() {
logger.warn("Implement ShrikeIndirectionData ?");
return indirectionData;
}
};

View File

@ -55,8 +55,6 @@ import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.ClassLoaderImpl;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader;
@ -77,8 +75,6 @@ import com.ibm.wala.util.warnings.Warnings;
*
*/
public class WDexClassLoaderImpl extends ClassLoaderImpl {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(WDexClassLoaderImpl.class);
private IClassLoader lParent;
private final SetOfClasses exclusions;
@ -110,7 +106,6 @@ public class WDexClassLoaderImpl extends ClassLoaderImpl {
for (Iterator<Module> it = modules.iterator(); it.hasNext();) {
Module archive = it.next();
logger.debug("add archive: : "+archive);
Set<ModuleEntry> classFiles = getDexFiles(archive);
removeClassFiles(classFiles, classModuleEntries);
@ -199,7 +194,6 @@ public class WDexClassLoaderImpl extends ClassLoaderImpl {
continue;
}
logger.debug("Load class: " + className);
loadedClasses.put(tName, iClass);
} else {
Warnings.add(InvalidDexFile.create(className));

View File

@ -49,102 +49,77 @@
package com.ibm.wala.dalvik.dex.instructions;
import org.jf.dexlib.Code.Opcode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dalvik.classLoader.DexIMethod;
public abstract class Instruction {
public static class Visitor {
private static final Logger logger = LoggerFactory.getLogger(Instruction.Visitor.class);
public void visitArrayLength(ArrayLength instruction) {
logger.error("visitArrayLength not overridden");
}
}
public void visitArrayGet(ArrayGet instruction) {
logger.error("visitArrayGet not overridden");
}
public void visitArrayPut(ArrayPut instruction) {
logger.error("visitArrayPut not overridden");
}
}
public void visitArrayFill(ArrayFill instruction) {
logger.error("visitArrayFill not overridden");
}
public void visitBinaryOperation(BinaryOperation instruction) {
logger.error("visitBinaryOperation not overridden");
}
public void visitBinaryLiteral(BinaryLiteralOperation binaryLiteralOperation) {
logger.error("visitBinaryLiteral not overridden");
}
public void visitBranch(Branch instruction) {
logger.error("visitBranch not overridden");
}
public void visitCheckCast(CheckCast checkCast) {
logger.error("visitCheckCast not overridden");
}
public void visitConstant(Constant instruction) {
logger.error("visitConstant not overridden");
}
public void visitGetField(GetField instruction) {
logger.error("visitGetField not overridden");
}
public void visitGoto(Goto inst) {
logger.error("visitGoto not overridden");
}
public void visitInstanceof(InstanceOf instruction) {
logger.error("visitInstanceof not overridden");
}
public void visitInvoke(Invoke instruction) {
logger.error("visitInvoke not overridden");
}
public void visitMonitor(Monitor instruction) {
logger.error("visitMonitor not overridden");
}
public void visitNew(New instruction) {
logger.error("visitNew not overridden");
}
public void visitNewArray(NewArray newArray) {
logger.error("visitNewArray not overridden");
}
public void visitNewArrayFilled(NewArrayFilled newArrayFilled) {
logger.error("visitNewArrayFilled not overridden");
}
public void visitPutField(PutField instruction) {
logger.error("visitPutField not overridden");
}
public void visitReturn(Return return1) {
logger.error("visitReturn not overridden");
}
public void visitSwitch(Switch instruction) {
logger.error("visitSwitch not overridden");
}
public void visitThrow(Throw instruction) {
logger.error("visitThrow not overridden");
}
public void visitUnaryOperation(UnaryOperation instruction) {
logger.error("visitUnaryOperation not overridden");
}

View File

@ -49,15 +49,12 @@
package com.ibm.wala.dalvik.dex.instructions;
import org.jf.dexlib.Code.Opcode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dalvik.classLoader.DexIMethod;
import com.ibm.wala.shrikeBT.IInvokeInstruction;
import com.ibm.wala.shrikeBT.IInvokeInstruction.IDispatch;
public abstract class Invoke extends Instruction {
private static final Logger logger = LoggerFactory.getLogger(Invoke.class);
public final int [] args;
public final String clazzName;
@ -80,7 +77,6 @@ public abstract class Invoke extends Instruction {
String clazzName, String methodName, String descriptor,
int[] args, Opcode opcode, DexIMethod method) {
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
logger.debug("constructing "+toString());
}
@Override
public IDispatch getInvocationCode() {
@ -109,9 +105,8 @@ public abstract class Invoke extends Instruction {
String clazzName, String methodName, String descriptor,
int[] args, Opcode opcode, DexIMethod method) {
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
logger.debug("constructing "+toString());
}
@Override
public IDispatch getInvocationCode() {
// TODO: check that this is correct -- I suspect the invoke super in dex is for method protection rather than dispatching
@ -141,8 +136,8 @@ public abstract class Invoke extends Instruction {
String clazzName, String methodName, String descriptor,
int[] args, Opcode opcode, DexIMethod method) {
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
logger.debug(toString());
}
}
@Override
public IDispatch getInvocationCode() {
return IInvokeInstruction.Dispatch.SPECIAL;
@ -172,8 +167,8 @@ public abstract class Invoke extends Instruction {
String clazzName, String methodName, String descriptor,
int[] args, Opcode opcode, DexIMethod method) {
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
logger.debug("constructing "+toString());
}
}
@Override
public IDispatch getInvocationCode() {
return IInvokeInstruction.Dispatch.STATIC;
@ -202,7 +197,6 @@ public abstract class Invoke extends Instruction {
String clazzName, String methodName, String descriptor,
int[] args, Opcode opcode, DexIMethod method) {
super(instLoc, clazzName, methodName, descriptor, args, opcode, method);
logger.debug("constructing "+toString());
}
@Override

View File

@ -49,13 +49,10 @@
package com.ibm.wala.dalvik.dex.instructions;
import org.jf.dexlib.Code.Opcode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dalvik.classLoader.DexIMethod;
public class Switch extends Instruction {
private static final Logger logger = LoggerFactory.getLogger(Switch.class);
public final int regA;
public final int tableAddressOffset;
@ -82,12 +79,6 @@ public class Switch extends Instruction {
casesAndLabels[i] = method.getInstructionIndex(pc+casesAndLabels[i]);
defaultLabel = method.getInstructionIndex(pc + pad.getDefaultOffset());
logger.debug("SwitchInstruction");
for (int i = 0; i < casesAndLabels.length; i+=2) {
logger.debug("\tcase: " + casesAndLabels[i] +
" label: "+casesAndLabels[i+1]);
}
logger.debug("\tdefaultLabel: " + defaultLabel);
}
public int[] getOffsets()

View File

@ -48,20 +48,13 @@
package com.ibm.wala.dalvik.dex.util.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import java.util.jar.JarFile;
import com.ibm.wala.classLoader.BinaryDirectoryTreeModule;
import com.ibm.wala.dalvik.classLoader.DexFileModule;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.shrikeCT.InvalidClassFileException;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.config.AnalysisScopeReader;
import com.ibm.wala.util.config.FileOfClasses;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.io.FileProvider;
/**
* Create AnalysisScope from java & dalvik file.

View File

@ -41,15 +41,12 @@
package com.ibm.wala.dalvik.ipa.callgraph.androidModel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
@ -128,8 +125,6 @@ import com.ibm.wala.util.strings.Atom;
*/
public class AndroidModel /* makes SummarizedMethod */
implements IClassHierarchyDweller {
private static Logger logger = LoggerFactory.getLogger(AndroidModel.class);
private final Atom name = Atom.findOrCreateAsciiAtom("AndroidModel");
public MethodReference mRef;
@ -225,7 +220,7 @@ public class AndroidModel /* makes SummarizedMethod */
if (this.klass == null) {
// add to cha
logger.info("Adding model-class to cha");
this.klass = AndroidModelClass.getInstance(cha);
cha.addClass(this.klass);
}
@ -242,7 +237,7 @@ public class AndroidModel /* makes SummarizedMethod */
final Selector selector = this.mRef.getSelector();
final AndroidModelClass mClass = AndroidModelClass.getInstance(cha);
if (mClass.containsMethod(selector)) {
logger.info("Returning existing {}", selector);
assert (mClass.getMethod(selector) instanceof SummarizedMethod);
this.model = (SummarizedMethod) mClass.getMethod(selector);
return;
@ -367,7 +362,7 @@ public class AndroidModel /* makes SummarizedMethod */
application = tmpApp;
} else {
// Generate a real one?
logger.warn("I didn't get an application. Generating a new object.");
application = paramManager.getUnmanaged(AndroidTypes.Application, "app");
this.body.addConstant(application.getNumber(), new ConstantValue(null));
application.setAssigned();
@ -386,7 +381,7 @@ public class AndroidModel /* makes SummarizedMethod */
nullBinder.setAssigned();
}
logger.info("Adding Boot-Code to the Android model");
{
final AndroidBoot boot = new AndroidBoot(null);
boot.addBootCode(tsif, null, paramManager, this.body);
@ -397,14 +392,14 @@ public class AndroidModel /* makes SummarizedMethod */
// TODO: Assign context to the other components
}
logger.info("Populating the AndroidModel with {} entryPoints", this.maxProgress);
for (final AndroidEntryPoint ep : entrypoints) {
this.monitor.subTask(ep.getMethod().getReference().getSignature() );
if (! selectEntryPoint(ep)) {
assert(false): "The ep should not reach here!";
logger.warn("SKIP: " + ep);
currentProgress++;
continue;
}
@ -413,7 +408,7 @@ public class AndroidModel /* makes SummarizedMethod */
// Is special handling to be inserted?
//
if (this.labelSpecial.hadSectionSwitch(ep.order)) {
logger.info("Adding special handling before: {}.", ep);
this.labelSpecial.enter(ep.getSection(), body.getNextProgramCounter());
}
@ -430,8 +425,7 @@ public class AndroidModel /* makes SummarizedMethod */
for (int i = 0; i < ep.getNumberOfParameters(); ++i) {
if (ep.getParameterTypes(i).length != 1) {
logger.debug("Got multiple types: {}", Arrays.toString(ep.getParameterTypes(i)));
mutliTypePositions.add(i);
mutliTypePositions.add(i);
params.add(null); // will get set later
} else {
for (final TypeReference type : ep.getParameterTypes(i)) {
@ -508,8 +502,6 @@ public class AndroidModel /* makes SummarizedMethod */
// Insert the call optionally handling its return value
//
for (final List<SSAValue> params : paramses) {
logger.debug("Adding Call to {}.{}", ep.getMethod().getDeclaringClass().getName(),
ep.getMethod().getName());
final int callPC = body.getNextProgramCounter();
final CallSiteReference site = ep.makeSite(callPC);
@ -527,7 +519,7 @@ public class AndroidModel /* makes SummarizedMethod */
if (this.paramManager.isSeen(returnKey)) {
// if it's seen it most likely is a REUSE-Type. However probably it makes sense for
// other types too so we don't test on isReuse.
logger.debug("Mixing in return type of this EP");
final SSAValue oldValue = this.paramManager.getCurrent(returnKey);
this.paramManager.invalidate(returnKey);
@ -560,7 +552,7 @@ public class AndroidModel /* makes SummarizedMethod */
MonitorUtil.throwExceptionIfCanceled(this.monitor);
}
logger.debug("All EntryPoints have been added - now closing the model");
// Close all sections by "jumping over" the remaining labels
labelSpecial.finish(body.getNextProgramCounter());
@ -721,12 +713,11 @@ public class AndroidModel /* makes SummarizedMethod */
if (intent != null) {
tool.setIntent(intent, allActivities);
} else if (! info.isSystemService()) { // it's normal for SystemServices
logger.warn("Got no Intent in call to: {} as {}", this.name, asMethod);
}
// Call the model
{
logger.debug("Calling model: {}", this.model.getReference().getName());
final List<SSAValue> redirectParams = acc.connectThrough(modelAcc, new HashSet<SSAValue>(allActivities), defaults,
getClassHierarchy(), /* IInstantiator this.createInstance(type, redirect, pm) */ instantiator, false, null, null);
final int callPC = redirect.getNextProgramCounter();
@ -782,8 +773,6 @@ public class AndroidModel /* makes SummarizedMethod */
tool.fetchResults(resultCodes, resultData, allActivities);
if (resultCodes.size() == 0) {
logger.error("Can't read back results from the started Activity => Can't call onActivityResult - " +
"The Activity has to be marked as REUSE in the IInstructionBehavior.");
throw new IllegalStateException("The call " + asMethod + " from " + caller + " failed, as the model " + this.model +
" did not take an activity to read the result from");
}
@ -794,7 +783,7 @@ public class AndroidModel /* makes SummarizedMethod */
{ // Send back the results
// TODO: Assert caller is an Activity
final SSAValue outRequestCode = acc.firstOf(TypeReference.Int); // TODO: Check is's the right parameter
logger.debug("Calling onActivityResult");
final int callPC = redirect.getNextProgramCounter();
// void onActivityResult (int requestCode, int resultCode, Intent data)
final Selector mSel = Selector.make("onActivityResult(IILandroid/content/Intent;)V");
@ -810,7 +799,7 @@ public class AndroidModel /* makes SummarizedMethod */
final SSAInstruction invokation = instructionFactory.InvokeInstruction(callPC, params, exception, site);
redirect.addStatement(invokation);
logger.info("Calling this.onActivityResult");
} // */
}

View File

@ -47,9 +47,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.FieldImpl;
@ -90,8 +88,6 @@ import com.ibm.wala.util.strings.Atom;
* @todo Move this class into an other loader? Currently: Primordial
*/
public final /* singleton */ class AndroidModelClass extends SyntheticClass {
private static Logger logger = LoggerFactory.getLogger(AndroidModelClass.class);
public static final TypeReference ANDROID_MODEL_CLASS = TypeReference.findOrCreate(
ClassLoaderReference.Primordial, TypeName.string2TypeName("Lcom/ibm/wala/AndroidModelClass"));
private static IClassHierarchy cha;
@ -108,9 +104,7 @@ public final /* singleton */ class AndroidModelClass extends SyntheticClass {
AndroidModelClass.cha = cha;
}
} else {
if (cha == null) {
logger.warn("Giving null as cha is discouraged in getInstance()");
} else if (! cha.equals(AndroidModelClass.cha)) {
if (! cha.equals(AndroidModelClass.cha)) {
throw new IllegalArgumentException("Cha differs!");
}
}
@ -199,7 +193,7 @@ public final /* singleton */ class AndroidModelClass extends SyntheticClass {
return methods.get(selector);
}
if (selector.equals(MethodReference.initSelector)) {
logger.warn("AndroidModelClass is not intended to be initialized");
return null;
}
throw new IllegalArgumentException("Could not resolve " + selector);

View File

@ -40,8 +40,7 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.androidModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.util.AndroidComponent;
@ -58,8 +57,7 @@ import com.ibm.wala.util.strings.Atom;
* @since 2014-02-12
*/
public class IntentModel extends AndroidModel {
private static Logger logger = LoggerFactory.getLogger(IntentModel.class);
public final Atom name;
public final Atom target;
// private SummarizedMethod activityModel;
@ -78,9 +76,6 @@ public class IntentModel extends AndroidModel {
this.target = target;
this.name = Atom.concat(Atom.findOrCreateAsciiAtom("intent"), target.right(target.rIndex((byte)'/') - 1));
logger.info("Model for {}", target);
logger.debug("Will be known as {}/{}.", AndroidModelClass.ANDROID_MODEL_CLASS.getName(), this.name);
}
private void register(SummarizedMethod model) {

View File

@ -40,8 +40,7 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.androidModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
@ -59,8 +58,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-12
*/
public class MicroModel extends AndroidModel {
private static Logger logger = LoggerFactory.getLogger(MicroModel.class);
public final Atom name;
public final Atom target;
// private SummarizedMethod activityModel;
@ -78,9 +75,6 @@ public class MicroModel extends AndroidModel {
this.target = target;
this.name = Atom.concat(Atom.findOrCreateAsciiAtom("start"), target.right(target.rIndex((byte)'/') - 1));
logger.info("Model for {}", target);
logger.debug("Will be known as {}/{}.", AndroidModelClass.ANDROID_MODEL_CLASS.getName(), this.name);
}
private void register(SummarizedMethod model) {

View File

@ -40,8 +40,7 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.androidModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.util.AndroidComponent;
@ -73,8 +72,7 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-29
*/
public class MiniModel extends AndroidModel {
private static Logger logger = LoggerFactory.getLogger(MiniModel.class);
private final Atom name;
private final AndroidComponent forCompo;
/**
@ -84,14 +82,14 @@ public class MiniModel extends AndroidModel {
*/
protected boolean selectEntryPoint(AndroidEntryPoint ep) {
if (ep.belongsTo(forCompo)) {
logger.debug("MiniModel calls: {}", ep);
return true;
}
return false;
}
public Descriptor getDescriptor() throws CancelException {
final Descriptor descr = super.getDescriptor();
logger.info("MiniModel: {}", descr);
return descr;
}

View File

@ -44,9 +44,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.types.MethodReference;
@ -75,8 +73,7 @@ import com.ibm.wala.util.ssa.SSAValue;
* might be not neccessary.
*/
public class AndroidModelParameterManager {
private static final Logger logger = LoggerFactory.getLogger(AndroidModelParameterManager.class);
private enum ValueStatus {
UNUSED, /** Value has never been mentioned before */
UNALLOCATED, /** Awaiting to be set using setAllocation */
@ -186,7 +183,7 @@ public class AndroidModelParameterManager {
nextLocal = ssaValue + 1;
}
logger.debug("reSetting SSA {} to allocated {}", ssaValue, type.getName());
param.status = ValueStatus.ALLOCATED;
param.ssa = ssaValue;
param.setInScope = currentScope;
@ -211,7 +208,7 @@ public class AndroidModelParameterManager {
List<ManagedParameter> aParam = new ArrayList<ManagedParameter>();
aParam.add(param);
logger.debug("Setting SSA{} to allocated {} ", ssaValue, type.getName());
seenTypes.put(type, aParam);
return;
}
@ -270,14 +267,13 @@ public class AndroidModelParameterManager {
param.setInScope = currentScope;
// param.setBy = setBy;
logger.info("Setting SSA {} to phi {} now {}", ssaValue, type.getName(), param.status);
didPhi = true;
} else if (param.setInScope == currentScope) {
if (param.status == ValueStatus.INVALIDATED) {
logger.info("Closing SSA Value {} in scope {} for {}", param.ssa, param.setInScope, param.type.getName());
param.status = ValueStatus.CLOSED;
} else if (param.status == ValueStatus.FREE_INVALIDATED) { // TODO: FREE CLOSED
logger.info("Closing free SSA Value {} in scope {} for {}", param.ssa, param.setInScope, param.type.getName());
param.status = ValueStatus.FREE_CLOSED;
}
} else if (param.setInScope < currentScope) {
@ -300,7 +296,7 @@ public class AndroidModelParameterManager {
nextLocal = ssaValue + 1;
}
logger.debug("Setting SSA {} to phi {}", ssaValue, type.getName());
List<ManagedParameter> aParam = new ArrayList<ManagedParameter>();
aParam.add(param);
@ -341,7 +337,7 @@ public class AndroidModelParameterManager {
seenTypes.put(type, aParam);
}
logger.debug("Returning as Free SSA: {} for {}.", param.ssa, type.getName());
return param.ssa;
}
@ -383,7 +379,7 @@ public class AndroidModelParameterManager {
seenTypes.put(type, aParam);
}
logger.debug("Returning as Unallocated SSA: {} for {}.", param.ssa, type.getName());
return param.ssa;
}
@ -422,10 +418,10 @@ public class AndroidModelParameterManager {
(param.status == ValueStatus.ALLOCATED)) {
assert (param.type.equals(type)) : "Inequal types";
if (param.setInScope > currentScope) {
logger.debug("SSA Value {} of {} is out of scope {}", param.ssa, param.type, currentScope);
continue;
} else if (param.setInScope == currentScope) {
logger.debug("Returning SSA Value {} of {} is {}", param.ssa, param.type, param.status);
return param.ssa;
} else {
if (param.setInScope > candidateScope) {
@ -434,7 +430,7 @@ public class AndroidModelParameterManager {
}
}
} else {
logger.debug("SSA Value {} of {} is {} ", param.ssa, param.type, param.status);
}
}
} else {
@ -442,7 +438,7 @@ public class AndroidModelParameterManager {
}
if (candidateSSA < 0 ) {
logger.debug("Returning inherited (from {} SSA Value {} for {}", candidateScope, candidateSSA, type.getName());
return candidateSSA;
} else {
throw new IllegalStateException("No suitable candidate has been found for " + type.getName());
@ -615,7 +611,7 @@ public class AndroidModelParameterManager {
} else {
param.status = ValueStatus.INVALIDATED;
}
logger.info("Invalidated SSA {} for type {}", param.ssa, type.getName());
}
}
}

View File

@ -44,9 +44,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader;
@ -64,7 +62,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-25
*/
public class DefaultInstantiationBehavior extends IInstantiationBehavior implements Serializable {
private static Logger logger = LoggerFactory.getLogger(DefaultInstantiationBehavior.class);
/* package-private */ static final class BehviourValue implements Serializable {
public final InstanceBehavior behaviour;
@ -271,7 +268,7 @@ public class DefaultInstantiationBehavior extends IInstantiationBehavior impleme
testClass = testClass.getSuperclass();
}
} else {
logger.warn("I got no ClassHierarchy. Can't test super classes");
}
} // */
@ -375,10 +372,7 @@ public class DefaultInstantiationBehavior extends IInstantiationBehavior impleme
private void readObject(java.io.ObjectInputStream stream)
throws IOException, ClassNotFoundException {
DefaultInstantiationBehavior.logger.warn("DefaultInstantiationBehavior is not intended to be deserialized into. (for no apparent reason)");
DefaultInstantiationBehavior.logger.warn("Deserializing it anyways...");
this.behaviours.clear();
DefaultInstantiationBehavior.this.behaviours.clear();
this.behaviours.putAll((Map<BehaviorKey, BehviourValue>) stream.readObject());
}

View File

@ -46,9 +46,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.analysis.typeInference.ConeType;
import com.ibm.wala.analysis.typeInference.PrimitiveType;
@ -83,7 +81,6 @@ import com.ibm.wala.util.ssa.TypeSafeInstructionFactory;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public class FlatInstantiator implements IInstantiator {
private static final Logger logger = LoggerFactory.getLogger(FlatInstantiator.class);
final IClassHierarchy cha;
final VolatileMethodSummary body;
@ -119,7 +116,7 @@ public class FlatInstantiator implements IInstantiator {
private boolean isExcluded(IClass cls) {
if (this.analysisScope.getExclusions().contains(cls.getName().toString())) { // XXX FUUUUU
logger.info("Hit exclusions with {}", cls);
return true;
} else {
return false;
@ -148,7 +145,7 @@ public class FlatInstantiator implements IInstantiator {
throw new IllegalArgumentException("Can't create an instance of null");
}
if (seen == null) {
logger.debug("Empty seen");
seen = new HashSet<SSAValue>();
}
@ -192,9 +189,9 @@ public class FlatInstantiator implements IInstantiator {
return instance;
} else if (klass == null) {
if (! T.getName().toString().startsWith("Landroid/")) {
logger.error("The Type {} is not in the ClassHierarchy! Returning null as instance", T);
} else {
logger.debug("The Type {} is not in the ClassHierarchy! Returning null as instance", T);
}
this.body.addConstant(instance.getNumber(), new ConstantValue(null));
instance.setAssigned();
@ -207,7 +204,7 @@ public class FlatInstantiator implements IInstantiator {
final Set<TypeReference> types = getTypes(T);
logger.info("Creating instance of {} is {}", T, types);
if (types.isEmpty()) {
throw new IllegalStateException("Types of " + T + " are empty");
}
@ -223,7 +220,7 @@ public class FlatInstantiator implements IInstantiator {
assert(newInst.getDef() == instance.getNumber());
return instance;
} else if (klass.isArrayClass()) {
logger.info("Creating Array-Class {}", klass.toString());
final TypeReference payloadType = T.getArrayElementType();
SSAValue payload = null;
@ -231,7 +228,7 @@ public class FlatInstantiator implements IInstantiator {
for (final SSAValue see : seen) {
if (ParameterAccessor.isAssignable(see.getType(), payloadType, this.cha)) {
// Happens on Array of interfaces
logger.trace("Reusing {} for array payload {}", see, payload);
payload = see;
}
}
@ -270,7 +267,7 @@ public class FlatInstantiator implements IInstantiator {
return instance;
} else {
// Abstract, Interface or array
logger.debug("Not a regular class {}", T);
final Set<SSAValue> subInstances = new HashSet<SSAValue>();
for (final TypeReference type : types) {
final IClass subKlass = this.cha.lookupClass(type);
@ -333,7 +330,7 @@ public class FlatInstantiator implements IInstantiator {
this.pm.setPhi(instance, phi);
}
} else {
logger.warn("No sub-instances for: {} - setting to null", instance);
this.body.addConstant(instance.getNumber(), new ConstantValue(null));
instance.setAssigned();
}
@ -402,7 +399,7 @@ public class FlatInstantiator implements IInstantiator {
final IMethod cTor = lookupConstructor(val.getType());
final ParameterAccessor ctorAcc = new ParameterAccessor(cTor);
assert (ctorAcc.hasImplicitThis()) : "CTor detected as not having implicit this pointer";
logger.debug("Acc for: %", this.scope);
final ParameterAccessor acc = new ParameterAccessor(this.scope, false); // TODO pm needs a connectThrough too!
// TODO false is false
// TODO: The overrides may lead to use before definition
@ -415,8 +412,8 @@ public class FlatInstantiator implements IInstantiator {
seen.add(nullSelf);
seen.addAll(overrides);
logger.debug("Recursing for: {}", cTor);
logger.debug("With seen: {}", seen);
final List<SSAValue> ctorParams = acc.connectThrough(ctorAcc, overrides, /* defaults */ null, this.cha,
this, /* managed */ false, /* key */ null, seen, currentDepth + 1); // XXX This starts the recursion!
addCallCtor(val, cTor.getReference(), ctorParams);
@ -442,19 +439,18 @@ public class FlatInstantiator implements IInstantiator {
* Used internally to avoid endless recursion on getTypes().
*/
private Set<TypeReference> getTypes(final TypeReference T, final Set<TypeReference> seen) {
logger.debug("getTypes({}, {})", T, seen);
final Set<TypeReference> ret = new HashSet<TypeReference>();
ret.add(T);
if (T.isPrimitiveType()) {
logger.warn("getTypes called on a primitive");
return ret;
//throw new IllegalArgumentException("Not you that call primitive type on :P");
}
final IClass cls = this.cha.lookupClass(T);
if (cls == null) {
logger.error("The type {} is not in the ClassHierarchy - try continuing anyway", T);
return ret;
//throw new IllegalArgumentException("The type " + T + " is not in the ClassHierarchy");
} else if (isExcluded(cls)) {
@ -468,9 +464,9 @@ public class FlatInstantiator implements IInstantiator {
if (impls.isEmpty()) {
//throw new IllegalStateException("The interface " + T + " has no known implementors");
if (! T.getName().toString().startsWith("Landroid/")) {
logger.error("The interface {} has no known implementors - skipping over it", T);
} else {
logger.debug("The interface {} has no known implementors - skipping over it", T);
}
return ret; // XXX: This is a bad idea?
} else {
@ -490,7 +486,7 @@ public class FlatInstantiator implements IInstantiator {
} else {
for (final IClass sub: subs) {
if (seen.contains(sub.getReference())) {
logger.debug("Seen: {}", sub);
continue;
}
if (sub.isAbstract()) {
@ -575,7 +571,7 @@ public class FlatInstantiator implements IInstantiator {
final IMethod method = methods.iterator().next();
assert (method.isInit());
final SSAInstruction firstInstruction = this.cache.getIR(method).iterateAllInstructions().next();
logger.debug("First instruction of ctor is: " + firstInstruction);
if (firstInstruction instanceof SSAAbstractInvokeInstruction) {
final SSAAbstractInvokeInstruction invokation = (SSAAbstractInvokeInstruction) firstInstruction;
return invokation.isSpecial(); // Always?
@ -647,12 +643,12 @@ public class FlatInstantiator implements IInstantiator {
score = candidScore;
}
logger.debug("CTor {} got score {}", im, candidScore);
}
if (ctor == null) {
logger.warn("Still found no CTor for {}", T);
return cha.resolveMethod(klass, MethodReference.initSelector);
} else {
return ctor;

View File

@ -46,9 +46,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.analysis.typeInference.ConeType;
import com.ibm.wala.analysis.typeInference.PrimitiveType;
@ -87,7 +85,6 @@ import com.ibm.wala.util.strings.Atom;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public class Instantiator implements IInstantiator {
private static final Logger logger = LoggerFactory.getLogger(Instantiator.class);
final IClassHierarchy cha;
final VolatileMethodSummary body;
@ -108,7 +105,7 @@ public class Instantiator implements IInstantiator {
private boolean isExcluded(IClass cls) {
if (this.analysisScope.getExclusions().contains(cls.getName().toString())) { // XXX FUUUUU
logger.info("Hit exclusions with {}", cls);
return true;
} else {
return false;
@ -133,7 +130,7 @@ public class Instantiator implements IInstantiator {
throw new IllegalArgumentException("Can't create an instance of null");
}
if (seen == null) {
logger.debug("Empty seen");
seen = new HashSet<SSAValue>();
}
@ -180,10 +177,10 @@ public class Instantiator implements IInstantiator {
pm.setAllocation(instance, getInst);
return instance;
} else {
logger.info("NEW Component {} \n\tbreadCrumb: {}", instance, pm.breadCrumb);
}
} else {
logger.info("NEW Component {} \n\tbreadCrumb: {}", instance, pm.breadCrumb);
}
}
} // */
@ -193,9 +190,9 @@ public class Instantiator implements IInstantiator {
return instance;
} else if (klass == null) {
if (! T.getName().toString().startsWith("Landroid/")) {
logger.error("The Type {} is not in the ClassHierarchy! Returning null as instance", T);
} else {
logger.debug("The Type {} is not in the ClassHierarchy! Returning null as instance", T);
}
this.body.addConstant(instance.getNumber(), new ConstantValue(null));
instance.setAssigned();
@ -208,7 +205,7 @@ public class Instantiator implements IInstantiator {
final Set<TypeReference> types = getTypes(T);
logger.info("Creating instance of {} is {}", T, types);
if (types.isEmpty()) {
throw new IllegalStateException("Types of " + T + " are empty");
}
@ -224,7 +221,7 @@ public class Instantiator implements IInstantiator {
assert(newInst.getDef() == instance.getNumber());
return instance;
} else if (klass.isArrayClass()) {
logger.info("Creating Array-Class {}", klass.toString());
final TypeReference payloadType = T.getArrayElementType();
SSAValue payload = null;
@ -232,7 +229,7 @@ public class Instantiator implements IInstantiator {
for (final SSAValue see : seen) {
if (ParameterAccessor.isAssignable(see.getType(), payloadType, this.cha)) {
// Happens on Array of interfaces
logger.trace("Reusing {} for array payload {}", see, payload);
payload = see;
}
}
@ -271,7 +268,7 @@ public class Instantiator implements IInstantiator {
return instance;
} else {
// Abstract, Interface or array
logger.debug("Not a regular class {}", T);
final Set<SSAValue> subInstances = new HashSet<SSAValue>();
for (final TypeReference type : types) {
final IClass subKlass = this.cha.lookupClass(type);
@ -334,7 +331,7 @@ public class Instantiator implements IInstantiator {
this.pm.setPhi(instance, phi);
}
} else {
logger.warn("No sub-instances for: {} - setting to null", instance);
this.body.addConstant(instance.getNumber(), new ConstantValue(null));
instance.setAssigned();
}
@ -403,7 +400,7 @@ public class Instantiator implements IInstantiator {
final IMethod cTor = lookupConstructor(val.getType());
final ParameterAccessor ctorAcc = new ParameterAccessor(cTor);
assert (ctorAcc.hasImplicitThis()) : "CTor detected as not having implicit this pointer";
logger.debug("Acc for: %", this.scope);
final ParameterAccessor acc = new ParameterAccessor(this.scope, false); // TODO pm needs a connectThrough too!
// TODO false is false
// TODO: The overrides may lead to use before definition
@ -416,8 +413,8 @@ public class Instantiator implements IInstantiator {
seen.add(nullSelf);
seen.addAll(overrides);
logger.debug("Recursing for: {}", cTor);
logger.debug("With seen: {}", seen);
final List<SSAValue> ctorParams = acc.connectThrough(ctorAcc, overrides, /* defaults */ null, this.cha,
this, /* managed */ false, /* key */ null, seen); // XXX This starts the recursion!
addCallCtor(val, cTor.getReference(), ctorParams);
@ -443,19 +440,18 @@ public class Instantiator implements IInstantiator {
* Used internally to avoid endless recursion on getTypes().
*/
private Set<TypeReference> getTypes(final TypeReference T, final Set<TypeReference> seen) {
logger.debug("getTypes({}, {})", T, seen);
final Set<TypeReference> ret = new HashSet<TypeReference>();
ret.add(T);
if (T.isPrimitiveType()) {
logger.warn("getTypes called on a primitive");
return ret;
//throw new IllegalArgumentException("Not you that call primitive type on :P");
}
final IClass cls = this.cha.lookupClass(T);
if (cls == null) {
logger.error("The type {} is not in the ClassHierarchy - try continuing anyway", T);
return ret;
//throw new IllegalArgumentException("The type " + T + " is not in the ClassHierarchy");
} else if (isExcluded(cls)) {
@ -469,9 +465,9 @@ public class Instantiator implements IInstantiator {
if (impls.isEmpty()) {
//throw new IllegalStateException("The interface " + T + " has no known implementors");
if (! T.getName().toString().startsWith("Landroid/")) {
logger.error("The interface {} has no known implementors - skipping over it", T);
} else {
logger.debug("The interface {} has no known implementors - skipping over it", T);
}
return ret; // XXX: This is a bad idea?
} else {
@ -491,7 +487,7 @@ public class Instantiator implements IInstantiator {
} else {
for (final IClass sub: subs) {
if (seen.contains(sub.getReference())) {
logger.debug("Seen: {}", sub);
continue;
}
if (sub.isAbstract()) {
@ -576,7 +572,7 @@ public class Instantiator implements IInstantiator {
final IMethod method = methods.iterator().next();
assert (method.isInit());
final SSAInstruction firstInstruction = this.cache.getIR(method).iterateAllInstructions().next();
logger.debug("First instruction of ctor is: " + firstInstruction);
if (firstInstruction instanceof SSAAbstractInvokeInstruction) {
final SSAAbstractInvokeInstruction invokation = (SSAAbstractInvokeInstruction) firstInstruction;
return invokation.isSpecial(); // Always?
@ -648,12 +644,12 @@ public class Instantiator implements IInstantiator {
score = candidScore;
}
logger.debug("CTor {} got score {}", im, candidScore);
}
if (ctor == null) {
logger.warn("Still found no CTor for {}", T);
return cha.resolveMethod(klass, MethodReference.initSelector);
} else {
return ctor;

View File

@ -45,9 +45,6 @@ import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader;
import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -64,7 +61,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-25
*/
public class LoadedInstantiationBehavior extends IInstantiationBehavior implements Serializable {
private static Logger logger = LoggerFactory.getLogger(LoadedInstantiationBehavior.class);
private static final class BehviourValue implements Serializable {
public final InstanceBehavior behaviour;
@ -201,7 +197,7 @@ public class LoadedInstantiationBehavior extends IInstantiationBehavior implemen
testClass = testClass.getSuperclass();
}
} else {
logger.warn("I got no classhierarchy. Can't test super classes");
}
}

View File

@ -42,9 +42,7 @@ package com.ibm.wala.dalvik.ipa.callgraph.androidModel.parameters;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.AndroidModel;
@ -82,9 +80,7 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-11-02
*/
public class ReuseParameters {
private Logger logger = LoggerFactory.getLogger(ReuseParameters.class);
public static class ReuseParameter extends Parameter {
public static class ReuseParameter extends Parameter {
protected ReuseParameter(final int number, final String name, final TypeReference type, final MethodReference mRef,
final int descriptorOffset) {
super(number, name, type, ParamerterDisposition.PARAM, BasedOn.IMETHOD, mRef, descriptorOffset);
@ -138,7 +134,7 @@ public class ReuseParameters {
if (isReuse(paramType, ALL_TARGETS)) {
if (! reuseParameters.contains(paramType)) { // XXX: Why not use a Set?
reuseParameters.add(paramType);
logger.info("REUSE: {}", paramType.toString());
}
}
}
@ -200,7 +196,7 @@ public class ReuseParameters {
withName = inCallTo.getLocalVariableName (bcIndex, localNumber);
} catch (UnsupportedOperationException e) {
// DexIMethod doesn't implement this :(
logger.warn("{}", e);
withName = null;
}
asParameterTo = inCallTo.getDeclaringClass().getName();
@ -220,7 +216,6 @@ public class ReuseParameters {
final InstanceBehavior beh = this.instanceBehavior.getBehavior(param, asParameterTo, inCall, withName);
logger.debug("getBehavior({}, {}, {}, {}) = {}", param, asParameterTo, inCall, withName, beh);
return (beh == InstanceBehavior.REUSE);
}
@ -262,7 +257,7 @@ public class ReuseParameters {
final ReuseParameter rp = new ReuseParameter(paramSSA, tName, tRef, mRef, descriptorOffset );
pm.setAllocation(rp);
//pm.setAllocation(tRef, paramSSA); // TODO: Old-school call
logger.info("Register: {}", rp);
paramSSA++;
}

View File

@ -44,9 +44,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.IField;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.AndroidModelClass;
@ -78,7 +76,6 @@ import com.ibm.wala.util.ssa.TypeSafeInstructionFactory;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public class SpecializedInstantiator extends FlatInstantiator {
private static final Logger logger = LoggerFactory.getLogger(SpecializedInstantiator.class);
final IInstantiator parent;
@ -108,7 +105,7 @@ public class SpecializedInstantiator extends FlatInstantiator {
/* package private */ SSAValue createInstance(final TypeReference T, final boolean asManaged, VariableKey key, Set<? extends SSAValue> seen, int currentDepth) {
if (seen == null) {
logger.debug("Empty seen");
seen = new HashSet<SSAValue>();
}
@ -232,7 +229,6 @@ public class SpecializedInstantiator extends FlatInstantiator {
instance.setAssigned();
}
logger.info("Created Android-Context from " + appComponents.size() + " components");
return instance;
}

View File

@ -43,9 +43,6 @@ package com.ibm.wala.dalvik.ipa.callgraph.androidModel.structure;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.IExecutionOrder;
@ -76,8 +73,6 @@ import com.ibm.wala.util.ssa.TypeSafeInstructionFactory;
* @since 2013-09-07
*/
public abstract class AbstractAndroidModel {
private static final Logger logger = LoggerFactory.getLogger(AbstractAndroidModel.class);
private ExecutionOrder currentSection = null;
protected VolatileMethodSummary body = null;
protected TypeSafeInstructionFactory insts = null;
@ -103,7 +98,7 @@ public abstract class AbstractAndroidModel {
*/
@Deprecated
protected int makeBrakingNOP(int PC) {
logger.info("Adding Jump-Target at " + PC);
body.addStatement(insts.GotoInstruction(PC, PC));
PC++;
return PC;
@ -355,7 +350,7 @@ public abstract class AbstractAndroidModel {
if ((this.currentSection != null) && (this.currentSection.compareTo(section) >= 0)) {
if (this.currentSection.compareTo(section) == 0) {
logger.error("You entered {} twice! Ignoring second atempt.", section);
} else {
throw new IllegalArgumentException("Sections must be in ascending order! When trying to " +
"enter " + this.currentSection.toString() + " from " + section.toString());
@ -374,28 +369,28 @@ public abstract class AbstractAndroidModel {
}
if ((this.currentSection == null) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.AT_FIRST) >= 0)) {
logger.info("ENTER: AT_FIRST");
PC = enterAT_FIRST(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.AT_FIRST;
}
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.AT_FIRST) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.BEFORE_LOOP) >= 0)) {
logger.info("ENTER: BEFORE_LOOP");
PC = enterBEFORE_LOOP(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.BEFORE_LOOP;
}
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.BEFORE_LOOP) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.START_OF_LOOP) >= 0)) {
logger.info("ENTER: START_OF_LOOP");
PC = enterSTART_OF_LOOP(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.START_OF_LOOP;
}
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.START_OF_LOOP) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.MIDDLE_OF_LOOP) >= 0)) {
logger.info("ENTER: MIDDLE_OF_LOOP");
PC = enterMIDDLE_OF_LOOP(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.MIDDLE_OF_LOOP;
}
@ -403,27 +398,27 @@ public abstract class AbstractAndroidModel {
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.MIDDLE_OF_LOOP) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.MULTIPLE_TIMES_IN_LOOP) >= 0)) {
PC = enterMULTIPLE_TIMES_IN_LOOP(PC);
logger.info("ENTER: MULTIPLE_TIMES_IN_LOOP");
this.currentSection = AndroidEntryPoint.ExecutionOrder.MULTIPLE_TIMES_IN_LOOP;
}
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.MULTIPLE_TIMES_IN_LOOP) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.END_OF_LOOP) >= 0)) {
logger.info("ENTER: END_OF_LOOP");
PC = enterEND_OF_LOOP(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.END_OF_LOOP;
}
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.END_OF_LOOP) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.AFTER_LOOP) >= 0)) {
logger.info("ENTER: AFTER_LOOP");
PC = enterAFTER_LOOP(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.AFTER_LOOP;
}
if ((this.currentSection.compareTo(AndroidEntryPoint.ExecutionOrder.AFTER_LOOP) <= 0) &&
(section.compareTo(AndroidEntryPoint.ExecutionOrder.AT_LAST) >= 0)) {
logger.info("ENTER: AT_LAST");
PC = enterAT_LAST(PC);
this.currentSection = AndroidEntryPoint.ExecutionOrder.AT_LAST;
}

View File

@ -44,9 +44,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.ipa.callgraph.Entrypoint;
@ -76,8 +74,6 @@ import com.ibm.wala.util.ssa.TypeSafeInstructionFactory;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public class LoopAndroidModel extends SingleStartAndroidModel {
private static final Logger logger = LoggerFactory.getLogger(LoopAndroidModel.class);
//protected VolatileMethodSummary body;
//protected JavaInstructionFactory insts;
//protected DexFakeRootMethod.ReuseParameters paramTypes;
@ -102,7 +98,7 @@ public class LoopAndroidModel extends SingleStartAndroidModel {
* {@inheritDoc}
*/
protected int enterSTART_OF_LOOP (int PC) {
logger.info("PC {} is the jump target of START_OF_LOOP", PC);
this.outerLoopPC = PC;
PC = makeBrakingNOP(this.outerLoopPC);
@ -141,7 +137,7 @@ public class LoopAndroidModel extends SingleStartAndroidModel {
// Insert the Phis at the beginning of the Block
int phiPC = outerLoopPC + 1;
boolean oldAllowReserved = body.allowReserved(true);
logger.info("Setting block-inner Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final SSAValue oldPhi = outerStartingPhis.get(phiType);
final List<SSAValue> forPhi = new ArrayList<SSAValue>(2);
@ -156,19 +152,19 @@ public class LoopAndroidModel extends SingleStartAndroidModel {
body.allowReserved(oldAllowReserved);
// Close the Loop
logger.info("Closing Loop");
logger.info("PC {}: Goto {}", PC, outerLoopPC);
body.addStatement(insts.GotoInstruction(PC, outerLoopPC));
paramManager.scopeUp();
// Add Phi-Statements at the beginning of this block...
logger.info("Setting outer-block Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final VariableKey phiKey = outerStartingPhis.get(phiType).key;
PC = body.getNextProgramCounter();
List<SSAValue> all = paramManager.getAllForPhi(phiKey);
logger.debug("Into phi {} for {}", all, phiType.getName());
// Narf ... unpacking...
paramManager.invalidate(phiKey);
@ -188,7 +184,7 @@ public class LoopAndroidModel extends SingleStartAndroidModel {
* {@inheritDoc}
*/
protected int leaveAT_LAST (int PC) {
logger.info("Leaving Model with PC = {}", PC);
return PC;
}

View File

@ -44,9 +44,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.ipa.callgraph.Entrypoint;
@ -72,8 +70,6 @@ import com.ibm.wala.util.ssa.TypeSafeInstructionFactory;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public class LoopKillAndroidModel extends LoopAndroidModel {
private static final Logger logger = LoggerFactory.getLogger(LoopKillAndroidModel.class);
//protected VolatileMethodSummary body;
//protected JavaInstructionFactory insts;
//protected DexFakeRootMethod.ReuseParameters paramTypes;
@ -96,7 +92,7 @@ public class LoopKillAndroidModel extends LoopAndroidModel {
* {@inheritDoc}
*/
protected int enterAT_FIRST(int PC) {
logger.info("PC {} is the jump target of START_OF_LOOP", PC);
this.outerLoopPC = PC;
PC = makeBrakingNOP(this.outerLoopPC);
@ -135,7 +131,7 @@ public class LoopKillAndroidModel extends LoopAndroidModel {
// Insert the Phis at the beginning of the Block
int phiPC = outerLoopPC + 1;
boolean oldAllowReserved = body.allowReserved(true);
logger.info("Setting block-inner Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final SSAValue oldPhi = outerStartingPhis.get(phiType);
final List<SSAValue> forPhi = new ArrayList<SSAValue>(2);
@ -150,19 +146,19 @@ public class LoopKillAndroidModel extends LoopAndroidModel {
body.allowReserved(oldAllowReserved);
// Close the Loop
logger.info("Closing Loop");
logger.info("PC {}: Goto {}", PC, outerLoopPC);
body.addStatement(insts.GotoInstruction(PC, outerLoopPC));
paramManager.scopeUp();
// Add Phi-Statements at the beginning of this block...
logger.info("Setting outer-block Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final VariableKey phiKey = outerStartingPhis.get(phiType).key;
PC = body.getNextProgramCounter();
List<SSAValue> all = paramManager.getAllForPhi(phiKey);
logger.debug("Into phi {} for {}", all, phiType.getName());
// Narf ... unpacking...
paramManager.invalidate(phiKey);

View File

@ -44,9 +44,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.ipa.callgraph.Entrypoint;
@ -75,8 +73,6 @@ import com.ibm.wala.util.ssa.TypeSafeInstructionFactory;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public class SingleStartAndroidModel extends AbstractAndroidModel {
private static final Logger logger = LoggerFactory.getLogger(SingleStartAndroidModel.class);
//protected VolatileMethodSummary body;
//protected JavaInstructionFactory insts;
//protected DexFakeRootMethod.ReuseParameters paramTypes;
@ -102,7 +98,7 @@ public class SingleStartAndroidModel extends AbstractAndroidModel {
* {@inheritDoc}
*/
protected int enterMULTIPLE_TIMES_IN_LOOP (int PC) {
logger.info("PC {} is the jump target of START_OF_LOOP", PC);
this.outerLoopPC = PC;
PC = makeBrakingNOP(this.outerLoopPC);
@ -141,7 +137,7 @@ public class SingleStartAndroidModel extends AbstractAndroidModel {
// Insert the Phis at the beginning of the Block
int phiPC = outerLoopPC + 1;
boolean oldAllowReserved = body.allowReserved(true);
logger.info("Setting block-inner Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final SSAValue oldPhi = outerStartingPhis.get(phiType);
final List<SSAValue> forPhi = new ArrayList<SSAValue>(2);
@ -156,19 +152,19 @@ public class SingleStartAndroidModel extends AbstractAndroidModel {
body.allowReserved(oldAllowReserved);
// Close the Loop
logger.info("Closing Loop");
logger.info("PC {}: Goto {}", PC, outerLoopPC);
body.addStatement(insts.GotoInstruction(PC, outerLoopPC));
paramManager.scopeUp();
// Add Phi-Statements at the beginning of this block...
logger.info("Setting outer-block Phis");
for (TypeReference phiType : outerStartingPhis.keySet()) {
final VariableKey phiKey = outerStartingPhis.get(phiType).key;
PC = body.getNextProgramCounter();
List<SSAValue> all = paramManager.getAllForPhi(phiKey);
logger.debug("Into phi {} for {}", all, phiType.getName());
// Narf ... unpacking...
paramManager.invalidate(phiKey);

View File

@ -43,9 +43,7 @@ package com.ibm.wala.dalvik.ipa.callgraph.androidModel.stubs;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
@ -81,7 +79,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-22
*/
public class AndroidStartComponentTool {
private static Logger logger = LoggerFactory.getLogger(AndroidStartComponentTool.class);
private final IClassHierarchy cha;
// private final MethodReference asMethod;
@ -133,7 +130,7 @@ public class AndroidStartComponentTool {
//}
logger.debug("Starting Component {} from {} ", info, callerNd);
this.cha = cha;
// this.asMethod = asMethod;
this.flags = flags;
@ -245,7 +242,7 @@ public class AndroidStartComponentTool {
*/
public SSAValue fetchCallerContext() {
/*if (flags.contains(StarterFlags.CONTEXT_FREE)) {
logger.warn("Asking for context when Context-Free");
return null; // XXX: Return a synthetic null?
}*/
if (caller == null) {
@ -257,14 +254,14 @@ public class AndroidStartComponentTool {
final IClass iApp = cha.lookupClass(AndroidTypes.Application);
final IClass iService = cha.lookupClass(AndroidTypes.Service);
logger.debug("Fetching caller context...");
final SSAValue androidContext;
if (caller.getName().equals(AndroidTypes.ContextWrapperName)) {
this.callerContext = AndroidTypes.AndroidContextType.USELESS;
return null;
/*{ // Fetch ContextWrapperName.mBase => androidContext
androidContext = pm.getUnmanaged(AndroidTypes.Context, "callerContext");
logger.debug("Fetching ContextWrapperName.mBase");
final FieldReference mBaseRef = FieldReference.findOrCreate(AndroidTypes.ContextWrapper, Atom.findOrCreateAsciiAtom("mBase"),
AndroidTypes.Context);
@ -281,14 +278,14 @@ public class AndroidStartComponentTool {
{ // self is already the right context
androidContext = self;
this.callerContext = AndroidTypes.AndroidContextType.CONTEXT_IMPL;
logger.info("Caller has android-context type: ContextImpl");
return androidContext;
}
} else if (cha.isAssignableFrom(iActivity, iCaller)) {
// We don't need it for now - TODO grab anyway
androidContext = null;
this.callerContext = AndroidTypes.AndroidContextType.ACTIVITY;
logger.info("Caller has android-context type: Activity");
return androidContext;
} else if (caller.equals(AndroidModelClass.ANDROID_MODEL_CLASS)) {
// TODO: Return something useful
@ -298,17 +295,17 @@ public class AndroidStartComponentTool {
// XXX ???
androidContext = self;
this.callerContext = AndroidTypes.AndroidContextType.CONTEXT_BRIDGE;
logger.info("Caller has android-context type: BridgeContext");
return androidContext;
} else if (cha.isAssignableFrom(iApp, iCaller)) {
androidContext = self;
this.callerContext = AndroidTypes.AndroidContextType.APPLICATION;
logger.info("Caller has android-context type: Application");
return androidContext;
} else if (cha.isAssignableFrom(iService, iCaller)) {
androidContext = self;
this.callerContext = AndroidTypes.AndroidContextType.SERVICE;
logger.info("Caller has android-context type: Service");
return androidContext;
} else {
throw new UnsupportedOperationException("Can not handle the callers android-context of " + caller);
@ -325,7 +322,7 @@ public class AndroidStartComponentTool {
* @throws UnsupportedOperationException when fetching is not supported with the current settings
*/
public SSAValue fetchIBinder(SSAValue androidContext) {
logger.debug("Fetching context to use for call...");
final SSAValue iBinder = pm.getUnmanaged(AndroidTypes.IBinder, "foreignIBinder");
if (flags.contains(StarterFlags.CONTEXT_FREE)) {
@ -365,7 +362,7 @@ public class AndroidStartComponentTool {
redirect.addStatement(invokation);
}
logger.info("The context to use for the call is from an IBinder");
return iBinder;
//} else if (caller.getName().equals(AndroidTypes.ActivityName)) {
} else if (this.callerContext == AndroidTypes.AndroidContextType.ACTIVITY) {
@ -400,14 +397,13 @@ public class AndroidStartComponentTool {
redirect.addStatement(invokation);
} // */
logger.info("The context (IBinder) to use for the call is the one from the calling activity");
return iBinder;
} else if (this.callerContext == AndroidTypes.AndroidContextType.CONTEXT_IMPL) {
// For bindService its mActivityToken - TODO: For the rest?
// startActivity uses mMainThread.getApplicationThread()
{ // read mActivityToken -> iBinder
logger.debug("Fetching ContextImpl.mActivityToken to iBinder");
final FieldReference mActivityTokenRef = FieldReference.findOrCreate(AndroidTypes.ContextImpl,
Atom.findOrCreateAsciiAtom("mActivityToken"), AndroidTypes.IBinder);
@ -416,11 +412,10 @@ public class AndroidStartComponentTool {
redirect.addStatement(getInst);
}
logger.info("The context (IBinder) to use for the call is the one from the caller");
return iBinder;
} else if (this.callerContext == AndroidTypes.AndroidContextType.CONTEXT_BRIDGE) {
// TODO: Return something useful
logger.error("Not Implemented: Fetch an IBinder from a BridgeContext.");
return null;
} else if (caller.equals(AndroidModelClass.ANDROID_MODEL_CLASS)) {
// TODO: Return something useful
@ -438,10 +433,10 @@ public class AndroidStartComponentTool {
// TODO: Some day we may throe here...
return;
}
logger.info("Assigning the iBinder");
// TODO: Use Phi?
for (SSAValue activity : allActivities) {
logger.debug("\tto: {}", activity);
//final int callPC = redirect.getNextProgramCounter();
final FieldReference mTokenRef = FieldReference.findOrCreate(AndroidTypes.Activity, Atom.findOrCreateAsciiAtom("mToken"),
@ -459,10 +454,10 @@ public class AndroidStartComponentTool {
if (intent == null) {
throw new IllegalArgumentException("Null-Intent");
}
logger.info("Assigning the intent");
// TODO: Use Phi?
for (SSAValue activity : allActivities) {
logger.debug("\tto: {}", activity);
final int callPC = redirect.getNextProgramCounter();
final Selector mSel = Selector.make("setIntent(Landroid/content/Intent;)V");
@ -490,7 +485,7 @@ public class AndroidStartComponentTool {
final SSAValue tmpResultCode = pm.getUnmanaged(TypeReference.Int, "mResultCode");
{ // Fetch mResultCode
//redirect.setLocalName(tmpResultCode, "gotResultCode");
logger.debug("Fetching ResultCode");
final FieldReference mResultCodeRef = FieldReference.findOrCreate(AndroidTypes.Activity, Atom.findOrCreateAsciiAtom("mResultCode"),
TypeReference.Int);
@ -502,7 +497,7 @@ public class AndroidStartComponentTool {
final SSAValue tmpResultData = pm.getUnmanaged(AndroidTypes.Intent, "mResultData");
{ // Fetch mResultData
//redirect.setLocalName(tmpResultData, "gotResultData");
logger.debug("Fetching Result data");
final FieldReference mResultDataRef = FieldReference.findOrCreate(AndroidTypes.Activity, Atom.findOrCreateAsciiAtom("mResultData"),
AndroidTypes.Intent);
@ -522,8 +517,6 @@ public class AndroidStartComponentTool {
* Add Phi (if necessary) - not if only one from.
*/
public SSAValue addPhi(List<? extends SSAValue> from) {
logger.debug("Add Phi({})", from);
if (from.size() == 1) {
return from.get(0);
} else {

View File

@ -43,9 +43,7 @@ package com.ibm.wala.dalvik.ipa.callgraph.androidModel.stubs;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
@ -85,7 +83,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-15
*/
public class ExternalModel extends AndroidModel {
private static Logger logger = LoggerFactory.getLogger(ExternalModel.class);
public final Atom name;
private SummarizedMethod activityModel;
@ -112,7 +109,6 @@ public class ExternalModel extends AndroidModel {
this.name = Atom.findOrCreateAsciiAtom("startExternal" + target.toString());
// this.target = target;
logger.debug("Will be known as {}/{}", AndroidModelClass.ANDROID_MODEL_CLASS.getName(), this.name);
}
//@Override
@ -155,7 +151,7 @@ public class ExternalModel extends AndroidModel {
this.body = new VolatileMethodSummary(new MethodSummary(this.mRef));
this.body.setStatic(true);
logger.debug("The Selector of the method will be {}", selector);
populate(null);
this.klass = AndroidModelClass.getInstance(this.cha);
@ -216,7 +212,7 @@ public class ExternalModel extends AndroidModel {
SSAValue outIntent;
{ // Read out Intent extras
logger.debug("Read Intent extras");
final int callPC = this.body.getNextProgramCounter();
// Bundle Intent.getExtras()
@ -233,7 +229,7 @@ public class ExternalModel extends AndroidModel {
}
/*{ // Read from the bundle returned by the Intent extras // TODO Defunct
logger.debug("Read Intent extras bundle");
// TODO: If I clone it - does it access all?
final int callPC = this.body.getNextProgramCounter();
@ -252,7 +248,7 @@ public class ExternalModel extends AndroidModel {
}
{ // Read from the bundle given as argument
logger.debug("Read optional argument bundle");
// TODO: If I clone it - does it access all?
final int callPC = this.body.getNextProgramCounter();
// Bundle Intent.getExtras()
@ -269,7 +265,7 @@ public class ExternalModel extends AndroidModel {
}*/
{ // Call Intent.putExtra(String name, int value) do add some new info
logger.debug("Calling putExtra");
final SSAValue outName = new SSAValue(nextLocal++, TypeReference.JavaLangString, this.mRef, "outName");
this.body.addConstant(outName.getNumber(), new ConstantValue("my.extra.object"));
final SSAValue outValue = new SSAValue(nextLocal++, TypeReference.Int, this.mRef, "outValue"); // Assign value?
@ -291,7 +287,7 @@ public class ExternalModel extends AndroidModel {
}
{ // Add return statement on intent
logger.debug("Adding return");
final int returnPC = this.body.getNextProgramCounter();
final SSAInstruction returnInstruction = instructionFactory.ReturnInstruction(returnPC, outIntent);

View File

@ -44,9 +44,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
@ -97,8 +95,6 @@ public class Overrides {
}
protected static class StartComponentMethodTargetSelector implements MethodTargetSelector {
private static Logger logger = LoggerFactory.getLogger(StartComponentMethodTargetSelector.class);
protected MethodTargetSelector parent;
protected MethodTargetSelector child;
protected final HashMap<MethodReference, SummarizedMethod> syntheticMethods;
@ -109,7 +105,7 @@ public class Overrides {
*/
public StartComponentMethodTargetSelector(HashMap<MethodReference, SummarizedMethod> syntheticMethods, MethodTargetSelector child) {
//for (MethodReference mRef : syntheticMethods.keySet()) {
// logger.debug("Override: " + mRef);
//
//}
this.syntheticMethods = syntheticMethods;
@ -167,14 +163,14 @@ public class Overrides {
if (caller != null) { // XXX: Debug remove
Context ctx = caller.getContext();
logger.info("Overriding {}", mRef);
logger.debug("Come from: {}", ctx.get(ContextKey.CALLER));
logger.debug("Param 1: {}", ctx.get(new ContextKey.ParameterKey(1)));
logger.debug("Receiver Class: {}", receiver);
}
if (receiver == null) {
logger.warn("Null receiver");
//return null;
//throw new IllegalArgumentException("site is null");
}

View File

@ -42,9 +42,7 @@ package com.ibm.wala.dalvik.ipa.callgraph.androidModel.stubs;
import java.util.Collection;
import java.util.HashSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.AndroidModel;
@ -85,8 +83,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-15
*/
public class SystemServiceModel extends AndroidModel {
private static Logger logger = LoggerFactory.getLogger(SystemServiceModel.class);
public final Atom name;
private SummarizedMethod activityModel;
private final String target;
@ -112,8 +108,6 @@ public class SystemServiceModel extends AndroidModel {
String cName = Character.toUpperCase(sName.charAt(0)) + sName.substring(1);
this.name = Atom.findOrCreateAsciiAtom("startSystemService" + cName);
this.target = target.toString();
logger.debug("Will be known as {}/{}", AndroidModelClass.ANDROID_MODEL_CLASS.getName(), this.name);
}
//@Override
@ -155,7 +149,7 @@ public class SystemServiceModel extends AndroidModel {
this.body = new VolatileMethodSummary(new MethodSummary(this.mRef));
this.body.setStatic(true);
logger.debug("The Selector of the method will be {}", selector);
populate(null);
this.klass = AndroidModelClass.getInstance(this.cha);
@ -207,10 +201,10 @@ public class SystemServiceModel extends AndroidModel {
final SSAValue retVal;
if (this.target.equals("phone")) {
logger.info("Creating new TelephonyManager");
retVal = instantiator.createInstance(AndroidTypes.TelephonyManager, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
//} else if (this.target.equals("Lwindow")) { // TODO: Is an interface
// logger.info("Creating new WindowManager");
//
// final TypeName wmN = TypeName.findOrCreate("Landroid/view/WindowManager");
// final TypeReference wmT = TypeReference.findOrCreate(ClassLoaderReference.Primordial, wmN);
// retVal = instantiator.createInstance(wmT, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
@ -220,43 +214,43 @@ public class SystemServiceModel extends AndroidModel {
//} else if (this.target.equals("Lalarm")) {
//} else if (this.target.equals("Lnotification")) {
} else if (this.target.equals("keyguard")) {
logger.info("Creating new KeyguardManager");
final TypeName n = TypeName.findOrCreate("Landroid/app/KeyguardManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
} else if (this.target.equals("location")) {
logger.info("Creating new LocationManager");
final TypeName n = TypeName.findOrCreate("Landroid/location/LocationManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
} else if (this.target.equals("search")) {
logger.info("Creating new SearchManager"); // TODO: Param: Handler
// TODO: Param: Handler
final TypeName n = TypeName.findOrCreate("Landroid/app/SearchManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
//} else if (this.target.equals("Lvibrator")) { // TODO: Is abstract
} else if (this.target.equals("connection")) {
logger.info("Creating new ConnectivityManager"); // TODO: use ConnectivityManager.from
// TODO: use ConnectivityManager.from
final TypeName n = TypeName.findOrCreate("Landroid/net/ConnectivityManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
} else if (this.target.equals("wifi")) {
logger.info("Creating new WifiManager"); // Handle Params: Context context, IWifiManager service
// Handle Params: Context context, IWifiManager service
final TypeName n = TypeName.findOrCreate("Landroid/net/wifi/WifiManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
} else if (this.target.equals("input_method")) {
logger.info("Creating new InputMethodManager"); // TODO: Use InputMethodManager.getInstance?
// TODO: Use InputMethodManager.getInstance?
final TypeName n = TypeName.findOrCreate("Landroid/view/inputmethod/InputMethodManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
} else if (this.target.equals("uimode")) {
logger.info("Creating new UiModeManager");
final TypeName n = TypeName.findOrCreate("Landroid/app/UiModeManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
} else if (this.target.equals("download")) {
logger.info("Creating new DownloadManager"); // TODO: Params ContentResolver resolver, String packageName
// TODO: Params ContentResolver resolver, String packageName
final TypeName n = TypeName.findOrCreate("Landroid/app/DownloadManager");
final TypeReference T = TypeReference.findOrCreate(ClassLoaderReference.Primordial, n);
retVal = instantiator.createInstance(T, false, new SSAValue.UniqueKey(), new HashSet<Parameter>(pAcc.all()));
@ -264,12 +258,12 @@ public class SystemServiceModel extends AndroidModel {
retVal = pm.getUnmanaged(TypeReference.JavaLangObject, "notFound");
this.body.addConstant(retVal.getNumber(), new ConstantValue(null));
retVal.setAssigned();
logger.error("Unimplemented SystemService: " + this.target);
}
{ // Add return statement on intent
logger.debug("Adding return");
final int returnPC = this.body.getNextProgramCounter();
final SSAInstruction returnInstruction = instructionFactory.ReturnInstruction(returnPC, retVal);

View File

@ -45,9 +45,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
@ -90,8 +88,6 @@ import com.ibm.wala.util.strings.Atom;
* @since 2013-10-18
*/
public class UnknownTargetModel extends AndroidModel {
private static Logger logger = LoggerFactory.getLogger(UnknownTargetModel.class);
public final Atom name;
private boolean doMini = true;
private MiniModel miniModel = null;
@ -127,8 +123,6 @@ public class UnknownTargetModel extends AndroidModel {
//this.allInternal = new MiniModel(cha, options, cache, target);
//this.external = new ExternalModel(cha, options, cache, target);
logger.debug("Will be known as {}/{}", AndroidModelClass.ANDROID_MODEL_CLASS.getName(), this.name);
}
//@Override
@ -180,7 +174,7 @@ public class UnknownTargetModel extends AndroidModel {
if (othersA != null) {
others = new HashSet<TypeName>(Arrays.asList(othersA));
} else {
logger.error("{} has no paramteres!", miniModel);
others = new HashSet<TypeName>();
}
doMini = others.size() > 0;
@ -196,7 +190,7 @@ public class UnknownTargetModel extends AndroidModel {
// not happen.
final AndroidModelClass mClass = AndroidModelClass.getInstance(this.cha);
if (mClass.containsMethod(selector)) {
logger.error("There is already an Android-Model with name {}!", selector);
this.built = true;
this.model = (SummarizedMethod) mClass.getMethod(selector);
return;
@ -323,7 +317,7 @@ public class UnknownTargetModel extends AndroidModel {
final IMethod externalMethod = this.external.getMethod();
{
logger.debug("Calling {} using parameters {}", externalMethod, args);
final int callPC = this.body.getNextProgramCounter();
final CallSiteReference site = CallSiteReference.make(callPC, externalMethod.getReference(),
IInvokeInstruction.Dispatch.STATIC);

View File

@ -42,19 +42,12 @@ package com.ibm.wala.dalvik.ipa.callgraph.impl;
import java.util.Comparator;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.strings.StringStuff;
import com.ibm.wala.util.strings.Atom;
/**
* An AdnroidEntryPoint is basically the same as a DexEntryPoint. The Difference is, that further

View File

@ -46,18 +46,16 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.impl.DefaultEntrypoint;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ipa.cha.IClassHierarchyDweller;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.ipa.cha.IClassHierarchyDweller;
public class DexEntryPoint extends DefaultEntrypoint implements IClassHierarchyDweller {
private static final Logger logger = LoggerFactory.getLogger(DexEntryPoint.class);
/** BEGIN Custom change */
private IClassHierarchy cha;
/** END Custom change */
@ -88,8 +86,6 @@ public class DexEntryPoint extends DefaultEntrypoint implements IClassHierarchyD
@Override
protected TypeReference[] makeParameterTypes(IMethod method, int i) {
TypeReference[] trA = new TypeReference[] {method.getParameterType(i)};
for (TypeReference tr:trA)
logger.trace("trA: " + tr);
return trA;
}

View File

@ -40,12 +40,7 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.Intent;
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallerContext;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.ipa.callgraph.ContextKey;

View File

@ -40,25 +40,15 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.ipa.callgraph.ContextKey;
import com.ibm.wala.types.TypeName;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointManager;
import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.ipa.callgraph.ContextKey;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.util.strings.Atom;
import java.util.Map;
import java.util.Set;
import java.util.EnumSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Determines the target of an Android-Intent.
*
@ -84,8 +74,6 @@ import org.slf4j.LoggerFactory;
* @since 2013-10-12
*/
public class Intent implements ContextItem, Comparable<Intent> {
private static final Logger logger = LoggerFactory.getLogger(Intent.class);
/**
* Key into the Context that represents the Intent.
*/
@ -133,7 +121,6 @@ public class Intent implements ContextItem, Comparable<Intent> {
this(action, null);
}
public Intent(Atom action, Atom uri) {
logger.info("Intent({})", action);
this.action = action;
this.uri = uri;
this.type = null; // Delay computation upon it's need
@ -153,7 +140,7 @@ public class Intent implements ContextItem, Comparable<Intent> {
explicit = Explicit.EXPLICIT;
break;
case EXPLICIT:
logger.warn("setExplicit was called multiple times on {}", this);
unbind();
}
}
@ -192,13 +179,12 @@ public class Intent implements ContextItem, Comparable<Intent> {
assert (! immutable) : "Intent was marked immutable - can't change it.";
this.action = action;
this.explicit = Explicit.EXPLICIT;
logger.info("Intent({})", action);
} else if (isExplicit() && (! this.action.equals(action))) {
// We already have the explicit target. Ignore the change.
logger.warn("Explicit Intent {} becomes ubound! Secod action {} requested", this, action);
unbind();
} else if (! isExplicit() ) {
logger.warn("Making implicit Intent {} explictit! Target: {}", this, action);
assert (! immutable) : "Intent was marked immutable - can't change it.";
this.action = action;
this.explicit = Explicit.EXPLICIT;
@ -225,7 +211,6 @@ public class Intent implements ContextItem, Comparable<Intent> {
if (this.action == null) {
assert (! immutable) : "Intent was marked immutable - can't change it.";
this.action = action;
logger.info("Intent({})", action);
} else if (isExplicit()) {
// We already have the explicit target. Ignore the change.
} else if (! action.equals(this.action)) {
@ -320,7 +305,7 @@ public class Intent implements ContextItem, Comparable<Intent> {
}
String pack = AndroidEntryPointManager.MANAGER.guessPackage();
logger.debug("Is external? {} startsWith {}", intent.action, pack);
if (pack == null) {
// Unknown so not selected as external

View File

@ -40,10 +40,6 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.Intent;
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallerContext;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.ipa.callgraph.ContextKey;

View File

@ -40,62 +40,42 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters.StartInfo;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
import com.ibm.wala.cfg.ControlFlowGraph;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.CodeScanner;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.AndroidModel;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.MicroModel;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.stubs.ExternalModel;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.stubs.SystemServiceModel;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.stubs.UnknownTargetModel;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.classLoader.NewSiteReference;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ssa.IR;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.ContextKey;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.classLoader.CodeScanner;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.summaries.SummarizedMethod;
import com.ibm.wala.util.collections.EmptyIterator;
import com.ibm.wala.util.strings.Atom;
import com.ibm.wala.dalvik.util.AndroidEntryPointManager;
import com.ibm.wala.ssa.ISSABasicBlock;
import com.ibm.wala.cfg.ControlFlowGraph;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.DefUse;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.ipa.callgraph.AnalysisCache;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextKey;
import com.ibm.wala.ipa.callgraph.propagation.AbstractTypeInNode;
import java.util.Iterator;
import com.ibm.wala.util.collections.EmptyIterator;
import java.util.Set;
import java.util.EnumSet;
import com.ibm.wala.ipa.callgraph.propagation.SSAContextInterpreter;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.ipa.summaries.SummarizedMethod;
import com.ibm.wala.ssa.DefUse;
import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.ISSABasicBlock;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.CancelException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.NOPLogger;
/**
* An {@link SSAContextInterpreter} that redirects functions that start Android-Components.
*
@ -115,8 +95,6 @@ import org.slf4j.helpers.NOPLogger;
* @since 2013-10-14
*/
public class IntentContextInterpreter implements SSAContextInterpreter {
private static final Logger logger = LoggerFactory.getLogger(IntentContextInterpreter.class);
private final IntentStarters intentStarters;
private final IClassHierarchy cha;
private final AnalysisOptions options;
@ -138,7 +116,7 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
if (intent.getComponent() != null) {
return intent.getComponent();
} else if (intent.getType() == Intent.IntentType.SYSTEM_SERVICE) {
logger.error("Called fetchTargetComponent on a SystemService");
return null;
} else {
final Set<AndroidComponent> possibleTargets = intentStarters.getInfo(method.getReference()).getComponentsPossible();
@ -149,9 +127,6 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
// TODO: Go interactive and ask user?
final Iterator<AndroidComponent> it = possibleTargets.iterator();
final AndroidComponent targetComponent = it.next();
logger.error("Unable to determine the exact type of component of the function {} calls." +
"Possible targets are {} we'll assume {} for now in " +
"order to not break fatally here.", method, possibleTargets, targetComponent);
return targetComponent;
}
}
@ -184,7 +159,6 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
throw new IllegalArgumentException("node is null");
}
assert understands(node); // Should already have been checked before
logger.debug("IntentContextInterpreter - Retreiving IR of " + node.getMethod().getSignature());
{
// TODO: CACHE!
final Context ctx = node.getContext();
@ -208,7 +182,7 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
info = intentStarters.getInfo(method.getReference());
model = new MicroModel(this.cha, this.options, this.cache, intent.getAction());
logger.info("{} resolved to {} - internal", inIntent, intent);
break;
case SYSTEM_SERVICE:
info = new IntentStarters.StartInfo(
@ -218,26 +192,26 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
new int[] {1} );
model = new SystemServiceModel(this.cha, this.options, this.cache, intent.getAction());
logger.info("{} resolved to {} - SystemService", inIntent, intent);
break;
case EXTERNAL_TARGET:
info = intentStarters.getInfo(method.getReference());
model = new ExternalModel(this.cha, this.options, this.cache, fetchTargetComponent(intent,method));
logger.info("{} resolved to {} - External {}", inIntent, intent, fetchTargetComponent(intent,method));
break;
case STANDARD_ACTION:
logger.warn("Still handling STANDARD_ACTION as UNKONOWN_TARGET: {}", intent.getAction()); // TODO!
// TODO!
// In Order to correctly evaluate a standard-action we would also have to look
// at the URI of the Intent.
case UNKNOWN_TARGET:
info = intentStarters.getInfo(method.getReference());
model = new UnknownTargetModel(this.cha, this.options, this.cache, fetchTargetComponent(intent, method));
logger.info("{} resolved to {} - {}", inIntent, intent, fetchTargetComponent(intent,method));
break;
case IGNORE:
logger.info("{} ignored", inIntent);
return null;
default:
throw new java.lang.UnsupportedOperationException("The Intent-Type " + intent.getType() + " is not known to IntentContextInterpreter");
@ -255,8 +229,6 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
} else {
// This should _not_ happen: IntentContextSelector should always create an IntentContext.
//
logger.error("No target: IntentContextSelector didn't add an IntentContext for the call to: {}, Context: {}",
node.getMethod(), node.getContext() );
final IMethod method = node.getMethod();
final IntentStarters.StartInfo info = intentStarters.getInfo(method.getReference());
assert (info != null) : "IntentInfo is null! Every Starter should have an StartInfo... - Method " + method.getReference();
@ -304,7 +276,6 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
}
assert understands(node); // Should already have been checked before
{
logger.debug("My new site for {} in {}", node.getMethod(), node.getContext());
final IR ir = getIR(node); // Speeeed
return ir.iterateNewSites();
}
@ -317,7 +288,7 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
}
assert understands(node); // Should already have been checked before
{
logger.debug("My call sites");
final IR ir = getIR(node); // Speeeed
return ir.iterateCallSites();
}
@ -346,7 +317,7 @@ public class IntentContextInterpreter implements SSAContextInterpreter {
@Override
public boolean recordFactoryType(CGNode node, IClass klass) {
//this.logger.error("FATAL: recordFactoryType does not understand Node " + node.toString());
//this.
return false;
}

View File

@ -40,53 +40,26 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.Intent;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentMap;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentContext;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.AndroidContext;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentContextInterpreter;
import java.util.Map;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.types.Selector;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters.StartInfo;
import com.ibm.wala.dalvik.util.AndroidEntryPointManager;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextSelector;
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.ipa.callgraph.propagation.NormalAllocationInNode;
import com.ibm.wala.ipa.callgraph.propagation.AbstractTypeInNode;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.util.strings.Atom;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.types.Selector;
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.intset.EmptyIntSet;
import com.ibm.wala.util.intset.IntSet;
import com.ibm.wala.util.intset.BimodalMutableIntSet;
import com.ibm.wala.util.intset.IntSetUtil;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.IntentStarters.StartInfo;
import com.ibm.wala.dalvik.util.AndroidEntryPointManager;
import com.ibm.wala.util.strings.StringStuff;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import com.ibm.wala.util.collections.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Adds Intents to the Context of functions that start Android-Components.
@ -102,9 +75,7 @@ import org.slf4j.LoggerFactory;
* @since 2013-10-14
*/
public class IntentContextSelector implements ContextSelector {
private static final Logger logger = LoggerFactory.getLogger(IntentContextSelector.class);
private final IntentMap intents = new IntentMap();
private final IntentMap intents = new IntentMap();
private final ContextSelector parent;
private final IntentStarters intentStarters;
private final Map<InstanceKey, AndroidContext> seenContext;
@ -149,7 +120,7 @@ public class IntentContextSelector implements ContextSelector {
if (seenContext.containsKey(self)) {
ctx = new AndroidContext(ctx, seenContext.get(self).getContextType());
} else {
logger.warn("No Android-Context seen for {}", caller);
}
} // */
@ -162,8 +133,8 @@ public class IntentContextSelector implements ContextSelector {
continue;
} else if (param.getConcreteType().getName().equals(AndroidTypes.IntentName)) {
if (! intents.contains(param) ) {
logger.error("Unable to resolve Intent called from {}", caller.getMethod());
logger.error("Search Key: {} hash: {}", param, param.hashCode());
break;
} else {
intent = intents.find(param);
@ -180,7 +151,7 @@ public class IntentContextSelector implements ContextSelector {
return new IntentContext(ctx, iintent);
//return new IntentContext(iintent);
} else {
logger.warn("Encountered unresolvable Intent");
intent = new Intent("Unresolvable");
intent.setImmutable();
AndroidEntryPointManager.MANAGER.addCallSeen(site, intent);
@ -205,9 +176,9 @@ public class IntentContextSelector implements ContextSelector {
} else {
intent = null;
if (param == null) {
logger.warn("Got param as 'null'. Obviously can't handle this. Caller was: {}", caller.getMethod());
} else {
logger.warn("Got param as {}. Can't handle this :(", param.getClass());
}
}
}
@ -215,7 +186,7 @@ public class IntentContextSelector implements ContextSelector {
// Add the context
if (intent != null) {
AndroidEntryPointManager.MANAGER.addCallSeen(site, intent);
logger.info("SystemService {} in {} by {}", intent, site, caller);
final Intent iintent = intents.findOrCreateImmutable(intent);
return new IntentContext(ctx, iintent);
//return new IntentContext(iintent);
@ -233,62 +204,55 @@ public class IntentContextSelector implements ContextSelector {
{ // fetch actionKey, uriKey
switch (callee.getNumberOfParameters()) {
case 1:
logger.debug("Handling Intent()");
actionKey = null;
uriKey = null;
break;
case 2:
if (calleeSel.equals(Selector.make("<init>(Ljava/lang/String;)V"))) {
logger.debug("Handling Intent(String action)");
actionKey = actualParameters[1];
} else if (calleeSel.equals(Selector.make("<init>(Landroid/content/Intent;)V"))) {
logger.debug("Handling Intent(Intent other)");
final InstanceKey inIntent = actualParameters[1];
if (intents.contains(inIntent)) {
intents.put(self, intents.find(inIntent));
} else {
logger.warn("In Intent-Copy constructor: Unable to find the original");
}
actionKey = null;
} else {
logger.error("No handling implemented for: {}", callee);
actionKey = null;
}
uriKey = null;
break;
case 3:
if (calleeSel.equals(Selector.make("<init>(Ljava/lang/String;Landroid/net/Uri;)V"))) {
logger.debug("Handling Intent(String action, Uri uri)");
// TODO: Use Information of the URI...
actionKey = actualParameters[1];
uriKey = actualParameters[2];
} else if (calleeSel.equals(Selector.make("<init>(Landroid/content/Context;Ljava/lang/Class;)V"))) {
logger.debug("Handling Intent(Context, Class)");
actionKey = actualParameters[2];
uriKey = null;
isExplicit = true;
} else {
logger.error("No handling implemented for: {}", callee);
actionKey = null;
uriKey = null;
}
break;
case 5:
if (calleeSel.equals(Selector.make("<init>(Ljava/lang/String;Landroid/net/Uri;Landroid/content/Context;Ljava/lang/Class;)V"))) {
logger.debug("Handling Intent(String action, Uri uri, Context, Class)");
actionKey = actualParameters[4];
uriKey = actualParameters[2];
isExplicit = true;
} else {
logger.error("No handling implemented for: {}", callee);
actionKey = null;
uriKey = null;
}
break;
default:
logger.error("Can't extract Info from Intent-Constructor: {} (not implemented)", site);
actionKey = null;
uriKey = null;
}
@ -297,9 +261,9 @@ public class IntentContextSelector implements ContextSelector {
final Intent intent = intents.findOrCreate(self); // Creates Wala-internal Intent
if (actionKey == null) {
logger.trace("Got action as 'null'. Obviously can't handle this. Caller was {}", caller.getMethod());
if (isExplicit) {
logger.warn("An Intent with undeteminable target would be explicit - unbinding. Caller was {}", caller.getMethod());
intent.unbind();
}
} else {
@ -310,7 +274,7 @@ public class IntentContextSelector implements ContextSelector {
// intents.setExplicit(self);
//}
logger.debug("Setting the target of Intent {} in {} by {}", intent, site, caller);
// TODO: Evaluate uriKey
} else if (callee.getSelector().equals(Selector.make("setAction(Ljava/lang/String;)Landroid/content/Intent;")) &&
callee.getDeclaringClass().getName().equals(AndroidTypes.IntentName)) {
@ -319,18 +283,18 @@ public class IntentContextSelector implements ContextSelector {
final Intent intent = intents.find(self);
if (AndroidEntryPointManager.MANAGER.isAllowIntentRerouting()) {
logger.warn("Re-Setting the target of Intent {} in {} by {}", intent, site, caller);
intents.setAction(self, actionKey, false); // May unbind internally
} else {
intents.unbind(self);
}
logger.info("Encountered Intent.setAction - Intent is now: {}", intent);
} else if (callee.getSelector().equals(Selector.make("setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;"))) {
// TODO: We can't extract from ComponentName yet.
final InstanceKey self = actualParameters[0];
final Intent intent = intents.find(self);
logger.warn("Re-Setting the target of Intent {} in {} by {}", intent, site, caller);
intent.setExplicit();
intents.unbind(self);
@ -342,19 +306,19 @@ public class IntentContextSelector implements ContextSelector {
final Intent intent = intents.find(self);
if (AndroidEntryPointManager.MANAGER.isAllowIntentRerouting()) {
logger.warn("Re-Setting the target of Intent {} in {} by {}", intent, site, caller);
intents.setAction(self, actionKey, true);
} else {
intents.unbind(self);
}
logger.info("Encountered Intent.setClass - Intent is now: {}", intent);
} else if (callee.getSelector().equals(Selector.make("fillIn(Landroid/content/Intent;I)I"))) {
// See 'setAction' before... TODO
logger.warn("Intent.fillIn not implemented - Caller: {}", caller);
final InstanceKey self = actualParameters[0];
intents.unbind(self);
} else if (callee.isInit() && callee.getDeclaringClass().getName().equals(AndroidTypes.IntentSenderName)) {
logger.error("Unable to evaluate IntentSender: Not implemented!"); // TODO
// TODO
} /*else if (site.isSpecial() && callee.getDeclaringClass().getName().equals(
AndroidTypes.ContextWrapperName)) {
final InstanceKey baseKey = actualParameters[1];
@ -365,9 +329,9 @@ public class IntentContextSelector implements ContextSelector {
seenContext.put(wrapperKey, seenContext.get(baseKey));
} else {
if (baseKey == null) {
logger.trace("Got baseKey as 'null'. Obviously can't handle this. Caller was: {}", caller.getMethod());
} else {
logger.warn("ContextWrapper: No AndroidContext was seen for baseKey");
}
}
} else if ((site.isSpecial() && callee.getDeclaringClass().getName().equals(
@ -384,9 +348,9 @@ public class IntentContextSelector implements ContextSelector {
seenContext.put(wrapperKey, seenContext.get(baseKey));
} else {
if (baseKey == null) {
logger.trace("Got baseKey as 'null'. Obviously can't handle this. Caller was: {}", caller.getMethod());
} else {
logger.warn("ContextWrapper: No AndroidContext was seen for baseKey");
}
}
} */
@ -420,7 +384,7 @@ public class IntentContextSelector implements ContextSelector {
}
}
logger.debug("Get relevant for {} is {}", site, ret);
} else if (site.isSpecial() && target.getDeclaringClass().getName().equals(
AndroidTypes.IntentName)) {
@ -441,38 +405,33 @@ public class IntentContextSelector implements ContextSelector {
case 1:
return IntSetUtil.make(new int[] { 0, 1 });
case 2:
logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector());
return IntSetUtil.make(new int[] { 0, 1, 2 });
case 3:
logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector());
return IntSetUtil.make(new int[] { 0, 1, 2, 3 });
case 4:
logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector());
return IntSetUtil.make(new int[] { 0, 1, 2, 3, 4 });
default:
logger.debug("Got Intent Constructor of: {}", site.getDeclaredTarget().getSelector());
return IntSetUtil.make(new int[] { 0, 1, 2, 3, 4, 5 });
}
} else if (site.isSpecial() && target.getDeclaringClass().getName().equals(
AndroidTypes.IntentSenderName)) {
// public IntentSender(IIntentSender target)
// public IntentSender(IBinder target)
logger.warn("Encountered an IntentSender-Object");
return IntSetUtil.make(new int[] { 0, 1 });
} /*else if (site.isSpecial() && target.getDeclaringClass().getName().equals(
AndroidTypes.ContextWrapperName)) {
logger.debug("Fetched ContextWrapper ctor");
return IntSetUtil.make(new int[] { 0, 1 });
} else if ((site.isSpecial() && target.getDeclaringClass().getName().equals(
AndroidTypes.ContextImplName))) {
logger.debug("Fetched Context ctor");
return IntSetUtil.make(new int[] { 0 });
} else if (target.getDeclaringClass().getName().equals(AndroidTypes.ContextWrapperName) &&
target.getSelector().equals(Selector.make("attachBaseContext(Landroid/content/Context;)V"))) {
logger.debug("Encountered ContextWrapper.attachBaseContext()");
return IntSetUtil.make(new int[] { 0, 1 });
}*/ else if (target.getSelector().equals(Selector.make("getSystemService(Ljava/lang/String;)Ljava/lang/Object;"))) {
logger.debug("Encountered Context.getSystemService()");
return IntSetUtil.make(new int[] { 0, 1 });
} else if (target.getSelector().equals(Selector.make("setAction(Ljava/lang/String;)Landroid/content/Intent;"))) {
return IntSetUtil.make(new int[] { 0, 1 });

View File

@ -40,19 +40,16 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.Intent;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.util.strings.Atom;
import com.ibm.wala.util.strings.StringStuff;
import java.util.Map;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Stores references to the WALA-Intent objects.
*
@ -61,8 +58,6 @@ import org.slf4j.LoggerFactory;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
/*package*/ class IntentMap {
private static final Logger logger = LoggerFactory.getLogger(IntentContextSelector.class);
private final Map<InstanceKey, Intent> seen = new HashMap<InstanceKey, Intent>();
private final Map<Intent, Intent> immutables = new HashMap<Intent, Intent>();
@ -75,7 +70,7 @@ import org.slf4j.LoggerFactory;
final Intent immutable = intent.clone();
immutable.setImmutable();
immutables.put(intent, immutable);
logger.debug("Now {} immutables", immutables.size());
return immutable;
}
}
@ -185,7 +180,7 @@ import org.slf4j.LoggerFactory;
}
return intent;
} else {
logger.error("setAction: No Intent found for key " + key);
final Intent intent = create(key, action);
return intent;
}
@ -203,7 +198,7 @@ import org.slf4j.LoggerFactory;
public Intent setAction(final InstanceKey key, final InstanceKey actionKey, boolean isExplicit) {
if (actionKey == null) {
logger.trace("Intent: given action is null, keeping it untouched.");
return find(key);
}
final String action;
@ -218,7 +213,7 @@ import org.slf4j.LoggerFactory;
throw new IllegalArgumentException("Wrong action type: " + actionO.getClass());
}
} else {
logger.error("Can't extract the action from Key {} Type {} - unbinding", actionKey, actionKey.getClass());
unbind(key);
return null;
}

View File

@ -40,35 +40,20 @@
*/
package com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.Context;
import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.ipa.callgraph.ContextKey;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointManager;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.util.strings.Atom;
import com.ibm.wala.dalvik.util.AndroidTypes;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Set;
import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.Intent.IntentType;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidTypes;
import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.types.Selector;
import java.util.Collections;
import java.util.Map;
import java.util.HashMap;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.collections.HashMapFactory;
import java.util.Set;
import java.util.EnumSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Contains Information on functions that start Android-Components based on an Intent.

View File

@ -12,14 +12,11 @@
package com.ibm.wala.dalvik.ssa;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
import com.ibm.wala.dalvik.classLoader.DexCFG;
import com.ibm.wala.dalvik.classLoader.DexCFG.BasicBlock;
import com.ibm.wala.dalvik.classLoader.DexConstants;
import com.ibm.wala.dalvik.classLoader.DexIMethod;
import com.ibm.wala.dalvik.dex.instructions.ArrayGet;
import com.ibm.wala.dalvik.dex.instructions.ArrayLength;
import com.ibm.wala.dalvik.dex.instructions.ArrayPut;
@ -75,8 +72,6 @@ import com.ibm.wala.util.debug.UnimplementedError;
*/
@SuppressWarnings("rawtypes")
public abstract class AbstractIntRegisterMachine implements FixedPointConstants {
private static final Logger logger = LoggerFactory.getLogger(AbstractIntRegisterMachine.class);
private static final boolean DEBUG = false;
public static final int TOP = -1;
@ -853,14 +848,14 @@ public abstract class AbstractIntRegisterMachine implements FixedPointConstants
currentSuccessorBlock = null;
Instruction[] instructions = getInstructions();
if (DEBUG) {
logger.debug(("Entry to BB" + cfg.getNumber(basicBlock) + " " + workingState));
System.err.println("Entry to BB" + cfg.getNumber(basicBlock) + " " + workingState);
}
for (int i = basicBlock.getFirstInstructionIndex(); i <= basicBlock.getLastInstructionIndex(); i++) {
currentInstructionIndex = i;
instructions[i].visit(visitor);
if (DEBUG) {
logger.debug(("After " + instructions[i] + " " + workingState));
}
}
return workingState;
@ -872,13 +867,13 @@ public abstract class AbstractIntRegisterMachine implements FixedPointConstants
currentSuccessorBlock = to;
Instruction[] instructions = getInstructions();
if (DEBUG) {
logger.debug(("Entry to BB" + cfg.getNumber(from) + " " + workingState));
System.err.println("Entry to BB" + cfg.getNumber(from) + " " + workingState);
}
for (int i = from.getFirstInstructionIndex(); i <= from.getLastInstructionIndex(); i++) {
currentInstructionIndex = i;
instructions[i].visit(edgeVisitor);
if (DEBUG) {
logger.debug(("After " + instructions[i] + " " + workingState));
}
}
return workingState;

View File

@ -13,10 +13,9 @@ package com.ibm.wala.dalvik.ssa;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.logging.Logger;
import org.jf.dexlib.Code.Format.ArrayDataPseudoInstruction.ArrayElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.cfg.IBasicBlock;
import com.ibm.wala.classLoader.CallSiteReference;
@ -100,8 +99,6 @@ import com.ibm.wala.util.intset.IntPair;
* abstraction and moving to a register-transfer language in SSA form.
*/
public class DexSSABuilder extends AbstractIntRegisterMachine {
private static final Logger logger = LoggerFactory.getLogger(DexSSABuilder.class);
public static DexSSABuilder make(DexIMethod method, SSACFG cfg, DexCFG scfg, SSAInstruction[] instructions,
SymbolTable symbolTable, boolean buildLocalMap, SSAPiNodePolicy piNodePolicy) throws IllegalArgumentException {
if (scfg == null) {
@ -370,7 +367,6 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
}
private void emitInstruction(SSAInstruction s) {
logger.debug("Setting instruction "+getCurrentInstructionIndex()+" to "+s);
instructions[getCurrentInstructionIndex()] = s;
for (int i = 0; i < s.getNumberOfDefs(); i++) {
if (creators.length < (s.getDef(i) + 1)) {
@ -527,7 +523,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
value = symbolTable.getConstant((byte_buffer.get() == 1)?true:false);
else
{
logger.error("Unhandled Primitive Type in visitArrayFill");
value = 0;
}
emitInstruction(insts.ArrayStoreInstruction(getCurrentInstructionIndex(), arrayRef, index, value, t));
@ -794,15 +790,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
@Override
public void visitInvoke(Invoke instruction) {
// TODO: can other methods do indirect reads from a dex method?
logger.debug("Visiting invoke for "+instruction);
if (workingState.getLocals() != null) {
logger.debug("workingState: ");
for(int i = 0; i < workingState.getLocals().length; i++)
{
logger.debug(" "+i+":"+workingState.getLocal(i)+",");
}
}
// doIndirectReads(bytecodeIndirections.indirectlyReadLocals(getCurrentInstructionIndex()));
// doIndirectReads(bytecodeIndirections.indirectlyReadLocals(getCurrentInstructionIndex()));
// int n = instruction.getPoppedCount();
// int n = instruction.args.length;
// int[] params = new int[n];
@ -813,7 +801,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
Language lang = dexCFG.getMethod().getDeclaringClass().getClassLoader().getLanguage();
// TODO: check that the signature needed by findOrCreate can use the descriptor
logger.debug("****" + instruction.clazzName + "****" + instruction.methodName + "****" + instruction.descriptor);
MethodReference m = MethodReference.findOrCreate(lang, loader, instruction.clazzName, instruction.methodName, instruction.descriptor);
@ -823,7 +811,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
// ((Instruction21c)inst).getRegisterA()));
logger.debug("Created method reference "+m+" from "+instruction.clazzName+" descriptor "+m.getReturnType());
IInvokeInstruction.IDispatch code = instruction.getInvocationCode();
CallSiteReference site = CallSiteReference.make(getCurrentProgramCounter(), m, code);
int exc = reuseOrCreateException();
@ -841,7 +829,7 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
if (n == m.getNumberOfParameters()) {
for (int i = 0; i < n; i++) {
params[i] = workingState.getLocal(instruction.args[arg_i]);
logger.trace("visitInvoke param["+i+"] = "+params[i]);
if (m.getParameterType(i) == TypeReference.Double || m.getParameterType(i) == TypeReference.Long)
arg_i++;
arg_i++;
@ -850,11 +838,10 @@ public class DexSSABuilder extends AbstractIntRegisterMachine {
//there is a "this" parameter in this invoke call
else if (n == m.getNumberOfParameters()+1) {
params[0] = workingState.getLocal(instruction.args[0]);
logger.trace("visitInvoke param[0] = "+params[0]);
arg_i = 1;
for (int i = 0; i < (n-1); i++) {
params[i+1] = workingState.getLocal(instruction.args[arg_i]);
logger.trace("visitInvoke param["+(i+1)+"] = "+params[i+1]);
if (m.getParameterType(i) == TypeReference.Double || m.getParameterType(i) == TypeReference.Long)
arg_i++;
arg_i++;

View File

@ -41,7 +41,6 @@
package com.ibm.wala.dalvik.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@ -51,9 +50,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IClassLoader;
import com.ibm.wala.classLoader.IMethod;
@ -81,7 +77,6 @@ import com.ibm.wala.util.config.SetOfClasses;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public final class AndroidEntryPointLocator {
private static final Logger logger = LoggerFactory.getLogger(AndroidEntryPointLocator.class);
private final IProgressMonitor mon;
/**
@ -181,9 +176,7 @@ nextMethod:
if (this.flags.contains(LocatorFlags.INCLUDE_CALLBACKS)) {
for (final AndroidComponent compo : AndroidComponent.values()) {
if (compo == AndroidComponent.UNKNOWN) continue;
if (compo.toReference() == null) {
logger.error("Null-Reference for " + compo);
} else {
if (compo.toReference() != null) {
bases.add(compo.toReference());
}
}
@ -230,7 +223,6 @@ nextMethod:
try {
candids = cha.computeSubClasses(base);
} catch (IllegalArgumentException e) { // Pretty agan :(
logger.error(e.getMessage());
continue;
}
for (final IClass candid : candids) {
@ -244,16 +236,13 @@ nextMethod:
if ((method.isInit() || method.isClinit()) && (! this.flags.contains(LocatorFlags.WITH_CTOR))) {
logger.debug("Skipping constructor of {}", method);
continue;
}
if (baseClass.getMethod(method.getSelector()) != null) {
final AndroidEntryPoint ep = makeEntryPointForHeuristic(method, cha);
if (! eps.contains(ep)) { // Just to be sure that a previous element stays as-is
if (eps.add(ep)) {
logger.debug("Heuristic 1: selecting {} for base {}", method, base);
}
eps.add(ep);
}
}
}
@ -299,9 +288,7 @@ nextMethod:
isAndroidClass = true;
break;
}
logger.trace("Heuristic: \t {} is {}", appClass.getName().toString(), androidClass.getName().toString());
for (IClass iface : appClass.getAllImplementedInterfaces ()) {
logger.trace("Heuristic: \t implements {}", iface.getName().toString());
if (isAPIComponent(iface)) {
isAndroidClass = true;
break;
@ -311,19 +298,16 @@ nextMethod:
androidClass = androidClass.getSuperclass();
}
if (! isAndroidClass) {
logger.trace("Heuristic: Skipping non andoid {}", appClass.getName().toString());
continue; // continue appClass;
}
}
logger.debug("Heuristic: Scanning methods of {}", appClass.getName().toString());
{ // Overridden methods
if (isAPIComponent(appClass)) continue;
if (isExcluded(appClass)) continue;
final Collection<IMethod> methods = appClass.getDeclaredMethods();
for (final IMethod method : methods) {
if ((method.isInit() || method.isClinit()) && (! this.flags.contains(LocatorFlags.WITH_CTOR))) {
logger.debug("Skipping constructor of {}", method);
continue;
}
assert (method.getSelector() != null): "Method has no selector: " + method;
@ -332,10 +316,7 @@ nextMethod:
final AndroidEntryPoint ep = makeEntryPointForHeuristic(method, cha);
if (! eps.contains(ep)) { // Just to be sure that a previous element stays as-is
if (eps.add(ep)) {
logger.debug("Heuristic 2a: selecting {}", method);
}} else {
logger.debug("Heuristic 2a: already selected {}", method);
eps.add(ep);
}
}
}
@ -345,11 +326,9 @@ nextMethod:
final Collection<IClass> iFaces = appClass.getAllImplementedInterfaces();
for (final IClass iFace : iFaces) {
if (isAPIComponent(iFace)) {
logger.debug("Skipping iFace: {}", iFace);
continue;
}
if (isExcluded(iFace)) continue;
logger.debug("Searching Interface {}", iFace);
final Collection<IMethod> ifMethods = iFace.getDeclaredMethods();
for (final IMethod ifMethod : ifMethods) {
final IMethod method = appClass.getMethod(ifMethod.getSelector());
@ -361,9 +340,8 @@ nextMethod:
final AndroidEntryPoint ep = new AndroidEntryPoint(selectPositionForHeuristic(method), method, cha);
if (! eps.contains(ep)) { // Just to be sure that a previous element stays as-is
if (eps.add(ep)) {
logger.debug("Heuristic 2b: selecting {}", method);
}}
eps.add(ep);
}
} else {
// The function is taken from the super-class
if (this.flags.contains(LocatorFlags.WITH_SUPER)) {
@ -378,7 +356,6 @@ nextMethod:
System.arraycopy(oldTypes, 0, newTypes, 0, oldTypes.length);
newTypes[oldTypes.length] = appClass.getReference();
eps_ep.setParameterTypes(0, newTypes);
logger.debug("New This-Types for {} are {}", method.getSelector(), Arrays.toString(newTypes));
}
}
} else {
@ -386,10 +363,7 @@ nextMethod:
ep.setParameterTypes(0, new TypeReference[]{appClass.getReference()});
}
eps.add(ep);
logger.debug("Heuristic 2b: selecting from super {}", method);
}
} else {
logger.debug("Heuristic 2b: Skipping {}", method);
}
}
}

View File

@ -49,9 +49,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.parameters.DefaultInstantiationBehavior;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.parameters.IInstantiationBehavior;
@ -79,8 +76,6 @@ import com.ibm.wala.util.strings.StringStuff;
* @author Tobias Blaschke <code@tobiasblaschke.de>
*/
public final /* singleton */ class AndroidEntryPointManager implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(AndroidEntryPointManager.class);
public static final AndroidEntryPointManager MANAGER = new AndroidEntryPointManager();
public static List<AndroidEntryPoint> ENTRIES = new ArrayList<AndroidEntryPoint>();
/**
@ -341,7 +336,6 @@ public final /* singleton */ class AndroidEntryPointManager implements Serializa
pack = StringStuff.deployment2CanonicalTypeString(pack);
}
if (this.pack == null) {
logger.info("Setting the package to {}", pack);
this.pack = pack;
} else if (!(this.pack.equals(pack))) {
throw new IllegalArgumentException("The already set package " + this.pack + " and " + pack +
@ -365,7 +359,6 @@ public final /* singleton */ class AndroidEntryPointManager implements Serializa
*/
public String getPackage() {
if (this.pack == null) {
logger.warn("Returning null as package");
return null;
} else {
return this.pack;
@ -386,7 +379,7 @@ public final /* singleton */ class AndroidEntryPointManager implements Serializa
return this.pack;
} else {
if (ENTRIES.isEmpty()) {
logger.error("guessPackage() called when no entrypoints had been set");
assert false : "guessPackage() called when no entrypoints had been set";
return null;
}
final String first = ENTRIES.get(0).getMethod().getReference().getDeclaringClass().getName().getPackage().toString();
@ -453,7 +446,6 @@ public final /* singleton */ class AndroidEntryPointManager implements Serializa
throw new IllegalArgumentException("The given Intent is null");
}
logger.info("Register Intent {}", intent);
// Looks a bit weired but works as Intents are only matched based on their action and uri
overrideIntents.put(intent, intent);
}
@ -567,7 +559,6 @@ public final /* singleton */ class AndroidEntryPointManager implements Serializa
throw new IllegalArgumentException("The Intent given as 'to' is null");
}
logger.info("Override Intent {} to {}", from, to);
overrideIntents.put(from, to);
}
@ -590,28 +581,20 @@ public final /* singleton */ class AndroidEntryPointManager implements Serializa
while (!(ret.equals(intent))) {
// Follow the chain of overrides
if (!overrideIntents.containsKey(intent)) {
logger.info("Resolved {} to {}", intent, ret);
return ret;
} else {
logger.debug("Resolving {} hop over {}", intent, ret);
final Intent old = ret;
ret = overrideIntents.get(ret);
if (ret == old) { // Yes, ==
// This is an evil hack(tm). I should fix the Intent-Table!
logger.warn("Malformend Intent-Table, staying with " + ret + " for " + intent);
return ret;
}
}
}
ret = overrideIntents.get(ret); // Once again to get Info set in register
logger.info("Resolved {} to {}", intent, ret);
return ret;
} else {
logger.info("No information on {} hash: {}", intent, intent.hashCode());
for (Intent known : overrideIntents.keySet()) {
logger.debug("Known Intents: {} hash: {}", known, known.hashCode());
}
return intent;
}
}

View File

@ -55,8 +55,6 @@ import java.util.Stack;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@ -95,8 +93,6 @@ public class AndroidManifestXMLReader {
* If you only want Information about objects created use the logger in AndroidSettingFactory as this
* parser generates all objects using it.
*/
private static final Logger logger = LoggerFactory.getLogger(AndroidSettingFactory.class);
public AndroidManifestXMLReader(File xmlFile) throws IOException {
if (xmlFile == null) {
throw new IllegalArgumentException("xmlFile may not be null");
@ -421,7 +417,6 @@ public class AndroidManifestXMLReader {
}
attributesHistory.get(relevant).push(attr);
logger.debug("Pushing '{}' for {} in {}", attr, relevant, self);
// if there is no such value in saxAttrs it returns null
}
}
@ -433,7 +428,6 @@ public class AndroidManifestXMLReader {
public void popAttributes() {
for (Attr relevant : self.getRelevantAttributes()) {
try {
logger.debug("Popping {} of value {} in {}", relevant, attributesHistory.get(relevant).peek(), self);
attributesHistory.get(relevant).pop();
} catch (java.util.EmptyStackException e) {
System.err.println(self + " failed to pop " + relevant);
@ -467,7 +461,6 @@ public class AndroidManifestXMLReader {
}
subTag.getHandler().popAttributes(); // hmmm....
logger.debug("New Stack: {}", parserStack);
//parserStack.pop();
} else {
throw new IllegalStateException(subTag + " is not allowed as sub-tag of " + self + " in Context:\n\t" + parserStack);
@ -579,12 +572,10 @@ public class AndroidManifestXMLReader {
if ((attributesHistory.get(Attr.PACKAGE) != null ) && (!(attributesHistory.get(Attr.PACKAGE).isEmpty()))) {
pack = (String) attributesHistory.get(Attr.PACKAGE).peek();
} else {
logger.warn("Empty Package {}", attributesHistory.get(Attr.PACKAGE).peek());
pack = null;
}
if (name != null) {
logger.info("New Intent ({}, {})", name, url);
final Intent intent = AndroidSettingFactory.intent(name, url);
attributesHistory.get(self).push(intent);
} else {
@ -632,16 +623,13 @@ public class AndroidManifestXMLReader {
if ((attributesHistory.get(Attr.PACKAGE) != null ) && (!(attributesHistory.get(Attr.PACKAGE).isEmpty()))) {
pack = (String) attributesHistory.get(Attr.PACKAGE).peek();
} else {
logger.warn("Empty Package {}", attributesHistory.get(Attr.PACKAGE).peek());
pack = null;
}
final String name = (String) attributesHistory.get(Attr.NAME).peek(); // TODO: Verify type!
final Intent intent = AndroidSettingFactory.intent(pack, name, null);
logger.info("\tRegister: {}", intent);
AndroidEntryPointManager.MANAGER.registerIntent(intent);
for (Intent ovr: overrideTargets) {
logger.info("\tOverride: {} --> {}", ovr, intent);
AndroidEntryPointManager.MANAGER.setOverride(ovr, intent);
}
}
@ -661,9 +649,7 @@ public class AndroidManifestXMLReader {
if ((tag == Tag.UNIMPORTANT) || (unimportantDepth > 0)) {
unimportantDepth++;
} else {
logger.debug("Handling {} made from {}", tag, qName);
final ParserItem handler = tag.getHandler();
final ParserItem handler = tag.getHandler();
if (handler != null) {
handler.enter(attrs);
}

View File

@ -44,9 +44,6 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dalvik.ipa.callgraph.androidModel.parameters.IInstantiationBehavior;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
@ -67,8 +64,6 @@ import com.ibm.wala.types.TypeReference;
* @since 2013-11-01
*/
public class AndroidPreFlightChecks {
private final Logger logger = LoggerFactory.getLogger(AndroidPreFlightChecks.class);
private final AndroidEntryPointManager manager;
// private final AnalysisOptions options;
private final IClassHierarchy cha;
@ -158,33 +153,28 @@ public class AndroidPreFlightChecks {
boolean pass = true;
if (this.cha.lookupClass(AndroidTypes.Fragment) == null) {
logger.warn("Stubs to old to contain Fragments or class not found");
pass = false;
}
if (this.cha.lookupClass(AndroidTypes.UserHandle) == null) {
logger.warn("Stubs to old to contain UserHandles or class not found");
pass = false;
}
if (this.cha.resolveMethod(
this.cha.lookupClass(AndroidTypes.Activity),
Selector.make("getLoaderManager()Landroid/app/LoaderManager;")) == null) {
logger.warn("Stubs to old to contain function Activity.getLoaderManager()");
pass = false;
}
if (this.cha.resolveMethod(
this.cha.lookupClass(AndroidTypes.Activity),
Selector.make("getSystemService(Ljava/lang/String;)Ljava/lang/Object;")) == null) {
logger.warn("Stubs do not contain function Activity.getSystemService");
pass = false;
pass = false;
}
if (this.cha.resolveMethod(
this.cha.lookupClass(AndroidTypes.Context),
Selector.make("getSystemService(Ljava/lang/String;)Ljava/lang/Object;")) == null) {
logger.warn("Stubs do not contain function Context.getSystemService");
pass = false;
}
@ -215,8 +205,7 @@ public class AndroidPreFlightChecks {
if (test.toString().startsWith("Landroid/")) {
continue;
}
logger.warn("No Intent-Specification was found for {}", test);
pass = false;
pass = false;
}
}
@ -244,14 +233,7 @@ public class AndroidPreFlightChecks {
IInstantiationBehavior.InstanceBehavior behave = behaviour.getBehavior(test,
/* asParameterTo= */ null, /* inCall= */ null, /* withName= */ null);
if (behave != IInstantiationBehavior.InstanceBehavior.REUSE) {
if (pass) {
logger.info("Android Components should be marked REUSE in order to");
logger.info("be able to read back their results.");
logger.info("Additionally the MiniModel expects them to be REUSE and");
logger.info("may fail to be constructed if not.");
}
logger.warn("The Type {} belongs to a {} and should be marked as REUSE", test, ep.getComponent());
pass = false;
pass = false;
}
}
@ -270,14 +252,6 @@ public class AndroidPreFlightChecks {
if (params == null) continue;
for (final TypeName type : params) {
if (type.equals(TypeReference.JavaLangObject.getName())) { // Why if JavaLangObjectName private? .. narf
if (pass) {
logger.info("When an Entry-Point takes a parameter of type Object all Objects");
logger.info("have to be considdered candidates. This will not exactly increase");
logger.info("the accuracy of the result.");
logger.info("You should take a look into this Entry-Points and check if you can");
logger.info("zap these completely.");
}
logger.warn("The entypoint {} has a parameter of type Object", ep);
pass = false;
}
}

View File

@ -44,9 +44,6 @@ import com.ibm.wala.dalvik.ipa.callgraph.propagation.cfa.Intent;
import com.ibm.wala.util.strings.Atom;
import com.ibm.wala.util.strings.StringStuff;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Generate a Settings-Object from a String-Representation.
*
@ -57,8 +54,6 @@ import org.slf4j.LoggerFactory;
* @since 2013-10-14
*/
public class AndroidSettingFactory {
private static final Logger logger = LoggerFactory.getLogger(AndroidSettingFactory.class);
/**
* Add an Intent that is _shure_ to be handled internally _only_.
*
@ -166,10 +161,8 @@ public class AndroidSettingFactory {
type = Intent.IntentType.INTERNAL_TARGET; // TODO Ehhh...
} else if (name.startsWith("android.intent.action")) {
type = Intent.IntentType.STANDARD_ACTION;
} else if ((pack == null) || (pack.isEmpty())) {
logger.warn("Could not determine if {} is internal due to the package not being set", name);
}
}
// convert name to the L-Slash format..
if ((name.startsWith("L") || name.contains("."))) {
name = StringStuff.deployment2CanonicalTypeString(name);
@ -201,7 +194,6 @@ public class AndroidSettingFactory {
}
}
logger.info("Built specification for {}", ret);
return ret;
}

View File

@ -40,9 +40,9 @@
*/
package com.ibm.wala.dalvik.util;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.TypeName;
import com.ibm.wala.types.TypeReference;
/**
* Constants for types used by the AndroidModel

View File

@ -42,10 +42,10 @@ package com.ibm.wala.dalvik.util.androidEntryPoints;
import java.util.List;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
/**
* Hardcoded EntryPoint-specifications for an Android-Activity.

View File

@ -42,10 +42,10 @@ package com.ibm.wala.dalvik.util.androidEntryPoints;
import java.util.List;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
/**
* Hardcoded EntryPoint-specifications for an Android-Application.

View File

@ -41,12 +41,11 @@
package com.ibm.wala.dalvik.util.androidEntryPoints;
import java.util.List;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.util.androidEntryPoints.ActivityEP;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
/**
* Hardcoded EntryPoint-specifications for an Android-Activity.

View File

@ -42,10 +42,10 @@ package com.ibm.wala.dalvik.util.androidEntryPoints;
import java.util.List;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
/**
* Hardcoded EntryPoint-specifications for an Android-ContentProvider.

View File

@ -42,10 +42,10 @@ package com.ibm.wala.dalvik.util.androidEntryPoints;
import java.util.List;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.util.AndroidComponent;
import com.ibm.wala.dalvik.util.AndroidEntryPointLocator.AndroidPossibleEntryPoint;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder;
import com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint;
/**
* Hardcoded EntryPoint-specifications for an Android-Service.

View File

@ -14,7 +14,7 @@
<booleanAttribute key="clearws" value="true"/>
<booleanAttribute key="clearwslog" value="false"/>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="false"/>
<booleanAttribute key="default" value="true"/>
<stringAttribute key="deselected_workspace_plugins" value="NewAtomicSetsBuilder,com.ibm.appscan.jstaint,com.ibm.appscan.jstaint.analysis.ap,com.ibm.appscan.jstaint.exceptions,com.ibm.appscan.jstaint.harness,com.ibm.appscan.jstaint.hybridapps,com.ibm.appscan.jstaint.rules,com.ibm.appscan.jstaint.util,com.ibm.appscan.jstaint.util.logging,com.ibm.wala.andromeda.js.tests,com.ibm.wala.andromeda.rules,com.ibm.wala.andromeda.util,com.ibm.wala.cast.java.polyglot,com.ibm.wala.cast.java.polyglot.test,com.ibm.wala.cast.java.test.data,com.ibm.wala.cast.js,com.ibm.wala.cast.js.html.nu_validator,com.ibm.wala.cast.js.jsir,com.ibm.wala.cast.js.rhino,com.ibm.wala.cast.js.rhino.test,com.ibm.wala.cast.js.test,com.ibm.wala.cast.js.test.data,com.ibm.wala.core.testdata.java8,com.ibm.wala.dalvik,com.ibm.wala.dalvik.test,com.ibm.wala.dotnet,com.ibm.wala.dotnet.ikvm,com.ibm.wala.dotnet.test,com.ibm.wala.eventRacer,com.ibm.wala.ide.jsdt,com.ibm.wala.ide.jsdt.tests,com.ibm.wala.jstaint.rules,com.ibm.wala.jstaint.util,com.ibm.wala.memsat,com.ibm.wala.memsat.jdt.test,com.ibm.wala.memsat.test,com.ibm.wala.memsat.testdata,com.ibm.wala.memsat.tests.internal,com.ibm.wala.scandroid,com.ibm.wala.worklight,com.ibm.wala.worklight.rules"/>
<stringAttribute key="featureDefaultLocation" value="workspace"/>
<stringAttribute key="featurePluginResolution" value="workspace"/>
@ -38,7 +38,7 @@
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dcom.ibm.wala.tracefile=/tmp/jdt15tests.txt -Xmx1024M -XX:MaxPermSize=256M -ea"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<stringAttribute key="product" value="org.eclipse.platform.ide"/>
<booleanAttribute key="run_in_ui_thread" value="false"/>
<setAttribute key="selected_features">
<setEntry value="com.ibm.wala-feature:default"/>

View File

@ -18,7 +18,9 @@ Require-Bundle: com.ibm.wala.core;bundle-version="1.1.3",
org.eclipse.pde;bundle-version="3.8.0",
org.eclipse.pde.core;bundle-version="3.8.1",
org.eclipse.equinox.common;bundle-version="3.6.100",
org.eclipse.core.runtime;bundle-version="3.8.0"
org.eclipse.core.runtime;bundle-version="3.8.0",
org.eclipse.platform;bundle-version="4.4.2",
org.eclipse.ui.ide.application;bundle-version="1.0.501"
Bundle-Activator: com.ibm.wala.ide.jsdt.tests.Activator
Export-Package: com.ibm.wala.ide.jsdt.tests
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View File

@ -68,7 +68,7 @@ public abstract class AbstractJSProjectScopeTest {
return JavaScriptEclipseProjectPath.make(p, Collections.<Pair<String,Plugin>>emptySet());
}
@Ignore("works for me on Eclipse Luna, but I cannot make it work with maven")
//@Ignore("works for me on Eclipse Luna, but I cannot make it work with maven")
@Test
public void testParsing() throws IOException, CoreException {
Set<ModuleEntry> mes = JsdtUtil.getJavaScriptCodeFromProject(project.projectName);

View File

@ -63,8 +63,6 @@ import org.scandroid.domain.IFDSTaintDomain;
import org.scandroid.flow.functions.TaintTransferFunctions;
import org.scandroid.flow.types.FlowType;
import org.scandroid.util.CGAnalysisContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IFlowFunctionMap;
import com.ibm.wala.dataflow.IFDS.IMergeFunction;
@ -86,9 +84,8 @@ import com.ibm.wala.util.MonitorUtil.IProgressMonitor;
public class FlowAnalysis {
private static final Logger logger = LoggerFactory.getLogger(FlowAnalysis.class);
public static <E extends ISSABasicBlock>
public static <E extends ISSABasicBlock>
TabulationResult<BasicBlockInContext<E>, CGNode, DomainElement>
analyze(final CGAnalysisContext<E> analysisContext,
Map<BasicBlockInContext<E>,
@ -144,10 +141,6 @@ public class FlowAnalysis {
final IFlowFunctionMap<BasicBlockInContext<E>> flowFunctionMap
) {
logger.info("*************************");
logger.info("* Running flow analysis *");
logger.info("*************************");
final IFDSTaintDomain<E> domain = d;
final List<PathEdge<BasicBlockInContext<E>>>
@ -219,7 +212,7 @@ public class FlowAnalysis {
TabulationResult<BasicBlockInContext<E>,CGNode, DomainElement> flowResult = solver.solve();
// if (options.ifdsExplorer()) {
// for (int i = 1; i < domain.getSize(); i++) {
// logger.debug("DomainElement #"+i+" = " + domain.getMappedObject(i));
//
// }
// GraphUtil.exploreIFDS(flowResult);
// }

View File

@ -60,12 +60,10 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.scandroid.domain.CodeElement;
import org.scandroid.flow.types.FlowType;
import org.scandroid.flow.types.IKFlow;
import org.scandroid.spec.CallArgSourceSpec;
import org.scandroid.spec.CallRetSourceSpec;
import org.scandroid.spec.EntryArgSourceSpec;
@ -73,8 +71,6 @@ import org.scandroid.spec.ISpecs;
import org.scandroid.spec.SourceSpec;
import org.scandroid.spec.StaticFieldSourceSpec;
import org.scandroid.util.CGAnalysisContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.dataflow.IFDS.ISupergraph;
@ -91,7 +87,6 @@ import com.ibm.wala.util.collections.HashMapFactory;
@SuppressWarnings("rawtypes")
public class InflowAnalysis <E extends ISSABasicBlock> {
private static final Logger logger = LoggerFactory.getLogger(InflowAnalysis.class);
@SuppressWarnings("unchecked")
public static <E extends ISSABasicBlock>
@ -167,10 +162,8 @@ public class InflowAnalysis <E extends ISSABasicBlock> {
bb = graph.getEntriesForProcedure(n)[0];
}
if ( null == bb ) {
logger.error("Could not find entry basic block.");
}
assert bb != null : "Could not find entry basic block.";
ss.addDomainElements(ctx, taintMap, bb.getMethod(), bb, null, null, graph, pa, cg);
}
@ -238,14 +231,9 @@ public class InflowAnalysis <E extends ISSABasicBlock> {
Map<InstanceKey, String> prefixes,
ISpecs s) {
logger.debug("***************************");
logger.debug("* Running inflow analysis *");
logger.debug("***************************");
Map<BasicBlockInContext<E>, Map<FlowType<E>,Set<CodeElement>>> taintMap = HashMapFactory.make();
SourceSpec[] ss = s.getSourceSpecs();
logger.debug(ss.length + " Source Specs. ");
ArrayList<SourceSpec> ssAL = new ArrayList<SourceSpec>();
for (int i = 0; i < ss.length; i++) {
@ -261,26 +249,6 @@ public class InflowAnalysis <E extends ISSABasicBlock> {
if (!ssAL.isEmpty())
processFunctionCalls(ctx, taintMap, ssAL, graph, pa, cha, cg);
logger.info("************");
logger.info("* Results: *");
logger.info("************");
for(Entry<BasicBlockInContext<E>, Map<FlowType<E>,Set<CodeElement>>> e:taintMap.entrySet())
{
for(Entry<FlowType<E>,Set<CodeElement>> e2:e.getValue().entrySet())
{
for(CodeElement o:e2.getValue())
{
if (e2.getKey() instanceof IKFlow) {
InstanceKey e2IK = ((IKFlow<?>)e2.getKey()).getIK();
if (prefixes.containsKey(e2IK))
logger.debug("Uri Prefix: " + prefixes.get(e2IK));
}
logger.debug("\tBasicBlockInContext: "+e.getKey()+"\n\tFlowType: "+e2.getKey()+"\n\tCodeElement: "+o+"\n");
}
}
}
return taintMap;
}

View File

@ -57,8 +57,6 @@ import org.scandroid.domain.IFDSTaintDomain;
import org.scandroid.domain.LocalElement;
import org.scandroid.flow.types.FlowType;
import org.scandroid.util.CGAnalysisContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.TabulationResult;
import com.ibm.wala.ipa.callgraph.CGNode;
@ -70,7 +68,6 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.intset.OrdinalSet;
public class LocalSinkPoint implements ISinkPoint {
private static final Logger logger = LoggerFactory.getLogger(LocalSinkPoint.class);
private final BasicBlockInContext<IExplodedBasicBlock> block;
private final int ssaVal;
@ -97,21 +94,15 @@ public class LocalSinkPoint implements ISinkPoint {
PointerKey pk = ctx.pa.getHeapModel().getPointerKeyForLocal(node,
ssaVal);
OrdinalSet<InstanceKey> iks = ctx.pa.getPointsToSet(pk);
if (null == iks) {
logger.warn("no instance keys found for SinkPoint {}", this);
}
for (InstanceKey ik : iks) {
elts.addAll(ctx.codeElementsForInstanceKey(ik));
}
logger.debug("checking for sources from code elements {}", elts);
for (CodeElement elt : elts) {
logger.debug("possible elements for {}: {}", elt, domain.getPossibleElements(elt));
for (DomainElement de : domain.getPossibleElements(elt)) {
if (flowResult.getResult(block).contains(
domain.getMappedIndex(de))) {
logger.debug("adding taint source {}", de.taintSource);
sources.add(de.taintSource);
}
}

View File

@ -73,8 +73,6 @@ import org.scandroid.spec.ISpecs;
import org.scandroid.spec.SinkSpec;
import org.scandroid.spec.StaticFieldSinkSpec;
import org.scandroid.util.CGAnalysisContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.dataflow.IFDS.ICFGSupergraph;
@ -106,8 +104,6 @@ import com.ibm.wala.util.intset.IntSet;
*
*/
public class OutflowAnalysis {
private static final Logger logger = LoggerFactory
.getLogger(OutflowAnalysis.class);
private final CGAnalysisContext<IExplodedBasicBlock> ctx;
private final CallGraph cg;
@ -136,7 +132,7 @@ public class OutflowAnalysis {
graph.put(source, dests);
}
dests.add(dest);
logger.debug("added edge from {} to {}", source, dest);
}
@SuppressWarnings({ "unused", "unchecked" })
@ -173,7 +169,7 @@ public class OutflowAnalysis {
if (!targetList.get(i).contains(target)) {
continue;
}
logger.debug("Found target: " + target);
int[] argNums = sinkSpecs.get(i).getArgNums();
if (null == argNums) {
@ -191,8 +187,6 @@ public class OutflowAnalysis {
IntSet resultSet = flowResult.getResult(block);
for (int j = 0; j < argNums.length; j++) {
logger.debug("Looping over arg[" + j + "] of "
+ argNums.length);
// The set of flow types we're looking for:
Set<FlowType<IExplodedBasicBlock>> taintTypeSet = HashSetFactory.make();
@ -205,8 +199,6 @@ public class OutflowAnalysis {
for (DomainElement de : elements) {
if (resultSet.contains(domain
.getMappedIndex(de))) {
logger.debug("added to taintTypeSpecs: "
+ de.taintSource);
taintTypeSet.add(de.taintSource);
}
}
@ -220,8 +212,6 @@ public class OutflowAnalysis {
ik))) {
if (resultSet.contains(domain
.getMappedIndex(de))) {
logger.debug("added to taintTypeSpecs: "
+ de.taintSource);
taintTypeSet.add(de.taintSource);
}
}
@ -230,8 +220,6 @@ public class OutflowAnalysis {
for (FlowType<IExplodedBasicBlock> dest : sinkSpecs
.get(i).getFlowType(block)) {
for (FlowType<IExplodedBasicBlock> source : taintTypeSet) {
logger.debug("added edge: " + source
+ " \n \tto \n\t" + dest);
// flow taint into uriIK
addEdge(flowGraph, source, dest);
}
@ -256,19 +244,16 @@ public class OutflowAnalysis {
CGNode node = cg.getNode(im, Everywhere.EVERYWHERE);
if (node == null) {
logger.warn("null CGNode for {}", im.getSignature());
continue;
}
BasicBlockInContext<IExplodedBasicBlock>[] entriesForProcedure = graph
.getEntriesForProcedure(node);
if (entriesForProcedure == null || 0 == entriesForProcedure.length) {
logger.warn("procedure without entries {}", im.getSignature());
continue;
}
if (1 != entriesForProcedure.length) {
logger.error("More than one procedure entry. (Are you sure you're using an ICFGSupergraph?)");
}
BasicBlockInContext<IExplodedBasicBlock> entryBlock = entriesForProcedure[0];
newArgNums = ss.getArgNums();
@ -286,7 +271,7 @@ public class OutflowAnalysis {
// IntIterator itr = flowResult.getResult(block).intIterator();
// while (itr.hasNext()) {
// int i = itr.next();
// logger.debug("domain element at exit: "+domain.getMappedObject(i));
//
//
//
// }
@ -323,7 +308,7 @@ public class OutflowAnalysis {
.getPossibleElements(new InstanceKeyElement(ik))) {
if (flowResult.getResult(entryBlock).contains(
domain.getMappedIndex(de))) {
logger.trace("found outflow in second EntryArgSink loop");
addEdge(flowGraph, de.taintSource,
new ParameterFlow<IExplodedBasicBlock>(
entryBlock, newArgNums[i], false));
@ -347,29 +332,25 @@ public class OutflowAnalysis {
CGNode node = cg.getNode(im, Everywhere.EVERYWHERE);
if (node == null) {
logger.warn("could not find CGNode for SinkSpec {}", ss);
continue;
}
BasicBlockInContext<IExplodedBasicBlock>[] exitsForProcedure = graph
.getExitsForProcedure(node);
if (exitsForProcedure == null || 0 == exitsForProcedure.length) {
logger.warn("could not find exit blocks for SinkSpec {}", ss);
continue;
}
final Set<DomainElement> possibleElements = domain
.getPossibleElements(new ReturnElement());
logger.debug("{} possible elements found for ReturnElement",
possibleElements.size());
for (DomainElement de : possibleElements) {
logger.debug("processing domain element {}", de);
for (BasicBlockInContext<IExplodedBasicBlock> block : exitsForProcedure) {
logger.debug("{} instructions in block",
block.getLastInstructionIndex());
if (flowResult.getResult(block).contains(
domain.getMappedIndex(de))) {
logger.debug("original block has edge");
addEdge(flowGraph, de.taintSource,
new ReturnFlow<IExplodedBasicBlock>(block,
false));
@ -379,7 +360,7 @@ public class OutflowAnalysis {
// while (it.hasNext()) {
// BasicBlockInContext<E> realBlock = it.next();
// if (realBlock.isExitBlock()) {
// logger.warn("found edge to exit");
//
// // addEdge(flowGraph,de.taintSource, new
// ReturnFlow<E>(realBlock, false));
// }
@ -440,14 +421,14 @@ public class OutflowAnalysis {
TabulationResult<BasicBlockInContext<IExplodedBasicBlock>, CGNode, DomainElement> flowResult,
IFDSTaintDomain<IExplodedBasicBlock> domain, ISpecs s) {
logger.debug("****************************");
logger.debug("* Running outflow analysis *");
logger.debug("****************************");
Map<FlowType<IExplodedBasicBlock>, Set<FlowType<IExplodedBasicBlock>>> taintFlow = HashMapFactory.make();
SinkSpec[] ss = s.getSinkSpecs();
logger.debug(ss.length + " sink Specs. ");
for (int i = 0; i < ss.length; i++) {
if (ss[i] instanceof EntryArgSinkSpec)
@ -463,11 +444,11 @@ public class OutflowAnalysis {
"SinkSpec not yet Implemented");
}
logger.info("************");
logger.info("* Results: *");
logger.info("************");
logger.debug("{}", taintFlow.toString());
/* TODO: re-enable this soon! */
/*
@ -475,13 +456,13 @@ public class OutflowAnalysis {
* WalaGraphToJGraphT walaJgraphT = new WalaGraphToJGraphT(flowResult,
* domain, e.getKey(), graph, cg); logger.debug("Source: " +
* e.getKey()); for(FlowType target:e.getValue()) {
* logger.debug("\t=> Sink: " + target); //logger.debug("SourceNode: "+
* //logger.debug("SourceNode: "+
* e.getKey().getRelevantNode() +
* "\nSinkNode: "+target.getRelevantNode());
* walaJgraphT.calcPath(e.getKey().getRelevantNode(),
* target.getRelevantNode()); Iterator<DefaultEdge> edgeI =
* walaJgraphT.getPath().getEdgeList().iterator(); if (edgeI.hasNext())
* logger.debug("\t::Method Trace::"); int counter = 1; while
* int counter = 1; while
* (edgeI.hasNext()) { DefaultEdge edge = edgeI.next();
* logger.debug("\t\t#"+counter+": " +
* walaJgraphT.getJGraphT().getEdgeSource
@ -502,7 +483,7 @@ public class OutflowAnalysis {
SinkSpec ss) {
Set<ISinkPoint> sinkPoints = calculateSinkPoints(ss);
if (!(ss instanceof StaticFieldSinkSpec)) {
logger.debug("for {}, sinkPoints={}", ss, sinkPoints);
}
for (ISinkPoint sinkPoint : sinkPoints) {
for (FlowType<IExplodedBasicBlock> source : sinkPoint.findSources(
@ -534,7 +515,7 @@ public class OutflowAnalysis {
Collection<IMethod> methods = sinkSpec.getNamePattern()
.getPossibleTargets(cha);
if (null == methods) {
logger.warn("no methods found for sink spec {}", sinkSpec);
}
for (IMethod method : methods) {
@ -562,7 +543,7 @@ public class OutflowAnalysis {
Collection<IMethod> methods = sinkSpec.getNamePattern()
.getPossibleTargets(cha);
if (null == methods) {
logger.warn("no methods found for sink spec {}", sinkSpec);
}
Set<CGNode> callees = HashSetFactory.make();
@ -571,8 +552,8 @@ public class OutflowAnalysis {
callees.addAll(cg.getNodes(method.getReference()));
calleeRefs.add(method.getReference());
}
logger.debug("callee nodes {}", callees);
logger.debug("callee refs {}", calleeRefs);
// for each possible callee
for (CGNode callee : callees) {
@ -602,7 +583,7 @@ public class OutflowAnalysis {
}
}
if (invokeIndex == -1) {
logger.error("couldn't find invoke instruction in caller node");
}
final IExplodedBasicBlock block = graph.getICFG()
.getCFG(caller)
@ -634,7 +615,7 @@ public class OutflowAnalysis {
Collection<IMethod> methods = sinkSpec.getNamePattern()
.getPossibleTargets(cha);
if (null == methods) {
logger.warn("no methods found for sink spec {}", sinkSpec);
}
// for all possible returning methods

View File

@ -57,8 +57,6 @@ import org.scandroid.domain.CodeElement;
import org.scandroid.domain.DomainElement;
import org.scandroid.domain.IFDSTaintDomain;
import org.scandroid.domain.LocalElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IUnaryFlowFunction;
import com.ibm.wala.ssa.ISSABasicBlock;
@ -74,8 +72,6 @@ import com.ibm.wala.util.intset.MutableSparseIntSet;
*/
public class CallFlowFunction<E extends ISSABasicBlock> implements
IUnaryFlowFunction {
private static final Logger logger = LoggerFactory
.getLogger(CallFlowFunction.class);
/**
* A map from the code elements of actual parameters, to the set of code
@ -95,7 +91,7 @@ public class CallFlowFunction<E extends ISSABasicBlock> implements
// add a mapping for each parameter
final CodeElement actual = actualParams.get(i);
if (!(actual instanceof LocalElement)) {
logger.warn("non-local code element in actual params list");
}
final CodeElement formal = new LocalElement(i + 1); // +1 for SSA
Set<CodeElement> existingFormals = paramArgsMap.get(actual);

View File

@ -53,8 +53,6 @@ import org.scandroid.domain.DomainElement;
import org.scandroid.domain.IFDSTaintDomain;
import org.scandroid.domain.LocalElement;
import org.scandroid.domain.ReturnElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IUnaryFlowFunction;
import com.ibm.wala.ssa.ISSABasicBlock;
@ -64,7 +62,6 @@ import com.ibm.wala.util.intset.MutableSparseIntSet;
public class CallToReturnFunction <E extends ISSABasicBlock>
implements IUnaryFlowFunction {
private static final Logger logger = LoggerFactory.getLogger(CallToReturnFunction.class);
private IFDSTaintDomain<E> domain;
@ -86,7 +83,7 @@ public class CallToReturnFunction <E extends ISSABasicBlock>
if (de.codeElement instanceof LocalElement || de.codeElement instanceof ReturnElement) {
set.add(d);
} else {
logger.trace("throwing away {}", de);
}
}
return set;

View File

@ -51,8 +51,6 @@ package org.scandroid.flow.functions;
import org.scandroid.domain.DomainElement;
import org.scandroid.domain.IFDSTaintDomain;
import org.scandroid.domain.LocalElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IUnaryFlowFunction;
import com.ibm.wala.ssa.ISSABasicBlock;
@ -68,7 +66,6 @@ import com.ibm.wala.util.intset.SparseIntSet;
*/
public class GlobalIdentityFunction <E extends ISSABasicBlock>
implements IUnaryFlowFunction {
private static final Logger logger = LoggerFactory.getLogger(GlobalIdentityFunction.class);
private final IFDSTaintDomain<E> domain;
@ -88,7 +85,7 @@ public class GlobalIdentityFunction <E extends ISSABasicBlock>
DomainElement de = domain.getMappedObject(d1);
if( de.codeElement instanceof LocalElement ) {
// if the query domain element is a local, then it is /not/ passed through.
logger.trace("taking {} to emptyset", de);
return TaintTransferFunctions.EMPTY_SET;
} else {
return SparseIntSet.singleton(d1);

View File

@ -56,8 +56,6 @@ import org.scandroid.domain.DomainElement;
import org.scandroid.domain.IFDSTaintDomain;
import org.scandroid.domain.InstanceKeyElement;
import org.scandroid.domain.LocalElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IUnaryFlowFunction;
import com.ibm.wala.ipa.callgraph.CGNode;
@ -81,8 +79,6 @@ import com.ibm.wala.util.intset.MutableSparseIntSet;
*/
public class GlobalReturnToNodeFunction<E extends ISSABasicBlock> implements
IUnaryFlowFunction {
private static final Logger logger = LoggerFactory
.getLogger(GlobalReturnToNodeFunction.class);
private final IFDSTaintDomain<E> domain;
private final Map<InstanceKey, Set<CodeElement>> ikMap;
@ -128,7 +124,7 @@ public class GlobalReturnToNodeFunction<E extends ISSABasicBlock> implements
}
}
} else {
logger.debug("throwing away {}", de);
}
}
return set;

View File

@ -48,8 +48,6 @@ package org.scandroid.flow.functions;
import org.scandroid.domain.IFDSTaintDomain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IFlowFunction;
import com.ibm.wala.dataflow.IFDS.IFlowFunctionMap;
@ -69,8 +67,6 @@ import com.ibm.wala.util.intset.SparseIntSet;
public class IDTransferFunctions <E extends ISSABasicBlock> implements
IFlowFunctionMap<BasicBlockInContext<E>> {
@SuppressWarnings("unused")
private static final Logger logger =
LoggerFactory.getLogger(IDTransferFunctions.class);
public static final IntSet EMPTY_SET = new SparseIntSet();
public static final IntSet ZERO_SET = SparseIntSet.singleton(0);

View File

@ -49,7 +49,6 @@
package org.scandroid.flow.functions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@ -64,8 +63,6 @@ import org.scandroid.domain.LocalElement;
import org.scandroid.domain.ReturnElement;
import org.scandroid.domain.StaticFieldElement;
import org.scandroid.flow.types.StaticFieldFlow;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
@ -105,8 +102,6 @@ import com.ibm.wala.util.intset.SparseIntSet;
public class TaintTransferFunctions<E extends ISSABasicBlock> implements
IFlowFunctionMap<BasicBlockInContext<E>> {
private static final Logger logger = LoggerFactory
.getLogger(TaintTransferFunctions.class);
// Java, you need type aliases.
private static class BlockPair<E extends ISSABasicBlock> extends
@ -170,17 +165,17 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
try {
return callFlowFunctions.get(new BlockPair<E>(src, dest));
} catch (ExecutionException e) {
logger.error("Exception accessing callFlowFunctions {}", e);
throw new RuntimeException(e);
}
}
private IUnaryFlowFunction makeCallFlowFunction(BasicBlockInContext<E> src,
BasicBlockInContext<E> dest, BasicBlockInContext<E> ret) {
logger.trace("getCallFlowFunction");
SSAInstruction srcInst = src.getLastInstruction();
if (null == srcInst) {
logger.warn("null source for a call");
return IDENTITY_FN;
}
@ -193,7 +188,7 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
for (int i = 0; i < numParams; i++) {
actualParams.add(i, new LocalElement(srcInst.getUse(i)));
}
logger.trace("actual param list length: {}", actualParams);
// return new TracingFlowFunction<E>(domain, union(new
// GlobalIdentityFunction<E>(domain),
// new CallFlowFunction<E>(domain, actualParams)));
@ -207,11 +202,6 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
@Override
public IUnaryFlowFunction getCallNoneToReturnFlowFunction(
BasicBlockInContext<E> src, BasicBlockInContext<E> dest) {
if (logger.isTraceEnabled()) {
logger.trace("getNoneToReturnFunction");
logger.trace("callee signature: {}", ((SSAInvokeInstruction) src
.getLastInstruction()).getDeclaredTarget().getSignature());
}
// return callNoneToReturn;
/*
* TODO: is this right?
@ -229,11 +219,6 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
@Override
public IUnaryFlowFunction getCallToReturnFlowFunction(
BasicBlockInContext<E> src, BasicBlockInContext<E> dest) {
if (logger.isTraceEnabled()) {
logger.trace("getCallToReturnFunction\n\t{}\n\t-> {}", src
.getMethod().getSignature(), dest.getMethod()
.getSignature());
}
// return new TracingFlowFunction<E>(domain, new
// CallToReturnFunction<E>(domain));
return callToReturn;
@ -245,7 +230,7 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
try {
return normalFlowFunctions.get(new BlockPair<E>(src, dest));
} catch (ExecutionException e) {
logger.error("Exception accessing normalFlowFunctions {}", e);
throw new RuntimeException(e);
}
}
@ -254,29 +239,23 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
BasicBlockInContext<E> src, BasicBlockInContext<E> dest) {
List<UseDefPair> pairs = new ArrayList<UseDefPair>();
if (logger.isTraceEnabled()) {
logger.trace("getNormalFlowFunction {}", dest.getMethod()
.getSignature());
}
// we first try to process the destination instruction
SSAInstruction inst = dest.getLastInstruction();
CGNode node = dest.getNode();
if (null == inst) {
logger.trace("Using identity fn. for normal flow (dest instruction null)");
return IDENTITY_FN;
}
logger.trace("\tinstruction: {}", inst);
Iterable<CodeElement> inCodeElts = getInCodeElts(node, inst);
Iterable<CodeElement> outCodeElts = getOutCodeElts(node, inst);
if (!inCodeElts.iterator().hasNext()) {
logger.trace("no input elements for {}", inst);
}
if (!outCodeElts.iterator().hasNext()) {
logger.trace("no output elements for {}", inst);
}
// for now, take the Cartesian product of the inputs and outputs:
@ -348,19 +327,11 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
@Override
public IFlowFunction getReturnFlowFunction(BasicBlockInContext<E> call,
BasicBlockInContext<E> src, BasicBlockInContext<E> dest) {
if (logger.isTraceEnabled()) {
logger.trace("getReturnFlowFunction\n\t{}\n\t-> {}\n\t-> {}", call
.getNode().getMethod().getSignature(), src.getNode()
.getMethod().getSignature(), dest.getNode().getMethod()
.getSignature());
logger.trace("\t{} -> {} -> {}", call.getLastInstruction(),
src.getLastInstruction(), dest.getLastInstruction());
}
final SSAInstruction inst = call.getLastInstruction();
if (null == inst || !(inst instanceof SSAInvokeInstruction)) {
// if we don't have an invoke, just punt and hope the necessary
// information is already in global elements
logger.warn("call block null or not an invoke instruction");
return globalId;
}
@ -394,10 +365,6 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
if (inst instanceof SSAReturnInstruction) {
// only one possible element for returns
if (logger.isTraceEnabled()) {
logger.trace("making a return element for {}", node.getMethod()
.getSignature());
}
elts.add(new ReturnElement());
return elts;
}
@ -405,10 +372,6 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
if (inst instanceof SSAPutInstruction) {
final Set<CodeElement> fieldAccessCodeElts = getFieldAccessCodeElts(
node, (SSAPutInstruction) inst);
if (logger.isTraceEnabled()) {
logger.trace("put outelts: {}",
Arrays.toString(fieldAccessCodeElts.toArray()));
}
elts.addAll(fieldAccessCodeElts);
}
@ -450,8 +413,8 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
try {
elts.addAll(CodeElement.valueElements(pa, node, valNo));
} catch (IllegalArgumentException e) {
logger.error("Exception working on node: " + node);
logger.error("Node is in method: " + node.getMethod());
throw e;
}
}
@ -493,18 +456,11 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
if (pointsToSet.isEmpty()) {
logger.debug(
"pointsToSet empty for ref of {}, creating InstanceKey manually",
inst);
InstanceKey ik = new ConcreteTypeKey(field.getDeclaringClass());
elts.add(new FieldElement(ik, fieldRef));
elts.add(new InstanceKeyElement(ik));
} else {
for (InstanceKey ik : pointsToSet) {
if (logger.isTraceEnabled()) {
logger.trace("adding elements for field {} on {}",
field.getName(), ik.getConcreteType().getName());
}
elts.add(new FieldElement(ik, fieldRef));
elts.add(new InstanceKeyElement(ik));
}
@ -529,9 +485,6 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
inst.getArrayRef());
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
if (pointsToSet.isEmpty()) {
logger.debug(
"pointsToSet empty for ref of {}, creating InstanceKey manually",
inst);
TypeReference arrayType = TypeReference.findOrCreateArrayOf(inst
.getElementType());
InstanceKey ik = new ConcreteTypeKey(pa.getClassHierarchy()
@ -539,10 +492,6 @@ public class TaintTransferFunctions<E extends ISSABasicBlock> implements
elts.add(new InstanceKeyElement(ik));
} else {
for (InstanceKey ik : pointsToSet) {
if (logger.isTraceEnabled()) {
logger.trace("adding element for array store in {}", ik
.getConcreteType().getName());
}
elts.add(new InstanceKeyElement(ik));
}
}

View File

@ -49,8 +49,6 @@
package org.scandroid.flow.functions;
import org.scandroid.domain.IFDSTaintDomain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.dataflow.IFDS.IUnaryFlowFunction;
import com.ibm.wala.ssa.ISSABasicBlock;
@ -60,23 +58,21 @@ import com.ibm.wala.util.intset.IntSetAction;
public class TracingFlowFunction<E extends ISSABasicBlock> implements IUnaryFlowFunction {
private final IFDSTaintDomain<E> domain;
private final IUnaryFlowFunction function;
private final Logger logger;
public TracingFlowFunction(IFDSTaintDomain<E> domain, IUnaryFlowFunction function) {
this.domain = domain;
this.function = function;
this.logger = LoggerFactory.getLogger(function.getClass());
}
@Override
public IntSet getTargets(int d1) {
IntSet result = function.getTargets(d1);
logger.debug("TRACING: {}", domain.getMappedObject(d1));
result.foreach(new IntSetAction() {
@Override
public void act(int x) {
logger.debug("\t{}", domain.getMappedObject(x));
}
});
return result;

View File

@ -59,9 +59,6 @@ import java.util.Set;
import org.scandroid.spec.AndroidSpecs;
import org.scandroid.spec.MethodNamePattern;
import org.scandroid.util.LoaderUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.ArrayClass;
import com.ibm.wala.classLoader.CallSiteReference;
@ -89,7 +86,6 @@ import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.strings.Atom;
public class AppModelMethod {
private final static Logger logger = LoggerFactory.getLogger(AppModelMethod.class);
int nextLocal;
/**
@ -223,7 +219,6 @@ public class AppModelMethod {
callBacks.add(new MethodParams(im));
TypeReference tr = im.getDeclaringClass().getReference();
if (!typeToID.containsKey(tr)) {
logger.debug("AppModel Mapping type "+tr.getName()+" to id " + nextLocal);
typeToID.put(tr, nextLocal++);
//class is an innerclass
if (tr.getName().getClassName().toString().contains("$")) {
@ -247,7 +242,6 @@ public class AppModelMethod {
TypeReference innerTR = TypeReference.findOrCreate(ClassLoaderReference.Application, packageName+outerClassName);
trLL.push(innerTR);
if (!typeToID.containsKey(innerTR)) {
logger.debug("AppModel Mapping type "+innerTR.getName()+" to id " + nextLocal);
typeToID.put(innerTR, nextLocal++);
aClassToTR.put(innerTR, tr);
}

View File

@ -59,9 +59,6 @@ import java.util.Set;
import org.scandroid.prefixtransfer.StringBuilderUseAnalysis.StringBuilderToStringInstanceKeySite;
import org.scandroid.prefixtransfer.modeledAllocations.ConstantString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IMethod;
@ -74,14 +71,10 @@ import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
import com.ibm.wala.ipa.callgraph.propagation.NormalAllocationInNode;
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
import com.ibm.wala.ssa.ISSABasicBlock;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.graph.Graph;
public class PrefixTransferGraph implements Graph<InstanceKeySite> {
private static final Logger logger = LoggerFactory.getLogger(PrefixTransferGraph.class);
private final Map<InstanceKey, InstanceKeySite> nodeMap = new HashMap<InstanceKey, InstanceKeySite>();
private final List<InstanceKeySite> nodes = new ArrayList<InstanceKeySite>();
@ -110,23 +103,14 @@ public class PrefixTransferGraph implements Graph<InstanceKeySite> {
}
catch(Exception e)
{
logger.error("SBUA failed", e);
continue;
}
for(Entry<ISSABasicBlock, ISSABasicBlock> e : sbua.blockOrdering.entrySet())
{
logger.debug(e.getKey().toString()+" --> "+e.getValue().toString());
SSAInstruction inst = e.getKey().getLastInstruction();
if (inst instanceof SSAInvokeInstruction) {
logger.debug("Call Site \t" + ((SSAInvokeInstruction) inst).getCallSite());
}
}
sbuaMap.put(k, sbua); // map k to sbua in some global map
}
continue;
}
logger.warn("Skipping StringBuilder InstanceKey: "+k);
logger.warn("\tClass loader reference: "+k.getConcreteType().getClassLoader().getReference());
}
}
InstanceKeySite node = null;
@ -137,24 +121,22 @@ public class PrefixTransferGraph implements Graph<InstanceKeySite> {
{
if(k instanceof ConstantKey)
{
logger.debug("ConstantKey: "+((ConstantKey<?>)k).getValue());
node = new ConstantString(pa.getInstanceKeyMapping().getMappedIndex(k), (String)((ConstantKey<?>)k).getValue());
addNode(node);
nodeMap.put(k, node);
}
else if(k instanceof NormalAllocationInNode)
{
logger.debug("NormalAllocationInNode: "+k);
IMethod m = ((NormalAllocationInNode) k).getNode().getMethod();
if (m.getSignature().equals("java.lang.StringBuilder.toString()Ljava/lang/String;")) {
Context context = ((NormalAllocationInNode) k).getNode().getContext();
CGNode caller = (CGNode) context.get(ContextKey.CALLER);
CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE);
InstanceKey receiver = (InstanceKey) context.get(ContextKey.RECEIVER);
logger.debug("StringBuilder.toString() csr: "+csr+" context: "+context+" receiver: "+receiver);
if (caller != null && caller.getMethod().getReference().getDeclaringClass().getClassLoader().equals(ClassLoaderReference.Application))
{
logger.debug("Found StringBuilder receiver for toString call");
node = sbuaMap.get(receiver).getNode(csr,k);
if(node == null)
{
@ -171,37 +153,37 @@ public class PrefixTransferGraph implements Graph<InstanceKeySite> {
// - this may have to be done in another phase
// NormalAllocationInNode ak = (NormalAllocationInNode)k;
// SSAInstruction inst = ak.getNode().getIR().getPEI(ak.getSite());
// logger.debug("NormalAllocationInNode inst: "+inst);
// logger.debug("NormalAllocationInNode uses:");
//
//
// for(int i = 0; i < inst.getNumberOfUses(); i++)
// {
// int use = inst.getUse(i);
// OrdinalSet<InstanceKey> useKeys = pa.getPointsToSet(new LocalPointerKey(ak.getNode(), use));
// logger.debug("\tUse "+use+": "+useKeys);
//
// }
// logger.debug("NormalAllocationInNode defs:");
//
// for(int i = 0; i < inst.getNumberOfDefs(); i++)
// {
// int def = inst.getDef(i);
// OrdinalSet<InstanceKey> useKeys = pa.getPointsToSet(new LocalPointerKey(ak.getNode(), def));
// logger.debug("\tDef "+def+": "+useKeys);
//
// }
}
}
}
else if(k instanceof AllocationSite)
{
logger.debug("AllocationSite: "+k);
}
else
{
logger.debug("Unknown type: "+k.toString());
}
// create an edge for dependencies used in the creation of each instance key
}
else
{
logger.debug("Got IK of other type "+k);
}
}
for(Entry<InstanceKeySite, Set<InstanceKey>> deps:unresolvedDependencies.entrySet())

View File

@ -54,9 +54,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.ipa.callgraph.propagation.ConstantKey;
@ -75,8 +72,6 @@ import com.ibm.wala.util.intset.OrdinalSetMapping;
public class StringBuilderUseAnalysis {
private static final Logger logger = LoggerFactory.getLogger(StringBuilderUseAnalysis.class);
public final Map<ISSABasicBlock, ISSABasicBlock> blockOrdering;
private final InstanceKey sbik;
@ -130,7 +125,7 @@ public class StringBuilderUseAnalysis {
if (nominatedNode == null) {
nominatedNode = lpk.getNode();
} else if (nominatedNode != lpk.getNode()) {
logger.warn("got conflicting nodes: "+nominatedNode+" <> "+lpk.getNode());
return null;
}
}
@ -139,7 +134,7 @@ public class StringBuilderUseAnalysis {
// if this pointer key points to our instance key then we have to give up -- we can only analyze local pointer keys
final OrdinalSet<InstanceKey> pts = pa.getPointsToSet(pk);
if (pts.contains(ik)) {
logger.warn("Found non LocalPointerKey refering to our ik: " + pk);
return null;
}
}
@ -224,10 +219,6 @@ public class StringBuilderUseAnalysis {
public InstanceKeySite getNode(final CallSiteReference csr, final InstanceKey k) {
final ISSABasicBlock bbs[] = node.getIR().getBasicBlocksForCall(csr);
if (bbs.length != 1) {
logger.warn("Got wrong number of basic blocks for call site: " + node.getMethod().getSignature()
+ " blocks:" + bbs.length);
}
final OrdinalSetMapping<InstanceKey> mapping = pa.getInstanceKeyMapping();
final HashSet<ISSABasicBlock> blocksSeen = new HashSet<ISSABasicBlock>();
@ -238,9 +229,9 @@ public class StringBuilderUseAnalysis {
while (bNext != null) {
// detect loops
if (blocksSeen.contains(bNext)) {
logger.warn("Loop detected in string builder use analysis for " + sbik + "!");
logger.warn("bPrev: " + bPrev);
logger.warn("bNext: " + bNext);
return null;
}
@ -274,7 +265,7 @@ public class StringBuilderUseAnalysis {
bNext = blockOrdering.get(bNext);
}
logger.warn("Ran out of parents before getting to <init> on SB: "+ csr + " with builder " + sbik);
return null;
}

View File

@ -62,8 +62,6 @@ import org.scandroid.prefixtransfer.StringBuilderUseAnalysis.StringBuilderToStri
import org.scandroid.prefixtransfer.modeledAllocations.ConstantString;
import org.scandroid.prefixtransfer.modeledAllocations.UriAppendString;
import org.scandroid.prefixtransfer.modeledAllocations.UriParseString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.analysis.reflection.InstanceKeyWithNode;
import com.ibm.wala.classLoader.CallSiteReference;
@ -88,8 +86,6 @@ import com.ibm.wala.util.intset.OrdinalSetMapping;
public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
private static final Logger logger = LoggerFactory.getLogger(UriPrefixTransferGraph.class);
public final Map<InstanceKey, InstanceKeySite> nodeMap = new HashMap<InstanceKey, InstanceKeySite>();
public final Map<InstanceKey, StringBuilderUseAnalysis> sbuaMap =
new HashMap<InstanceKey, StringBuilderUseAnalysis>();
@ -167,15 +163,12 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
try {
sbua = new StringBuilderUseAnalysis(ik, pa);
} catch(Exception e) {
logger.warn("SBUA failed", e);
return;
}
sbuaMap.put(ik, sbua); // map ik to sbua in some global map
}
} else {
logger.warn("Skipping StringBuilder InstanceKey: " + ik);
logger.warn("\tClass loader reference: " + ik.getConcreteType().getClassLoader().getReference());
}
}
}
@ -206,17 +199,14 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
iks.add(mapping.getMappedObject(i));
}
logger.debug("adding to UnresolvedDependencies => node: " + node + " => iks: " + iks);
unresolvedDependencies.put(node, iks);
// TODO: if this string is created inside the toString function of a string builder,
// find the StringBuilderUseAnalysis for that string builder and call getNode(k) to
// get the node for this instance key
// - this may have to be done in another phase
}
} else {
logger.warn("Receiver instancekey is null in UriPrefixTransferGraph, Method: "
+ ((NormalAllocationInNode) receiver).getNode().getMethod().getSignature());
}
}
}
}
}
@ -245,19 +235,12 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
final OrdinalSet<InstanceKey> returnSet =
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getReturnValue(0)));
logger.debug("Sizeof returnset: " + returnSet.size() + "--" + lpk);
for (final Iterator<InstanceKey> rIK = returnSet.iterator(); rIK.hasNext(); ) {
final InstanceKey returnIK = rIK.next();
final UriAppendString node = new UriAppendString(mapping.getMappedIndex(returnIK),
mapping.getMappedIndex(uriKey), mapping.getMappedIndex(stringKey));
logger.debug("\t Uri.withAppendedPath(): "+ invoke + ", returnIK: " + returnIK
+ ", uriKey: " + uriKey + ", stringKey: " + stringKey);
logger.debug("\t returnIK_Index: " + mapping.getMappedIndex(returnIK)
+ ", uriKey_Index: " + mapping.getMappedIndex(uriKey) + ", stringKey_Index: "
+ mapping.getMappedIndex(stringKey));
if (!nodeMap.containsKey(returnIK)) {
addNode(node);
nodeMap.put(returnIK, node);
@ -281,7 +264,6 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
if (hasSignature(allocNode, "android.net.Uri.withAppendedPath(Landroid/net/Uri;Ljava/lang/String;)Landroid/net/Uri;")) {
//Doesn't seem to be entering this else with the current android jar -- reimplemented above using LocalPointerKey
logger.debug("android.net.Uri.withAppendedPath(Landroid/net/Uri;Ljava/lang/String;)Landroid/net/Uri call: " + caller);
final CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE);
final SSAInvokeInstruction invoke =
(SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction();
@ -300,7 +282,6 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
mapping.getMappedIndex(uriKey),
mapping.getMappedIndex(stringKey));
logger.debug("\t Uri.withAppendedPath(): "+ invoke + "..." + uriKey + "..." + stringKey);
addNode(node);
nodeMap.put(ik, node);
final HashSet<InstanceKey> iks = new HashSet<InstanceKey>();
@ -323,8 +304,8 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
final CallSiteReference csr = (CallSiteReference) context.get(ContextKey.CALLSITE);
final SSAInvokeInstruction invoke =
(SSAInvokeInstruction) caller.getIR().getBasicBlocksForCall(csr)[0].getLastInstruction();
logger.debug("invoke inst: " + invoke + " getuse: " + invoke.getUse(0));
logger.debug("in node: " + caller);
final OrdinalSet<InstanceKey> points =
pa.getPointsToSet(new LocalPointerKey(caller, invoke.getUse(0)));
@ -334,7 +315,6 @@ public class UriPrefixTransferGraph implements Graph<InstanceKeySite> {
mapping.getMappedIndex(ik),
mapping.getMappedIndex(stringKey));
logger.debug("\t Uri.parse(): "+ invoke + "..." + stringKey);
addNode(node);
nodeMap.put(ik, node);
final HashSet<InstanceKey> iks = new HashSet<InstanceKey>();

View File

@ -56,8 +56,6 @@ import org.scandroid.flow.InflowAnalysis;
import org.scandroid.flow.types.FlowType;
import org.scandroid.flow.types.ParameterFlow;
import org.scandroid.util.CGAnalysisContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
@ -84,7 +82,6 @@ import com.ibm.wala.util.intset.OrdinalSet;
*
*/
public class EntryArgSourceSpec extends SourceSpec {
private static final Logger logger = LoggerFactory.getLogger(EntryArgSourceSpec.class);
public EntryArgSourceSpec(MethodNamePattern name, int[] args) {
namePattern = name;
@ -110,10 +107,10 @@ public class EntryArgSourceSpec extends SourceSpec {
TypeReference typeRef = node.getMethod().getParameterType(i);
IClass clazz = node.getMethod().getClassHierarchy().lookupClass(typeRef);
if (null == clazz) {
logger.error("couldn't find entry arg class {}", typeRef);
} else if (clazz.isInterface()) {
for (IClass impl : pa.getClassHierarchy().getImplementors(typeRef)) {
logger.debug("creating instance key {} for interface {}", impl, clazz);
InstanceKey ik = new ConcreteTypeKey(impl);
valueElements.addAll(ctx.codeElementsForInstanceKey(ik));
}
@ -127,7 +124,7 @@ public class EntryArgSourceSpec extends SourceSpec {
valueElements.addAll(ctx.codeElementsForInstanceKey(ik));
}
InflowAnalysis.addDomainElements(taintMap, block, flow, valueElements);
logger.debug("added elements for entry {}: {}", this, valueElements);
}
}
}

View File

@ -59,8 +59,6 @@ import org.scandroid.flow.InflowAnalysis;
import org.scandroid.flow.types.FlowType;
import org.scandroid.flow.types.StaticFieldFlow;
import org.scandroid.util.CGAnalysisContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IField;
@ -85,7 +83,6 @@ import com.ibm.wala.util.intset.OrdinalSet;
*
*/
public class StaticFieldSourceSpec extends SourceSpec {
private static final Logger logger = LoggerFactory.getLogger(EntryArgSourceSpec.class);
private final IField field;
@ -128,7 +125,7 @@ public class StaticFieldSourceSpec extends SourceSpec {
if (pointsToSet.isEmpty()) {
IClassHierarchy cha = im.getClassHierarchy();
if (null == cha.lookupClass(typeRef)) {
logger.warn("could not resolve class for {}", field);
return;
}
if (cha.isInterface(typeRef)) {
@ -140,7 +137,7 @@ public class StaticFieldSourceSpec extends SourceSpec {
IClass clazz = cha.lookupClass(typeRef);
if (null == clazz) {
logger.error("couldn't find entry arg class {}", typeRef);
} else {
InstanceKey ik = new ConcreteTypeKey(clazz);
valueElements.add(new InstanceKeyElement(ik));

View File

@ -53,8 +53,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -88,8 +86,6 @@ import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.strings.Atom;
public class SSAtoXMLVisitor implements SSAInstruction.IVisitor {
private static final Logger logger = LoggerFactory.getLogger(SSAtoXMLVisitor.class);
/**
* A counter to use for generating unique local definition names.
*/
@ -495,12 +491,12 @@ public class SSAtoXMLVisitor implements SSAInstruction.IVisitor {
Atom className = fieldType.getName().getClassName();
Atom pkgName = fieldType.getName().getPackage();
if ( null == pkgName && null != className ) {
logger.debug("pkg name null for type ref: "+fieldType);
return className.toUnicodeString();
}
if (null == className ) {
logger.debug("className null for type ref: "+fieldType);
}
return pkgName.toUnicodeString() + "/" + className.toUnicodeString();

View File

@ -54,7 +54,6 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
@ -62,10 +61,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.scandroid.synthmethod.DefaultSCanDroidOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
import com.ibm.wala.classLoader.IClass;
@ -100,11 +95,6 @@ import com.ibm.wala.util.warnings.Warning;
import com.ibm.wala.util.warnings.Warnings;
public class AndroidAnalysisContext {
private static final Logger logger = LoggerFactory
.getLogger(AndroidAnalysisContext.class);
static {
// ((ch.qos.logback.classic.Logger) logger).setLevel(Level.TRACE);
}
private static final String methodSpec = "MethodSummaries.xml";
private static final String pathToSpec = "data";
@ -135,7 +125,7 @@ public class AndroidAnalysisContext {
public AndroidAnalysisContext(ISCanDroidOptions options, String exclusions)
throws IOException, IllegalArgumentException, CancelException,
ClassHierarchyException, URISyntaxException {
logger.debug(DefaultSCanDroidOptions.dumpString(options));
this.options = options;
scope = AndroidAnalysisScope.setUpAndroidAnalysisScope(options.getClasspath(), exclusions, getClass().getClassLoader(), options.getAndroidLibrary());
@ -145,7 +135,7 @@ public class AndroidAnalysisContext {
// log ClassHierarchy warnings
for (Iterator<Warning> wi = Warnings.iterator(); wi.hasNext();) {
Warning w = wi.next();
logger.warn(w.getMsg());
}
}
Warnings.clear();
@ -274,14 +264,10 @@ public class AndroidAnalysisContext {
XMLMethodSummaryReader newSummaryXML = loadMethodSummaries(
scope, xmlIStream);
summaryClasses.addAll(newSummaryXML.getAllocatableClasses());
for (MethodSummary summary : newSummaryXML.getSummaries().values()) {
logger.trace("SSA instructions for summary of {}:\n{}", summary.getMethod().getSignature().toString(), Arrays.toString(summary.getStatements()));
}
summaries.putAll(newSummaryXML.getSummaries());
}
logger.debug("loaded " + summaries.size() + " new summaries");
// for (MethodReference mr : summaries.keySet()) {
// logger.debug("summary loaded for: "+mr.getSignature());
//
// }
s = new FileProvider().getInputStreamFromClassLoader(pathToSpec
@ -291,9 +277,6 @@ public class AndroidAnalysisContext {
XMLMethodSummaryReader nativeSummaries = loadMethodSummaries(scope,
s);
logger.debug("loaded " + nativeSummaries.getSummaries().size()
+ " native summaries");
summaries.putAll(nativeSummaries.getSummaries());
summaryClasses.addAll(nativeSummaries.getAllocatableClasses());
if (extraSummary != null) {

View File

@ -62,8 +62,6 @@ import java.util.Set;
import org.scandroid.domain.CodeElement;
import org.scandroid.domain.FieldElement;
import org.scandroid.domain.InstanceKeyElement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Queues;
import com.ibm.wala.classLoader.IClass;
@ -113,7 +111,6 @@ import com.ibm.wala.util.warnings.Warnings;
* a particular classpath
*/
public class CGAnalysisContext<E extends ISSABasicBlock> {
private static final Logger logger = LoggerFactory.getLogger(CGAnalysisContext.class);
public final AndroidAnalysisContext analysisContext;
@ -143,7 +140,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
entrypoints = specifier.specify(analysisContext);
AnalysisOptions analysisOptions = new AnalysisOptions(scope, entrypoints);
for (Entrypoint e : entrypoints) {
logger.debug("Entrypoint: " + e);
}
analysisOptions.setReflectionOptions(options.getReflectionOptions());
@ -162,14 +159,14 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
// CallGraphBuilder construction warnings
for (Iterator<Warning> wi = Warnings.iterator(); wi.hasNext();) {
Warning w = wi.next();
logger.warn(w.getMsg());
}
}
Warnings.clear();
logger.info("*************************");
logger.info("* Building Call Graph *");
logger.info("*************************");
boolean graphBuilt = true;
try {
@ -192,7 +189,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
// makeCallGraph warnings
for (Iterator<Warning> wi = Warnings.iterator(); wi.hasNext();) {
Warning w = wi.next();
logger.warn(w.getMsg());
}
Warnings.clear();
@ -281,26 +278,20 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
for (Iterator<CGNode> nodeI = cg.iterator(); nodeI.hasNext();) {
CGNode node = nodeI.next();
logger.debug("CGNode: " + node);
for (Iterator<CGNode> succI = cg.getSuccNodes(node); succI.hasNext();) {
logger.debug("\tSuccCGNode: " + succI.next().getMethod().getSignature());
}
}
}
for (Iterator<CGNode> nodeI = cg.iterator(); nodeI.hasNext();) {
CGNode node = nodeI.next();
if (node.getMethod().isSynthetic()) {
logger.trace("Synthetic Method: {}", node.getMethod().getSignature());
logger.trace("{}", node.getIR().getControlFlowGraph().toString());
SSACFG ssaCFG = node.getIR().getControlFlowGraph();
int totalBlocks = ssaCFG.getNumberOfNodes();
for (int i = 0; i < totalBlocks; i++) {
logger.trace("BLOCK #{}", i);
BasicBlock bb = ssaCFG.getBasicBlock(i);
for (SSAInstruction ssaI : bb.getAllInstructions()) {
logger.trace("\tInstruction: {}", ssaI);
}
}
}
@ -319,7 +310,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
while (!iks.isEmpty()) {
InstanceKey ik = iks.pop();
logger.debug("getting code elements for {}", ik);
elts.add(new InstanceKeyElement(ik));
final IClass clazz = ik.getConcreteType();
final TypeReference typeRef = clazz.getReference();
@ -332,7 +323,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
OrdinalSet<InstanceKey> pointsToSet =
pa.getPointsToSet(pa.getHeapModel().getPointerKeyForArrayContents(ik));
if (pointsToSet.isEmpty()) {
logger.debug("pointsToSet empty for array contents, creating InstanceKey manually");
final IClass contentsClass = pa.getClassHierarchy().lookupClass(typeRef.getArrayElementType());
if (contentsClass.isInterface()) {
for (IClass implementor : analysisContext.concreteClassesForInterface(contentsClass)) {
@ -363,7 +354,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
continue;
}
for (IField field : clazz.getAllInstanceFields()) {
logger.debug("adding elements for field {}", field);
final TypeReference fieldTypeRef = field.getFieldTypeReference();
elts.add(new FieldElement(ik, field.getReference()));
final IClass fieldClass = analysisContext.getClassHierarchy().lookupClass(fieldTypeRef);
@ -373,7 +364,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
PointerKey pk = pa.getHeapModel().getPointerKeyForInstanceField(ik, field);
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
if (pointsToSet.isEmpty()) {
logger.debug("pointsToSet empty for array field, creating InstanceKey manually");
InstanceKey fieldIK = new ConcreteTypeKey(pa.getClassHierarchy().lookupClass(fieldTypeRef));
final InstanceKeyElement elt = new InstanceKeyElement(fieldIK);
if (!elts.contains(elt)) {
@ -393,7 +384,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
PointerKey pk = pa.getHeapModel().getPointerKeyForInstanceField(ik, field);
final OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(pk);
if (pointsToSet.isEmpty() && !analysisContext.getClassHierarchy().isInterface(fieldTypeRef)) {
logger.debug("pointsToSet empty for reference field, creating InstanceKey manually");
InstanceKey fieldIK = new ConcreteTypeKey(fieldClass);
final InstanceKeyElement elt = new InstanceKeyElement(fieldIK);
if (!elts.contains(elt)) {
@ -410,7 +401,7 @@ public class CGAnalysisContext<E extends ISSABasicBlock> {
}
}
} else {
logger.warn("unknown field type {}", field);
}
}
}

View File

@ -58,10 +58,6 @@ import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import com.ibm.wala.ipa.callgraph.AnalysisOptions.ReflectionOptions;
@ -161,10 +157,6 @@ public class CLISCanDroidOptions implements ISCanDroidOptions {
// handle verbosity
// parse this arg as a Logback level, then set the root logger level
// appropriately
Level level = Level.toLevel(getOption(VERBOSE), Level.INFO);
Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(level);
if (!hasOption(ANDROID_LIB)) {
System.err.println("Please specify an android library");

View File

@ -16,13 +16,9 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ibm.wala.util.WalaException;
import com.ibm.wala.util.collections.Iterator2Collection;
import com.ibm.wala.util.debug.Assertions;
@ -31,7 +27,6 @@ import com.ibm.wala.viz.DotUtil;
import com.ibm.wala.viz.NodeDecorator;
public class DexDotUtil extends DotUtil {
private static final Logger logger = LoggerFactory.getLogger(DexDotUtil.class);
/**
* possible output formats for dot
@ -98,7 +93,7 @@ public class DexDotUtil extends DotUtil {
throw new IllegalArgumentException("dotFile is null");
}
String[] cmdarray = { dotExe, outputTypeCmdLineParam(), "-o", outputFile, "-v", dotFile.getAbsolutePath() };
logger.debug("spawning process " + Arrays.toString(cmdarray));
BufferedInputStream output = null;
BufferedInputStream error = null;
try {
@ -116,18 +111,18 @@ public class DexDotUtil extends DotUtil {
if (output.available() > 0) {
byte[] data = new byte[output.available()];
int nRead = output.read(data);
logger.error("read " + nRead + " bytes from output stream");
}
if (error.available() > 0) {
byte[] data = new byte[error.available()];
int nRead = error.read(data);
logger.error("read " + nRead + " bytes from error stream");
}
try {
p.exitValue();
// if we get here, the process has terminated
repeat = false;
logger.debug("process terminated with exit code " + p.exitValue());
} catch (IllegalThreadStateException e) {
// this means the process has not yet terminated.
repeat = true;

View File

@ -63,8 +63,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.scandroid.spec.AndroidSpecs;
import org.scandroid.spec.MethodNamePattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -80,7 +78,6 @@ import com.ibm.wala.util.strings.StringStuff;
public class EntryPoints {
private static final Logger logger = LoggerFactory.getLogger(EntryPoints.class);
private String pathToApkFile;
private String pathToApkTool;
@ -100,12 +97,12 @@ public class EntryPoints {
for(MethodReference mr:entryPointMRs)
for(IMethod im:cha.getPossibleTargets(mr))
{
logger.debug("Considering target "+im.getSignature());
// limit to functions defined within the application
if(im.getReference().getDeclaringClass().getClassLoader().
equals(ClassLoaderReference.Application)) {
logger.debug("Adding entry point: "+im.getSignature());
entries.add(new DefaultEntrypoint(im, cha));
}
}
@ -115,11 +112,11 @@ public class EntryPoints {
List<Entrypoint> entries = new ArrayList<Entrypoint>();
for (MethodNamePattern mnp:new AndroidSpecs().getEntrypointSpecs()) {
for (IMethod im: mnp.getPossibleTargets(cha)) {
logger.debug("Considering target "+im.getSignature());
// limit to functions defined within the application
if(LoaderUtils.fromLoader(im, ClassLoaderReference.Application))
{
logger.debug("Adding entry point: "+im.getSignature());
entries.add(new DefaultEntrypoint(im, cha));
}
}
@ -145,12 +142,12 @@ public class EntryPoints {
StringStuff.makeMethodReference(methodReferences[i]);
for (IMethod im : cha.getPossibleTargets(mr)) {
logger.debug("Considering target " + im.getSignature());
// limit to functions defined within the application
if (im.getReference().getDeclaringClass().getClassLoader()
.equals(ClassLoaderReference.Application)) {
logger.debug("Adding entry point: " + im.getSignature());
entries.add(new DefaultEntrypoint(im, cha));
}
}
@ -180,7 +177,7 @@ public class EntryPoints {
StringStuff.makeMethodReference(systemEntyPoints[i]);
for (IMethod im : cha.getPossibleTargets(methodRef)) {
logger.debug("Adding entry point: " + im.getSignature());
entries.add(new DefaultEntrypoint(im, cha));
}
}
@ -203,7 +200,7 @@ public class EntryPoints {
StringStuff.makeMethodReference(methodReferences[i]);
for (IMethod im : cha.getPossibleTargets(mr)) {
logger.debug("Adding entry point: " + im.getSignature());
entries.add(new DefaultEntrypoint(im, cha));
}
}
@ -236,15 +233,14 @@ public class EntryPoints {
InputStreamReader(p.getErrorStream()));
// read the output from the command
logger.debug("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
logger.debug(s);
}
// read any errors from the attempted command
logger.debug("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
logger.debug(s);
System.err.println(s);
}
} catch (IOException e) {
@ -339,7 +335,7 @@ public class EntryPoints {
for (String[] intent: ActivityIntentList) {
//method = IntentToMethod(intent[0]);
method = "onCreate(Landroid/os/Bundle;)V";
logger.debug("activity intent method: "+intent[1]+"."+method);
if (method != null)
im = cha.resolveMethod(StringStuff.makeMethodReference(intent[1]+"."+method));
if (im!=null)
@ -350,7 +346,7 @@ public class EntryPoints {
//Seems that every broadcast receiver can be an entrypoints?
// method = IntentToMethod(intent[0]);
method = "onReceive(Landroid/content/Context;Landroid/content/Intent;)V";
logger.debug("receiver intent method: "+intent[1]+"."+method);
if (method != null)
im = cha.resolveMethod(StringStuff.makeMethodReference(intent[1]+"."+method));
if (im!=null)
@ -392,20 +388,7 @@ public class EntryPoints {
}
}
@SuppressWarnings("unused")
private void outputIntentList() {
if (ActivityIntentList != null)
for (int i = 0; i < ActivityIntentList.size(); i++)
logger.debug("Activity Intent: " + ActivityIntentList.get(i)[0] + " ~> " + ActivityIntentList.get(i)[1]);
if (ReceiverIntentList != null)
for (int i = 0; i < ReceiverIntentList.size(); i++)
logger.debug("Receiver Intent: " + ReceiverIntentList.get(i)[0] + " ~> " + ReceiverIntentList.get(i)[1]);
if (ServiceIntentList != null)
for (int i = 0; i < ServiceIntentList.size(); i++)
logger.debug("Service Intent: " + ServiceIntentList.get(i)[0] + " ~> " + ServiceIntentList.get(i)[1]);
}
public LinkedList<Entrypoint> getEntries() {
public LinkedList<Entrypoint> getEntries() {
return entries;
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc>
<jar path="/tmp/cg.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/com.ibm.wala.shrike/cg.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="true" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="false" manifestLocation="/com.ibm.wala.shrike/manifest.cg" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<file path="/com.ibm.wala.shrike/build.xml"/>
<file path="/com.ibm.wala.shrike/.project"/>
<file path="/com.ibm.wala.shrike/exportPlugin.xml"/>
<file path="/com.ibm.wala.shrike/manifest.codescrape"/>
<javaElement handleIdentifier="=com.ibm.wala.shrike/src"/>
<file path="/com.ibm.wala.shrike/pom.xml"/>
<file path="/com.ibm.wala.shrike/plugin.properties"/>
<file path="/com.ibm.wala.util/build.properties"/>
<file path="/com.ibm.wala.util/mvncentral.xml"/>
<file path="/com.ibm.wala.shrike/.classpath"/>
<file path="/com.ibm.wala.util/.gitignore"/>
<file path="/com.ibm.wala.shrike/mvncentral.xml"/>
<file path="/com.ibm.wala.shrike/javaCompiler...args"/>
<javaElement handleIdentifier="=com.ibm.wala.util/src"/>
<file path="/com.ibm.wala.shrike/report"/>
<file path="/com.ibm.wala.util/.classpath"/>
<file path="/com.ibm.wala.util/.project"/>
<file path="/com.ibm.wala.shrike/.cvsignore"/>
<file path="/com.ibm.wala.util/pom.xml"/>
<file path="/com.ibm.wala.shrike/build.properties"/>
<file path="/com.ibm.wala.util/walaUtil.jar"/>
</selectedElements>
</jardesc>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc>
<jar path="/tmp/codescrape.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/com.ibm.wala.shrike/codescrape.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="true" overwrite="true" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="false" manifestLocation="/com.ibm.wala.shrike/manifest.codescrape" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<file path="/com.ibm.wala.shrike/build.xml"/>
<file path="/com.ibm.wala.shrike/.project"/>
<file path="/com.ibm.wala.shrike/exportPlugin.xml"/>
<file path="/com.ibm.wala.shrike/manifest.codescrape"/>
<javaElement handleIdentifier="=com.ibm.wala.shrike/src"/>
<file path="/com.ibm.wala.shrike/pom.xml"/>
<file path="/com.ibm.wala.shrike/plugin.properties"/>
<file path="/com.ibm.wala.util/build.properties"/>
<file path="/com.ibm.wala.util/mvncentral.xml"/>
<file path="/com.ibm.wala.shrike/.classpath"/>
<file path="/com.ibm.wala.util/.gitignore"/>
<file path="/com.ibm.wala.shrike/mvncentral.xml"/>
<file path="/com.ibm.wala.shrike/javaCompiler...args"/>
<javaElement handleIdentifier="=com.ibm.wala.util/src"/>
<file path="/com.ibm.wala.shrike/report"/>
<file path="/com.ibm.wala.util/.classpath"/>
<file path="/com.ibm.wala.util/.project"/>
<file path="/com.ibm.wala.shrike/.cvsignore"/>
<file path="/com.ibm.wala.util/pom.xml"/>
<file path="/com.ibm.wala.shrike/build.properties"/>
<file path="/com.ibm.wala.util/walaUtil.jar"/>
</selectedElements>
</jardesc>

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Premain-Class: com.ibm.wala.shrike.cg.OnlineDynamicCallGraph

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Premain-Class: com.ibm.wala.shrike.instrumentation.CodeScraper

View File

@ -56,14 +56,12 @@ import com.ibm.wala.util.config.SetOfClasses;
* @author Julian Dolby (dolby@us.ibm.com)
* @since 10/18
*/
public class DynamicCallGraph {
public class OfflineDynamicCallGraph {
private final static boolean disasm = true;
private final static boolean verify = true;
private static boolean patchExits = true;
private static OfflineInstrumenter instrumenter;
private static Class<?> runtime = Runtime.class;
private static SetOfClasses filter;
@ -71,6 +69,7 @@ public class DynamicCallGraph {
private static ClassHierarchyStore cha = new ClassHierarchyStore();
public static void main(String[] args) throws IOException, ClassNotFoundException, InvalidClassFileException, FailureException {
OfflineInstrumenter instrumenter;
ClassInstrumenter ci;
Writer w = new BufferedWriter(new FileWriter("report", false));
@ -105,20 +104,26 @@ public class DynamicCallGraph {
instrumenter.beginTraversal();
while ((ci = instrumenter.nextClass()) != null) {
doClass(ci, w);
ClassWriter cw = doClass(ci, w);
if (cw != null) {
instrumenter.outputModifiedClass(ci, cw);
}
}
instrumenter.close();
}
private static void doClass(final ClassInstrumenter ci, Writer w) throws InvalidClassFileException, IOException, FailureException {
static ClassWriter doClass(final ClassInstrumenter ci, Writer w) throws InvalidClassFileException, IOException, FailureException {
final String className = ci.getReader().getName();
if (filter != null && filter.contains(className)) {
return;
return null;
}
w.write("Class: " + className + "\n");
w.flush();
if (disasm) {
w.write("Class: " + className + "\n");
w.flush();
}
final ClassReader r = ci.getReader();
for (int m = 0; m < ci.getReader().getMethodCount(); m++) {
@ -127,13 +132,11 @@ public class DynamicCallGraph {
// d could be null, e.g., if the method is abstract or native
if (d != null) {
if (filter != null && filter.contains(className + "." + ci.getReader().getMethodName(m))) {
return;
return null;
}
w.write("Instrumenting " + ci.getReader().getMethodName(m) + " " + ci.getReader().getMethodType(m) + ":\n");
w.flush();
if (disasm) {
w.write("Instrumenting " + ci.getReader().getMethodName(m) + " " + ci.getReader().getMethodType(m) + ":\n");
w.write("Initial ShrikeBT code:\n");
(new Disassembler(d)).disassembleTo(w);
w.flush();
@ -147,12 +150,12 @@ public class DynamicCallGraph {
final MethodEditor me = new MethodEditor(d);
me.beginPass();
final String theClass = r.getName();
final String theMethod = r.getMethodName(m).concat(r.getMethodType(m));
final boolean isConstructor = theMethod.contains("<init>");
final boolean nonStatic = !java.lang.reflect.Modifier.isStatic(r.getMethodAccessFlags(m));
me.insertAtStart(new MethodEditor.Patch() {
@Override
public void emitTo(MethodEditor.Output w) {
@ -163,7 +166,7 @@ public class DynamicCallGraph {
else
w.emit(Util.makeGet(runtime, "NULL_TAG"));
// w.emit(ConstantInstruction.make(Constants.TYPE_null, null));
w.emit(Util.makeInvoke(runtime, "execution", new Class[] {Class.class, String.class, Object.class}));
w.emit(Util.makeInvoke(runtime, "execution", new Class[] {String.class, String.class, Object.class}));
}
});
@ -277,7 +280,10 @@ public class DynamicCallGraph {
}
};
ci.emitClass(cw);
instrumenter.outputModifiedClass(ci, cw);
return cw;
} else {
return null;
}
}

View File

@ -0,0 +1,67 @@
package com.ibm.wala.shrike.cg;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
import com.ibm.wala.shrikeBT.analysis.Analyzer.FailureException;
import com.ibm.wala.shrikeBT.analysis.ClassHierarchyStore;
import com.ibm.wala.shrikeBT.shrikeCT.CTUtils;
import com.ibm.wala.shrikeBT.shrikeCT.ClassInstrumenter;
import com.ibm.wala.shrikeBT.shrikeCT.OfflineInstrumenter;
import com.ibm.wala.shrikeCT.InvalidClassFileException;
public class OnlineDynamicCallGraph implements ClassFileTransformer {
private ClassHierarchyStore cha = new ClassHierarchyStore();
private Writer out = new PrintWriter(System.err);
public OnlineDynamicCallGraph() throws IllegalArgumentException, IOException, InvalidClassFileException {
OfflineInstrumenter libReader = new OfflineInstrumenter(true);
for (String cps : new String[]{ System.getProperty("java.class.path"), System.getProperty("sun.boot.class.path") }) {
for (String cp : cps.split(File.pathSeparator)) {
File x = new File(cp);
if (x.exists()) {
if (x.isDirectory()) {
libReader.addInputDirectory(x, x);
} else {
libReader.addInputJar(x);
}
}
}
}
ClassInstrumenter ci;
while ((ci = libReader.nextClass()) != null) {
CTUtils.addClassToHierarchy(cha, ci.getReader());
}
}
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
byte[] classfileBuffer) throws IllegalClassFormatException {
try {
if (className.contains("com/ibm/wala") || className.contains("java/lang") || (className.contains("java/") && !className.matches("java/util/[A-Z]")) || className.contains("sun/")) {
return classfileBuffer;
} else {
ClassInstrumenter ci = new ClassInstrumenter(className, classfileBuffer, cha, false);
return OfflineDynamicCallGraph.doClass(ci, out).makeBytes();
}
} catch (InvalidClassFileException | IOException | FailureException e) {
e.printStackTrace();
System.err.println("got here with " + e.getMessage());
throw new IllegalClassFormatException(e.getMessage());
}
}
public static void premain(String agentArgs, Instrumentation inst) throws IllegalArgumentException, IOException, InvalidClassFileException {
inst.addTransformer(new OnlineDynamicCallGraph());
}
}

View File

@ -65,9 +65,11 @@ public class Runtime {
}
public static void endTrace() {
if (runtime.output != null) {
runtime.output.close();
runtime.output = null;
synchronized (runtime) {
if (runtime.output != null) {
runtime.output.close();
runtime.output = null;
}
}
}
@ -88,8 +90,8 @@ public class Runtime {
return className;
}
public static void execution(Class klass, String method, Object receiver) {
if (runtime.filter == null || ! runtime.filter.contains(bashToDescriptor(klass.getName()))) {
public static void execution(String klass, String method, Object receiver) {
if (runtime.filter == null || ! runtime.filter.contains(bashToDescriptor(klass))) {
if (runtime.output != null) {
String caller = runtime.callStacks.get().peek();
@ -106,16 +108,18 @@ public class Runtime {
}
}
String line = String.valueOf(caller) + "\t" + bashToDescriptor(String.valueOf(klass)) + "\t" + String.valueOf(method) + "\n";
String line = String.valueOf(caller) + "\t" + bashToDescriptor(klass) + "\t" + String.valueOf(method) + "\n";
synchronized (runtime) {
runtime.output.printf(line);
runtime.output.flush();
if (runtime.output != null) {
runtime.output.printf(line);
runtime.output.flush();
}
}
}
}
}
runtime.callStacks.get().push(bashToDescriptor(klass.getName()) + "\t" + method);
runtime.callStacks.get().push(bashToDescriptor(klass) + "\t" + method);
}
public static void termination(String klass, String method, Object receiver, boolean exception) {

View File

@ -0,0 +1,60 @@
package com.ibm.wala.shrike.instrumentation;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
import com.ibm.wala.shrikeCT.ClassReader;
import com.ibm.wala.shrikeCT.ClassReader.AttrIterator;
import com.ibm.wala.shrikeCT.InvalidClassFileException;
import com.ibm.wala.shrikeCT.SourceFileReader;
public class CodeScraper implements ClassFileTransformer {
private static final String prefix = System.getProperty("java.io.tmpdir") + File.separator + "loggedClasses" + File.separator + System.currentTimeMillis();
static {
System.err.println("scraping to " + prefix);
(new File(prefix)).mkdirs();
}
@Override
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain,
byte[] classfileBuffer) throws IllegalClassFormatException {
try {
String sourceFile = null;
ClassReader reader = new ClassReader(classfileBuffer);
AttrIterator attrs = new ClassReader.AttrIterator();
reader.initClassAttributeIterator(attrs);
for (; attrs.isValid(); attrs.advance()) {
if (attrs.getName().equals("SourceFile")) {
SourceFileReader file = new SourceFileReader(attrs);
int index = file.getSourceFileCPIndex();
sourceFile = reader.getCP().getCPUtf8(index);
}
}
if (className == null || sourceFile == null || !sourceFile.endsWith("java")) try {
String log = prefix + File.separator + reader.getName() + ".class";
FileOutputStream f = new FileOutputStream(log);
f.write(classfileBuffer);
f.close();
} catch (IOException e) {
assert false : e;
}
return classfileBuffer;
} catch (InvalidClassFileException e1) {
e1.printStackTrace();
throw new IllegalClassFormatException(e1.getLocalizedMessage());
}
}
public static void premain(String agentArgs, Instrumentation inst) {
System.err.println("adding CodeScraper");
inst.addTransformer(new CodeScraper());
}
}

View File

@ -208,7 +208,6 @@ public class Analyzer {
}
if (String.valueOf(t1).equals("L;") || String.valueOf(t2).equals("L;")) {
System.err.println("++ " + t1 + " -- " + t2 + " ++");
if (String.valueOf(t1).equals("L;")) {
return t2;
} else {
@ -226,14 +225,6 @@ public class Analyzer {
String x = ClassHierarchy.findCommonSupertype(hierarchy, patchType(t1), patchType(t2));
if (String.valueOf(t1).contains("groovy/lang/GroovyObject") || String.valueOf(t2).contains("groovy/lang/GroovyObject")) {
System.err.println(t1 + " -- " + t2 + " --> " + x);
}
if ("L?;".equals(x)) {
System.err.println(t1 + " -- " + t2);
}
return x;
}
@ -584,12 +575,6 @@ public class Analyzer {
String t = findCommonSupertype(ls[lj], curLocals[cj]);
if (t != ls[lj]) {
ls[lj] = t;
if (longType(curLocals[lj]) != longType(ls[cj])) {
System.err.println("merging " + curLocals[cj] + " and " + ls[lj] + " to " + t);
if (ls.length > lj+1) {
System.err.println("next " + curLocals[cj+1] + " and " + ls[lj+1]);
}
}
changed = true;
}
}
@ -725,8 +710,6 @@ public class Analyzer {
if (varTypes[bc].length > local && varTypes[bc][local] != null) {
String declaredType = varTypes[bc][local];
curLocals[local] = declaredType;
System.err.println("setting local " + local + " to " + declaredType + " at " + instToBC[i] + " in " + classType + " " + signature);
}
}
}
@ -749,8 +732,6 @@ public class Analyzer {
}
}
//System.err.println(i + " -- " + Arrays.toString(curLocals) + " -- " + Arrays.toString(curStack));
int[] targets = instr.getBranchTargets();
for (int j = 0; j < targets.length; j++) {
if (targets[j] == 29 && classType.contains("MetaClassImpl;") && signature.contains("(Ljava/lang/String;Lorg/codehaus/groovy/reflection/CachedClass;)")) {

Some files were not shown because too many files have changed in this diff Show More