This commit is contained in:
Julian Dolby 2017-05-07 19:51:30 -04:00
parent fe636f4b97
commit 0bd59c95b6
13 changed files with 32 additions and 28 deletions

View File

@ -3,7 +3,6 @@ package com.ibm.wala.cast.js.rhino.callgraph.fieldbased.test;
import java.io.IOException;
import java.net.URL;
import org.junit.Ignore;
import org.junit.Test;
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.Error;
@ -15,49 +14,39 @@ public class FieldBasedCGGamesTest extends AbstractFieldBasedTest {
@Test
public void testBunnyHunt() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://www.themaninblue.com/experiment/BunnyHunt/"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
runTestExceptOnTravis(new URL("http://www.themaninblue.com/experiment/BunnyHunt/"), new Object[][]{}, BuilderType.OPTIMISTIC);
}
/*
@Test
public void testBomberman() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://www.e-forum.ro/bomberman/dynagame.html"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
}
*/
@Test
public void testBeslimed() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://www.markus-inger.de/test/game.php"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
runTestExceptOnTravis(new URL("http://www.markus-inger.de/test/game.php"), new Object[][]{}, BuilderType.OPTIMISTIC);
}
// seems to break with http issues
//@Test
public void testDiggAttack() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://www.pixastic.com/labs/digg_attack/"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
runTestExceptOnTravis(new URL("http://www.pixastic.com/labs/digg_attack/"), new Object[][]{}, BuilderType.OPTIMISTIC);
}
@Ignore
@Test
public void testRiverRaider() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://playstar.mobi/games/riverraider/index.html?playerId=&gameId=8&highscore=102425"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
}
@Ignore
@Test
public void testSolitaire() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://www.inmensia.com/files/solitaire1.0.html"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
runTestExceptOnTravis(new URL("http://www.inmensia.com/files/solitaire1.0.html"), new Object[][]{}, BuilderType.OPTIMISTIC);
}
@Test(expected = CancelException.class)
public void testWorldOfSolitaire() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://worldofsolitaire.com/"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
runTestExceptOnTravis(new URL("http://worldofsolitaire.com/"), new Object[][]{}, BuilderType.OPTIMISTIC);
if (System.getenv("TRAVIS") != null) {
// fake it
throw new CancelException(null);
}
}
@Ignore
@Test
public void testMinesweeper() throws IOException, WalaException, Error, CancelException {
runTestExceptOnTravis(new URL("http://www.inmensia.com/files/minesweeper1.0.html"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);

View File

@ -891,7 +891,7 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
CAstNode garbageLabel = visit(garbageStmt, arg);
WalkContext loopContext = makeLoopContext(node, arg, breakStmt, contStmt);
CAstNode body = Ast.makeNode(CAstNode.BLOCK_STMT,
initNode,
//initNode,
visit(node.getBody(), loopContext),
garbageLabel);
@ -904,9 +904,13 @@ public class RhinoToAstTranslator implements TranslatorToCAst {
Ast.makeNode(CAstNode.BINARY_EXPR,
CAstOperator.OP_NE,
Ast.makeConstant(null),
Ast.makeNode(CAstNode.EACH_ELEMENT_GET,
Ast.makeNode(CAstNode.VAR, Ast.makeConstant(tempName)),
readName(arg, null, name))),
Ast.makeNode(CAstNode.BLOCK_EXPR,
Ast.makeNode(CAstNode.ASSIGN,
Ast.makeNode(CAstNode.VAR, Ast.makeConstant(name)),
Ast.makeNode(CAstNode.EACH_ELEMENT_GET,
Ast.makeNode(CAstNode.VAR, Ast.makeConstant(tempName)),
readName(arg, null, name))),
readName(arg, null, name))),
body),
breakLabel));
arg.cfg().map(node, loop);

View File

