#include <algorithm>
#include <new>
#include <stdarg.h>
+#include <string.h>
#include "model.h"
#include "action.h"
earliest_diverge(NULL),
trace_analyses()
{
+ memset(&stats,0,sizeof(struct execution_stats));
}
/** @brief Destructor */
/** @brief Print bug report listing for this execution (if any bugs exist) */
void ModelChecker::print_bugs() const
{
- if (execution->have_bug_reports()) {
- SnapVector<bug_message *> *bugs = execution->get_bugs();
-
- model_print("Bug report: %zu bug%s detected\n",
- bugs->size(),
- bugs->size() > 1 ? "s" : "");
- for (unsigned int i = 0; i < bugs->size(); i++)
- (*bugs)[i]->print();
- }
+ SnapVector<bug_message *> *bugs = execution->get_bugs();
+
+ model_print("Bug report: %zu bug%s detected\n",
+ bugs->size(),
+ bugs->size() > 1 ? "s" : "");
+ for (unsigned int i = 0; i < bugs->size(); i++)
+ (*bugs)[i]->print();
}
/**
model_print("Number of buggy executions: %d\n", stats.num_buggy_executions);
model_print("Number of infeasible executions: %d\n", stats.num_infeasible);
model_print("Total executions: %d\n", stats.num_total);
- model_print("Total nodes created: %d\n", node_stack->get_total_nodes());
+ if (params.verbose)
+ model_print("Total nodes created: %d\n", node_stack->get_total_nodes());
}
/**
*/
void ModelChecker::print_execution(bool printbugs) const
{
+ model_print("Program output from execution %d:\n",
+ get_execution_number());
print_program_output();
- if (params.verbose >= 2) {
- model_print("Earliest divergence point since last feasible execution:\n");
+ if (params.verbose >= 3) {
+ model_print("\nEarliest divergence point since last feasible execution:\n");
if (earliest_diverge)
earliest_diverge->print();
else
}
/* Don't print invalid bugs */
- if (printbugs)
+ if (printbugs && execution->have_bug_reports()) {
+ model_print("\n");
print_bugs();
+ }
model_print("\n");
execution->print_summary();
record_stats();
/* Output */
- if (params.verbose || (complete && execution->have_bug_reports()))
+ if ( (complete && params.verbose) || params.verbose>1 || (complete && execution->have_bug_reports()))
print_execution(complete);
else
clear_program_output();
execution_number++;
+ if (params.maxexecutions != 0 && stats.num_complete >= params.maxexecutions)
+ return false;
+
reset_to_initial_state();
return true;
}
return execution->get_thread(act);
}
-/**
- * @brief Check if a Thread is currently enabled
- * @param t The Thread to check
- * @return True if the Thread is currently enabled
- */
-bool ModelChecker::is_enabled(Thread *t) const
-{
- return scheduler->is_enabled(t);
-}
-
-/**
- * @brief Check if a Thread is currently enabled
- * @param tid The ID of the Thread to check
- * @return True if the Thread is currently enabled
- */
-bool ModelChecker::is_enabled(thread_id_t tid) const
-{
- return scheduler->is_enabled(tid);
-}
-
/**
* Switch from a model-checker context to a user-thread context. This is the
* complement of ModelChecker::switch_to_master and must be called from the
for (unsigned int i = 0; i < get_num_threads(); i++) {
Thread *th = get_thread(int_to_id(i));
ModelAction *act = th->get_pending();
- if (act && is_enabled(th) && !execution->check_action_enabled(act)) {
+ if (act && execution->is_enabled(th) && !execution->check_action_enabled(act)) {
scheduler->sleep(th);
}
}