some edits to NewFuzzer
authorweiyu <weiyuluo1232@gmail.com>
Tue, 27 Aug 2019 00:27:21 +0000 (17:27 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Tue, 27 Aug 2019 00:27:21 +0000 (17:27 -0700)
execution.cc
fuzzer.h
model.cc
model.h
newfuzzer.cc
newfuzzer.h

index eefb9107b7d3d52d5f38cd702a250642c28b30f2..9ee915708edd18550266126af75ad746c8f3544e 100644 (file)
@@ -74,6 +74,7 @@ ModelExecution::ModelExecution(ModelChecker *m, Scheduler *scheduler) :
        model_thread = new Thread(get_next_id());
        add_thread(model_thread);
        scheduler->register_engine(this);
+       fuzzer->register_engine(m->get_history(), this);
 }
 
 /** @brief Destructor */
index eb6fd4ef35d7d2c05f5838829fac89962f8c23fe..d291268610721b918e48f2e7eea296a302e81479 100644 (file)
--- a/fuzzer.h
+++ b/fuzzer.h
@@ -12,6 +12,7 @@ public:
        Thread * selectNotify(action_list_t * waiters);
        bool shouldSleep(const ModelAction *sleep);
        bool shouldWake(const ModelAction *sleep);
+       virtual void register_engine(ModelHistory * history, ModelExecution * execution) {}
        MEMALLOC
 private:
 };
index 58a785923d2826673cfb259962cd306dda3cbed1..0a2e844d32e2136e582600f1858574c143f5bd53 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -33,8 +33,8 @@ ModelChecker::ModelChecker() :
        params(),
        restart_flag(false),
        scheduler(new Scheduler()),
-       execution(new ModelExecution(this, scheduler)),
        history(new ModelHistory()),
+       execution(new ModelExecution(this, scheduler)),
        execution_number(1),
        trace_analyses(),
        inspect_plugin(NULL)
diff --git a/model.h b/model.h
index 82d9bc8c4fc9853f15ed3b2d2bef7e6e1f27cf83..a3a7bc0ee8f22a059a1b9572d82a2f266f9e2a04 100644 (file)
--- a/model.h
+++ b/model.h
@@ -76,9 +76,9 @@ private:
 
        /** The scheduler to use: tracks the running/ready Threads */
        Scheduler * const scheduler;
+       ModelHistory * history;
        ModelExecution *execution;
        Thread * init_thread;
-       ModelHistory *history;
 
        int execution_number;
 
index 7bcda8f26174e00904fb45fd69517730b5e44eea..5ec1c5d2c74f792207286b32e6721bbac270742a 100644 (file)
@@ -2,9 +2,36 @@
 #include "threads-model.h"
 #include "model.h"
 #include "action.h"
+#include "execution.h"
+#include "funcnode.h"
+
+/**
+ * @brief Register the ModelHistory and ModelExecution engine
+ */
+void NewFuzzer::register_engine(ModelHistory * history, ModelExecution *execution)
+{
+       this->history = history;
+       this->execution = execution;
+}
+
 
 int NewFuzzer::selectWrite(ModelAction *read, SnapVector<ModelAction *> * rf_set)
 {
+       thread_id_t tid = read->get_tid();
+       int thread_id = id_to_int(tid);
+
+       SnapVector<func_id_list_t> * thrd_func_list = execution->get_thrd_func_list();
+       uint32_t func_id = (*thrd_func_list)[thread_id].back();
+
+       FuncNode * func_node = history->get_func_node(func_id);
+       FuncInst * read_inst = func_node->get_inst(read);
+       Predicate * curr_pred = func_node->get_predicate_tree_position(tid);
+
+       ModelVector<Predicate *> * children = curr_pred->get_children();
+       if (children->size() == 0)
+               return random() % rf_set->size();
+
        int random_index = random() % rf_set->size();
        return random_index;
 }
+
index 0fb730ab18cb78b2730000d17cc5b44033ae23ec..f50c47651fa01ded23ec65db13d951edf2e543c0 100644 (file)
@@ -14,8 +14,13 @@ public:
        Thread * selectNotify(action_list_t * waiters);
        bool shouldSleep(const ModelAction *sleep);
        bool shouldWake(const ModelAction *sleep);
+
+       void register_engine(ModelHistory * history, ModelExecution * execution);
+
        MEMALLOC
 private:
+       ModelHistory * history;
+       ModelExecution * execution;
 };
 
 #endif /* end of __NEWFUZZER_H__ */