model_thread = new Thread(get_next_id());
add_thread(model_thread);
scheduler->register_engine(this);
+ fuzzer->register_engine(m->get_history(), this);
}
/** @brief Destructor */
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:
};
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)
/** The scheduler to use: tracks the running/ready Threads */
Scheduler * const scheduler;
+ ModelHistory * history;
ModelExecution *execution;
Thread * init_thread;
- ModelHistory *history;
int execution_number;
#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;
}
+
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__ */