Skip to content

Commit 79e92e7

Browse files
authored
Merge branch 'develop' into ci/snapshotrelease
2 parents 9e64cd1 + f116186 commit 79e92e7

File tree

72 files changed

+2066
-915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2066
-915
lines changed

SynchronizedPDS/src/main/java/sync/pds/solver/SyncPDSSolver.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Map;
2828
import java.util.Map.Entry;
2929
import java.util.Set;
30+
import org.slf4j.Logger;
3031
import org.slf4j.LoggerFactory;
3132
import sync.pds.solver.nodes.ExclusionNode;
3233
import sync.pds.solver.nodes.GeneratedState;
@@ -58,9 +59,7 @@ public enum PDSSystem {
5859
CALLS
5960
}
6061

61-
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(SyncPDSSolver.class);
62-
private static final boolean FieldSensitive = true;
63-
private static final boolean ContextSensitive = true;
62+
private static final Logger logger = LoggerFactory.getLogger(SyncPDSSolver.class);
6463
protected final WeightedPushdownSystem<Stmt, INode<Fact>, W> callingPDS =
6564
new WeightedPushdownSystem<Stmt, INode<Fact>, W>() {
6665
public String toString() {
@@ -81,6 +80,8 @@ public String toString() {
8180
reachedStateUpdateListeners = HashMultimap.create();
8281
protected final WeightedPAutomaton<Field, INode<Node<Stmt, Fact>>, W> fieldAutomaton;
8382
protected final WeightedPAutomaton<Stmt, INode<Fact>, W> callAutomaton;
83+
private final boolean fieldSensitive;
84+
private final boolean contextSensitive;
8485

8586
protected boolean preventFieldTransitionAdd(
8687
Transition<Field, INode<Node<Stmt, Fact>>> trans, W weight) {
@@ -99,8 +100,33 @@ public SyncPDSSolver(
99100
int maxCallDepth,
100101
int maxFieldDepth,
101102
int maxUnbalancedCallDepth) {
103+
this(
104+
useCallSummaries,
105+
callSummaries,
106+
useFieldSummaries,
107+
fieldSummaries,
108+
maxCallDepth,
109+
maxFieldDepth,
110+
maxUnbalancedCallDepth,
111+
true,
112+
true);
113+
}
114+
115+
public SyncPDSSolver(
116+
final boolean useCallSummaries,
117+
NestedWeightedPAutomatons<Stmt, INode<Fact>, W> callSummaries,
118+
final boolean useFieldSummaries,
119+
NestedWeightedPAutomatons<Field, INode<Node<Stmt, Fact>>, W> fieldSummaries,
120+
int maxCallDepth,
121+
int maxFieldDepth,
122+
int maxUnbalancedCallDepth,
123+
boolean fieldSensitive,
124+
boolean contextSensitive) {
125+
this.fieldSensitive = fieldSensitive;
126+
this.contextSensitive = contextSensitive;
127+
102128
fieldAutomaton =
103-
new WeightedPAutomaton<Field, INode<Node<Stmt, Fact>>, W>() {
129+
new WeightedPAutomaton<>() {
104130
@Override
105131
public INode<Node<Stmt, Fact>> createState(INode<Node<Stmt, Fact>> d, Field loc) {
106132
if (loc.equals(emptyField())) return d;
@@ -141,7 +167,7 @@ public boolean isGeneratedState(INode<Node<Stmt, Fact>> d) {
141167
};
142168

143169
callAutomaton =
144-
new WeightedPAutomaton<Stmt, INode<Fact>, W>() {
170+
new WeightedPAutomaton<>() {
145171
@Override
146172
public INode<Fact> createState(INode<Fact> d, Stmt loc) {
147173
return generateCallState(d, loc);
@@ -556,7 +582,7 @@ public void processPop(Node<Stmt, Fact> curr, PopNode popNode) {
556582
Object location = popNode.location();
557583
if (system.equals(PDSSystem.FIELDS)) {
558584
NodeWithLocation<Stmt, Fact, Field> node = (NodeWithLocation) location;
559-
if (FieldSensitive) {
585+
if (fieldSensitive) {
560586
addFieldRule(
561587
new PopRule<>(
562588
asFieldFact(curr),
@@ -568,7 +594,7 @@ public void processPop(Node<Stmt, Fact> curr, PopNode popNode) {
568594
}
569595
addNormalCallFlow(curr, node.fact());
570596
} else if (system.equals(PDSSystem.CALLS)) {
571-
if (ContextSensitive) {
597+
if (contextSensitive) {
572598
addCallRule(
573599
new PopRule<>(
574600
wrap(curr.fact()), curr.stmt(), wrap((Fact) location), getCallWeights().pop(curr)));
@@ -657,7 +683,7 @@ public void processPush(
657683
Node<Stmt, Fact> curr, Location location, PushNode<Stmt, Fact, ?> succ, PDSSystem system) {
658684
if (system.equals(PDSSystem.FIELDS)) {
659685

660-
if (FieldSensitive) {
686+
if (fieldSensitive) {
661687
addFieldRule(
662688
new PushRule<>(
663689
asFieldFact(curr),
@@ -673,7 +699,7 @@ public void processPush(
673699

674700
} else if (system.equals(PDSSystem.CALLS)) {
675701
addNormalFieldFlow(curr, succ);
676-
if (ContextSensitive) {
702+
if (contextSensitive) {
677703
addCallRule(
678704
new PushRule<>(
679705
wrap(curr.fact()),

boomerangPDS/src/main/java/boomerang/WeightedBoomerang.java

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,10 @@ protected BackwardBoomerangSolver<W> createItem(BackwardQuery key) {
137137
cfg(),
138138
genField,
139139
key,
140-
WeightedBoomerang.this.options,
141140
createCallSummaries(null, backwardCallSummaries),
142141
createFieldSummaries(null, backwardFieldSummaries),
143-
WeightedBoomerang.this.dataFlowscope,
144-
options.getBackwardFlowFunction(),
145-
callGraph.getFieldLoadStatements(),
146-
callGraph.getFieldStoreStatements(),
142+
frameworkScope,
143+
options,
147144
null) {
148145

149146
@Override
@@ -435,6 +432,10 @@ protected FieldWritePOI createItem(FieldWritePOI key) {
435432
private final CallGraph callGraph;
436433
private INode<Val> rootQuery;
437434

435+
public WeightedBoomerang(FrameworkScope frameworkScope) {
436+
this(frameworkScope, BoomerangOptions.DEFAULT());
437+
}
438+
438439
public WeightedBoomerang(FrameworkScope frameworkScope, BoomerangOptions options) {
439440
this.frameworkScope = frameworkScope;
440441
this.options = options;
@@ -461,10 +462,6 @@ public WeightedBoomerang(FrameworkScope frameworkScope, BoomerangOptions options
461462
this.queryGraph = new QueryGraph<>(this);
462463
}
463464

464-
public WeightedBoomerang(FrameworkScope frameworkScope) {
465-
this(frameworkScope, BoomerangOptions.DEFAULT());
466-
}
467-
468465
protected void addVisitedMethod(Method method) {
469466
if (!dataFlowscope.isExcluded(method) && visitedMethods.add(method)) {
470467
LOGGER.trace("Reach Method: {}", method);
@@ -482,13 +479,10 @@ protected ForwardBoomerangSolver<W> createForwardSolver(final ForwardQuery sourc
482479
cfg(),
483480
sourceQuery,
484481
genField,
485-
options,
486482
createCallSummaries(sourceQuery, forwardCallSummaries),
487483
createFieldSummaries(sourceQuery, forwardFieldSummaries),
488-
dataFlowscope,
489-
options.getForwardFlowFunction(),
490-
callGraph.getFieldLoadStatements(),
491-
callGraph.getFieldStoreStatements(),
484+
frameworkScope,
485+
options,
492486
sourceQuery.getType()) {
493487

494488
@Override
@@ -990,10 +984,7 @@ public ForwardBoomerangResults<W> solve(ForwardQuery query) {
990984
this.queryToSolvers,
991985
getStats(),
992986
analysisWatch,
993-
visitedMethods,
994-
options.trackDataFlowPath(),
995-
options.prunePathConditions(),
996-
options.trackImplicitFlows());
987+
visitedMethods);
997988
}
998989

999990
public BackwardBoomerangResults<W> solve(BackwardQuery query) {
@@ -1103,10 +1094,7 @@ public ForwardBoomerangResults<W> solveUnderScope(
11031094
this.queryToSolvers,
11041095
getStats(),
11051096
analysisWatch,
1106-
visitedMethods,
1107-
options.trackDataFlowPath(),
1108-
options.prunePathConditions(),
1109-
options.trackImplicitFlows());
1097+
visitedMethods);
11101098
}
11111099

11121100
public void debugOutput() {

boomerangPDS/src/main/java/boomerang/flowfunction/DefaultBackwardFlowFunction.java

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
package boomerang.flowfunction;
1616

17+
import boomerang.options.IAllocationSite;
1718
import boomerang.scope.ControlFlowGraph.Edge;
1819
import boomerang.scope.Field;
1920
import boomerang.scope.IArrayRef;
@@ -25,9 +26,7 @@
2526
import boomerang.scope.StaticFieldVal;
2627
import boomerang.scope.Val;
2728
import boomerang.scope.fields.ArrayField;
28-
import boomerang.solver.BackwardBoomerangSolver;
2929
import boomerang.solver.Strategies;
30-
import com.google.common.collect.Multimap;
3130
import java.util.Collection;
3231
import java.util.Collections;
3332
import java.util.LinkedHashSet;
@@ -43,10 +42,18 @@
4342

4443
public class DefaultBackwardFlowFunction implements IBackwardFlowFunction {
4544

46-
private final DefaultBackwardFlowFunctionOptions options;
47-
private Strategies strategies;
45+
private final IAllocationSite allocationSite;
46+
private final Strategies strategies;
47+
private final FlowFunctionOptions options;
4848

49-
public DefaultBackwardFlowFunction(DefaultBackwardFlowFunctionOptions options) {
49+
public DefaultBackwardFlowFunction(IAllocationSite allocationSite, Strategies strategies) {
50+
this(allocationSite, strategies, FlowFunctionOptions.DEFAULT());
51+
}
52+
53+
public DefaultBackwardFlowFunction(
54+
IAllocationSite allocationSite, Strategies strategies, FlowFunctionOptions options) {
55+
this.allocationSite = allocationSite;
56+
this.strategies = strategies;
5057
this.options = options;
5158
}
5259

@@ -105,10 +112,7 @@ public Collection<Val> callFlow(Statement callSite, Val fact, Method callee, Sta
105112
@Override
106113
public Collection<State> normalFlow(Edge currEdge, Edge nextEdge, Val fact) {
107114
Statement nextStmt = nextEdge.getTarget();
108-
if (options
109-
.allocationSite()
110-
.getAllocationSite(nextStmt.getMethod(), nextStmt, fact)
111-
.isPresent()) {
115+
if (allocationSite.getAllocationSite(nextStmt.getMethod(), nextStmt, fact).isPresent()) {
112116
return Collections.emptySet();
113117
}
114118
if (nextStmt.isThrowStmt()) {
@@ -193,20 +197,6 @@ public Collection<State> callToReturnFlow(Edge currEdge, Edge nextEdge, Val fact
193197
return normalFlow(currEdge, nextEdge, fact);
194198
}
195199

196-
@Override
197-
public void setSolver(
198-
BackwardBoomerangSolver<?> solver,
199-
Multimap<Field, Statement> fieldLoadStatements,
200-
Multimap<Field, Statement> fieldStoreStatements) {
201-
this.strategies =
202-
new Strategies(
203-
options.staticFieldStrategy(),
204-
options.arrayStrategy(),
205-
solver,
206-
fieldLoadStatements,
207-
fieldStoreStatements);
208-
}
209-
210200
protected Collection<State> systemArrayCopyFlow(Edge edge, Val fact) {
211201
Statement callSite = edge.getTarget();
212202
if (fact.equals(callSite.getInvokeExpr().getArg(2))) {

boomerangPDS/src/main/java/boomerang/flowfunction/DefaultBackwardFlowFunctionOptions.java

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)