cprover
single_path_symex_only_checker.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Goto Checker using Single Path Symbolic Execution only
4 
5 Author: Daniel Kroening, Peter Schrammel
6 
7 \*******************************************************************/
8 
11 
13 
14 #include <chrono>
15 
19 #include <goto-symex/show_vcc.h>
20 
21 #include "bmc_util.h"
22 #include "symex_bmc.h"
23 
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 
36 operator()(propertiest &properties)
37 {
38  resultt result(resultt::progresst::DONE);
39 
41 
42  while(!has_finished_exploration(properties))
43  {
44  path_storaget::patht &path = worklist->peek();
45 
46  (void)resume_path(path);
47 
48  update_properties(properties, result.updated_properties, path.equation);
49 
50  worklist->pop();
51  }
52 
53  final_update_properties(properties, result.updated_properties);
54 
55  return result;
56 }
57 
59 {
60  // Put initial state into the work list
62  symex_bmct symex(
65  equation,
66  options,
67  *worklist,
69  setup_symex(symex);
70 
73 }
74 
76  const propertiest &properties)
77 {
78  return worklist->empty() ||
79  (!options.get_bool_option("paths-symex-explore-all") &&
80  !has_properties_to_check(properties));
81 }
82 
84 {
85  symex_bmct symex(
88  path.equation,
89  options,
90  *worklist,
92  setup_symex(symex);
93 
96  path.state,
97  &path.equation,
100 
101  equation_output(symex, path.equation);
102 
103  return is_ready_to_decide(symex, path);
104 }
105 
107  const symex_bmct &,
108  const path_storaget::patht &)
109 {
110  // we don't check anything here
111  return false;
112 }
113 
115  const symex_bmct &symex,
116  const symex_target_equationt &equation)
117 {
119  options.get_option("symex-coverage-report"),
120  goto_model,
121  symex,
123 
124  if(options.get_bool_option("show-vcc"))
125  show_vcc(options, ui_message_handler, equation);
126 
127  if(options.get_bool_option("program-only"))
128  show_program(ns, equation);
129 
130  if(options.get_bool_option("show-byte-ops"))
132 
133  if(options.get_bool_option("validate-ssa-equation"))
134  {
136  }
137 }
138 
140 {
142 }
143 
145  propertiest &properties,
146  std::unordered_set<irep_idt> &updated_properties,
147  const symex_target_equationt &equation)
148 {
149  if(options.get_bool_option("symex-driven-lazy-loading"))
151 
153  properties, updated_properties, equation);
154 }
155 
157  propertiest &properties,
158  std::unordered_set<irep_idt> &updated_properties)
159 {
160  // For now, we assume that NOT_REACHED properties are PASS.
161  update_status_of_not_checked_properties(properties, updated_properties);
162 
163  // For now, we assume that UNKNOWN properties are PASS.
164  update_status_of_unknown_properties(properties, updated_properties);
165 }
propertiest
std::unordered_map< irep_idt, property_infot > propertiest
A map of property IDs to property infos.
Definition: properties.h:75
show_program
void show_program(const namespacet &ns, const symex_target_equationt &equation)
Print the steps of equation on the standard output.
Definition: show_program.cpp:59
update_status_of_unknown_properties
void update_status_of_unknown_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties)
Sets the property status of UNKNOWN properties to PASS.
Definition: bmc_util.cpp:289
single_path_symex_only_checkert::ns
namespacet ns
Definition: single_path_symex_only_checker.h:37
postprocess_equation
void postprocess_equation(symex_bmct &symex, symex_target_equationt &equation, const optionst &options, const namespacet &ns, ui_message_handlert &ui_message_handler)
Post process the equation.
Definition: bmc_util.cpp:321
single_path_symex_only_checkert::setup_symex
virtual void setup_symex(symex_bmct &symex)
Definition: single_path_symex_only_checker.cpp:139
abstract_goto_modelt::get_symbol_table
virtual const symbol_tablet & get_symbol_table() const =0
Accessor to get the symbol table.
ui_message_handlert
Definition: ui_message.h:20
incremental_goto_checkert::resultt
Definition: incremental_goto_checker.h:41
memory_model_pso.h
Memory models for partial order concurrency.
optionst
Definition: options.h:23
show_vcc.h
Output of the verification conditions (VCCs)
incremental_goto_checkert::options
const optionst & options
Definition: incremental_goto_checker.h:89
optionst::get_option
const std::string get_option(const std::string &option) const
Definition: options.cpp:67
single_path_symex_only_checkert::symex_symbol_table
symbol_tablet symex_symbol_table
Definition: single_path_symex_only_checker.h:36
goto_symext::resume_symex_from_saved_state
virtual void resume_symex_from_saved_state(const get_goto_functiont &get_goto_function, const statet &saved_state, symex_target_equationt *saved_equation, symbol_tablet &new_symbol_table)
Performs symbolic execution using a state and equation that have already been used to symbolically ex...
Definition: symex_main.cpp:381
single_path_symex_only_checkert::operator()
resultt operator()(propertiest &) override
Check whether the given properties with status NOT_CHECKED, UNKNOWN or properties newly discovered by...
Definition: single_path_symex_only_checker.cpp:36
single_path_symex_only_checkert::resume_path
virtual bool resume_path(path_storaget::patht &path)
Continues exploring the given path using goto-symex.
Definition: single_path_symex_only_checker.cpp:83
update_status_of_not_checked_properties
void update_status_of_not_checked_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties)
Sets the property status of NOT_CHECKED properties to PASS.
Definition: bmc_util.cpp:273
goto_symext::initialize_path_storage_from_entry_point_of
virtual void initialize_path_storage_from_entry_point_of(const get_goto_functiont &get_goto_function, symbol_tablet &new_symbol_table)
Puts the initial state of the entry point function into the path storage.
Definition: symex_main.cpp:479
single_path_symex_only_checkert::goto_model
abstract_goto_modelt & goto_model
Definition: single_path_symex_only_checker.h:35
update_properties_from_goto_model
void update_properties_from_goto_model(propertiest &properties, const abstract_goto_modelt &goto_model)
Updates properties with the assertions in goto_model.
Definition: properties.cpp:73
path_storage.h
Storage of symbolic execution paths to resume.
single_path_symex_only_checkert::single_path_symex_only_checkert
single_path_symex_only_checkert(const optionst &options, ui_message_handlert &ui_message_handler, abstract_goto_modelt &goto_model)
Definition: single_path_symex_only_checker.cpp:24
single_path_symex_only_checkert::is_ready_to_decide
virtual bool is_ready_to_decide(const symex_bmct &symex, const path_storaget::patht &path)
Returns whether the given path produced by symex is ready to be checked.
Definition: single_path_symex_only_checker.cpp:106
bmc_util.h
Bounded Model Checking Utilities.
path_storaget::patht::equation
symex_target_equationt equation
Definition: path_storage.h:43
single_path_symex_only_checkert::final_update_properties
virtual void final_update_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties)
Updates the properties after having finished exploration and adds their property IDs to updated_prope...
Definition: single_path_symex_only_checker.cpp:156
update_properties_status_from_symex_target_equation
void update_properties_status_from_symex_target_equation(propertiest &properties, std::unordered_set< irep_idt > &updated_properties, const symex_target_equationt &equation)
Sets property status to PASS for properties whose conditions are constant true in the equation.
Definition: bmc_util.cpp:237
has_properties_to_check
bool has_properties_to_check(const propertiest &properties)
Return true if there as a property with NOT_CHECKED or UNKNOWN status.
Definition: properties.cpp:174
single_path_symex_only_checkert::worklist
std::unique_ptr< path_storaget > worklist
Definition: single_path_symex_only_checker.h:39
goto_symext::validate
void validate(const validation_modet vm) const
Definition: goto_symex.h:843
single_path_symex_only_checkert::guard_manager
guard_managert guard_manager
Definition: single_path_symex_only_checker.h:38
single_path_symex_only_checkert::initialize_worklist
virtual void initialize_worklist()
Adds the initial goto-symex state as a path to the worklist.
Definition: single_path_symex_only_checker.cpp:58
path_storaget::patht
Information saved at a conditional goto to resume execution.
Definition: path_storage.h:42
symex_target_equationt
Inheriting the interface of symex_targett this class represents the SSA form of the input program as ...
Definition: symex_target_equation.h:41
show_vcc
void show_vcc(const optionst &options, ui_message_handlert &ui_message_handler, const symex_target_equationt &equation)
Output equations from equation to a file or to the standard output.
Definition: show_vcc.cpp:169
single_path_symex_only_checkert::equation_output
void equation_output(const symex_bmct &symex, const symex_target_equationt &equation)
Definition: single_path_symex_only_checker.cpp:114
incremental_goto_checkert
An implementation of incremental_goto_checkert provides functionality for checking a set of propertie...
Definition: incremental_goto_checker.h:34
path_storaget::patht::state
goto_symex_statet state
Definition: path_storage.h:44
optionst::get_bool_option
bool get_bool_option(const std::string &option) const
Definition: options.cpp:44
goto_symext::get_goto_function
static get_goto_functiont get_goto_function(abstract_goto_modelt &goto_model)
Return a function to get/load a goto function from the given goto model Create a default delegate to ...
Definition: symex_main.cpp:493
output_coverage_report
void output_coverage_report(const std::string &cov_out, const abstract_goto_modelt &goto_model, const symex_bmct &symex, ui_message_handlert &ui_message_handler)
Output a coverage report as generated by symex_coveraget if cov_out is non-empty.
Definition: bmc_util.cpp:305
single_path_symex_only_checkert::has_finished_exploration
virtual bool has_finished_exploration(const propertiest &)
Returns whether we should stop exploring paths.
Definition: single_path_symex_only_checker.cpp:75
incremental_goto_checkert::resultt::updated_properties
std::unordered_set< irep_idt > updated_properties
Changed properties since the last call to incremental_goto_checkert::operator()
Definition: incremental_goto_checker.h:59
show_program.h
Output of the program (SSA) constraints.
abstract_goto_modelt
Abstract interface to eager or lazy GOTO models.
Definition: abstract_goto_model.h:21
symex_bmct
Definition: symex_bmc.h:26
incremental_goto_checkert::ui_message_handler
ui_message_handlert & ui_message_handler
Definition: incremental_goto_checker.h:90
show_byte_ops
void show_byte_ops(const optionst &options, ui_message_handlert &ui_message_handler, const namespacet &ns, const symex_target_equationt &equation)
Count and display all byte extract and byte update operations from equation on standard output or fil...
Definition: show_program.cpp:321
single_path_symex_only_checker.h
Goto Checker using Single Path Symbolic Execution only.
symex_bmc.h
Bounded Model Checking for ANSI-C.
single_path_symex_only_checkert::update_properties
virtual void update_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties, const symex_target_equationt &equation)
Updates the properties from the equation and adds their property IDs to updated_properties.
Definition: single_path_symex_only_checker.cpp:144
validation_modet::INVARIANT
@ INVARIANT
get_path_strategy
std::unique_ptr< path_storaget > get_path_strategy(const std::string strategy)
Ensure that is_valid_strategy() returns true for a particular string before calling this function on ...
Definition: path_storage.cpp:128