X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=datarace.cc;h=653039b3307e3ebfb195e2dc99efda36ae123a7c;hb=130a35155171503883aaf18e57f8957ce63d06e8;hp=af70041b231fbccbba9f109a8c4b282267e4a022;hpb=92dd847e38280a3bb0ec93781c47173a3848f1d7;p=model-checker.git diff --git a/datarace.cc b/datarace.cc index af70041..653039b 100644 --- a/datarace.cc +++ b/datarace.cc @@ -8,9 +8,10 @@ #include "config.h" #include "action.h" #include "execution.h" +#include "stl-model.h" static struct ShadowTable *root; -SnapVector unrealizedraces; +static SnapVector *unrealizedraces; static void *memory_base; static void *memory_top; @@ -25,6 +26,7 @@ void initRaceDetector() root = (struct ShadowTable *)snapshot_calloc(sizeof(struct ShadowTable), 1); memory_base = snapshot_calloc(sizeof(struct ShadowBaseTable) * SHADOWBASETABLES, 1); memory_top = ((char *)memory_base) + sizeof(struct ShadowBaseTable) * SHADOWBASETABLES; + unrealizedraces = new SnapVector(); } void * table_calloc(size_t size) @@ -110,7 +112,7 @@ static void reportDataRace(thread_id_t oldthread, modelclock_t oldclock, bool is race->newaction = newaction; race->isnewwrite = isnewwrite; race->address = address; - unrealizedraces.push_back(race); + unrealizedraces->push_back(race); /* If the race is realized, bail out now. */ if (checkDataRaces()) @@ -131,15 +133,15 @@ bool checkDataRaces() if (get_execution()->isfeasibleprefix()) { bool race_asserted = false; /* Prune the non-racing unrealized dataraces */ - for (unsigned i = 0; i < unrealizedraces.size(); i++) { - struct DataRace *race = unrealizedraces[i]; + for (unsigned i = 0; i < unrealizedraces->size(); i++) { + struct DataRace *race = (*unrealizedraces)[i]; if (clock_may_race(race->newaction->get_cv(), race->newaction->get_tid(), race->oldclock, race->oldthread)) { assert_race(race); race_asserted = true; } snapshot_free(race); } - unrealizedraces.clear(); + unrealizedraces->clear(); return race_asserted; } return false; @@ -354,3 +356,8 @@ void raceCheckRead(thread_id_t thread, const void *location) *shadow = ENCODEOP(threadid, ourClock, id_to_int(writeThread), writeClock); } + +bool haveUnrealizedRaces() +{ + return !unrealizedraces->empty(); +}