X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=model.cc;h=72a8d13385fa7d3a78863f3bd83e2d235a2c90cd;hb=a2e32839cc2d45b6f8f559061ac4315acc628396;hp=16d5db4ab280262d1c4439de6544a413f8ba794e;hpb=fb6d374952284313141eaee75ecd322209d152db;p=model-checker.git diff --git a/model.cc b/model.cc index 16d5db4..72a8d13 100644 --- a/model.cc +++ b/model.cc @@ -2,6 +2,7 @@ #include #include #include +#include #include "model.h" #include "action.h" @@ -30,6 +31,7 @@ ModelChecker::ModelChecker(struct model_params params) : earliest_diverge(NULL), trace_analyses() { + memset(&stats,0,sizeof(struct execution_stats)); } /** @brief Destructor */ @@ -241,7 +243,8 @@ void ModelChecker::print_stats() const 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()); } /** @@ -254,7 +257,7 @@ void ModelChecker::print_execution(bool printbugs) const get_execution_number()); print_program_output(); - if (params.verbose >= 2) { + if (params.verbose >= 3) { model_print("\nEarliest divergence point since last feasible execution:\n"); if (earliest_diverge) earliest_diverge->print(); @@ -302,7 +305,7 @@ bool ModelChecker::next_execution() 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(); @@ -320,6 +323,9 @@ bool ModelChecker::next_execution() execution_number++; + if (params.maxexecutions != 0 && stats.num_complete >= params.maxexecutions) + return false; + reset_to_initial_state(); return true; } @@ -350,26 +356,6 @@ Thread * ModelChecker::get_thread(const ModelAction *act) const 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 @@ -458,7 +444,7 @@ void ModelChecker::run() 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); } }