add some support for traceanalysis plugins
[model-checker.git] / model.cc
index 569dd472bab4aeb908e0e1df60d50540cf607d87..0f2f0366ebf136f448965c2d5449e317b199ca30 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -16,6 +16,7 @@
 #include "datarace.h"
 #include "threads-model.h"
 #include "output.h"
+#include "traceanalysis.h"
 
 #define INITIAL_THREAD_ID      0
 
@@ -92,6 +93,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 *>()),
        priv(new struct model_snapshot_members()),
        mo_graph(new CycleGraph())
 {
@@ -121,6 +123,9 @@ ModelChecker::~ModelChecker()
        delete thrd_last_action;
        delete thrd_last_fence_release;
        delete node_stack;
+       for (unsigned int i = 0; i <trace_analyses->size();i++)
+               delete (*trace_analyses)[i];
+       delete trace_analyses;
        delete scheduler;
        delete mo_graph;
        delete priv;
@@ -553,6 +558,7 @@ bool ModelChecker::next_execution()
                        assert_bug("Deadlock detected");
 
                checkDataRaces();
+               run_trace_analyses();
        }
 
        record_stats();
@@ -578,6 +584,15 @@ bool ModelChecker::next_execution()
        return true;
 }
 
+/**
+ * @brief Run trace analyses on complete trace. */
+
+void ModelChecker::run_trace_analyses() {
+       for(unsigned int i=0; i < trace_analyses->size(); i++) {
+               (*trace_analyses)[i]->analyze(action_trace);
+       }
+}
+
 /**
  * @brief Find the last fence-related backtracking conflict for a ModelAction
  *
@@ -1500,8 +1515,6 @@ ModelAction * ModelChecker::check_current_action(ModelAction *curr)
        bool newly_explored = initialize_curr_action(&curr);
 
        DBG();
-       if (DBG_ENABLED())
-               curr->print();
 
        wake_up_sleeping_actions(curr);
 
@@ -1798,16 +1811,15 @@ bool ModelChecker::check_recency(ModelAction *curr, const T *rf) const
 }
 
 /**
- * Updates the mo_graph with the constraints imposed from the current
+ * @brief Updates the mo_graph with the constraints imposed from the current
  * read.
  *
  * Basic idea is the following: Go through each other thread and find
  * the last action that happened before our read.  Two cases:
  *
- * (1) The action is a write => that write must either occur before
+ * -# The action is a write: that write must either occur before
  * the write we read from or be the write we read from.
- *
- * (2) The action is a read => the write that that action read from
+ * -# The action is a read: the write that that action read from
  * must occur before the write we read from or be the same write.
  *
  * @param curr The current action. Must be a read.