Skip to content

Commit

Permalink
Merge commit 'f30eccd8b983809d71ec76609f6009fe5489b409' into #29
Browse files Browse the repository at this point in the history
Conflicts:
	src/test/java/test/core/selfrunning/AbstractBoomerangTest.java
  • Loading branch information
johspaeth committed Jun 16, 2017
2 parents 70b98a1 + f30eccd commit 0073019
Show file tree
Hide file tree
Showing 18 changed files with 265 additions and 398 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
ant.settings
/target/
/testBin/
*.DS_Store
*.DS_Store
.classpath
.project
.settings/
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>de.fraunhofer.iem</groupId>
<artifactId>boomerang</artifactId>
<version>0.9</version>
<version>0.0.1-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/boomerang/AliasFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import boomerang.accessgraph.SetBasedFieldGraph;
import boomerang.accessgraph.WrappedSootField;
import boomerang.backward.BackwardSolver;
import boomerang.cfg.BackwardsInfoflowCFG;
import boomerang.cfg.IExtendedICFG;
import boomerang.context.IContextRequester;
import boomerang.context.NoContextRequester;
import boomerang.forward.ForwardSolver;
Expand All @@ -22,8 +24,6 @@
import soot.Type;
import soot.Unit;
import soot.jimple.ThrowStmt;
import soot.jimple.infoflow.solver.cfg.BackwardsInfoflowCFG;
import soot.jimple.infoflow.solver.cfg.IInfoflowCFG;

