CBMC
multi_path_symex_checker.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Goto Checker using Bounded Model Checking
4 
5 Author: Daniel Kroening, Peter Schrammel
6 
7 \*******************************************************************/
8 
11 
13 
14 #include <util/ui_message.h>
15 
18 
19 #include <assembler/remove_asm.h>
21 
22 #include "bmc_util.h"
25 
27  const optionst &options,
28  ui_message_handlert &ui_message_handler,
29  abstract_goto_modelt &goto_model)
30  : multi_path_symex_only_checkert(options, ui_message_handler, goto_model),
31  equation_generated(false),
32  property_decider(options, ui_message_handler, equation, ns)
33 {
34  // check for certain unsupported language features
38 }
39 
41 operator()(propertiest &properties)
42 {
43  resultt result(resultt::progresst::DONE);
44 
45  // When the equation has been generated, we know all the properties.
46  // Have we got anything to check? Otherwise we return DONE.
48  return result;
49 
50  std::chrono::duration<double> solver_runtime(0);
51 
52  // we haven't got an equation yet
54  {
56 
58  options.get_option("symex-coverage-report"),
59  goto_model,
60  symex,
62 
63  update_properties(properties, result.updated_properties);
64 
65  // Have we got anything to check? Otherwise we return DONE.
66  if(!has_properties_to_check(properties))
67  return result;
68 
69  solver_runtime += prepare_property_decider(properties);
70 
71  equation_generated = true;
72  }
73 
74  run_property_decider(result, properties, solver_runtime);
75 
76  return result;
77 }
78 
79 std::chrono::duration<double>
81 {
82  std::chrono::duration<double> solver_runtime = ::prepare_property_decider(
84 
85  return solver_runtime;
86 }
87 
90  propertiest &properties,
91  std::chrono::duration<double> solver_runtime)
92 {
94  result, properties, property_decider, ui_message_handler, solver_runtime);
95 }
96 
98 {
99  goto_tracet goto_trace;
101  equation,
102  equation.SSA_steps.end(),
104  ns,
105  goto_trace);
106 
107  return goto_trace;
108 }
109 
111 {
112  if(options.get_bool_option("beautify"))
113  {
114  // NOLINTNEXTLINE(whitespace/braces)
117  equation);
118  }
119 
120  goto_tracet goto_trace;
123 
124  return goto_trace;
125 }
126 
129 {
130  goto_tracet goto_trace;
132  equation,
135  ns,
136  goto_trace);
137 
138  return goto_trace;
139 }
140 
142 {
143  return ns;
144 }
145 
147 {
149 }
150 
152  const goto_tracet &error_trace)
153 {
154  output_graphml(error_trace, ns, options);
155 }
156 
159 {
160  goto_symex_fault_localizert fault_localizer(
161  options,
163  equation,
165 
166  return fault_localizer(property_id);
167 }
168 
170 {
171  if(options.is_set("write-solver-stats-to"))
172  {
175  [](solver_hardnesst &hardness) { hardness.produce_report(); });
176  }
177 }
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:306
ssa_step_predicatet ssa_step_matches_failing_property(const irep_idt &property_id)
Returns a function that checks whether an SSA step is an assertion with property_id.
Definition: bmc_util.cpp:54
void output_graphml(const goto_tracet &goto_trace, const namespacet &ns, const optionst &options)
outputs an error witness in graphml format
Definition: bmc_util.cpp:107
Bounded Model Checking Utilities.
void build_goto_trace(const symex_target_equationt &target, ssa_step_predicatet is_last_step_to_keep, const decision_proceduret &decision_procedure, const namespacet &ns, goto_tracet &goto_trace)
Build a trace by going through the steps of target and stopping after the step matching a given condi...
Abstract interface to eager or lazy GOTO models.
virtual const goto_functionst & get_goto_functions() const =0
Accessor to get a raw goto_functionst.
Definition: boolbv.h:46
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
decision_proceduret & get_decision_procedure() const
Returns the solver instance.
stack_decision_proceduret & get_stack_decision_procedure() const
Returns the solver instance.
Trace of a GOTO program.
Definition: goto_trace.h:177
ui_message_handlert & ui_message_handler
void report() override
Additional reporting that may result from the underlying solver, no-op by default.
resultt operator()(propertiest &) override
Check whether the given properties with status NOT_CHECKED, UNKNOWN or properties newly discovered by...
goto_tracet build_full_trace() const override
Builds and returns the complete trace.
virtual void run_property_decider(incremental_goto_checkert::resultt &result, propertiest &properties, std::chrono::duration< double > solver_runtime)
Run the property decider, which calls the SAT solver, and set the status of checked properties accord...
fault_location_infot localize_fault(const irep_idt &property_id) const override
Returns the most likely fault locations for the given FAILed property_id.
goto_symex_property_decidert property_decider
virtual std::chrono::duration< double > prepare_property_decider(propertiest &properties)
Prepare the property decider for solving.
multi_path_symex_checkert(const optionst &options, ui_message_handlert &ui_message_handler, abstract_goto_modelt &goto_model)
void output_error_witness(const goto_tracet &) override
goto_tracet build_shortest_trace() const override
Builds and returns the trace up to the first failed property.
const namespacet & get_namespace() const override
Returns the namespace associated with the traces.
goto_tracet build_trace(const irep_idt &) const override
Builds and returns the trace for the FAILed property with the given property_id.
virtual void update_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties)
Updates the properties from the equation and adds their property IDs to updated_properties.
virtual void generate_equation()
Generates the equation by running goto-symex.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
bool is_set(const std::string &option) const
N.B. opts.is_set("foo") does not imply opts.get_bool_option("foo")
Definition: options.cpp:62
bool get_bool_option(const std::string &option) const
Definition: options.cpp:44
const std::string get_option(const std::string &option) const
Definition: options.cpp:67
Counterexample Beautification.
Fault Localization for Goto Symex.
Goto Checker using Multi-Path Symbolic Execution.
bool has_properties_to_check(const propertiest &properties)
Return true if there as a property with NOT_CHECKED or UNKNOWN status.
Definition: properties.cpp:181
std::map< irep_idt, property_infot > propertiest
A map of property IDs to property infos.
Definition: properties.h:76
bool has_asm(const goto_functionst &goto_functions)
returns true iff the given goto functions use asm instructions
Definition: remove_asm.cpp:598
Remove 'asm' statements by compiling them into suitable standard goto program instructions.
bool has_function_pointers(const goto_programt &goto_program)
Remove Indirect Function Calls.
bool has_vector(const goto_functionst &goto_functions)
returns true iff any of the given goto functions has instructions that use the vector type
Remove the 'vector' data type by compilation into arrays.
static void with_solver_hardness(decision_proceduret &maybe_hardness_collector, std::function< void(solver_hardnesst &hardness)> handler)
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
std::unordered_set< irep_idt > updated_properties
Changed properties since the last call to incremental_goto_checkert::operator()
A structure that facilitates collecting the complexity statistics from a decision procedure.