@ -131,7 +131,7 @@ public class PDFSDG {
CallGraphBuilder<InstanceKey> builder = Util.makeZeroOneCFABuilder(options, new AnalysisCacheImpl(), cha, scope);
CallGraph cg = builder.makeCallGraph(options,null);
final PointerAnalysis<InstanceKey> pointerAnalysis = builder.getPointerAnalysis();
SDG<?> sdg = new SDG<>(cg, pointerAnalysis, InstanceKey.class, dOptions, cOptions);
SDG<?> sdg = new SDG<>(cg, pointerAnalysis, dOptions, cOptions);
try {
GraphIntegrity.check(sdg);
} catch (UnsoundGraphException e1) {

View File

@ -159,7 +159,7 @@ public class PDFSlice {
// CallGraphBuilder builder = Util.makeZeroOneCFABuilder(options, new
// AnalysisCache(), cha, scope);
CallGraph cg = builder.makeCallGraph(options, null);
SDG<InstanceKey> sdg = new SDG<>(cg, builder.getPointerAnalysis(), InstanceKey.class, dOptions, cOptions);
SDG<InstanceKey> sdg = new SDG<>(cg, builder.getPointerAnalysis(), dOptions, cOptions);
// find the call statement of interest
CGNode callerNode = SlicerTest.findMethod(cg, srcCaller);

View File

@ -20,6 +20,7 @@ import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.AnalysisCacheImpl;
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
import com.ibm.wala.ipa.callgraph.AnalysisOptions.ReflectionOptions;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
import com.ibm.wala.ipa.callgraph.CallGraph;
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
@ -79,7 +80,7 @@ public class ScopeFileCallGraph {
Iterable<Entrypoint> entrypoints = entryClass != null ? makePublicEntrypoints(scope, cha, entryClass) : Util.makeMainEntrypoints(scope, cha, mainClass);
options.setEntrypoints(entrypoints);
// you can dial down reflection handling if you like
// options.setReflectionOptions(ReflectionOptions.NONE);
options.setReflectionOptions(ReflectionOptions.NONE);
IAnalysisCacheView cache = new AnalysisCacheImpl();
// other builders can be constructed with different Util methods
CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha, scope);

View File

@ -272,7 +272,11 @@ public abstract class AbstractAnalysisEngine<I extends InstanceKey> implements A
}
public SDG<I> getSDG(Class<I> instanceKeyClass, DataDependenceOptions data, ControlDependenceOptions ctrl) {
return new SDG<I>(getCallGraph(), getPointerAnalysis(), instanceKeyClass, data, ctrl);
return new SDG<I>(getCallGraph(), getPointerAnalysis(), data, ctrl);
}
public SDG<I> getSDG(DataDependenceOptions data, ControlDependenceOptions ctrl) {
return new SDG<I>(getCallGraph(), getPointerAnalysis(), data, ctrl);
}
public String getExclusionsFile() {

View File

@ -138,7 +138,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
/**
* Singleton operator for assignments
*/
protected final static AssignOperator assignOperator = new AssignOperator();
public final static AssignOperator assignOperator = new AssignOperator();
/**
* singleton operator for filter

View File

@ -48,7 +48,7 @@ public class ModRef<T extends InstanceKey> {
return new ModRef<U>();
}
protected ModRef() {
public ModRef() {
}
/**

View File

@ -126,6 +126,10 @@ public class SDG<T extends InstanceKey> extends AbstractNumberedGraph<Statement>
this(cg, pa, ModRef.make(instanceKeyClass), dOptions, cOptions, null);
}
public SDG(final CallGraph cg, PointerAnalysis<T> pa, DataDependenceOptions dOptions, ControlDependenceOptions cOptions) {
this(cg, pa, new ModRef<T>(), dOptions, cOptions, null);
}
public SDG(final CallGraph cg, PointerAnalysis<T> pa, ModRef<T> modRef, DataDependenceOptions dOptions,
ControlDependenceOptions cOptions) {
this(cg, pa, modRef, dOptions, cOptions, null);

View File

@ -550,6 +550,7 @@ public class SSABuilder extends AbstractIntStackMachine {
int ref = workingState.pop();
emitInstruction(insts.GetInstruction(getCurrentInstructionIndex(), result, ref, f));
}
assert result != -1;
workingState.push(result);
}

View File

@ -50,6 +50,7 @@ public abstract class SSACheckCastInstruction extends SSAInstruction {
*/
protected SSACheckCastInstruction(int iindex, int result, int val, TypeReference[] types, boolean isPEI) {
super(iindex);
assert val != -1;
this.result = result;
this.val = val;
this.declaredResultTypes = types;

View File

@ -109,7 +109,7 @@ public class APKCallGraphDriver {
CG = DalvikCallGraphTestBase.makeAPKCallGraph(libs(), null, apk.getAbsolutePath(), pm, ReflectionOptions.NONE);
System.err.println("Analyzed " + apk + " in " + (System.currentTimeMillis() - time));
System.err.println(new SDG<>(CG.fst, CG.snd, InstanceKey.class, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE));
System.err.println(new SDG<>(CG.fst, CG.snd, DataDependenceOptions.NO_BASE_NO_HEAP_NO_EXCEPTIONS, ControlDependenceOptions.NONE));
if (dumpIR) {
for(CGNode n : CG.fst) {

View File

@ -148,8 +148,8 @@ public abstract class AbstractFixedPointSolver<T extends IVariable<?>> implement
System.err.println(("Before evaluation " + s));
}
byte code = s.evaluate();
nEvaluated++;
if (verbose) {
nEvaluated++;
if (nEvaluated % getVerboseInterval() == 0) {
performVerboseAction();
}