|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Goto Verifier for Verifying all Properties and Localizing Faults |
| 4 | +
|
| 5 | +Author: Daniel Kroening, Peter Schrammel |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +/// \file |
| 10 | +/// Goto verifier for verifying all properties that stores traces |
| 11 | +/// and localizes faults |
| 12 | + |
| 13 | +#ifndef CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_WITH_FAULT_LOCALIZATION_H |
| 14 | +#define CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_WITH_FAULT_LOCALIZATION_H |
| 15 | + |
| 16 | +#include "goto_verifier.h" |
| 17 | + |
| 18 | +#include "fault_localization_provider.h" |
| 19 | +#include "goto_trace_storage.h" |
| 20 | +#include "incremental_goto_checker.h" |
| 21 | +#include "properties.h" |
| 22 | +#include "report_util.h" |
| 23 | + |
| 24 | +/// Requires an incremental goto checker that is a |
| 25 | +/// `goto_trace_providert` and `fault_localization_providert`. |
| 26 | +template <class incremental_goto_checkerT> |
| 27 | +class all_properties_verifier_with_fault_localizationt : public goto_verifiert |
| 28 | +{ |
| 29 | +public: |
| 30 | + all_properties_verifier_with_fault_localizationt( |
| 31 | + const optionst &options, |
| 32 | + ui_message_handlert &ui_message_handler, |
| 33 | + abstract_goto_modelt &goto_model) |
| 34 | + : goto_verifiert(options, ui_message_handler), |
| 35 | + goto_model(goto_model), |
| 36 | + incremental_goto_checker(options, ui_message_handler, goto_model), |
| 37 | + traces(incremental_goto_checker.get_namespace()) |
| 38 | + { |
| 39 | + properties = initialize_properties(goto_model); |
| 40 | + } |
| 41 | + |
| 42 | + resultt operator()() override |
| 43 | + { |
| 44 | + while(true) |
| 45 | + { |
| 46 | + const auto result = incremental_goto_checker(properties); |
| 47 | + if(result.progress == incremental_goto_checkert::resultt::progresst::DONE) |
| 48 | + break; |
| 49 | + |
| 50 | + // we've got an error trace |
| 51 | + message_building_error_trace(log); |
| 52 | + for(const auto &property_id : result.updated_properties) |
| 53 | + { |
| 54 | + if(properties.at(property_id).status == property_statust::FAIL) |
| 55 | + { |
| 56 | + // get correctly truncated error trace for property and store it |
| 57 | + (void)traces.insert( |
| 58 | + incremental_goto_checker.build_trace(property_id)); |
| 59 | + |
| 60 | + fault_locations.insert( |
| 61 | + {property_id, |
| 62 | + incremental_goto_checker.localize_fault(property_id)}); |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + ++iterations; |
| 67 | + } |
| 68 | + |
| 69 | + return determine_result(properties); |
| 70 | + } |
| 71 | + |
| 72 | + void report() override |
| 73 | + { |
| 74 | + if( |
| 75 | + options.get_bool_option("trace") || |
| 76 | + // currently --trace only affects plain text output |
| 77 | + ui_message_handler.get_ui() != ui_message_handlert::uit::PLAIN) |
| 78 | + { |
| 79 | + const trace_optionst trace_options(options); |
| 80 | + output_properties_with_traces_and_fault_localization( |
| 81 | + properties, |
| 82 | + traces, |
| 83 | + trace_options, |
| 84 | + fault_locations, |
| 85 | + iterations, |
| 86 | + ui_message_handler); |
| 87 | + } |
| 88 | + else |
| 89 | + { |
| 90 | + output_properties_with_fault_localization( |
| 91 | + properties, fault_locations, iterations, ui_message_handler); |
| 92 | + } |
| 93 | + output_overall_result(determine_result(properties), ui_message_handler); |
| 94 | + } |
| 95 | + |
| 96 | + const goto_trace_storaget &get_traces() const |
| 97 | + { |
| 98 | + return traces; |
| 99 | + } |
| 100 | + |
| 101 | +protected: |
| 102 | + abstract_goto_modelt &goto_model; |
| 103 | + incremental_goto_checkerT incremental_goto_checker; |
| 104 | + std::size_t iterations = 1; |
| 105 | + goto_trace_storaget traces; |
| 106 | + std::unordered_map<irep_idt, fault_location_infot> fault_locations; |
| 107 | +}; |
| 108 | + |
| 109 | +#endif // CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_WITH_FAULT_LOCALIZATION_H |
0 commit comments