aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2018-11-02 14:48:35 +0000
committerMartinNowack <martin.nowack@gmail.com>2018-11-02 16:39:47 +0000
commitf621d52fb1d58efa061e18d1e356c2cd7c4fa8ea (patch)
tree73e39105d55695a400519fa035eba75fa5b4d930 /lib/Core
parent534d28787c486470aa141468ceceb0fe9baf2991 (diff)
downloadklee-f621d52fb1d58efa061e18d1e356c2cd7c4fa8ea.tar.gz
Replaced --no-externals and --allow-external-sym-calls with --external-calls, updated tests accordingly, and improved documentation on external calls
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Executor.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index ddf11929..099123cd 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -103,11 +103,6 @@ namespace {
cl::init(true),
cl::desc("Dump test cases for all active states on exit (default=on)"));
- cl::opt<bool>
- AllowExternalSymCalls("allow-external-sym-calls",
- cl::init(false),
- cl::desc("Allow calls with symbolic arguments to external functions. This concretizes the symbolic arguments. (default=off)"));
-
/// The different query logging solvers that can switched on/off
enum PrintDebugInstructionsType {
STDERR_ALL, ///
@@ -185,10 +180,21 @@ namespace {
cl::init(false),
cl::desc("Generate tests cases for all errors "
"(default=off, i.e. one per (error,instruction) pair)"));
-
- cl::opt<bool>
- NoExternals("no-externals",
- cl::desc("Do not allow external function calls (default=off)"));
+
+ enum class ExternalCallPolicy {
+ None, // No external calls allowed
+ Concrete, // Only external calls with concrete arguments allowed
+ All, // All external calls allowed
+ };
+
+ cl::opt<ExternalCallPolicy>
+ ExternalCalls("external-calls",
+ cl::desc("Specify the external call policy"),
+ cl::values(clEnumValN(ExternalCallPolicy::None, "none", "No external function calls are allowed. Note that KLEE always allows some external calls with concrete arguments to go through (in particular printf and puts), regardless of this option."),
+ clEnumValN(ExternalCallPolicy::Concrete, "concrete", "Only external function calls with concrete arguments are allowed (default)"),
+ clEnumValN(ExternalCallPolicy::All, "all", "All external function calls are allowed. This concretizes any symbolic arguments in calls to external functions.")
+ KLEE_LLVM_CL_VAL_END),
+ cl::init(ExternalCallPolicy::Concrete));
cl::opt<bool>
AlwaysOutputSeeds("always-output-seeds",
@@ -3099,10 +3105,11 @@ void Executor::callExternalFunction(ExecutionState &state,
if (specialFunctionHandler->handle(state, function, target, arguments))
return;
- if (NoExternals && !okExternals.count(function->getName())) {
+ if (ExternalCalls == ExternalCallPolicy::None
+ && !okExternals.count(function->getName())) {
klee_warning("Disallowed call to external function: %s\n",
function->getName().str().c_str());
- terminateStateOnError(state, "externals disallowed", User);
+ terminateStateOnError(state, "external calls disallowed", User);
return;
}
@@ -3115,7 +3122,7 @@ void Executor::callExternalFunction(ExecutionState &state,
unsigned wordIndex = 2;
for (std::vector<ref<Expr> >::iterator ai = arguments.begin(),
ae = arguments.end(); ai!=ae; ++ai) {
- if (AllowExternalSymCalls) { // don't bother checking uniqueness
+ if (ExternalCalls == ExternalCallPolicy::All) { // don't bother checking uniqueness
*ai = optimizer.optimizeExpr(*ai, true);
ref<ConstantExpr> ce;
bool success = solver->getValue(state, *ai, ce);