check in test
[model-checker.git] / datarace.h
index ef1ef8ca4a256eeaede006d24c7c806fa5844103..627b8cc88c7016b27cc2660bdebdf4693e674c40 100644 (file)
@@ -1,7 +1,16 @@
+/** @file datarace.h
+ *  @brief Data race detection code.
+ */
+
 #ifndef DATARACE_H
 #include "config.h"
 #include <stdint.h>
-#include "clockvector.h"
+#include <vector>
+#include "modeltypes.h"
+
+/* Forward declaration */
+class ClockVector;
+class ModelAction;
 
 struct ShadowTable {
        void * array[65536];
@@ -11,15 +20,36 @@ struct ShadowBaseTable {
        uint64_t array[65536];
 };
 
+struct DataRace {
+       /* Clock and thread associated with first action.  This won't change in
+                response to synchronization. */
+
+       thread_id_t oldthread;
+       modelclock_t oldclock;
+       /* Record whether this is a write, so we can tell the user. */
+       bool isoldwrite;
+
+       /* Model action associated with second action.  This could change as
+                a result of synchronization. */
+       ModelAction *newaction;
+       /* Record whether this is a write, so we can tell the user. */
+       bool isnewwrite;
+
+       /* Address of data race. */
+       void *address;
+};
+
 #define MASK16BIT 0xffff
 
 void initRaceDetector();
 void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock);
 void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock);
+bool checkDataRaces();
+void printRace(struct DataRace *race);
 
+extern std::vector<struct DataRace *> unrealizedraces;
 
-
-/** Encoding idea:
+/** Basic encoding idea:
  *      (void *) Either:
  *      (1) points to a full record or
  *