Add "Custom Change" where applicable

Added the lines
BEGIN Custom Change
END Custom Change
This commit is contained in:
Tobias Blaschke 2014-03-24 12:56:04 +01:00 committed by Juergen Graf
parent 3751366295
commit 1857121a44
12 changed files with 63 additions and 8 deletions

View File

@ -190,9 +190,11 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
while (instructions[j] instanceof SSAPhiInstruction) {
b.addPhi((SSAPhiInstruction) instructions[j]);
j++;
/** BEGIN Custom change */
if (j >= instructions.length) {
break;
}
/** END Custom change */
}
if (DEBUG) {
@ -244,12 +246,14 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
@Override
public void visitGoto(SSAGotoInstruction instruction) {
/** BEGIN Custom change */
logger.debug("Breaking Basic block after instruction " + instruction + " index " + index);
breakBasicBlock(index); // Breaks __after__ the GoTo-Instruction
final int jumpTarget = getIndexFromIIndex(instruction.getTarget());
assert(instructions[jumpTarget] != null) : "GoTo cant go to null";
logger.debug("Breaking Basic block before instruction " + instructions[jumpTarget] + " index " + jumpTarget + " -1");
breakBasicBlock(jumpTarget - 1); // Breaks __before__ the target
/** END Custom change */
}
@Override
@ -439,10 +443,12 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
*/
private void addExceptionalEdges(SSAInstruction last) {
if (last == null) {
/** BEGIN Custom change */
// XXX: Bug here?
// throw new IllegalStateException("Missing last SSA-Instruction in basic block (null)."); // XXX: When does this happen?
System.err.println("Missing last SSA-Instruction in basic block (null).");
return;
/** END Custom change */
}
if (last.isPEI()) {
// we don't currently model catch blocks here ... instead just link
@ -469,6 +475,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
SSAInstruction last = getInstructions()[getLastInstructionIndex()];
addExceptionalEdges(last);
/** BEGIN Custom change: Add GoTo Instruction */
if (last instanceof SSAGotoInstruction) {
int tgt = ((SSAGotoInstruction)last).getTarget();
@ -494,6 +501,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
addNormalEdgeTo(target);
}
}
/** END Custom change: Add GoTo Instruction */
// this CFG is odd in that we assume fallthru might always
// happen .. this is because I'm too lazy to code control
@ -650,6 +658,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
}
}
/** BEGIN Custom change: Needed for GoTo Instruction */
/**
* Get the position of a instruction with a given iindex in the internal list.
*
@ -687,6 +696,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
throw new IllegalStateException("The searched iindex (" + iindex + ") does not exist! In " +
getMethod() + ", Contenxt: " + this.context);
}
/** END Custom change: Needed for GoTo Instruction */
public Collection<SSAPhiInstruction> getAllPhiInstructions() {
Collection<SSAPhiInstruction> result = HashSetFactory.make();

View File

@ -214,9 +214,11 @@ public class JavaLanguage extends LanguageImpl implements BytecodeLanguage, Cons
return new SSAGotoInstruction(iindex);
}
/** BEGIN Custom change: Add GoTo Instruction */
public SSAGotoInstruction GotoInstruction(int iindex, int target) {
return new SSAGotoInstruction(iindex, target);
}
/** END Custom change: Add GoTo Instruction */
@Override
public SSAInstanceofInstruction InstanceofInstruction(int iindex, int result, int ref, TypeReference checkedType) {

View File

@ -14,13 +14,15 @@ package com.ibm.wala.ssa;
* Unconditional branch instruction for SSA form.
*/
public class SSAGotoInstruction extends SSAInstruction {
/** BEGIN Custom change: Add GoTo Instruction */
int targetIndex = -1;
/** END Custom change: Add GoTo Instruction */
public SSAGotoInstruction(int index) {
super(index);
}
//@Warning("SSAGotoInstruction requires a BasicBlock change at targetIndex, but has no method to enforce it!")
/** BEGIN Custom change: Add GoTo Instruction */
public SSAGotoInstruction(int index, int targetIndex) {
super(index);
this.targetIndex = targetIndex;
@ -33,6 +35,7 @@ public class SSAGotoInstruction extends SSAInstruction {
public int getTarget() {
return this.targetIndex;
}
/** END Custom change: Add GoTo Instruction */
@Override
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {

View File

@ -75,10 +75,12 @@ public class AnalysisScopeReader {
} else {
// try to read from jar
InputStream inFromJar = scope.getClass().getClassLoader().getResourceAsStream(scopeFileName);
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
if (inFromJar == null) {
throw new IllegalArgumentException("Unable to retreive " + scopeFileName + " from the jar using the loader of " +
scope.getClass());
}
/** END Custom change: Fixes in AndroidAnalysisScope */
r = new BufferedReader(new InputStreamReader(inFromJar));
}
/** END Custom change: try to load from jar as fallback */
@ -103,6 +105,7 @@ public class AnalysisScopeReader {
return scope;
}
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
protected static AnalysisScope read(AnalysisScope scope, final URI scopeFileURI, final File exclusionsFile, ClassLoader javaLoader,
FileProvider fp) throws IOException {
BufferedReader r = null;
@ -134,7 +137,7 @@ public class AnalysisScopeReader {
return scope;
}
/** END Custom change: Fixes in AndroidAnalysisScope */
public static void processScopeDefLine(AnalysisScope scope, ClassLoader javaLoader, String line) throws IOException {
if (line == null) {

View File

@ -26,6 +26,7 @@ public class FileSuffixes {
private static final String WAR_SUFFIX = ".war";
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
private static final String DEX_SUFFIX = ".dex";
private static final String APK_SUFFIX = ".apk";
@ -82,6 +83,7 @@ public class FileSuffixes {
}
return fileName.toLowerCase().endsWith(APK_SUFFIX);
}
/** END Custom change: Fixes in AndroidAnalysisScope */
/**
* Does the file name represent a .class file?
@ -160,10 +162,12 @@ public class FileSuffixes {
}
}
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
/**
* Does the URI point to a ressource in a jar-file
*/
public static boolean isRessourceFromJar(final URI uri) {
return uri.toString().startsWith("jar:"); // How Pretty
}
/** END Custom change: Fixes in AndroidAnalysisScope */
}

View File

@ -156,6 +156,7 @@ public final class Atom implements Serializable {
return UTF8Convert.fromUTF8(val);
}
/** BEGIN Custom change: Handy helper functions */
/**
* New Atom containing first count bytes
*/
@ -180,7 +181,7 @@ public final class Atom implements Serializable {
return true;
}
/** END Custom change: Handy helper functions */
/**
* Return array descriptor corresponding to "this" array-element descriptor. this: array-element descriptor - something like "I"
@ -420,6 +421,7 @@ public final class Atom implements Serializable {
return false;
}
/** BEGIN Custom change: Handy helper functions */
public int rIndex(byte b) {
for (int i = val.length - 1; i >=0; --i) {
if (val[i] == b) {
@ -428,6 +430,7 @@ public final class Atom implements Serializable {
}
return -1;
}
/** END Custom change: Handy helper functions */
private static Atom concat(byte c, byte[] bs) {
byte[] val = new byte[bs.length + 1];
@ -443,6 +446,7 @@ public final class Atom implements Serializable {
return concat(c, b.b);
}
/** BEGIN Custom change: Handy helper functions */
public static Atom concat(Atom a, Atom b) {
if ((a == null ) || (b == null)) {
throw new IllegalArgumentException("argument may not be null!");
@ -458,6 +462,7 @@ public final class Atom implements Serializable {
return findOrCreate(val);
}
/** END Custom change: Handy helper functions */
public static boolean isArrayDescriptor(ImmutableByteArray b) {
if (b == null) {

View File

@ -718,6 +718,7 @@ public class StringStuff {
return dotForm.toString();
}
/** BEGIN Custom change: quite handy */
/**
* Rerturn th right potion of the string up to '.' or '/' stripping ';'
*/
@ -737,5 +738,5 @@ public class StringStuff {
return typeName.substring(start, stop);
}
/** END Custom change: quite handy */
}

View File

@ -208,7 +208,7 @@ public class DexIMethod implements IBytecodeMethod {
public TypeReference[] getDeclaredExceptions()
throws InvalidClassFileException, UnsupportedOperationException {
/** 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");
@ -216,6 +216,8 @@ public class DexIMethod implements IBytecodeMethod {
}
ArrayList<String> strings = new ArrayList<String>();
AnnotationSetItem annotationSet = myClass.getClassDefItem().getAnnotations().getMethodAnnotations(eMethod.method);
/** END Custom change: Variable Names in synth. methods */
if (annotationSet != null) {
for (AnnotationItem annotationItem: annotationSet.getAnnotations())
{
@ -3291,7 +3293,7 @@ public class DexIMethod implements IBytecodeMethod {
/**
*
* hrows InvalidClassFileException
* @throws InvalidClassFileException
* @throws UnsupportedOperationException
*
* @todo Review this implementation - it may be horribly wrong!
@ -3299,6 +3301,7 @@ public class DexIMethod implements IBytecodeMethod {
@Override
public Collection<CallSiteReference> getCallSites()
throws InvalidClassFileException {
/** BEGIN Custom change: Variable Names in synth. methods */
Collection<CallSiteReference> empty = Collections.emptySet();
if (isNative()) {
return empty;
@ -3331,6 +3334,7 @@ public class DexIMethod implements IBytecodeMethod {
}
}
return Collections.unmodifiableCollection(csites);
/** END Custom change: Variable Names in synth. methods */
}
@Override

View File

@ -65,18 +65,21 @@ public class DexAnalysisScopeReader extends AnalysisScopeReader {
private static final ClassLoader WALA_CLASSLOADER = AnalysisScopeReader.class
.getClassLoader();
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
//private static final String BASIC_FILE = "conf" + File.separator+ "primordial.txt";
private static final String BASIC_FILE = "./primordial.txt"; // Path inside jar
/** END Custom change: Fixes in AndroidAnalysisScope */
public static AnalysisScope makeAndroidBinaryAnalysisScope(String classPath, String exclusions) throws IOException {
if (classPath == null) {
throw new IllegalArgumentException("classPath null");
}
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
//AnalysisScope scope = AnalysisScopeReader.makePrimordialScope(null);
scope.setExclusions(new FileOfClasses(new ByteArrayInputStream(exclusions.getBytes())));
ClassLoaderReference loader = scope.getLoader(AnalysisScope.APPLICATION);
/** END Custom change: Fixes in AndroidAnalysisScope */
addClassPathToScope(classPath, scope, loader);
return scope;
}
@ -94,9 +97,11 @@ public class DexAnalysisScopeReader extends AnalysisScopeReader {
if (classPath == null) {
throw new IllegalArgumentException("classPath null");
}
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
AnalysisScope scope = AnalysisScope.createJavaAnalysisScope();
scope.setExclusions(new FileOfClasses(new FileInputStream(exclusionsFile)));
ClassLoaderReference loader = scope.getLoader(AnalysisScope.APPLICATION);
/** END Custom change: Fixes in AndroidAnalysisScope */
addClassPathToScope(classPath, scope, loader);
return scope;
}

View File

@ -49,24 +49,32 @@ 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 */
public DexEntryPoint(IMethod method, IClassHierarchy cha) {
super(method, cha);
/** BEGIN Custom change */
this.cha = cha;
/** END Custom change */
// TODO Auto-generated constructor stub
}
public DexEntryPoint(MethodReference method, IClassHierarchy cha) {
super(method, cha);
/** BEGIN Custom change */
this.cha = cha;
/** END Custom change */
// TODO Auto-generated constructor stub
}
/** BEGIN Custom change */
@Override
public IClassHierarchy getClassHierarchy() {
return cha;
}
/** END Custom change */
@Override
protected TypeReference[] makeParameterTypes(IMethod method, int i) {

View File

@ -46,11 +46,13 @@ public class AndroidAnalysisScope {
return scope;
}
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
public static AnalysisScope setUpAndroidAnalysisScope(String androidLib, String classpath, File exclusions) throws IOException {
AnalysisScope scope = DexAnalysisScopeReader.makeAndroidBinaryAnalysisScope(classpath, exclusions);
setUpAnalysisScope(scope, new File(androidLib).toURI());
return scope;
}
/** END Custom change: Fixes in AndroidAnalysisScope */
public static AnalysisScope setUpAndroidAnalysisScope(URI androidLib, URI classpath, File exclusions) throws IOException {
AnalysisScope scope = DexAnalysisScopeReader.makeAndroidBinaryAnalysisScope(classpath, exclusions);
@ -59,9 +61,11 @@ public class AndroidAnalysisScope {
}
private static void setUpAnalysisScope(AnalysisScope scope, URI androidLib) throws IOException {
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
if (androidLib == null) {
throw new IllegalArgumentException("The argument androidLib may not be null.");
}
/** END Custom change: Fixes in AndroidAnalysisScope */
scope.setLoaderImpl(ClassLoaderReference.Application,
"com.ibm.wala.dalvik.classLoader.WDexClassLoaderImpl");
@ -69,7 +73,9 @@ public class AndroidAnalysisScope {
scope.setLoaderImpl(ClassLoaderReference.Primordial,
"com.ibm.wala.dalvik.classLoader.WDexClassLoaderImpl");
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
if (FileSuffixes.isDexFile(androidLib)) {
/** END Custom change: Fixes in AndroidAnalysisScope */
Module dexMod = new DexFileModule(new File(androidLib));
// Iterator<ModuleEntry> mitr = dexMod.getEntries();
@ -80,6 +86,7 @@ public class AndroidAnalysisScope {
scope.addToScope(ClassLoaderReference.Primordial, dexMod);
} else {
/** BEGIN Custom change: Fixes in AndroidAnalysisScope */
if (FileSuffixes.isRessourceFromJar(androidLib)) {
//final FileProvider fileProvider = new FileProvider();
final InputStream is = androidLib.toURL().openStream();
@ -91,6 +98,7 @@ public class AndroidAnalysisScope {
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(new File(
androidLib)));
}
/** END Custom change: Fixes in AndroidAnalysisScope */
}
}

View File

@ -21,8 +21,10 @@ public class MonitorUtil {
* Use this interface to decouple core utilities from the Eclipse layer
*/
public interface IProgressMonitor {
/** BEGIN Custom change */
/** Constant indicating an unknown amount of work. */
public static final int UNKNOWN = -1;
/** END Custom change */
void beginTask(String task, int totalWork);