Merge cleanup code from Brian N.
authorBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 00:09:53 +0000 (17:09 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 16 Apr 2013 00:10:32 +0000 (17:10 -0700)
bugmessage.h [new file with mode: 0644]
main.cc
model.cc
model.h
params.h [new file with mode: 0644]
scanalysis.h
traceanalysis.h

diff --git a/bugmessage.h b/bugmessage.h
new file mode 100644 (file)
index 0000000..bd7d0b6
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef __BUGMESSAGE_H__
+#define __BUGMESSAGE_H__
+
+#include "common.h"
+#include "mymemory.h"
+
+struct bug_message {
+       bug_message(const char *str) {
+               const char *fmt = "  [BUG] %s\n";
+               msg = (char *)snapshot_malloc(strlen(fmt) + strlen(str));
+               sprintf(msg, fmt, str);
+       }
+       ~bug_message() { if (msg) snapshot_free(msg); }
+
+       char *msg;
+       void print() { model_print("%s", msg); }
+
+       SNAPSHOTALLOC
+};
+
+#endif /* __BUGMESSAGE_H__ */
diff --git a/main.cc b/main.cc
index 815a382360d5ed87763fe64e5bdf497cdeb243ae..689fe9dd4dbd3698e66d5bfe5adfbd66330efbe6 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -11,6 +11,7 @@
 
 /* global "model" object */
 #include "model.h"
+#include "params.h"
 #include "snapshot-interface.h"
 #include "scanalysis.h"
 
index 3be75b250a9d6f3cd172f7cec2eebbe7529742fe..a7558c8c3a67dba4636264dd038d0204d37009c7 100644 (file)
--- a/model.cc
+++ b/model.cc
 #include "threads-model.h"
 #include "output.h"
 #include "traceanalysis.h"
+#include "bugmessage.h"
 
 #define INITIAL_THREAD_ID      0
 
 ModelChecker *model;
 
-struct bug_message {
-       bug_message(const char *str) {
-               const char *fmt = "  [BUG] %s\n";
-               msg = (char *)snapshot_malloc(strlen(fmt) + strlen(str));
-               sprintf(msg, fmt, str);
-       }
-       ~bug_message() { if (msg) snapshot_free(msg); }
-
-       char *msg;
-       void print() { model_print("%s", msg); }
-
-       SNAPSHOTALLOC
-};
-
 /**
  * Structure for holding small ModelChecker members that should be snapshotted
  */
@@ -93,7 +80,7 @@ ModelChecker::ModelChecker(struct model_params params) :
        thrd_last_action(new SnapVector<ModelAction *>(1)),
        thrd_last_fence_release(new SnapVector<ModelAction *>()),
        node_stack(new NodeStack()),
-       trace_analyses(new ModelVector<Trace_Analysis *>()),
+       trace_analyses(new ModelVector<TraceAnalysis *>()),
        priv(new struct model_snapshot_members()),
        mo_graph(new CycleGraph())
 {
@@ -3113,6 +3100,12 @@ void user_main_wrapper(void *)
        user_main(model->params.argc, model->params.argv);
 }
 
+/** @return True if the execution has taken too many steps */
+bool ModelChecker::too_many_steps() const
+{
+       return params.bound != 0 && priv->used_sequence_numbers > params.bound;
+}
+
 bool ModelChecker::should_terminate_execution()
 {
        /* Infeasible -> don't take any more steps */
@@ -3123,7 +3116,7 @@ bool ModelChecker::should_terminate_execution()
                return true;
        }
 
-       if (params.bound != 0 && priv->used_sequence_numbers > params.bound)
+       if (too_many_steps())
                return true;
        return false;
 }
diff --git a/model.h b/model.h
index b5c7c30520cb7138cb4219bf8c35a21a6c69d0ab..d5b0e76196b4fac41150d6638fc838ba8b38eeb9 100644 (file)
--- a/model.h
+++ b/model.h
@@ -15,6 +15,7 @@
 #include "modeltypes.h"
 #include "stl-model.h"
 #include "context.h"
+#include "params.h"
 
 /* Forward declaration */
 class Node;
@@ -24,46 +25,13 @@ class Promise;
 class Scheduler;
 class Thread;
 class ClockVector;
