37 switch(ui_message_handler.
get_ui())
54 msg.
result() << json_result;
65 switch(ui_message_handler.
get_ui())
82 msg.
result() << json_result;
93 switch(ui_message_handler.
get_ui())
109 json_result[
"cProverStatus"] =
json_stringt(
"inconclusive");
110 msg.
result() << json_result;
121 switch(ui_message_handler.
get_ui())
138 msg.
result() << json_result;
150 const auto &l = property_info.
pc->source_location();
153 if(l.get_file() != current_file)
154 log.result() <<
"file " << l.get_file() <<
' ';
155 if(!l.get_line().empty())
156 log.result() <<
"line " << l.get_line() <<
' ';
158 switch(property_info.
status)
198 if(p1.get_file() != p2.get_file())
200 if(p1.get_function() != p2.get_function())
203 !p1.get_line().empty() && !p2.get_line().empty() &&
204 p1.get_line() != p2.get_line())
205 return std::stoul(
id2string(p1.get_line())) <
208 const auto split_property_id =
209 [](
const irep_idt &property_id) -> std::pair<std::string, std::size_t> {
210 const auto property_string =
id2string(property_id);
211 const auto last_dot = property_string.rfind(
'.');
212 std::string property_name;
213 std::string property_number;
214 if(last_dot == std::string::npos)
217 property_number = property_string;
221 property_name = property_string.substr(0, last_dot);
222 property_number = property_string.substr(last_dot + 1);
225 if(maybe_number.has_value())
226 return std::make_pair(property_name, *maybe_number);
228 return std::make_pair(property_name, 0);
231 const auto left_split = split_property_id(property1.first);
232 const auto left_id_name = left_split.first;
233 const auto left_id_number = left_split.second;
235 const auto right_split = split_property_id(property2.first);
236 const auto right_id_name = right_split.first;
237 const auto right_id_number = right_split.second;
239 if(left_id_name != right_id_name)
240 return left_id_name < right_id_name;
242 return left_id_number < right_id_number;
245 static std::vector<propertiest::const_iterator>
248 std::vector<propertiest::const_iterator> sorted_properties;
249 for(
auto p_it = properties.begin(); p_it != properties.end(); p_it++)
250 sorted_properties.push_back(p_it);
253 sorted_properties.begin(),
254 sorted_properties.end(),
255 [](propertiest::const_iterator pit1, propertiest::const_iterator pit2) {
256 return is_property_less_than(*pit1, *pit2);
258 return sorted_properties;
262 const std::vector<propertiest::const_iterator> &sorted_properties,
265 if(sorted_properties.empty())
272 for(
const auto &p : sorted_properties)
274 const auto &l = p->second.pc->source_location();
275 if(l.get_function() != previous_function)
277 if(!previous_function.
empty())
278 log.result() <<
'\n';
279 previous_function = l.get_function();
280 if(!previous_function.
empty())
282 current_file = l.get_file();
283 if(!current_file.
empty())
284 log.result() << current_file <<
' ';
285 if(!l.get_function().empty())
286 log.result() <<
"function " << l.get_function();
296 std::size_t iterations,
299 if(properties.empty())
302 log.status() <<
"\n** "
304 << properties.size() <<
" failed (" << iterations
310 std::size_t iterations,
314 switch(ui_message_handler.
get_ui())
325 for(
const auto &property_pair : properties)
327 log.result() <<
xml(property_pair.first, property_pair.second);
337 for(
const auto &property_pair : properties)
339 result_array.
push_back(
json(property_pair.first, property_pair.second));
350 std::size_t iterations,
354 switch(ui_message_handler.
get_ui())
360 for(
const auto &property_it : sorted_properties)
365 <<
"Trace for " << property_it->first <<
":"
370 traces[property_it->first],
380 for(
const auto &property_pair : properties)
382 xmlt xml_result =
xml(property_pair.first, property_pair.second);
387 traces[property_pair.first],
390 log.result() << xml_result;
400 for(
const auto &property_pair : properties)
404 json(json_property, property_pair.
first, property_pair.second);
409 convert<json_stream_arrayt>(
411 traces[property_pair.first],
425 log.conditional_output(
427 out <<
"Fault localization scores:" << messaget::eom;
428 for(auto &score_pair : fault_location.scores)
430 out << score_pair.first->source_location()
431 <<
"\n score: " << score_pair.second << messaget::eom;
441 return std::max_element(
442 fault_location.
scores.begin(),
443 fault_location.
scores.end(),
445 fault_location_infot::score_mapt::value_type score_pair1,
446 fault_location_infot::score_mapt::value_type score_pair2) {
447 return score_pair1.second < score_pair2.second;
457 if(fault_location.
scores.empty())
466 <<
"[" +
id2string(property_id) +
"]: \n "
472 const std::unordered_map<irep_idt, fault_location_infot> &fault_locations,
476 for(
const auto &fault_location_pair : fault_locations)
479 fault_location_pair.first, fault_location_pair.second,
log);
488 xmlt xml_diagnosis(
"diagnosis");
492 if(fault_location.
scores.empty())
495 return xml_diagnosis;
504 return xml_diagnosis;
508 const std::unordered_map<irep_idt, fault_location_infot> &fault_locations,
511 xmlt dest(
"fault-localization");
512 for(
const auto &fault_location_pair : fault_locations)
515 xml(fault_location_pair.first, fault_location_pair.second,
log);
518 log.result() << dest;
524 if(fault_location.
scores.empty())
526 json_result[
"result"] =
json_stringt(
"unable to localize fault");
530 json_result[
"result"] =
538 const std::unordered_map<irep_idt, fault_location_infot> &fault_locations,
539 std::size_t iterations,
543 switch(ui_message_handler.
get_ui())
557 for(
const auto &property_pair : properties)
561 json(json_property, property_pair.
first, property_pair.second);
565 "diagnosis",
json(fault_locations.at(property_pair.first)));
583 const std::unordered_map<irep_idt, fault_location_infot> &fault_locations,
584 std::size_t iterations,
588 switch(ui_message_handler.
get_ui())
593 properties, traces, trace_options, iterations, ui_message_handler);
603 for(
const auto &property_pair : properties)
607 json(json_property, property_pair.
first, property_pair.second);
612 convert<json_stream_arrayt>(
614 traces[property_pair.first],
618 "diagnosis",
json(fault_locations.at(property_pair.first)));
626 properties, traces, trace_options, iterations, ui_message_handler);
641 switch(ui_message_handler.
get_ui())
659 convert<json_stream_arrayt>(ns, goto_trace, json_trace, trace_options);
660 json_result.
push_back(
"diagnosis",
json(fault_location_info));
668 "fault-localization",
671 log.result() << dest;
void output_error_trace(const goto_tracet &goto_trace, const namespacet &ns, const trace_optionst &trace_options, ui_message_handlert &ui_message_handler)
Bounded Model Checking Utilities.
static bool convert(const irep_idt &identifier, const std::ostringstream &s, symbol_table_baset &symbol_table, message_handlert &message_handler)
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
instructionst::const_iterator const_targett
Step of the trace of a GOTO program.
const namespacet & get_namespace() const
goto_trace_stept & get_last_step()
Retrieves the final step in the trace for manipulation (used to fill a trace from code,...
Provides methods for streaming JSON arrays.
void push_back(const jsont &json)
Push back a JSON element into the current array stream.
json_stream_objectt & push_back_stream_object()
Add a JSON object child stream.
Provides methods for streaming JSON objects.
void push_back(const std::string &key, const jsont &json)
Push back a JSON element into the current object stream.
json_stream_arrayt & push_back_stream_array(const std::string &key)
Add a JSON array stream for a specific key.
bool first
Is the current element the first element in the object or array? This is required to know whether a d...
Class that provides messages with a built-in verbosity 'level'.
static const commandt yellow
render text with yellow foreground color
static const commandt magenta
render text with magenta foreground color
static const commandt reset
return to default formatting, as defined by the terminal
static const commandt green
render text with green foreground color
static const commandt faint
render text with faint font
static const commandt bright_red
render text with bright red foreground color
mstreamt & result() const
static const commandt red
render text with red foreground color
static const commandt bright_green
render text with bright green foreground color
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
source_locationt source_location
virtual uit get_ui() const
virtual json_stream_arrayt & get_json_stream()
void set_attribute(const std::string &attribute, unsigned value)
xmlt & new_element(const std::string &key)
Interface for Goto Checkers to provide Fault Localization.
void show_goto_trace(messaget::mstreamt &out, const namespacet &ns, const goto_tracet &goto_trace, const trace_optionst &options)
Output the trace on the given stream out.
const std::string & id2string(const irep_idt &d)
std::size_t count_properties(const propertiest &properties, property_statust status)
Return the number of properties with given status.
@ UNKNOWN
The checker was unable to determine the status of the property.
@ NOT_REACHABLE
The property was proven to be unreachable.
@ PASS
The property was not violated.
@ ERROR
An error occurred during goto checking.
@ FAIL
The property was violated.
@ NOT_CHECKED
The property was not checked (also used for initialization)
std::map< irep_idt, property_infot > propertiest
A map of property IDs to property infos.
resultt
The result of goto verifying.
@ UNKNOWN
No property was violated, neither was there an error.
@ PASS
No properties were violated.
@ ERROR
An error occurred during goto checking.
@ FAIL
Some properties were violated.
void output_properties(const propertiest &properties, std::size_t iterations, ui_message_handlert &ui_message_handler)
static void output_properties_plain(const std::vector< propertiest::const_iterator > &sorted_properties, messaget &log)
static goto_programt::const_targett max_fault_localization_score(const fault_location_infot &fault_location)
void output_properties_with_fault_localization(const propertiest &properties, const std::unordered_map< irep_idt, fault_location_infot > &fault_locations, std::size_t iterations, ui_message_handlert &ui_message_handler)
void output_properties_with_traces_and_fault_localization(const propertiest &properties, const goto_trace_storaget &traces, const trace_optionst &trace_options, const std::unordered_map< irep_idt, fault_location_infot > &fault_locations, std::size_t iterations, ui_message_handlert &ui_message_handler)
static json_objectt json(const fault_location_infot &fault_location)
static void output_fault_localization_plain(const irep_idt &property_id, const fault_location_infot &fault_location, messaget &log)
void report_success(ui_message_handlert &ui_message_handler)
static bool is_property_less_than(const propertyt &property1, const propertyt &property2)
Compare two properties according to the following sort:
static xmlt xml(const irep_idt &property_id, const fault_location_infot &fault_location, messaget &log)
void report_inconclusive(ui_message_handlert &ui_message_handler)
void output_overall_result(resultt result, ui_message_handlert &ui_message_handler)
void output_properties_with_traces(const propertiest &properties, const goto_trace_storaget &traces, const trace_optionst &trace_options, std::size_t iterations, ui_message_handlert &ui_message_handler)
static std::vector< propertiest::const_iterator > get_sorted_properties(const propertiest &properties)
void output_fault_localization_scores(const fault_location_infot &fault_location, messaget &log)
static void output_fault_localization_xml(const std::unordered_map< irep_idt, fault_location_infot > &fault_locations, messaget &log)
void output_error_trace_with_fault_localization(const goto_tracet &goto_trace, const namespacet &ns, const trace_optionst &trace_options, const fault_location_infot &fault_location_info, ui_message_handlert &ui_message_handler)
static void output_iterations(const propertiest &properties, std::size_t iterations, messaget &log)
void report_error(ui_message_handlert &ui_message_handler)
void report_failure(ui_message_handlert &ui_message_handler)
static void output_single_property_plain(const irep_idt &property_id, const property_infot &property_info, messaget &log, irep_idt current_file=irep_idt())
Bounded Model Checking Utilities.
#define PRECONDITION(CONDITION)
std::string as_string(const ai_verifier_statust &status)
Makes a status message string from a status.
std::optional< std::size_t > string2optional_size_t(const std::string &str, int base)
Convert string to size_t similar to the stoul or stoull functions, return nullopt when the conversion...
property_statust status
The status of the property.
std::string description
A description (usually derived from the assertion's comment)
goto_programt::const_targett pc
A pointer to the corresponding goto instruction.
Options for printing the trace using show_goto_trace.