Skip to content

Commit

Permalink
Do not artificially separate message handler and uit
Browse files Browse the repository at this point in the history
They were passed around independently, even though they originated from the very
same object.
  • Loading branch information
tautschnig committed Jun 24, 2018
1 parent d6bdee6 commit 31e6b52
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 69 deletions.
9 changes: 3 additions & 6 deletions jbmc/src/jbmc/jbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,7 @@ int jbmc_parse_optionst::doit()
path_strategy_chooser,
options,
goto_model,
ui_message_handler.get_ui(),
*this,
ui_message_handler,
configure_bmc);
}
else
Expand Down Expand Up @@ -605,8 +604,7 @@ int jbmc_parse_optionst::doit()
path_strategy_chooser,
options,
lazy_goto_model,
ui_message_handler.get_ui(),
*this,
ui_message_handler,
configure_bmc,
callback_after_symex);
}
Expand Down Expand Up @@ -661,8 +659,7 @@ int jbmc_parse_optionst::get_goto_program(
{
class_hierarchyt hierarchy;
hierarchy(lazy_goto_model.symbol_table);
show_class_hierarchy(
hierarchy, get_message_handler(), ui_message_handler.get_ui());
show_class_hierarchy(hierarchy, ui_message_handler);
return CPROVER_EXIT_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/all_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ safety_checkert::resultt bmc_all_propertiest::operator()()

void bmc_all_propertiest::report(const cover_goalst &cover_goals)
{
switch(bmc.ui)
switch(bmc.ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
{
Expand Down
22 changes: 9 additions & 13 deletions src/cbmc/bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void bmct::error_trace()
goto_tracet &goto_trace=safety_checkert::error_trace;
build_goto_trace(equation, prop_conv, ns, goto_trace);

switch(ui)
switch(ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
result() << "Counterexample:" << eom;
Expand Down Expand Up @@ -150,7 +150,7 @@ void bmct::report_success()
{
result() << "VERIFICATION SUCCESSFUL" << eom;

switch(ui)
switch(ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
break;
Expand All @@ -177,7 +177,7 @@ void bmct::report_failure()
{
result() << "VERIFICATION FAILED" << eom;

switch(ui)
switch(ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
break;
Expand Down Expand Up @@ -562,15 +562,14 @@ int bmct::do_language_agnostic_bmc(
const path_strategy_choosert &path_strategy_chooser,
const optionst &opts,
abstract_goto_modelt &model,
const ui_message_handlert::uit &ui,
messaget &message,
ui_message_handlert &ui,
std::function<void(bmct &, const symbol_tablet &)> driver_configure_bmc,
std::function<bool(void)> callback_after_symex)
{
safety_checkert::resultt final_result = safety_checkert::resultt::UNKNOWN;
safety_checkert::resultt tmp_result = safety_checkert::resultt::UNKNOWN;
const symbol_tablet &symbol_table = model.get_symbol_table();
message_handlert &mh = message.get_message_handler();
messaget message(ui);
std::unique_ptr<path_storaget> worklist;
std::string strategy = opts.get_option("exploration-strategy");
INVARIANT(
Expand All @@ -580,13 +579,11 @@ int bmct::do_language_agnostic_bmc(
try
{
{
cbmc_solverst solvers(opts, symbol_table, message.get_message_handler());
solvers.set_ui(ui);
cbmc_solverst solvers(opts, symbol_table, ui);
std::unique_ptr<cbmc_solverst::solvert> cbmc_solver;
cbmc_solver = solvers.get_solver();
prop_convt &pc = cbmc_solver->prop_conv();
bmct bmc(opts, symbol_table, mh, pc, *worklist, callback_after_symex);
bmc.set_ui(ui);
bmct bmc(opts, symbol_table, ui, pc, *worklist, callback_after_symex);
if(driver_configure_bmc)
driver_configure_bmc(bmc, symbol_table);
tmp_result = bmc.run(model);
Expand Down Expand Up @@ -621,16 +618,15 @@ int bmct::do_language_agnostic_bmc(
<< "Starting new path (" << worklist->size()
<< " to go)\n"
<< message.eom;
cbmc_solverst solvers(opts, symbol_table, message.get_message_handler());
solvers.set_ui(ui);
cbmc_solverst solvers(opts, symbol_table, ui);
std::unique_ptr<cbmc_solverst::solvert> cbmc_solver;
cbmc_solver = solvers.get_solver();
prop_convt &pc = cbmc_solver->prop_conv();
path_storaget::patht &resume = worklist->peek();
path_explorert pe(
opts,
symbol_table,
mh,
ui,
pc,
resume.equation,
resume.state,
Expand Down
17 changes: 7 additions & 10 deletions src/cbmc/bmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class bmct:public safety_checkert
bmct(
const optionst &_options,
const symbol_tablet &outer_symbol_table,
message_handlert &_message_handler,
ui_message_handlert &_message_handler,
prop_convt &_prop_conv,
path_storaget &_path_storage,
std::function<bool(void)> callback_after_symex)
Expand All @@ -83,7 +83,7 @@ class bmct:public safety_checkert
options,
path_storage),
prop_conv(_prop_conv),
ui(ui_message_handlert::uit::PLAIN),
ui_message_handler(_message_handler),
driver_callback_after_symex(callback_after_symex)
{
symex.constant_propagation=options.get_bool_option("propagation");
Expand All @@ -103,8 +103,6 @@ class bmct:public safety_checkert
safety_checkert::resultt execute(abstract_goto_modelt &);
virtual ~bmct() { }

void set_ui(ui_message_handlert::uit _ui) { ui=_ui; }

// the safety_checkert interface
virtual resultt operator()(
const goto_functionst &goto_functions)
Expand All @@ -127,8 +125,7 @@ class bmct:public safety_checkert
const path_strategy_choosert &path_strategy_chooser,
const optionst &opts,
abstract_goto_modelt &goto_model,
const ui_message_handlert::uit &ui,
messaget &message,
ui_message_handlert &ui,
std::function<void(bmct &, const symbol_tablet &)>
driver_configure_bmc = nullptr,
std::function<bool(void)> callback_after_symex = nullptr);
Expand All @@ -144,7 +141,7 @@ class bmct:public safety_checkert
bmct(
const optionst &_options,
const symbol_tablet &outer_symbol_table,
message_handlert &_message_handler,
ui_message_handlert &_message_handler,
prop_convt &_prop_conv,
symex_target_equationt &_equation,
path_storaget &_path_storage,
Expand All @@ -162,7 +159,7 @@ class bmct:public safety_checkert
options,
path_storage),
prop_conv(_prop_conv),
ui(ui_message_handlert::uit::PLAIN),
ui_message_handler(_message_handler),
driver_callback_after_symex(callback_after_symex)
{
symex.constant_propagation = options.get_bool_option("propagation");
Expand All @@ -186,7 +183,7 @@ class bmct:public safety_checkert
prop_convt &prop_conv;
std::unique_ptr<memory_model_baset> memory_model;
// use gui format
ui_message_handlert::uit ui;
ui_message_handlert &ui_message_handler;

virtual decision_proceduret::resultt
run_decision_procedure(prop_convt &prop_conv);
Expand Down Expand Up @@ -266,7 +263,7 @@ class path_explorert : public bmct
path_explorert(
const optionst &_options,
const symbol_tablet &outer_symbol_table,
message_handlert &_message_handler,
ui_message_handlert &_message_handler,
prop_convt &_prop_conv,
symex_target_equationt &saved_equation,
const goto_symex_statet &saved_state,
Expand Down
4 changes: 2 additions & 2 deletions src/cbmc/bmc_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ bool bmc_covert::operator()()
if(g.second.satisfied)
goals_covered++;

switch(bmc.ui)
switch(bmc.ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
{
Expand Down Expand Up @@ -412,7 +412,7 @@ bool bmc_covert::operator()()
<< (cover_goals.iterations()==1?"":"s")
<< eom;

if(bmc.ui==ui_message_handlert::uit::PLAIN)
if(bmc.ui_message_handler.get_ui() == ui_message_handlert::uit::PLAIN)
{
result() << "Test suite:" << '\n';

Expand Down
3 changes: 1 addition & 2 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,7 @@ int cbmc_parse_optionst::doit()
path_strategy_chooser,
options,
goto_model,
ui_message_handler.get_ui(),
*this);
ui_message_handler);
}

bool cbmc_parse_optionst::set_properties()
Expand Down
27 changes: 15 additions & 12 deletions src/cbmc/cbmc_solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_default()
solver->set_prop(util_make_unique<satcheckt>());
}

solver->prop().set_message_handler(get_message_handler());
solver->prop().set_message_handler(ui);

auto bv_cbmc=util_make_unique<bv_cbmct>(ns, solver->prop());

Expand All @@ -90,7 +90,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_dimacs()
no_incremental_check();

auto prop=util_make_unique<dimacs_cnft>();
prop->set_message_handler(get_message_handler());
prop->set_message_handler(ui);

std::string filename=options.get_option("outfile");

Expand All @@ -111,12 +111,12 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_bv_refinement()
return util_make_unique<satcheck_no_simplifiert>();
}();

prop->set_message_handler(get_message_handler());
prop->set_message_handler(ui);

bv_refinementt::infot info;
info.ns=&ns;
info.prop=prop.get();
info.ui=ui;
info.ui=ui.get_ui();

// we allow setting some parameters
if(options.get_bool_option("max-node-refinement"))
Expand All @@ -139,10 +139,10 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_string_refinement()
string_refinementt::infot info;
info.ns=&ns;
auto prop=util_make_unique<satcheck_no_simplifiert>();
prop->set_message_handler(get_message_handler());
prop->set_message_handler(ui);
info.prop=prop.get();
info.refinement_bound=DEFAULT_MAX_NB_REFINEMENT;
info.ui=ui;
info.ui=ui.get_ui();
if(options.get_bool_option("string-max-length"))
info.max_string_length = options.get_signed_int_option("string-max-length");
info.trace=options.get_bool_option("trace");
Expand All @@ -159,6 +159,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_string_refinement()
std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
smt2_dect::solvert solver)
{
messaget msg(ui);
no_beautification();

const std::string &filename=options.get_option("outfile");
Expand All @@ -167,7 +168,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
{
if(solver==smt2_dect::solvert::GENERIC)
{
error() << "please use --outfile" << eom;
msg.error() << "please use --outfile" << messaget::eom;
throw 0;
}

Expand Down Expand Up @@ -198,7 +199,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
if(options.get_bool_option("fpa"))
smt2_conv->use_FPA_theory=true;

smt2_conv->set_message_handler(get_message_handler());
smt2_conv->set_message_handler(ui);

return util_make_unique<solvert>(std::move(smt2_conv));
}
Expand All @@ -212,7 +213,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(

if(!*out)
{
error() << "failed to open " << filename << eom;
msg.error() << "failed to open " << filename << messaget::eom;
throw 0;
}

Expand All @@ -228,7 +229,7 @@ std::unique_ptr<cbmc_solverst::solvert> cbmc_solverst::get_smt2(
if(options.get_bool_option("fpa"))
smt2_conv->use_FPA_theory=true;

smt2_conv->set_message_handler(get_message_handler());
smt2_conv->set_message_handler(ui);

return util_make_unique<solvert>(std::move(smt2_conv), std::move(out));
}
Expand All @@ -238,7 +239,8 @@ void cbmc_solverst::no_beautification()
{
if(options.get_bool_option("beautify"))
{
error() << "sorry, this solver does not support beautification" << eom;
messaget(ui).error() << "sorry, this solver does not support beautification"
<< messaget::eom;
throw 0;
}
}
Expand All @@ -249,7 +251,8 @@ void cbmc_solverst::no_incremental_check()
options.get_option("cover")!="" ||
options.get_option("incremental-check")!="")
{
error() << "sorry, this solver does not support incremental solving" << eom;
messaget(ui).error() << "sorry, this solver does not support incremental "
<< "solving" << messaget::eom;
throw 0;
}
}
13 changes: 4 additions & 9 deletions src/cbmc/cbmc_solvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ Author: Daniel Kroening, [email protected]

#include "bv_cbmc.h"

class cbmc_solverst:public messaget
class cbmc_solverst
{
public:
cbmc_solverst(
const optionst &_options,
const symbol_tablet &_symbol_table,
message_handlert &_message_handler):
messaget(_message_handler),
ui_message_handlert &_message_handler):
options(_options),
symbol_table(_symbol_table),
ns(_symbol_table),
ui(ui_message_handlert::uit::PLAIN)
ui(_message_handler)
{
}

Expand Down Expand Up @@ -120,15 +119,11 @@ class cbmc_solverst:public messaget
{
}

void set_ui(ui_message_handlert::uit _ui) { ui=_ui; }

protected:
const optionst &options;
const symbol_tablet &symbol_table;
namespacet ns;

// use gui format
ui_message_handlert::uit ui;
ui_message_handlert &ui;

std::unique_ptr<solvert> get_default();
std::unique_ptr<solvert> get_dimacs();
Expand Down
4 changes: 2 additions & 2 deletions src/cbmc/fault_localization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ safety_checkert::resultt fault_localizationt::stop_on_fail()
// localize faults
run(ID_nil);

switch(bmc.ui)
switch(bmc.ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
{
Expand Down Expand Up @@ -356,7 +356,7 @@ void fault_localizationt::report(
{
bmc_all_propertiest::report(cover_goals);

switch(bmc.ui)
switch(bmc.ui_message_handler.get_ui())
{
case ui_message_handlert::uit::PLAIN:
if(cover_goals.number_covered()>0)
Expand Down
2 changes: 1 addition & 1 deletion src/cbmc/show_vcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void bmct::show_vcc()

std::ostream &out=have_file?of:std::cout;

switch(ui)
switch(ui_message_handler.get_ui())
{
case ui_message_handlert::uit::XML_UI:
error() << "XML UI not supported" << eom;
Expand Down
Loading

0 comments on commit 31e6b52

Please sign in to comment.