model/main: disable most printing by default, add verbosity
[model-checker.git] / main.cc
diff --git a/main.cc b/main.cc
index fb4acbe75d6b530feabc4e76b111cc0f4bf4b29d..f6ab259a64bb1ddfe85ec092518fdb091f23849a 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -7,6 +7,7 @@
 #include <threads.h>
 #include "common.h"
 #include "threads-model.h"
+#include "output.h"
 
 #include "datarace.h"
 
@@ -22,13 +23,14 @@ static void param_defaults(struct model_params * params) {
        params->bound = 0;
        params->maxfuturevalues = 0;
        params->expireslop = 10;
+       params->verbose = 0;
 }
 
 static void print_usage(struct model_params *params) {
        /* Reset defaults before printing */
        param_defaults(params);
 
-       printf(
+       model_print(
 "Usage: <program name> [MC_OPTIONS] -- [PROGRAM ARGUMENTS]\n"
 "\n"
 "Options:\n"
@@ -46,13 +48,14 @@ static void print_usage(struct model_params *params) {
 "                      priority for execution. Default: %d\n"
 "-e                    Enabled count. Default: %d\n"
 "-b                    Upper length bound. Default: %d\n"
+"-v                    Print verbose execution information.\n"
 "--                    Program arguments follow.\n\n",
 params->maxreads, params->maxfuturevalues, params->maxfuturedelay, params->expireslop, params->fairwindow, params->enabledcount, params->bound);
        exit(EXIT_SUCCESS);
 }
 
 static void parse_options(struct model_params *params, int *argc, char ***argv) {
-       const char *shortopts = "hm:M:s:S:f:e:b:";
+       const char *shortopts = "hm:M:s:S:f:e:b:v";
        int opt;
        bool error = false;
        while (!error && (opt = getopt(*argc, *argv, shortopts)) != -1) {
@@ -81,6 +84,9 @@ static void parse_options(struct model_params *params, int *argc, char ***argv)
                case 'M':
                        params->maxfuturevalues = atoi(optarg);
                        break;
+               case 'v':
+                       params->verbose = 1;
+                       break;
                default: /* '?' */
                        error = true;
                        break;
@@ -130,6 +136,8 @@ static void model_main() {
                model->finish_execution();
        } while (model->next_execution());
 
+       model->print_stats();
+
        delete model;
 
        DEBUG("Exiting\n");
@@ -143,6 +151,9 @@ int main(int argc, char ** argv) {
        main_argc = argc;
        main_argv = argv;
 
+       /* Configure output redirection for the model-checker */
+       redirect_output();
+
        /* Let's jump in quickly and start running stuff */
        initSnapshotLibrary(10000, 1024, 1024, 4000, &model_main);
 }