remove plugins
[c11tester.git] / main.cc
diff --git a/main.cc b/main.cc
index 0ca78b97a8ced2e2cd9e9188386415f0d6192997..61554eaa8e11b0d684d1d13a9df5d9a60aca2e83 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -4,6 +4,7 @@
 
 #include <unistd.h>
 #include <getopt.h>
+#include <string.h>
 
 #include "common.h"
 #include "output.h"
@@ -14,7 +15,6 @@
 #include "model.h"
 #include "params.h"
 #include "snapshot-interface.h"
-#include "scanalysis.h"
 
 static void param_defaults(struct model_params *params)
 {
@@ -23,13 +23,13 @@ static void param_defaults(struct model_params *params)
        params->fairwindow = 0;
        params->yieldon = false;
        params->yieldblock = false;
-       params->sc_trace_analysis = false;
        params->enabledcount = 1;
        params->bound = 0;
        params->maxfuturevalues = 0;
        params->expireslop = 4;
        params->verbose = !!DBG_ENABLED();
        params->uninitvalue = 0;
+       params->maxexecutions = 0;
 }
 
 static void print_usage(const char *program_name, struct model_params *params)
@@ -44,7 +44,7 @@ static void print_usage(const char *program_name, struct model_params *params)
 "\n"
 "Usage: %s [MODEL-CHECKER OPTIONS] -- [PROGRAM ARGS]\n"
 "\n"
-"MODLE-CHECKER OPTIONS can be any of the model-checker options listed below. Arguments\n"
+"MODEL-CHECKER OPTIONS can be any of the model-checker options listed below. Arguments\n"
 "provided after the `--' (the PROGRAM ARGS) are passed to the user program.\n"
 "\n"
 "Model-checker options:\n"
@@ -61,7 +61,8 @@ static void print_usage(const char *program_name, struct model_params *params)
 "                              Default: %d\n"
 "-S, --fvslop=NUM            Future value expiration sloppiness.\n"
 "                              Default: %u\n"
-"-y, --yield                 Enable CHESS-like yield-based fairness support.\n"
+"-y, --yield                 Enable CHESS-like yield-based fairness support\n"
+"                              (requires thrd_yield() in test program).\n"
 "                              Default: %s\n"
 "-Y, --yieldblock            Prohibit an execution from running a yield.\n"
 "                              Default: %s\n"
@@ -73,11 +74,18 @@ static void print_usage(const char *program_name, struct model_params *params)
 "                              Default: %d\n"
 "-b, --bound=MAX             Upper length bound.\n"
 "                              Default: %d\n"
-"-v, --verbose               Print verbose execution information.\n"
+"-v[NUM], --verbose[=NUM]    Print verbose execution information. NUM is optional:\n"
+"                              0 is quiet; 1 shows valid executions; 2 is noisy;\n"
+"                              3 is noisier.\n"
+"                              Default: %d\n"
 "-u, --uninitialized=VALUE   Return VALUE any load which may read from an\n"
 "                              uninitialized atomic.\n"
 "                              Default: %u\n"
-"-c, --analysis              Use SC Trace Analysis.\n"
+"-t, --analysis=NAME         Use Analysis Plugin.\n"
+"-o, --options=NAME          Option for previous analysis plugin.  \n"
+"-x, --maxexec=NUM           Maximum number of executions.\n"
+"                            Default: %u\n"
+"                            -o help for a list of options\n"
 " --                         Program arguments follow.\n\n",
                program_name,
                params->maxreads,
@@ -89,13 +97,17 @@ static void print_usage(const char *program_name, struct model_params *params)
                params->fairwindow,
                params->enabledcount,
                params->bound,
-               params->uninitvalue);
+               params->verbose,
+    params->uninitvalue,
+               params->maxexecutions);
+       model_print("Analysis plugins:\n");
+
        exit(EXIT_SUCCESS);
 }
 
 static void parse_options(struct model_params *params, int argc, char **argv)
 {
-       const char *shortopts = "hyYcm:M:s:S:f:e:b:u:v::";
+       const char *shortopts = "hyYt:o:m:M:s:S:f:e:b:u:x:v::";
        const struct option longopts[] = {
                {"help", no_argument, NULL, 'h'},
                {"liveness", required_argument, NULL, 'm'},
@@ -108,8 +120,10 @@ static void parse_options(struct model_params *params, int argc, char **argv)
                {"enabled", required_argument, NULL, 'e'},
                {"bound", required_argument, NULL, 'b'},
                {"verbose", optional_argument, NULL, 'v'},
-               {"uninitialized", optional_argument, NULL, 'u'},
-               {"analysis", optional_argument, NULL, 'c'},
+               {"uninitialized", required_argument, NULL, 'u'},
+               {"analysis", required_argument, NULL, 't'},
+               {"options", required_argument, NULL, 'o'},
+               {"maxexecutions", required_argument, NULL, 'x'},
                {0, 0, 0, 0} /* Terminator */
        };
        int opt, longindex;
@@ -119,6 +133,9 @@ static void parse_options(struct model_params *params, int argc, char **argv)
                case 'h':
                        print_usage(argv[0], params);
                        break;
+               case 'x':
+                       params->maxexecutions = atoi(optarg);
+                       break;
                case 's':
                        params->maxfuturedelay = atoi(optarg);
                        break;
@@ -146,12 +163,21 @@ static void parse_options(struct model_params *params, int argc, char **argv)
                case 'u':
                        params->uninitvalue = atoi(optarg);
                        break;
-               case 'c':
-                       params->sc_trace_analysis = true;
-                       break;
                case 'y':
                        params->yieldon = true;
                        break;
+/**            case 't':
+                       if (install_plugin(optarg))
+                               error = true;
+                       break;
+               case 'o':
+                       {
+                               ModelVector<TraceAnalysis *> * analyses = getInstalledTraceAnalysis();
+                               if ( analyses->size() == 0 || (*analyses)[analyses->size()-1]->option(optarg))
+                                       error = true;
+                       }
+                       break;
+*/
                case 'Y':
                        params->yieldblock = true;
                        break;
@@ -178,12 +204,6 @@ static void parse_options(struct model_params *params, int argc, char **argv)
 int main_argc;
 char **main_argv;
 
-static void install_trace_analyses(const ModelExecution *execution)
-{
-       if (model->params.sc_trace_analysis)
-               model->add_trace_analysis(new SCAnalysis(execution));
-}
-
 /** The model_main function contains the main model checking loop. */
 static void model_main()
 {
@@ -198,8 +218,8 @@ static void model_main()
 
        snapshot_stack_init();
 
-       model = new ModelChecker(params);
-       install_trace_analyses(model->get_execution());
+       model = new ModelChecker(params);       // L: Model thread is created
+//     install_trace_analyses(model->get_execution());         L: disable plugin
 
        snapshot_record(0);
        model->run();
@@ -217,6 +237,18 @@ int main(int argc, char **argv)
        main_argc = argc;
        main_argv = argv;
 
+       /*
+        * If this printf statement is removed, CDSChecker will fail on an
+        * assert on some versions of glibc.  The first time printf is
+        * called, it allocated internal buffers.  We can't easily snapshot
+        * libc since we also use it.
+        */
+
+       printf("CDSChecker\n"
+                                "Copyright (c) 2013 Regents of the University of California. All rights reserved.\n"
+                                "Distributed under the GPLv2\n"
+                                "Written by Brian Norris and Brian Demsky\n\n");
+
        /* Configure output redirection for the model-checker */
        redirect_output();