-
Notifications
You must be signed in to change notification settings - Fork 274
Integrate fault localizer into goto checker [blocks: 4215] #3970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
peterschrammel
merged 12 commits into
diffblue:develop
from
peterschrammel:fault-localizer
Feb 20, 2019
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d575d5f
Add invariant for avoiding duplicated error traces
peterschrammel f072391
Add freeze_guards to bmc_util
peterschrammel 560b720
Add const version for returning last trace step
peterschrammel 123280a
Add fault localization output functions
peterschrammel 8aab418
Add fault localization provider interface
peterschrammel 8d01d81
Fault localizer for goto-symex
peterschrammel b436150
Make multi-path symex checker a fault localization provider
peterschrammel 80f1ee8
All properties verifier with fault localization
peterschrammel feb8bcb
Stop-on-fail verifier with fault localization
peterschrammel 19f2cec
Use goto verifier for fault localization in CBMC
peterschrammel 28435fe
Use goto verifier for fault localization in JBMC
peterschrammel b1d9072
Remove unused localize-faults-method option
peterschrammel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,10 @@ Author: Daniel Kroening, [email protected] | |
#include <ansi-c/ansi_c_language.h> | ||
|
||
#include <goto-checker/all_properties_verifier.h> | ||
#include <goto-checker/all_properties_verifier_with_fault_localization.h> | ||
#include <goto-checker/all_properties_verifier_with_trace_storage.h> | ||
#include <goto-checker/stop_on_fail_verifier.h> | ||
#include <goto-checker/stop_on_fail_verifier_with_fault_localization.h> | ||
|
||
#include <goto-programs/adjust_float_expressions.h> | ||
#include <goto-programs/lazy_goto_model.h> | ||
|
@@ -161,12 +163,6 @@ void jbmc_parse_optionst::get_command_line_options(optionst &options) | |
|
||
if(cmdline.isset("localize-faults")) | ||
options.set_option("localize-faults", true); | ||
if(cmdline.isset("localize-faults-method")) | ||
{ | ||
options.set_option( | ||
"localize-faults-method", | ||
cmdline.get_value("localize-faults-method")); | ||
} | ||
|
||
if(cmdline.isset("unwind")) | ||
options.set_option("unwind", cmdline.get_value("unwind")); | ||
|
@@ -613,9 +609,19 @@ int jbmc_parse_optionst::doit() | |
} | ||
else | ||
{ | ||
verifier = util_make_unique< | ||
stop_on_fail_verifiert<java_multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
if(options.get_bool_option("localize-faults")) | ||
{ | ||
verifier = | ||
util_make_unique<stop_on_fail_verifier_with_fault_localizationt< | ||
java_multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
else | ||
{ | ||
verifier = util_make_unique< | ||
stop_on_fail_verifiert<java_multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
} | ||
} | ||
else | ||
|
@@ -629,10 +635,20 @@ int jbmc_parse_optionst::doit() | |
} | ||
else | ||
{ | ||
verifier = | ||
util_make_unique<all_properties_verifier_with_trace_storaget< | ||
java_multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
if(options.get_bool_option("localize-faults")) | ||
{ | ||
verifier = | ||
util_make_unique<all_properties_verifier_with_fault_localizationt< | ||
java_multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
else | ||
{ | ||
verifier = | ||
util_make_unique<all_properties_verifier_with_trace_storaget< | ||
java_multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Author: Daniel Kroening, [email protected] | |
#include <cpp/cprover_library.h> | ||
|
||
#include <goto-checker/all_properties_verifier.h> | ||
#include <goto-checker/all_properties_verifier_with_fault_localization.h> | ||
#include <goto-checker/all_properties_verifier_with_trace_storage.h> | ||
#include <goto-checker/bmc_util.h> | ||
#include <goto-checker/cover_goals_verifier_with_trace_storage.h> | ||
|
@@ -43,6 +44,7 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-checker/single_path_symex_checker.h> | ||
#include <goto-checker/single_path_symex_only_checker.h> | ||
#include <goto-checker/stop_on_fail_verifier.h> | ||
#include <goto-checker/stop_on_fail_verifier_with_fault_localization.h> | ||
|
||
#include <goto-programs/adjust_float_expressions.h> | ||
#include <goto-programs/initialize_goto_model.h> | ||
|
@@ -230,12 +232,6 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options) | |
|
||
if(cmdline.isset("localize-faults")) | ||
options.set_option("localize-faults", true); | ||
if(cmdline.isset("localize-faults-method")) | ||
{ | ||
options.set_option( | ||
"localize-faults-method", | ||
cmdline.get_value("localize-faults-method")); | ||
} | ||
|
||
if(cmdline.isset("unwind")) | ||
options.set_option("unwind", cmdline.get_value("unwind")); | ||
|
@@ -625,9 +621,19 @@ int cbmc_parse_optionst::doit() | |
} | ||
else | ||
{ | ||
verifier = | ||
util_make_unique<stop_on_fail_verifiert<multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
if(options.get_bool_option("localize-faults")) | ||
{ | ||
verifier = | ||
util_make_unique<stop_on_fail_verifier_with_fault_localizationt< | ||
multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
else | ||
{ | ||
verifier = | ||
util_make_unique<stop_on_fail_verifiert<multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
} | ||
} | ||
else | ||
|
@@ -639,8 +645,20 @@ int cbmc_parse_optionst::doit() | |
} | ||
else | ||
{ | ||
verifier = util_make_unique<all_properties_verifier_with_trace_storaget< | ||
multi_path_symex_checkert>>(options, ui_message_handler, goto_model); | ||
if(options.get_bool_option("localize-faults")) | ||
{ | ||
verifier = | ||
util_make_unique<all_properties_verifier_with_fault_localizationt< | ||
multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
else | ||
{ | ||
verifier = | ||
util_make_unique<all_properties_verifier_with_trace_storaget< | ||
multi_path_symex_checkert>>( | ||
options, ui_message_handler, goto_model); | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/goto-checker/all_properties_verifier_with_fault_localization.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Goto Verifier for Verifying all Properties and Localizing Faults | ||
|
||
Author: Daniel Kroening, Peter Schrammel | ||
|
||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Goto verifier for verifying all properties that stores traces | ||
/// and localizes faults | ||
|
||
#ifndef CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_WITH_FAULT_LOCALIZATION_H | ||
#define CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_WITH_FAULT_LOCALIZATION_H | ||
|
||
#include "goto_verifier.h" | ||
|
||
#include "fault_localization_provider.h" | ||
#include "goto_trace_storage.h" | ||
#include "incremental_goto_checker.h" | ||
#include "properties.h" | ||
#include "report_util.h" | ||
|
||
/// Requires an incremental goto checker that is a | ||
/// `goto_trace_providert` and `fault_localization_providert`. | ||
template <class incremental_goto_checkerT> | ||
class all_properties_verifier_with_fault_localizationt : public goto_verifiert | ||
{ | ||
public: | ||
all_properties_verifier_with_fault_localizationt( | ||
const optionst &options, | ||
ui_message_handlert &ui_message_handler, | ||
abstract_goto_modelt &goto_model) | ||
: goto_verifiert(options, ui_message_handler), | ||
goto_model(goto_model), | ||
incremental_goto_checker(options, ui_message_handler, goto_model), | ||
traces(incremental_goto_checker.get_namespace()) | ||
{ | ||
properties = initialize_properties(goto_model); | ||
} | ||
|
||
resultt operator()() override | ||
{ | ||
while(true) | ||
{ | ||
const auto result = incremental_goto_checker(properties); | ||
if(result.progress == incremental_goto_checkert::resultt::progresst::DONE) | ||
break; | ||
|
||
// we've got an error trace | ||
message_building_error_trace(log); | ||
for(const auto &property_id : result.updated_properties) | ||
{ | ||
if(properties.at(property_id).status == property_statust::FAIL) | ||
{ | ||
// get correctly truncated error trace for property and store it | ||
(void)traces.insert( | ||
incremental_goto_checker.build_trace(property_id)); | ||
|
||
fault_locations.insert( | ||
{property_id, | ||
incremental_goto_checker.localize_fault(property_id)}); | ||
} | ||
} | ||
|
||
++iterations; | ||
} | ||
|
||
return determine_result(properties); | ||
} | ||
|
||
void report() override | ||
{ | ||
if( | ||
options.get_bool_option("trace") || | ||
// currently --trace only affects plain text output | ||
ui_message_handler.get_ui() != ui_message_handlert::uit::PLAIN) | ||
{ | ||
const trace_optionst trace_options(options); | ||
output_properties_with_traces_and_fault_localization( | ||
properties, | ||
traces, | ||
trace_options, | ||
fault_locations, | ||
iterations, | ||
ui_message_handler); | ||
} | ||
else | ||
{ | ||
output_properties_with_fault_localization( | ||
properties, fault_locations, iterations, ui_message_handler); | ||
} | ||
output_overall_result(determine_result(properties), ui_message_handler); | ||
} | ||
|
||
const goto_trace_storaget &get_traces() const | ||
{ | ||
return traces; | ||
} | ||
|
||
protected: | ||
abstract_goto_modelt &goto_model; | ||
incremental_goto_checkerT incremental_goto_checker; | ||
std::size_t iterations = 1; | ||
goto_trace_storaget traces; | ||
std::unordered_map<irep_idt, fault_location_infot> fault_locations; | ||
}; | ||
|
||
#endif // CPROVER_GOTO_CHECKER_ALL_PROPERTIES_VERIFIER_WITH_FAULT_LOCALIZATION_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Interface for Goto Checkers to provide Fault Localization | ||
|
||
Author: Daniel Kroening, Peter Schrammel | ||
|
||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Interface for Goto Checkers to provide Fault Localization | ||
|
||
#ifndef CPROVER_GOTO_CHECKER_FAULT_LOCALIZATION_PROVIDER_H | ||
#define CPROVER_GOTO_CHECKER_FAULT_LOCALIZATION_PROVIDER_H | ||
|
||
#include <map> | ||
|
||
#include <goto-programs/goto_program.h> | ||
|
||
class goto_tracet; | ||
class namespacet; | ||
|
||
struct fault_location_infot | ||
{ | ||
typedef std::map<goto_programt::const_targett, std::size_t> score_mapt; | ||
score_mapt scores; | ||
}; | ||
|
||
/// An implementation of `incremental_goto_checkert` | ||
/// may implement this interface to provide fault localization information. | ||
class fault_localization_providert | ||
{ | ||
public: | ||
/// Returns the most likely fault locations | ||
/// for the given FAILed \p property_id | ||
virtual fault_location_infot | ||
localize_fault(const irep_idt &property_id) const = 0; | ||
|
||
virtual ~fault_localization_providert() = default; | ||
}; | ||
|
||
#endif // CPROVER_GOTO_CHECKER_FAULT_LOCALIZATION_PROVIDER_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these both expected to be insert-new-key? If so suggest cross-checking with a CHECK_RETURN that they are indeed new.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(If not, suggest inserting a dummy value and only calling the expensive build / localize functions if they really are new)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added an invariant in the trace storage.