initial commit for declaring member functions of Fuzzer as virtual
authorweiyu <weiyuluo1232@gmail.com>
Mon, 26 Aug 2019 20:26:44 +0000 (13:26 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Mon, 26 Aug 2019 20:26:44 +0000 (13:26 -0700)
classlist.h
execution.cc
fuzzer.h
newfuzzer.cc [new file with mode: 0644]
newfuzzer.h [new file with mode: 0644]

index 5a17449..e528a47 100644 (file)
@@ -15,6 +15,7 @@ class Scheduler;
 class Thread;
 class TraceAnalysis;
 class Fuzzer;
+class NewFuzzer;
 class FuncNode;
 class FuncInst;
 class Predicate;
index c6962bc..eefb910 100644 (file)
@@ -15,6 +15,7 @@
 #include "bugmessage.h"
 #include "history.h"
 #include "fuzzer.h"
+#include "newfuzzer.h"
 
 #define INITIAL_THREAD_ID       0
 
@@ -64,7 +65,7 @@ ModelExecution::ModelExecution(ModelChecker *m, Scheduler *scheduler) :
        thrd_last_fence_release(),
        priv(new struct model_snapshot_members ()),
        mo_graph(new CycleGraph()),
-       fuzzer(new Fuzzer()),
+       fuzzer(new NewFuzzer()),
        thrd_func_list(),
        thrd_func_act_lists(),
        isfinished(false)
@@ -303,7 +304,6 @@ void ModelExecution::process_read(ModelAction *curr, SnapVector<ModelAction *> *
                int index = fuzzer->selectWrite(curr, rf_set);
                ModelAction *rf = (*rf_set)[index];
 
-
                ASSERT(rf);
                bool canprune = false;
                if (r_modification_order(curr, rf, priorset, &canprune)) {
index e794d22..eb6fd4e 100644 (file)
--- a/fuzzer.h
+++ b/fuzzer.h
@@ -7,7 +7,7 @@
 class Fuzzer {
 public:
        Fuzzer() {}
-       int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
+       virtual int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
        Thread * selectThread(int * threadlist, int numthreads);
        Thread * selectNotify(action_list_t * waiters);
        bool shouldSleep(const ModelAction *sleep);
diff --git a/newfuzzer.cc b/newfuzzer.cc
new file mode 100644 (file)
index 0000000..7bcda8f
--- /dev/null
@@ -0,0 +1,10 @@
+#include "newfuzzer.h"
+#include "threads-model.h"
+#include "model.h"
+#include "action.h"
+
+int NewFuzzer::selectWrite(ModelAction *read, SnapVector<ModelAction *> * rf_set)
+{
+       int random_index = random() % rf_set->size();
+       return random_index;
+}
diff --git a/newfuzzer.h b/newfuzzer.h
new file mode 100644 (file)
index 0000000..0fb730a
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef __NEWFUZZER_H__
+#define __NEWFUZZER_H__
+
+#include "fuzzer.h"
+#include "classlist.h"
+#include "mymemory.h"
+#include "stl-model.h"
+
+class NewFuzzer : public Fuzzer {
+public:
+       NewFuzzer() {}
+       int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
+       Thread * selectThread(int * threadlist, int numthreads);
+       Thread * selectNotify(action_list_t * waiters);
+       bool shouldSleep(const ModelAction *sleep);
+       bool shouldWake(const ModelAction *sleep);
+       MEMALLOC
+private:
+};
+
+#endif /* end of __NEWFUZZER_H__ */