Skip to content

Commit cba7647

Browse files
Add single-path symex-only checker
Replaces the path_explorert variant of bmct. The current implementation of this is overly complicated because path_explorert distinguishes the first run of goto-symex from the following ones. To drastically simplify the code goto-symex/symex_bmc needs to be refactored so that all runs can be handled uniformly (e.g. push entry point into work list and then 'resume' from there). See also single_path_symex_checkert.
1 parent 4b896ba commit cba7647

File tree

3 files changed

+169
-0
lines changed

3 files changed

+169
-0
lines changed

src/goto-checker/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SRC = bmc_util.cpp \
77
goto_verifier.cpp \
88
multi_path_symex_checker.cpp \
99
multi_path_symex_only_checker.cpp \
10+
single_path_symex_only_checker.cpp \
1011
properties.cpp \
1112
report_util.cpp \
1213
solver_factory.cpp \
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*******************************************************************\
2+
3+
Module: Goto Checker using Single Path Symbolic Execution only
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Goto Checker using Single Path Symbolic Execution only
11+
12+
#include "single_path_symex_only_checker.h"
13+
14+
#include <chrono>
15+
16+
#include <goto-symex/memory_model_pso.h>
17+
#include <goto-symex/path_storage.h>
18+
#include <goto-symex/show_program.h>
19+
#include <goto-symex/show_vcc.h>
20+
21+
#include "bmc_util.h"
22+
#include "symex_bmc.h"
23+
24+
single_path_symex_only_checkert::single_path_symex_only_checkert(
25+
const optionst &options,
26+
ui_message_handlert &ui_message_handler,
27+
abstract_goto_modelt &goto_model)
28+
: incremental_goto_checkert(options, ui_message_handler),
29+
goto_model(goto_model),
30+
ns(goto_model.get_symbol_table(), symex_symbol_table),
31+
worklist(get_path_strategy(options.get_option("exploration-strategy")))
32+
{
33+
}
34+
35+
incremental_goto_checkert::resultt single_path_symex_only_checkert::
36+
operator()(propertiest &properties)
37+
{
38+
resultt result(resultt::progresst::DONE);
39+
40+
// First run goto-symex from entry point to initialize worklist
41+
{
42+
symex_target_equationt first_equation;
43+
symex_bmct symex(
44+
ui_message_handler,
45+
goto_model.get_symbol_table(),
46+
first_equation,
47+
options,
48+
*worklist);
49+
50+
setup_symex(symex);
51+
perform_symex(
52+
goto_model,
53+
symex,
54+
symex_symbol_table,
55+
first_equation,
56+
options,
57+
ns,
58+
ui_message_handler);
59+
60+
equation_output(symex, first_equation);
61+
update_properties_status_from_symex_target_equation(
62+
properties, result.updated_properties, first_equation);
63+
}
64+
65+
while(!worklist->empty())
66+
{
67+
path_storaget::patht &resume = worklist->peek();
68+
symex_bmct symex(
69+
ui_message_handler,
70+
goto_model.get_symbol_table(),
71+
resume.equation,
72+
options,
73+
*worklist);
74+
75+
setup_symex(symex);
76+
perform_symex(
77+
goto_model,
78+
symex,
79+
resume,
80+
symex_symbol_table,
81+
options,
82+
ns,
83+
ui_message_handler);
84+
equation_output(symex, resume.equation);
85+
update_properties_status_from_symex_target_equation(
86+
properties, result.updated_properties, resume.equation);
87+
88+
worklist->pop();
89+
}
90+
91+
// For now, we assume that NOT_REACHED properties are PASS.
92+
update_status_of_not_checked_properties(
93+
properties, result.updated_properties);
94+
return result;
95+
}
96+
97+
void single_path_symex_only_checkert::equation_output(
98+
const symex_bmct &symex,
99+
const symex_target_equationt &equation)
100+
{
101+
output_coverage_report(
102+
options.get_option("symex-coverage-report"),
103+
goto_model,
104+
symex,
105+
ui_message_handler);
106+
107+
if(options.get_bool_option("show-vcc"))
108+
show_vcc(options, ui_message_handler, equation);
109+
110+
if(options.get_bool_option("program-only"))
111+
show_program(ns, equation);
112+
113+
if(options.get_bool_option("validate-ssa-equation"))
114+
{
115+
symex.validate(validation_modet::INVARIANT);
116+
}
117+
}
118+
119+
void single_path_symex_only_checkert::setup_symex(symex_bmct &symex)
120+
{
121+
::setup_symex(symex, ns, options, ui_message_handler);
122+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*******************************************************************\
2+
3+
Module: Goto Checker using Single Path Symbolic Execution only
4+
5+
Author: Daniel Kroening, Peter Schrammel
6+
7+
\*******************************************************************/
8+
9+
/// \file
10+
/// Goto Checker using Single Path Symbolic Execution only
11+
12+
#ifndef CPROVER_GOTO_CHECKER_SINGLE_PATH_SYMEX_ONLY_CHECKER_H
13+
#define CPROVER_GOTO_CHECKER_SINGLE_PATH_SYMEX_ONLY_CHECKER_H
14+
15+
#include "incremental_goto_checker.h"
16+
17+
#include <goto-symex/path_storage.h>
18+
19+
class symex_bmct;
20+
21+
class single_path_symex_only_checkert : public incremental_goto_checkert
22+
{
23+
public:
24+
single_path_symex_only_checkert(
25+
const optionst &options,
26+
ui_message_handlert &ui_message_handler,
27+
abstract_goto_modelt &goto_model);
28+
29+
resultt operator()(propertiest &) override;
30+
31+
virtual ~single_path_symex_only_checkert() = default;
32+
33+
protected:
34+
abstract_goto_modelt &goto_model;
35+
symbol_tablet symex_symbol_table;
36+
namespacet ns;
37+
std::unique_ptr<path_storaget> worklist;
38+
39+
void equation_output(
40+
const symex_bmct &symex,
41+
const symex_target_equationt &equation);
42+
43+
virtual void setup_symex(symex_bmct &symex);
44+
};
45+
46+
#endif // CPROVER_GOTO_CHECKER_SINGLE_PATH_SYMEX_ONLY_CHECKER_H

0 commit comments

Comments
 (0)