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); klee_message("Logging queries that reach solver in .pc format to %s\n", baseSolverQueryPCLogPath.c_str()); } if (optionIsSet(queryLoggingOptions, SOLVER_SMTLIB)) { solver = createSMTLIBLoggingSolver(solver, baseSolverQuerySMT2LogPath, MinQueryTimeToLog); klee_message("Logging queries that reach solver in .smt2 format to %s\n", baseSolverQuerySMT2LogPath.c_str()); } if (UseFastCexSolver) solver = createFastCexSolver(solver); if (UseCexCache) solver = createCexCachingSolver(solver); if (UseCache) solver = createCachingSolver(solver); if (UseIndependentSolver) solver = createIndependentSolver(solver); if (DebugValidateSolver) solver = createValidatingSolver(solver, coreSolver); if (optionIsSet(queryLoggingOptions, ALL_PC)) { solver = createPCLoggingSolver(solver, queryPCLogPath, MinQueryTimeToLog); klee_message("Logging all queries in .pc format to %s\n", queryPCLogPath.c_str()); } if (optionIsSet(queryLoggingOptions, ALL_SMTLIB)) { solver = createSMTLIBLoggingSolver(solver, querySMT2LogPath, MinQueryTimeToLog); klee_message("Logging all queries in .smt2 format to %s\n", querySMT2LogPath.c_str()); } if (DebugCrossCheckCoreSolverWith != NO_SOLVER) { Solver *oracleSolver = createCoreSolver(DebugCrossCheckCoreSolverWith); solver = createValidatingSolver(/*s=*/solver, /*oracle=*/oracleSolver); } return solver; }
Z3SolverImpl::Z3SolverImpl() : builder(new Z3Builder( /*autoClearConstructCache=*/false, /*z3LogInteractionFileArg=*/Z3LogInteractionFile.size() > 0 ? Z3LogInteractionFile.c_str() : NULL)), timeout(0.0), runStatusCode(SOLVER_RUN_STATUS_FAILURE), dumpedQueriesFile(0) { assert(builder && "unable to create Z3Builder"); solverParameters = Z3_mk_params(builder->ctx); Z3_params_inc_ref(builder->ctx, solverParameters); timeoutParamStrSymbol = Z3_mk_string_symbol(builder->ctx, "timeout"); setCoreSolverTimeout(timeout); if (!Z3QueryDumpFile.empty()) { std::string error; dumpedQueriesFile = klee_open_output_file(Z3QueryDumpFile, error); if (!error.empty()) { klee_error("Error creating file for dumping Z3 queries: %s", error.c_str()); } klee_message("Dumping Z3 queries to \"%s\"", Z3QueryDumpFile.c_str()); } // Set verbosity if (Z3VerbosityLevel > 0) { std::string underlyingString; llvm::raw_string_ostream ss(underlyingString); ss << Z3VerbosityLevel; ss.flush(); Z3_global_param_set("verbose", underlyingString.c_str()); } }