Skip to content

Commit 7f2aaf9

Browse files
Factor out perform_symex into bmc_util
1 parent 26c9617 commit 7f2aaf9

5 files changed

+77
-36
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,54 @@ void output_coverage_report(
292292
<< "'" << messaget::eom;
293293
}
294294
}
295+
296+
static void postprocess_equation(
297+
symex_bmct &symex,
298+
symex_target_equationt &equation,
299+
const optionst &options,
300+
const namespacet &ns,
301+
ui_message_handlert &ui_message_handler)
302+
{
303+
304+
// add a partial ordering, if required
305+
// We won't be able to decide any properties by adding this,
306+
// but we'd like to see the entire SSA.
307+
if(equation.has_threads())
308+
{
309+
std::unique_ptr<memory_model_baset> memory_model =
310+
get_memory_model(options, ns);
311+
memory_model->set_message_handler(ui_message_handler);
312+
(*memory_model)(equation);
313+
}
314+
315+
messaget log(ui_message_handler);
316+
log.statistics() << "size of program expression: "
317+
<< equation.SSA_steps.size() << " steps" << messaget::eom;
318+
319+
slice(symex, equation, ns, options, ui_message_handler);
320+
321+
if(options.get_bool_option("validate-ssa-equation"))
322+
{
323+
symex.validate(validation_modet::INVARIANT);
324+
}
325+
}
326+
327+
void perform_symex(
328+
abstract_goto_modelt &goto_model,
329+
symex_bmct &symex,
330+
symbol_tablet &symex_symbol_table,
331+
symex_target_equationt &equation,
332+
const optionst &options,
333+
const namespacet &ns,
334+
ui_message_handlert &ui_message_handler)
335+
{
336+
auto get_goto_function =
337+
[&goto_model](const irep_idt &id) -> const goto_functionst::goto_functiont & {
338+
return goto_model.get_goto_function(id);
339+
};
340+
341+
// perform symbolic execution
342+
symex.symex_from_entry_point_of(get_goto_function, symex_symbol_table);
343+
344+
postprocess_equation(symex, equation, options, ns, ui_message_handler);
345+
}

src/goto-checker/bmc_util.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ void slice(
6969
const optionst &,
7070
ui_message_handlert &);
7171

72+
/// Perform symbolic execution from the entry point
73+
void perform_symex(
74+
abstract_goto_modelt &,
75+
symex_bmct &,
76+
symbol_tablet &,
77+
symex_target_equationt &,
78+
const optionst &,
79+
const namespacet &,
80+
ui_message_handlert &);
81+
7282
void output_coverage_report(
7383
const std::string &cov_out,
7484
const abstract_goto_modelt &goto_model,

src/goto-checker/multi_path_symex_checker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ operator()(propertiest &properties)
3939

4040
if(!symex_has_run)
4141
{
42-
perform_symex();
42+
perform_symex(
43+
goto_model,
44+
symex,
45+
symex_symbol_table,
46+
equation,
47+
options,
48+
ns,
49+
ui_message_handler);
4350

4451
output_coverage_report(
4552
options.get_option("symex-coverage-report"),

src/goto-checker/multi_path_symex_only_checker.cpp

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ multi_path_symex_only_checkert::multi_path_symex_only_checkert(
3939
incremental_goto_checkert::resultt multi_path_symex_only_checkert::
4040
operator()(propertiest &properties)
4141
{
42-
perform_symex();
42+
perform_symex(
43+
goto_model,
44+
symex,
45+
symex_symbol_table,
46+
equation,
47+
options,
48+
ns,
49+
ui_message_handler);
4350

4451
output_coverage_report(
4552
options.get_option("symex-coverage-report"),
@@ -67,35 +74,3 @@ operator()(propertiest &properties)
6774
properties, result.updated_properties);
6875
return result;
6976
}
70-
71-
void multi_path_symex_only_checkert::perform_symex()
72-
{
73-
auto get_goto_function =
74-
[this](const irep_idt &id) -> const goto_functionst::goto_functiont & {
75-
return goto_model.get_goto_function(id);
76-
};
77-
78-
// perform symbolic execution
79-
symex.symex_from_entry_point_of(get_goto_function, symex_symbol_table);
80-
81-
// add a partial ordering, if required
82-
// We won't be able to decide any properties by adding this,
83-
// but we'd like to see the entire SSA.
84-
if(equation.has_threads())
85-
{
86-
std::unique_ptr<memory_model_baset> memory_model =
87-
get_memory_model(options, ns);
88-
memory_model->set_message_handler(ui_message_handler);
89-
(*memory_model)(equation);
90-
}
91-
92-
log.statistics() << "size of program expression: "
93-
<< equation.SSA_steps.size() << " steps" << messaget::eom;
94-
95-
slice(symex, equation, ns, options, ui_message_handler);
96-
97-
if(options.get_bool_option("validate-ssa-equation"))
98-
{
99-
symex.validate(validation_modet::INVARIANT);
100-
}
101-
}

src/goto-checker/multi_path_symex_only_checker.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class multi_path_symex_only_checkert : public incremental_goto_checkert
3333
symex_target_equationt equation;
3434
path_fifot path_storage; // should go away
3535
symex_bmct symex;
36-
37-
void perform_symex();
3836
};
3937

4038
#endif // CPROVER_GOTO_CHECKER_MULTI_PATH_SYMEX_ONLY_CHECKER_H

0 commit comments

Comments
 (0)