b42c34b1ca99884e82a836bd016e0ceb7421c570
[c11tester.git] / history.h
1 #include "stl-model.h"
2 #include "common.h"
3 #include "hashtable.h"
4 #include "threads-model.h"
5
6 typedef SnapList<uint32_t> func_id_list_t;
7
8 class ModelHistory {
9 public:
10         ModelHistory();
11         ~ModelHistory();
12
13         void enter_function(const uint32_t func_id, thread_id_t tid);
14         void exit_function(const uint32_t func_id, thread_id_t tid);
15
16         uint32_t get_func_counter() { return func_counter; }
17         void incr_func_counter() { func_counter++; }
18
19         void add_func_atomic(ModelAction *act, thread_id_t tid);
20
21         HashTable<const char *, uint32_t, uintptr_t, 4> * getFuncMap() { return &func_map; }
22         ModelVector<FuncNode *> * getFuncAtomics() { return &func_atomics; }
23
24         void print();
25
26         MEMALLOC
27 private:
28         uint32_t func_counter;
29
30         /* map function names to integer ids */ 
31         HashTable<const char *, uint32_t, uintptr_t, 4> func_map;
32
33         ModelVector<FuncNode *> func_atomics;
34
35         /* Work_list stores a list of function ids for each thread. 
36          * Each element in work_list is intended to be used as a stack storing
37          * the functions that thread i has entered and yet to exit from 
38          */
39
40         /* todo: move work_list to execution.cc to avoid seg fault */
41         SnapVector< func_id_list_t * > work_list;
42 };