seems to work
[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 typedef HashTable<FuncInst *, ModelAction *, uintptr_t, 0> inst_act_map_t;
10
11 class NewFuzzer : public Fuzzer {
12 public:
13         NewFuzzer();
14         int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
15         Predicate * get_selected_child_branch(thread_id_t tid);
16         void conditional_sleep(Thread * thread);
17         bool has_paused_threads();
18         void wake_up_paused_threads(int * threadlist, int * numthreads);
19
20         Thread * selectThread(int * threadlist, int numthreads);
21         Thread * selectNotify(action_list_t * waiters);
22         bool shouldSleep(const ModelAction *sleep);
23         bool shouldWake(const ModelAction *sleep);
24
25         void register_engine(ModelHistory * history, ModelExecution * execution);
26
27         SNAPSHOTALLOC
28 private:
29         ModelHistory * history;
30         ModelExecution * execution;
31
32         SnapVector<ModelAction *> thrd_last_read_act;
33         SnapVector<Predicate *> thrd_curr_pred;
34         SnapVector<Predicate *> thrd_selected_child_branch;
35         SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
36
37         bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map);
38         Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
39
40         /* Threads put to sleep by NewFuzzer because no writes in rf_set satisfies the selected predicate.
41          * Only used by selectWrite;
42          */
43         SnapVector<Thread *> paused_thread_set;
44 };
45
46 #endif /* end of __NEWFUZZER_H__ */