Skip to content

Commit 3e9b4a8

Browse files
committed
Add debug logging of commands sent to SMT2 solver
So that we can see the text sent to the solver when debugging and so that the text can be checked in regression tests. The commands are shown as debug output messages rather than written to file because a file based approach is not well suited to incremental solving.
1 parent aad1bf5 commit 3e9b4a8

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

src/goto-checker/solver_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ solver_factoryt::get_incremental_smt2(std::string solver_command)
333333

334334
return util_make_unique<solvert>(
335335
util_make_unique<smt2_incremental_decision_proceduret>(
336-
std::move(solver_command)));
336+
std::move(solver_command), message_handler));
337337
}
338338

339339
std::unique_ptr<solver_factoryt::solvert>

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
#include <util/string_utils.h>
99

1010
smt2_incremental_decision_proceduret::smt2_incremental_decision_proceduret(
11-
std::string _solver_command)
12-
: solver_command{std::move(_solver_command)},
11+
std::string _solver_command,
12+
message_handlert &message_handler)
13+
: solver_command(std::move(_solver_command)),
1314
number_of_solver_calls{0},
14-
solver_process{split_string(solver_command, ' ', false, true)}
15+
solver_process{split_string(solver_command, ' ', false, true)},
16+
log{message_handler}
1517
{
1618
send_to_solver(smt_set_option_commandt{smt_option_produce_modelst{true}});
1719
send_to_solver(smt_set_logic_commandt{
@@ -83,5 +85,8 @@ decision_proceduret::resultt smt2_incremental_decision_proceduret::dec_solve()
8385
void smt2_incremental_decision_proceduret::send_to_solver(
8486
const smt_commandt &command)
8587
{
86-
solver_process.send(smt_to_smt2_string(command) + "\n");
88+
const std::string command_string = smt_to_smt2_string(command);
89+
log.debug() << "Sending command to SMT2 solver - " << command_string
90+
<< messaget::eom;
91+
solver_process.send(command_string + "\n");
8792
}

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@
77
#define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT2_INCREMENTAL_DECISION_PROCEDURE_H
88

99
#include <solvers/stack_decision_procedure.h>
10+
#include <util/message.h>
1011
#include <util/piped_process.h>
1112

1213
class smt_commandt;
14+
class message_handlert;
1315

1416
class smt2_incremental_decision_proceduret final
1517
: public stack_decision_proceduret
1618
{
1719
public:
18-
/// \param solver_command: The command and arguments for invoking the smt2
19-
/// solver.
20-
explicit smt2_incremental_decision_proceduret(std::string solver_command);
20+
/// \param solver_command:
21+
/// The command and arguments for invoking the smt2 solver.
22+
/// \param message_handler:
23+
/// The messaging system to be used for logging purposes.
24+
explicit smt2_incremental_decision_proceduret(
25+
std::string solver_command,
26+
message_handlert &message_handler);
2127

2228
// Implementation of public decision_proceduret member functions.
2329
exprt handle(const exprt &expr) override;
@@ -44,6 +50,7 @@ class smt2_incremental_decision_proceduret final
4450
size_t number_of_solver_calls;
4551

4652
piped_processt solver_process;
53+
messaget log;
4754
};
4855

4956
#endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT2_INCREMENTAL_DECISION_PROCEDURE_H

0 commit comments

Comments
 (0)