Skip to content
This repository has been archived by the owner on Jul 8, 2021. It is now read-only.

Added and integrated BoomerangAbortedException #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package boomerang;

import boomerang.stats.IBoomerangStats;

public class BoomerangAbortedException extends RuntimeException {

private static final long serialVersionUID = 3767732949845559629L;

private final IBoomerangStats stats;

public BoomerangAbortedException(IBoomerangStats stats) {
this.stats = stats;
}

public IBoomerangStats getStats() {
return stats;
}

@Override
public String toString() {
return "Boomerang aborted " + getStats();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@

import boomerang.stats.IBoomerangStats;

public class BoomerangTimeoutException extends RuntimeException {
public class BoomerangTimeoutException extends BoomerangAbortedException {

private IBoomerangStats stats;
private long elapsed;
private static final long serialVersionUID = 3767732949845559629L;

BoomerangTimeoutException(long elapsed, IBoomerangStats stats) {
private final long elapsed;

public BoomerangTimeoutException(long elapsed, IBoomerangStats stats) {
super(stats);
this.elapsed = elapsed;
this.stats = stats;
}

@Override
public String toString() {
return "Boomerang Timeout after " + elapsed + "ms\n " + stats;
return "Boomerang Timeout after " + elapsed + "ms\n " + getStats();
}
}

49 changes: 29 additions & 20 deletions boomerangPDS/src/main/java/boomerang/WeightedBoomerang.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public void run() {
@Override
public void onWeightAdded(Transition<Statement, INode<Val>> t, W w,
WeightedPAutomaton<Statement, INode<Val>, W> aut) {
checkTimeout();
throwOnEarlyTermination();
}
});
solver.getFieldAutomaton().registerListener(new WPAUpdateListener<Field, INode<Node<Statement, Val>>, W>() {

@Override
public void onWeightAdded(Transition<Field, INode<Node<Statement, Val>>> t, W w,
WeightedPAutomaton<Field, INode<Node<Statement, Val>>, W> aut) {
checkTimeout();
throwOnEarlyTermination();
}
});
SeedFactory<W> seedFactory = getSeedFactory();
Expand All @@ -204,6 +204,15 @@ private void registerUnbalancedPopListener(Node<Statement, AbstractBoomerangSolv

}

public final void throwOnEarlyTermination() {
checkAborted();
checkTimeout();
}

public void checkAborted() {

}

public void checkTimeout() {
if (options.analysisTimeoutMS() > 0) {
long elapsed = analysisWatch.elapsed(TimeUnit.MILLISECONDS);
Expand Down Expand Up @@ -301,7 +310,7 @@ protected WeightFunctions<Statement, Val, Statement, W> getCallWeights() {

@Override
protected void onManyStateListenerRegister() {
checkTimeout();
throwOnEarlyTermination();
}

};
Expand Down Expand Up @@ -423,7 +432,7 @@ public void addCallRule(Rule<Statement, INode<Val>, W> rule) {

@Override
protected void onManyStateListenerRegister() {
checkTimeout();
throwOnEarlyTermination();
}

};
Expand Down Expand Up @@ -606,7 +615,7 @@ protected void forwardHandleFieldWrite(final Node<Statement, Val> node, final Fi
public BackwardBoomerangResults<W> backwardSolveUnderScope(BackwardQuery backwardQuery, ForwardQuery forwardQuery,
Node<Statement, Val> node) {
scopedQueries.add(backwardQuery);
boolean timedout = false;
boolean aborted = false;
try {
backwardSolve(backwardQuery);
final AbstractBoomerangSolver<W> bwSolver = queryToSolvers.getOrCreate(backwardQuery);
Expand Down Expand Up @@ -634,12 +643,12 @@ public void anyContext(Statement end) {
}
}
});
} catch (BoomerangTimeoutException e) {
timedout = true;
} catch (BoomerangAbortedException e) {
aborted = true;
cleanup();
}

return new BackwardBoomerangResults<W>(backwardQuery, timedout, this.queryToSolvers, getStats(), analysisWatch);
return new BackwardBoomerangResults<W>(backwardQuery, aborted, this.queryToSolvers, getStats(), analysisWatch);
}

private void cleanup() {
Expand All @@ -653,7 +662,7 @@ private void cleanup() {
public BackwardBoomerangResults<W> backwardSolveUnderScope(BackwardQuery backwardQuery,
IContextRequester requester) {
scopedQueries.add(backwardQuery);
boolean timedout = false;
boolean aborted = false;
try {
if (analysisWatch.isRunning()) {
analysisWatch.stop();
Expand All @@ -670,12 +679,12 @@ public BackwardBoomerangResults<W> backwardSolveUnderScope(BackwardQuery backwar
if (analysisWatch.isRunning()) {
analysisWatch.stop();
}
} catch (BoomerangTimeoutException e) {
timedout = true;
} catch (BoomerangAbortedException e) {
aborted = true;
cleanup();
}

return new BackwardBoomerangResults<W>(backwardQuery, timedout, this.queryToSolvers, getStats(), analysisWatch);
return new BackwardBoomerangResults<W>(backwardQuery, aborted, this.queryToSolvers, getStats(), analysisWatch);
}

private final class UnbalancedPopCallerListener implements CallerListener<Unit, SootMethod> {
Expand Down Expand Up @@ -1077,21 +1086,21 @@ public ForwardBoomerangResults<W> solve(ForwardQuery query) {
if (!analysisWatch.isRunning()) {
analysisWatch.start();
}
boolean timedout = false;
boolean aborted = false;
try {
logger.debug("Starting forward analysis of: {}", query);
forwardSolve(query);
logger.debug("Terminated forward analysis of: {}", query);
} catch (BoomerangTimeoutException e) {
timedout = true;
} catch (BoomerangAbortedException e) {
aborted = true;
cleanup();
logger.debug("Timeout of query: {}", query);
}

if (analysisWatch.isRunning()) {
analysisWatch.stop();
}
return new ForwardBoomerangResults<W>(query, icfg(), timedout, this.queryToSolvers, getStats(), analysisWatch);
return new ForwardBoomerangResults<W>(query, icfg(), aborted, this.queryToSolvers, getStats(), analysisWatch);
}

public BackwardBoomerangResults<W> solve(BackwardQuery query) {
Expand All @@ -1103,21 +1112,21 @@ public BackwardBoomerangResults<W> solve(BackwardQuery query, boolean timing) {
if (timing && !analysisWatch.isRunning()) {
analysisWatch.start();
}
boolean timedout = false;
boolean aborted = false;
try {
logger.debug("Starting backward analysis of: {}", query);
backwardSolve(query);
logger.debug("Terminated backward analysis of: {}", query);
} catch (BoomerangTimeoutException e) {
timedout = true;
} catch (BoomerangAbortedException e) {
aborted = true;
cleanup();
logger.debug("Timeout of query: {}", query);
}
if (timing && analysisWatch.isRunning()) {
analysisWatch.stop();
}

return new BackwardBoomerangResults<W>(query, timedout, this.queryToSolvers, getStats(), analysisWatch);
return new BackwardBoomerangResults<W>(query, aborted, this.queryToSolvers, getStats(), analysisWatch);
}

protected void backwardSolve(BackwardQuery query) {
Expand Down
2 changes: 1 addition & 1 deletion idealPDS/src/main/java/ideal/IDEALSeedSolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void anyContext(Statement end) {

@Override
public void stackElement(Statement callSite) {
boomerang.checkTimeout();
boomerang.throwOnEarlyTermination();
addAffectedPotentialStrongUpdate(strongUpdateNode, callSite);
for (ForwardQuery e : queryAllocationSites) {
AbstractBoomerangSolver<W> solver = boomerang.getSolvers().get(e);
Expand Down