X-Git-Url: http://demsky.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=model.cc;h=230607a0137c957ab475ae0aee3d32f960e231c1;hp=8e94561531ca063ccbd23bec2bf51d778530a95d;hb=2d0d4ac38e05905a6633b3f2d5112ccadd45c27f;hpb=634ad19a6e82ddefd9c30d01523fc7fb42540c4c diff --git a/model.cc b/model.cc index 8e94561..230607a 100644 --- a/model.cc +++ b/model.cc @@ -24,7 +24,7 @@ ModelChecker::ModelChecker(struct model_params params) : params(params), scheduler(new Scheduler()), node_stack(new NodeStack()), - execution(new ModelExecution(this, ¶ms, scheduler, node_stack)), + execution(new ModelExecution(this, &this->params, scheduler, node_stack)), execution_number(1), diverge(NULL), earliest_diverge(NULL), @@ -36,8 +36,6 @@ ModelChecker::ModelChecker(struct model_params params) : ModelChecker::~ModelChecker() { delete node_stack; - for (unsigned int i = 0; i < trace_analyses.size(); i++) - delete trace_analyses[i]; delete scheduler; } @@ -199,15 +197,13 @@ void ModelChecker::assert_user_bug(const char *msg) /** @brief Print bug report listing for this execution (if any bugs exist) */ void ModelChecker::print_bugs() const { - if (execution->have_bug_reports()) { - SnapVector *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 *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(); } /** @@ -245,7 +241,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,10 +251,12 @@ void ModelChecker::print_stats() const */ void ModelChecker::print_execution(bool printbugs) const { + model_print("Program output from execution %d:\n", + get_execution_number()); print_program_output(); - if (params.verbose) { - model_print("Earliest divergence point since last feasible execution:\n"); + if (params.verbose >= 2) { + model_print("\nEarliest divergence point since last feasible execution:\n"); if (earliest_diverge) earliest_diverge->print(); else @@ -268,8 +267,10 @@ void ModelChecker::print_execution(bool printbugs) const } /* Don't print invalid bugs */ - if (printbugs) + if (printbugs && execution->have_bug_reports()) { + model_print("\n"); print_bugs(); + } model_print("\n"); execution->print_summary(); @@ -350,26 +351,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 @@ -444,7 +425,7 @@ void ModelChecker::run() * thread which just took a step--plus the first step * for any newly-created thread */ - for (unsigned int i = 0; i < execution->get_num_threads(); i++) { + for (unsigned int i = 0; i < get_num_threads(); i++) { thread_id_t tid = int_to_id(i); Thread *thr = get_thread(tid); if (!thr->is_model_thread() && !thr->is_complete() && !thr->get_pending()) { @@ -458,7 +439,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); } } @@ -485,4 +466,8 @@ void ModelChecker::run() model_print("******* Model-checking complete: *******\n"); print_stats(); + + /* Have the trace analyses dump their output. */ + for (unsigned int i = 0; i < trace_analyses.size(); i++) + trace_analyses[i]->finish(); }