From 746c25599f75088c3b4d02fe51e4240b0079781c Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 11 Apr 2016 08:17:18 -0500 Subject: Clang-format ``ConstructSolverChain.cpp`` --- lib/Basic/ConstructSolverChain.cpp | 98 ++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 56 deletions(-) diff --git a/lib/Basic/ConstructSolverChain.cpp b/lib/Basic/ConstructSolverChain.cpp index 59790551..b48c5cb0 100644 --- a/lib/Basic/ConstructSolverChain.cpp +++ b/lib/Basic/ConstructSolverChain.cpp @@ -1,4 +1,4 @@ -//===-- ConstructSolverChain.cpp ------------------------------------------------*- C++ -*-===// +//===-- ConstructSolverChain.cpp ------------------------------------++ -*-===// // // The KLEE Symbolic Virtual Machine // @@ -14,69 +14,55 @@ #include "klee/CommandLine.h" #include "llvm/Support/raw_ostream.h" -namespace klee -{ - Solver *constructSolverChain(Solver *coreSolver, - std::string querySMT2LogPath, - std::string baseSolverQuerySMT2LogPath, - std::string queryPCLogPath, - std::string baseSolverQueryPCLogPath) - { - Solver *solver = coreSolver; +namespace klee { +Solver *constructSolverChain(Solver *coreSolver, std::string querySMT2LogPath, + std::string baseSolverQuerySMT2LogPath, + std::string queryPCLogPath, + std::string baseSolverQueryPCLogPath) { + Solver *solver = coreSolver; - if (optionIsSet(queryLoggingOptions, SOLVER_PC)) - { - solver = createPCLoggingSolver(solver, - baseSolverQueryPCLogPath, - MinQueryTimeToLog); - llvm::errs() << "Logging queries that reach solver in .pc format to " - << baseSolverQueryPCLogPath.c_str() << "\n"; - } + if (optionIsSet(queryLoggingOptions, SOLVER_PC)) { + solver = createPCLoggingSolver(solver, baseSolverQueryPCLogPath, + MinQueryTimeToLog); + llvm::errs() << "Logging queries that reach solver in .pc format to " + << baseSolverQueryPCLogPath.c_str() << "\n"; + } - if (optionIsSet(queryLoggingOptions, SOLVER_SMTLIB)) - { - solver = createSMTLIBLoggingSolver(solver, - baseSolverQuerySMT2LogPath, - MinQueryTimeToLog); - llvm::errs() << "Logging queries that reach solver in .smt2 format to " - << baseSolverQuerySMT2LogPath.c_str() << "\n"; - } + if (optionIsSet(queryLoggingOptions, SOLVER_SMTLIB)) { + solver = createSMTLIBLoggingSolver(solver, baseSolverQuerySMT2LogPath, + MinQueryTimeToLog); + llvm::errs() << "Logging queries that reach solver in .smt2 format to " + << baseSolverQuerySMT2LogPath.c_str() << "\n"; + } - if (UseFastCexSolver) - solver = createFastCexSolver(solver); + if (UseFastCexSolver) + solver = createFastCexSolver(solver); - if (UseCexCache) - solver = createCexCachingSolver(solver); + if (UseCexCache) + solver = createCexCachingSolver(solver); - if (UseCache) - solver = createCachingSolver(solver); + if (UseCache) + solver = createCachingSolver(solver); - if (UseIndependentSolver) - solver = createIndependentSolver(solver); + if (UseIndependentSolver) + solver = createIndependentSolver(solver); - if (DebugValidateSolver) - solver = createValidatingSolver(solver, coreSolver); + if (DebugValidateSolver) + solver = createValidatingSolver(solver, coreSolver); - if (optionIsSet(queryLoggingOptions, ALL_PC)) - { - solver = createPCLoggingSolver(solver, - queryPCLogPath, - MinQueryTimeToLog); - llvm::errs() << "Logging all queries in .pc format to " - << queryPCLogPath.c_str() << "\n"; - } + if (optionIsSet(queryLoggingOptions, ALL_PC)) { + solver = createPCLoggingSolver(solver, queryPCLogPath, MinQueryTimeToLog); + llvm::errs() << "Logging all queries in .pc format to " + << queryPCLogPath.c_str() << "\n"; + } - if (optionIsSet(queryLoggingOptions, ALL_SMTLIB)) - { - solver = createSMTLIBLoggingSolver(solver,querySMT2LogPath, - MinQueryTimeToLog); - llvm::errs() << "Logging all queries in .smt2 format to " - << querySMT2LogPath.c_str() << "\n"; - } - - return solver; - } + if (optionIsSet(queryLoggingOptions, ALL_SMTLIB)) { + solver = + createSMTLIBLoggingSolver(solver, querySMT2LogPath, MinQueryTimeToLog); + llvm::errs() << "Logging all queries in .smt2 format to " + << querySMT2LogPath.c_str() << "\n"; + } + return solver; +} } - - -- cgit 1.4.1 From d34a946acb7f5155ee62f1bdc95ae7ef7b848e49 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 11 Apr 2016 08:19:02 -0500 Subject: Add ``-debug-cross-check-core-solver`` option to allow cross-checking with another solver. For example the core solver can be STP and the cross checking solver can be Z3. Unfortunately a few fragile tests don't pass when actually using this option. --- include/klee/CommandLine.h | 10 +++++++++- lib/Basic/CmdLineOptions.cpp | 13 +++++++++++++ lib/Basic/ConstructSolverChain.cpp | 4 ++++ lib/Solver/CoreSolver.cpp | 4 ++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/klee/CommandLine.h b/include/klee/CommandLine.h index 00cdeebb..dc69de6e 100644 --- a/include/klee/CommandLine.h +++ b/include/klee/CommandLine.h @@ -44,9 +44,17 @@ enum QueryLoggingSolverType */ extern llvm::cl::list queryLoggingOptions; -enum CoreSolverType { STP_SOLVER, METASMT_SOLVER, DUMMY_SOLVER, Z3_SOLVER }; +enum CoreSolverType { + STP_SOLVER, + METASMT_SOLVER, + DUMMY_SOLVER, + Z3_SOLVER, + NO_SOLVER +}; extern llvm::cl::opt CoreSolverToUse; +extern llvm::cl::opt DebugCrossCheckCoreSolverWith; + #ifdef ENABLE_METASMT enum MetaSMTBackendType diff --git a/lib/Basic/CmdLineOptions.cpp b/lib/Basic/CmdLineOptions.cpp index 20c190a5..70ef999e 100644 --- a/lib/Basic/CmdLineOptions.cpp +++ b/lib/Basic/CmdLineOptions.cpp @@ -139,6 +139,19 @@ llvm::cl::opt CoreSolverToUse( clEnumValN(Z3_SOLVER, "z3", "Z3" Z3_IS_DEFAULT_STR), clEnumValEnd), llvm::cl::init(DEFAULT_CORE_SOLVER)); + +llvm::cl::opt DebugCrossCheckCoreSolverWith( + "debug-cross-check-core-solver", + llvm::cl::desc( + "Specifiy a solver to use for cross checking with the core solver"), + llvm::cl::values(clEnumValN(STP_SOLVER, "stp", "stp"), + clEnumValN(METASMT_SOLVER, "metasmt", "metaSMT"), + clEnumValN(DUMMY_SOLVER, "dummy", "Dummy solver"), + clEnumValN(Z3_SOLVER, "z3", "Z3"), + clEnumValN(NO_SOLVER, "none", + "Do not cross check (default)"), + clEnumValEnd), + llvm::cl::init(NO_SOLVER)); } #undef STP_IS_DEFAULT_STR #undef METASMT_IS_DEFAULT_STR diff --git a/lib/Basic/ConstructSolverChain.cpp b/lib/Basic/ConstructSolverChain.cpp index b48c5cb0..2df87d51 100644 --- a/lib/Basic/ConstructSolverChain.cpp +++ b/lib/Basic/ConstructSolverChain.cpp @@ -62,6 +62,10 @@ Solver *constructSolverChain(Solver *coreSolver, std::string querySMT2LogPath, llvm::errs() << "Logging all queries in .smt2 format to " << querySMT2LogPath.c_str() << "\n"; } + if (DebugCrossCheckCoreSolverWith != NO_SOLVER) { + Solver *oracleSolver = createCoreSolver(DebugCrossCheckCoreSolverWith); + solver = createValidatingSolver(/*s=*/solver, /*oracle=*/oracleSolver); + } return solver; } diff --git a/lib/Solver/CoreSolver.cpp b/lib/Solver/CoreSolver.cpp index 66328f30..783047f8 100644 --- a/lib/Solver/CoreSolver.cpp +++ b/lib/Solver/CoreSolver.cpp @@ -83,11 +83,15 @@ Solver *createCoreSolver(CoreSolverType cst) { return createDummySolver(); case Z3_SOLVER: #ifdef ENABLE_Z3 + llvm::errs() << "Using Z3 solver backend\n"; return new Z3Solver(); #else llvm::errs() << "Not compiled with Z3 support\n"; return NULL; #endif + case NO_SOLVER: + llvm::errs() << "Invalid solver\n"; + return NULL; default: llvm_unreachable("Unsupported CoreSolverType"); } -- cgit 1.4.1 From c9778f9278ee0d0ccb845843a35edf66c3fcb2ac Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Sun, 1 May 2016 14:52:56 -0700 Subject: Correct out of date comments for some of the klee error handling functions. --- include/klee/Internal/Support/ErrorHandling.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/klee/Internal/Support/ErrorHandling.h b/include/klee/Internal/Support/ErrorHandling.h index 330985e9..29451692 100644 --- a/include/klee/Internal/Support/ErrorHandling.h +++ b/include/klee/Internal/Support/ErrorHandling.h @@ -23,7 +23,7 @@ namespace klee { extern FILE *klee_warning_file; extern FILE *klee_message_file; -/// Print "KLEE: ERROR" followed by the msg in printf format and a +/// Print "KLEE: ERROR: " followed by the msg in printf format and a /// newline on stderr and to warnings.txt, then exit with an error. void klee_error(const char *msg, ...) __attribute__((format(printf, 1, 2), noreturn)); @@ -37,11 +37,11 @@ void klee_message(const char *msg, ...) __attribute__((format(printf, 1, 2))); void klee_message_to_file(const char *msg, ...) __attribute__((format(printf, 1, 2))); -/// Print "KLEE: WARNING" followed by the msg in printf format and a +/// Print "KLEE: WARNING: " followed by the msg in printf format and a /// newline on stderr and to warnings.txt. void klee_warning(const char *msg, ...) __attribute__((format(printf, 1, 2))); -/// Print "KLEE: WARNING" followed by the msg in printf format and a +/// Print "KLEE: WARNING: " followed by the msg in printf format and a /// newline on stderr and to warnings.txt. However, the warning is only /// printed once for each unique (id, msg) pair (as pointers). void klee_warning_once(const void *id, const char *msg, ...) -- cgit 1.4.1 From 3200fe7b15a89619ee0cf9a31841ef9737c38950 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 15 Sep 2016 13:07:10 +0100 Subject: Rename `-debug-cross-check-core-solver` option to `-debug-crosscheck-core-solver` as requested by Cristian --- lib/Basic/CmdLineOptions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Basic/CmdLineOptions.cpp b/lib/Basic/CmdLineOptions.cpp index 70ef999e..399c27a2 100644 --- a/lib/Basic/CmdLineOptions.cpp +++ b/lib/Basic/CmdLineOptions.cpp @@ -141,7 +141,7 @@ llvm::cl::opt CoreSolverToUse( llvm::cl::init(DEFAULT_CORE_SOLVER)); llvm::cl::opt DebugCrossCheckCoreSolverWith( - "debug-cross-check-core-solver", + "debug-crosscheck-core-solver", llvm::cl::desc( "Specifiy a solver to use for cross checking with the core solver"), llvm::cl::values(clEnumValN(STP_SOLVER, "stp", "stp"), -- cgit 1.4.1