d6fa3a4fba861915d0e6cd87e615405d38898158
[c11tester.git] / newfuzzer.h
1 #ifndef __NEWFUZZER_H__
2 #define __NEWFUZZER_H__
3
4 #include "fuzzer.h"
5 #include "classlist.h"
6 #include "mymemory.h"
7 #include "stl-model.h"
8
9 class NewFuzzer : public Fuzzer {
10 public:
11         NewFuzzer();
12         int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
13         Predicate * get_selected_child_branch(thread_id_t tid);
14         bool has_paused_threads();
15
16         Thread * selectThread(int * threadlist, int numthreads);
17         Thread * selectNotify(action_list_t * waiters);
18         bool shouldSleep(const ModelAction * sleep);
19         bool shouldWake(const ModelAction * sleep);
20         bool shouldWait(const ModelAction * wait);
21
22         void register_engine(ModelHistory * history, ModelExecution * execution);
23
24         SNAPSHOTALLOC
25 private:
26         ModelHistory * history;
27         ModelExecution * execution;
28
29         SnapVector<ModelAction *> thrd_last_read_act;
30         SnapVector<Predicate *> thrd_curr_pred;
31         SnapVector<Predicate *> thrd_selected_child_branch;
32         SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
33
34         bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map);
35         Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
36
37         /* Threads put to sleep by NewFuzzer because no writes in rf_set satisfies the selected predicate.
38          * Only used by selectWrite;
39          */
40         SnapVector<Thread *> paused_thread_set;
41
42         void conditional_sleep(Thread * thread);
43         void wake_up_paused_threads(int * threadlist, int * numthreads);
44         bool notify_conditional_sleep(Thread * thread);
45 };
46
47 #endif /* end of __NEWFUZZER_H__ */