Select a new predicate branch when the selected branch in the predicate tree fails...
[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         void notify_paused_thread(Thread * thread);
16
17         Thread * selectThread(int * threadlist, int numthreads);
18         Thread * selectNotify(action_list_t * waiters);
19         bool shouldSleep(const ModelAction * sleep);
20         bool shouldWake(const ModelAction * sleep);
21         bool shouldWait(const ModelAction * wait);
22
23         void register_engine(ModelHistory * history, ModelExecution * execution);
24
25         SNAPSHOTALLOC
26 private:
27         ModelHistory * history;
28         ModelExecution * execution;
29
30         SnapVector<ModelAction *> thrd_last_read_act;
31         SnapVector<FuncInst *> thrd_last_func_inst;
32
33         SnapVector<Predicate *> thrd_selected_child_branch;
34         SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
35
36         bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map);
37         Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
38
39         /* The set of Threads put to sleep by NewFuzzer because no writes in rf_set satisfies the selected predicate. Only used by selectWrite.
40          */
41         SnapVector<Thread *> paused_thread_list;
42         HashTable<Thread *, int, uintptr_t, 0> paused_thread_table;
43         HashTable<Predicate *, bool, uintptr_t, 0> failed_predicates;
44
45         void conditional_sleep(Thread * thread);
46         void wake_up_paused_threads(int * threadlist, int * numthreads);
47
48         bool find_threads(ModelAction * pending_read);
49 };
50
51 #endif /* end of __NEWFUZZER_H__ */