X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=datarace.h;h=627b8cc88c7016b27cc2660bdebdf4693e674c40;hp=e3cab5d6612aeb7f5770122ad27201a5245435f1;hb=b5cdd7ee16b73bbfe53040d23994351f85f83785;hpb=9b784333e1a62ed6d258e96502a5733041389c8f diff --git a/datarace.h b/datarace.h index e3cab5d..627b8cc 100644 --- a/datarace.h +++ b/datarace.h @@ -1,7 +1,16 @@ +/** @file datarace.h + * @brief Data race detection code. + */ + #ifndef DATARACE_H #include "config.h" #include -#include "clockvector.h" +#include +#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 unrealizedraces; - -/** Encoding idea: +/** Basic encoding idea: * (void *) Either: * (1) points to a full record or * @@ -29,12 +59,12 @@ void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock); * next 23 bits are write clock vector. */ struct RaceRecord { - int *readClock; + modelclock_t *readClock; thread_id_t *thread; int capacity; int numReads; thread_id_t writeThread; - int writeClock; + modelclock_t writeClock; }; #define INITCAPACITY 4