-class Trace_Analysis;
+class TraceAnalysis;
 struct model_snapshot_members;
 
 /** @brief Shorthand for a list of release sequence heads */
 typedef ModelVector<const ModelAction *> rel_heads_list_t;
 typedef SnapList<ModelAction *> action_list_t;
 
-/**
- * Model checker parameter structure. Holds run-time configuration options for
- * the model checker.
- */
-struct model_params {
-       int maxreads;
-       int maxfuturedelay;
-       bool yieldon;
-       bool sc_trace_analysis;
-       unsigned int fairwindow;
-       unsigned int enabledcount;
-       unsigned int bound;
-       unsigned int uninitvalue;
-
-       /** @brief Maximum number of future values that can be sent to the same
-        *  read */
-       int maxfuturevalues;
-
-       /** @brief Only generate a new future value/expiration pair if the
-        *  expiration time exceeds the existing one by more than the slop
-        *  value */
-       unsigned int expireslop;
-
-       /** @brief Verbosity (0 = quiet; 1 = noisy) */
-       int verbose;
-
-       /** @brief Command-line argument count to pass to user program */
-       int argc;
-
-       /** @brief Command-line arguments to pass to user program */
-       char **argv;
-};
-
 /** @brief Model checker execution stats */
 struct execution_stats {
        int num_total; /**< @brief Total number of executions */
@@ -138,7 +106,7 @@ public:
 
        const model_params params;
        Node * get_curr_node() const;
-       void add_trace_analysis(Trace_Analysis * a) {
+       void add_trace_analysis(TraceAnalysis *a) {
                trace_analyses->push_back(a);
        }
 
@@ -252,7 +220,7 @@ private:
        SnapVector<ModelAction *> * const thrd_last_action;
        SnapVector<ModelAction *> * const thrd_last_fence_release;
        NodeStack * const node_stack;
-       ModelVector<Trace_Analysis *> * trace_analyses;
+       ModelVector<TraceAnalysis *> * trace_analyses;
 
 
        /** Private data members that should be snapshotted. They are grouped
@@ -287,6 +255,7 @@ private:
        bool is_feasible_prefix_ignore_relseq() const;
        bool is_infeasible() const;
        bool is_deadlocked() const;
+       bool too_many_steps() const;
        bool is_complete_execution() const;
        bool have_bug_reports() const;
        void print_bugs() const;
diff --git a/params.h b/params.h
new file mode 100644 (file)
index 0000000..946c801
--- /dev/null
+++ b/params.h
@@ -0,0 +1,37 @@
+#ifndef __PARAMS_H__
+#define __PARAMS_H__
+
+/**
+ * Model checker parameter structure. Holds run-time configuration options for
+ * the model checker.
+ */
+struct model_params {
+       int maxreads;
+       int maxfuturedelay;
+       bool yieldon;
+       bool sc_trace_analysis;
+       unsigned int fairwindow;
+       unsigned int enabledcount;
+       unsigned int bound;
+       unsigned int uninitvalue;
+
+       /** @brief Maximum number of future values that can be sent to the same
+        *  read */
+       int maxfuturevalues;
+
+       /** @brief Only generate a new future value/expiration pair if the
+        *  expiration time exceeds the existing one by more than the slop
+        *  value */
+       unsigned int expireslop;
+
+       /** @brief Verbosity (0 = quiet; 1 = noisy) */
+       int verbose;
+
+       /** @brief Command-line argument count to pass to user program */
+       int argc;
+
+       /** @brief Command-line arguments to pass to user program */
+       char **argv;
+};
+
+#endif /* __PARAMS_H__ */
index f9db2db74693d4e4706dc08a2462d1e842f2bb3d..06fc2ed54d7cc0b04bd04071a2649895e4a4ef05 100644 (file)
@@ -3,7 +3,7 @@
 #include "traceanalysis.h"
 #include "hashtable.h"
 
-class SCAnalysis : public Trace_Analysis {
+class SCAnalysis : public TraceAnalysis {
  public:
        SCAnalysis();
        ~SCAnalysis();
index a0b1b5cf920d77747b99227c5d076766c3601c7b..8376bbcf10c1fa433f18ff8bb8501727e649a15f 100644 (file)
@@ -2,7 +2,7 @@
 #define TRACE_ANALYSIS_H
 #include "model.h"
 
-class Trace_Analysis {
+class TraceAnalysis {
  public:
        virtual void analyze(action_list_t *) = 0;
        SNAPSHOTALLOC