public class AliasFinder {

Expand Down
18 changes: 16 additions & 2 deletions src/main/java/boomerang/AliasResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
import com.google.common.collect.ForwardingMultimap;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;

import boomerang.accessgraph.AccessGraph;
import boomerang.accessgraph.FieldGraph;
import boomerang.accessgraph.WrappedSootField;
import boomerang.cfg.IExtendedICFG;
import heros.solver.Pair;
import soot.Unit;
import soot.jimple.infoflow.solver.cfg.IInfoflowCFG;
import soot.Value;
import soot.jimple.AssignStmt;

public class AliasResults extends ForwardingMultimap<Pair<Unit, AccessGraph>, AccessGraph> {
private Multimap<Pair<Unit, AccessGraph>, AccessGraph> delegate;
Expand Down Expand Up @@ -138,7 +141,7 @@ public static Set<AccessGraph> appendFields(Set<AccessGraph> in, AccessGraph gra
return out;
}

public String withMethodOfAllocationSite(IInfoflowCFG cfg) {
public String withMethodOfAllocationSite(IExtendedICFG cfg) {
StringBuilder sb = new StringBuilder();
sb.append("{");
for (Pair<Unit, AccessGraph> k : keySet()) {
Expand Down Expand Up @@ -167,4 +170,15 @@ public void setTimedout() {
public boolean queryTimedout(){
return timedout;
}

public Set<Value> getValues(){
Set<Value> res = Sets.newHashSet();
for(Pair<Unit, AccessGraph> key : this.keySet()){
if(key.getO1() instanceof AssignStmt){
AssignStmt as = (AssignStmt) key.getO1();
res.add(as.getRightOp());
}
}
return res;
}
}
8 changes: 4 additions & 4 deletions src/main/java/boomerang/BoomerangContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import boomerang.backward.BackwardProblem;
import boomerang.backward.BackwardSolver;
import boomerang.bidi.PathEdgeStore;
import boomerang.cfg.BackwardsInfoflowCFG;
import boomerang.cfg.IExtendedICFG;
import boomerang.context.IContextRequester;
import boomerang.debug.IBoomerangDebugger;
import boomerang.debug.JSONOutputDebugger;
Expand All @@ -38,23 +40,21 @@
import soot.Unit;
import soot.Value;
import soot.jimple.ReturnStmt;
import soot.jimple.infoflow.solver.cfg.BackwardsInfoflowCFG;
import soot.jimple.infoflow.solver.cfg.IInfoflowCFG;

@SuppressWarnings("serial")
public class BoomerangContext {

/**
* The inter-procedural control flow graph to be used.
*/
public IInfoflowCFG icfg;
public IExtendedICFG icfg;

public IBoomerangDebugger debugger;

/**
* The inter-procedural backward control flow graph to be used.
*/
public IInfoflowCFG bwicfg;
public IExtendedICFG bwicfg;

/**
* Native call handler, defines how aliases flow at native call sites.
Expand Down
74 changes: 4 additions & 70 deletions src/main/java/boomerang/BoomerangOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.google.common.base.Optional;

import boomerang.accessgraph.AccessGraph;
import boomerang.allocationsitehandler.ReferenceType;
import boomerang.cfg.IExtendedICFG;
import boomerang.debug.DefaultBoomerangDebugger;
import boomerang.debug.IBoomerangDebugger;
import boomerang.ifdssolver.IPathEdge;
Expand All @@ -20,7 +22,6 @@
import soot.jimple.NewExpr;
import soot.jimple.NewMultiArrayExpr;
import soot.jimple.NullConstant;
import soot.jimple.infoflow.solver.cfg.IInfoflowCFG;

public abstract class BoomerangOptions {

Expand All @@ -47,7 +48,7 @@ public boolean stronglyUpdateFields() {
return true;
}

public abstract IInfoflowCFG icfg();
public abstract IExtendedICFG icfg();

public String toString() {
String str = "====== Boomerang Options ======";
Expand All @@ -72,73 +73,6 @@ public boolean continuePropagate(IPathEdge<Unit, AccessGraph> edge) {
}

public AllocationSiteHandlers allocationSiteHandlers() {
return new AllocationSiteHandlers() {

private boolean isAllocationValue(Value val) {
return (val instanceof NewExpr || val instanceof NewArrayExpr
|| val instanceof NewMultiArrayExpr || val instanceof NullConstant);
}

@Override
public Optional<AllocationSiteHandler> assignStatement(final AssignStmt stmt,final Value rightOp,
final AccessGraph source) {
if (!isAllocationValue(rightOp))
return Optional.absent();

if (source.getFieldCount() > 0 && !source.firstFieldMustMatch(AliasFinder.ARRAY_FIELD)) {
return Optional.absent();
}
if (source.getFieldCount() > 1 && source.firstFieldMustMatch(AliasFinder.ARRAY_FIELD))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source,stmt, rightOp instanceof NullConstant);
}
});
}

@Override
public Optional<AllocationSiteHandler> arrayStoreStatement(final AssignStmt stmt, Value rightOp,
final AccessGraph source) {
if (!isAllocationValue(rightOp))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source,stmt ,false);
}
});
}

@Override
public Optional<AllocationSiteHandler> returnStmtViaCall(final AssignStmt assignedCallSite, final AccessGraph source,
Value retOp) {
if (!(retOp instanceof NullConstant))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source,assignedCallSite, true);
}
});
}

@Override
public Optional<AllocationSiteHandler> fieldStoreStatement(final AssignStmt stmt, InstanceFieldRef fieldRef,
Value rightOp, final AccessGraph source) {
if (!(rightOp instanceof NullConstant))
return Optional.absent();
if(source.getFieldCount() != 1){
return Optional.absent();
}
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source,stmt, true);
}
});
}
};
return new ReferenceType();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package boomerang.allocationsitehandler;

import com.google.common.base.Optional;

import boomerang.AliasFinder;
import boomerang.accessgraph.AccessGraph;
import boomerang.pointsofindirection.Alloc;
import boomerang.pointsofindirection.AllocationSiteHandler;
import boomerang.pointsofindirection.AllocationSiteHandlers;
import soot.Value;
import soot.jimple.AssignStmt;
import soot.jimple.Constant;
import soot.jimple.InstanceFieldRef;
import soot.jimple.NewArrayExpr;
import soot.jimple.NewExpr;
import soot.jimple.NewMultiArrayExpr;
import soot.jimple.NullConstant;

public class PrimitiveTypeAndReferenceType implements AllocationSiteHandlers {

private boolean isAllocationValue(Value val) {
return (val instanceof NewExpr || val instanceof NewArrayExpr || val instanceof NewMultiArrayExpr
|| val instanceof Constant);
}

@Override
public Optional<AllocationSiteHandler> assignStatement(final AssignStmt stmt, final Value rightOp,
final AccessGraph source) {
if (!isAllocationValue(rightOp))
return Optional.absent();

if (source.getFieldCount() > 0 && !source.firstFieldMustMatch(AliasFinder.ARRAY_FIELD)) {
return Optional.absent();
}
if (source.getFieldCount() > 1 && source.firstFieldMustMatch(AliasFinder.ARRAY_FIELD))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, stmt, rightOp instanceof NullConstant);
}
});
}

@Override
public Optional<AllocationSiteHandler> arrayStoreStatement(final AssignStmt stmt, Value rightOp,
final AccessGraph source) {
if (!isAllocationValue(rightOp))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, stmt, false);
}
});
}

@Override
public Optional<AllocationSiteHandler> returnStmtViaCall(final AssignStmt assignedCallSite,
final AccessGraph source, Value retOp) {
if (!(retOp instanceof NullConstant))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, assignedCallSite, true);
}
});
}

@Override
public Optional<AllocationSiteHandler> fieldStoreStatement(final AssignStmt stmt, InstanceFieldRef fieldRef,
Value rightOp, final AccessGraph source) {
if (!(rightOp instanceof NullConstant))
return Optional.absent();
if (source.getFieldCount() != 1) {
return Optional.absent();
}
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, stmt, true);
}
});
}
}
85 changes: 85 additions & 0 deletions src/main/java/boomerang/allocationsitehandler/ReferenceType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package boomerang.allocationsitehandler;

import com.google.common.base.Optional;

import boomerang.AliasFinder;
import boomerang.accessgraph.AccessGraph;
import boomerang.pointsofindirection.Alloc;
import boomerang.pointsofindirection.AllocationSiteHandler;
import boomerang.pointsofindirection.AllocationSiteHandlers;
import soot.Value;
import soot.jimple.AssignStmt;
import soot.jimple.InstanceFieldRef;
import soot.jimple.NewArrayExpr;
import soot.jimple.NewExpr;
import soot.jimple.NewMultiArrayExpr;
import soot.jimple.NullConstant;

public class ReferenceType implements AllocationSiteHandlers {

private boolean isAllocationValue(Value val) {
return (val instanceof NewExpr || val instanceof NewArrayExpr || val instanceof NewMultiArrayExpr
|| val instanceof NullConstant);
}

@Override
public Optional<AllocationSiteHandler> assignStatement(final AssignStmt stmt, final Value rightOp,
final AccessGraph source) {
if (!isAllocationValue(rightOp))
return Optional.absent();

if (source.getFieldCount() > 0 && !source.firstFieldMustMatch(AliasFinder.ARRAY_FIELD)) {
return Optional.absent();
}
if (source.getFieldCount() > 1 && source.firstFieldMustMatch(AliasFinder.ARRAY_FIELD))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, stmt, rightOp instanceof NullConstant);
}
});
}

@Override
public Optional<AllocationSiteHandler> arrayStoreStatement(final AssignStmt stmt, Value rightOp,
final AccessGraph source) {
if (!isAllocationValue(rightOp))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, stmt, false);
}
});
}

@Override
public Optional<AllocationSiteHandler> returnStmtViaCall(final AssignStmt assignedCallSite,
final AccessGraph source, Value retOp) {
if (!(retOp instanceof NullConstant))
return Optional.absent();
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, assignedCallSite, true);
}
});
}

@Override
public Optional<AllocationSiteHandler> fieldStoreStatement(final AssignStmt stmt, InstanceFieldRef fieldRef,
Value rightOp, final AccessGraph source) {
if (!(rightOp instanceof NullConstant))
return Optional.absent();
if (source.getFieldCount() != 1) {
return Optional.absent();
}
return Optional.<AllocationSiteHandler>of(new AllocationSiteHandler() {
@Override
public Alloc alloc() {
return new Alloc(source, stmt, true);
}
});
}
}
Loading

0 comments on commit 0073019

Please sign in to comment.