|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Goto Checker using Multi-Path Symbolic Execution Only |
| 4 | +
|
| 5 | +Author: Daniel Kroening, Peter Schrammel |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +/// \file |
| 10 | +/// Goto Checker using Multi-Path Symbolic Execution only (no SAT solving) |
| 11 | + |
| 12 | +#include "multi_path_symex_only_checker.h" |
| 13 | + |
| 14 | +#include <util/invariant.h> |
| 15 | + |
| 16 | +#include <goto-symex/memory_model_pso.h> |
| 17 | +#include <goto-symex/show_program.h> |
| 18 | +#include <goto-symex/show_vcc.h> |
| 19 | + |
| 20 | +#include "bmc_util.h" |
| 21 | + |
| 22 | +multi_path_symex_only_checkert::multi_path_symex_only_checkert( |
| 23 | + const optionst &options, |
| 24 | + ui_message_handlert &ui_message_handler, |
| 25 | + abstract_goto_modelt &goto_model) |
| 26 | + : incremental_goto_checkert(options, ui_message_handler), |
| 27 | + goto_model(goto_model), |
| 28 | + ns(goto_model.get_symbol_table(), symex_symbol_table), |
| 29 | + symex( |
| 30 | + ui_message_handler, |
| 31 | + goto_model.get_symbol_table(), |
| 32 | + equation, |
| 33 | + options, |
| 34 | + path_storage) |
| 35 | +{ |
| 36 | + setup_symex(symex, ns, options, ui_message_handler); |
| 37 | +} |
| 38 | + |
| 39 | +incremental_goto_checkert::resultt multi_path_symex_only_checkert:: |
| 40 | +operator()(propertiest &properties) |
| 41 | +{ |
| 42 | + perform_symex(); |
| 43 | + |
| 44 | + output_coverage_report(); |
| 45 | + |
| 46 | + if(options.get_bool_option("show-vcc")) |
| 47 | + { |
| 48 | + show_vcc(options, ui_message_handler, equation); |
| 49 | + } |
| 50 | + |
| 51 | + if(options.get_bool_option("program-only")) |
| 52 | + { |
| 53 | + show_program(ns, equation); |
| 54 | + } |
| 55 | + |
| 56 | + return resultt( |
| 57 | + resultt::progresst::DONE, |
| 58 | + update_properties_status_from_symex_target_equation(properties, equation)); |
| 59 | +} |
| 60 | + |
| 61 | +void multi_path_symex_only_checkert::perform_symex() |
| 62 | +{ |
| 63 | + auto get_goto_function = |
| 64 | + [this](const irep_idt &id) -> const goto_functionst::goto_functiont & { |
| 65 | + return goto_model.get_goto_function(id); |
| 66 | + }; |
| 67 | + |
| 68 | + // perform symbolic execution |
| 69 | + symex.symex_from_entry_point_of(get_goto_function, symex_symbol_table); |
| 70 | + |
| 71 | + // add a partial ordering, if required |
| 72 | + // We won't be able to decide any properties by adding this, |
| 73 | + // but we'd like to see the entire SSA. |
| 74 | + if(equation.has_threads()) |
| 75 | + { |
| 76 | + std::unique_ptr<memory_model_baset> memory_model = |
| 77 | + get_memory_model(options, ns); |
| 78 | + memory_model->set_message_handler(ui_message_handler); |
| 79 | + (*memory_model)(equation); |
| 80 | + } |
| 81 | + |
| 82 | + log.statistics() << "size of program expression: " |
| 83 | + << equation.SSA_steps.size() << " steps" << messaget::eom; |
| 84 | + |
| 85 | + slice(symex, equation, ns, options, ui_message_handler); |
| 86 | +} |
| 87 | + |
| 88 | +void multi_path_symex_only_checkert::output_coverage_report() |
| 89 | +{ |
| 90 | + std::string cov_out = options.get_option("symex-coverage-report"); |
| 91 | + if( |
| 92 | + !cov_out.empty() && |
| 93 | + symex.output_coverage_report(goto_model.get_goto_functions(), cov_out)) |
| 94 | + { |
| 95 | + log.error() << "Failed to write symex coverage report to '" << cov_out |
| 96 | + << "'" << messaget::eom; |
| 97 | + } |
| 98 | +} |
0 commit comments