aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2020-12-22 18:39:46 +0000
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2021-04-20 11:42:23 +0100
commit88893697f6630f0d281d21be6362489e616bca2f (patch)
tree64bbfa3d5e53c266cf99dceda04ff0ed8359e45e /lib
parent536f363587956ef1e59ecce4c932262ef57ff371 (diff)
downloadklee-88893697f6630f0d281d21be6362489e616bca2f.tar.gz
Refactored MaxStatis*Pct conditions into a separate function.
Diffstat (limited to 'lib')
-rw-r--r--lib/Core/Executor.cpp66
-rw-r--r--lib/Core/Executor.h4
2 files changed, 43 insertions, 27 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index bf359c2d..cea7f173 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -962,6 +962,43 @@ void Executor::branch(ExecutionState &state,
addConstraint(*result[i], conditions[i]);
}
+ref<Expr> Executor::maxStaticPctChecks(ExecutionState &current,
+ ref<Expr> condition) {
+ if (isa<klee::ConstantExpr>(condition))
+ return condition;
+
+ if (MaxStaticForkPct == 1. && MaxStaticSolvePct == 1. &&
+ MaxStaticCPForkPct == 1. && MaxStaticCPSolvePct == 1.)
+ return condition;
+
+ if (statsTracker->elapsed() <= time::seconds(60))
+ return condition;
+
+ StatisticManager &sm = *theStatisticManager;
+ CallPathNode *cpn = current.stack.back().callPathNode;
+ if ((MaxStaticForkPct < 1. &&
+ sm.getIndexedValue(stats::forks, sm.getIndex()) >
+ stats::forks * MaxStaticForkPct) ||
+ (MaxStaticCPForkPct < 1. && cpn &&
+ (cpn->statistics.getValue(stats::forks) >
+ stats::forks * MaxStaticCPForkPct)) ||
+ (MaxStaticSolvePct < 1 &&
+ sm.getIndexedValue(stats::solverTime, sm.getIndex()) >
+ stats::solverTime * MaxStaticSolvePct) ||
+ (MaxStaticCPForkPct < 1. && cpn &&
+ (cpn->statistics.getValue(stats::solverTime) >
+ stats::solverTime * MaxStaticCPSolvePct))) {
+ ref<klee::ConstantExpr> value;
+ bool success = solver->getValue(current.constraints, condition, value,
+ current.queryMetaData);
+ assert(success && "FIXME: Unhandled solver failure");
+ (void)success;
+ addConstraint(current, EqExpr::create(value, condition));
+ condition = value;
+ }
+ return condition;
+}
+
Executor::StatePair
Executor::fork(ExecutionState &current, ref<Expr> condition, bool isInternal) {
Solver::Validity res;
@@ -969,33 +1006,8 @@ Executor::fork(ExecutionState &current, ref<Expr> condition, bool isInternal) {
seedMap.find(&current);
bool isSeeding = it != seedMap.end();
- if (!isSeeding && !isa<ConstantExpr>(condition) &&
- (MaxStaticForkPct!=1. || MaxStaticSolvePct != 1. ||
- MaxStaticCPForkPct!=1. || MaxStaticCPSolvePct != 1.) &&
- statsTracker->elapsed() > time::seconds(60)) {
- StatisticManager &sm = *theStatisticManager;
- CallPathNode *cpn = current.stack.back().callPathNode;
- if ((MaxStaticForkPct<1. &&
- sm.getIndexedValue(stats::forks, sm.getIndex()) >
- stats::forks*MaxStaticForkPct) ||
- (MaxStaticCPForkPct<1. &&
- cpn && (cpn->statistics.getValue(stats::forks) >
- stats::forks*MaxStaticCPForkPct)) ||
- (MaxStaticSolvePct<1 &&
- sm.getIndexedValue(stats::solverTime, sm.getIndex()) >
- stats::solverTime*MaxStaticSolvePct) ||
- (MaxStaticCPForkPct<1. &&
- cpn && (cpn->statistics.getValue(stats::solverTime) >
- stats::solverTime*MaxStaticCPSolvePct))) {
- ref<ConstantExpr> value;
- bool success = solver->getValue(current.constraints, condition, value,
- current.queryMetaData);
- assert(success && "FIXME: Unhandled solver failure");
- (void) success;
- addConstraint(current, EqExpr::create(value, condition));
- condition = value;
- }
- }
+ if (!isSeeding)
+ condition = maxStaticPctChecks(current, condition);
time::Span timeout = coreSolverTimeout;
if (isSeeding)
diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h
index eb3417ae..ae960731 100644
--- a/lib/Core/Executor.h
+++ b/lib/Core/Executor.h
@@ -355,6 +355,10 @@ private:
// current state, and one of the states may be null.
StatePair fork(ExecutionState &current, ref<Expr> condition, bool isInternal);
+ // If the MaxStatic*Pct limits have been reached, concretize the condition and
+ // return it. Otherwise, return the unmodified condition.
+ ref<Expr> maxStaticPctChecks(ExecutionState &current, ref<Expr> condition);
+
/// Add the given (boolean) condition as a constraint on state. This
/// function is a wrapper around the state's addConstraint function
/// which also manages propagation of implied values,