bug fixes
[c11tester.git] / history.h
1 #include "stl-model.h"
2 #include "common.h"
3 #include "hashtable.h"
4 #include "modeltypes.h"
5
6 /* forward declaration */
7 class ModelAction;
8
9 typedef ModelList<ModelAction *> action_mlist_t;
10
11 class ModelHistory {
12 public:
13         ModelHistory();
14
15         void enter_function(const uint32_t func_id, thread_id_t tid);
16         void exit_function(const uint32_t func_id, thread_id_t tid);
17
18         uint32_t get_func_counter() { return func_id; }
19         void incr_func_counter() { func_id++; }
20
21         HashTable<const char *, uint32_t, uintptr_t, 4> * getFuncMap() { return &func_map; }
22         HashTable<uint32_t, action_mlist_t *, uintptr_t, 4> * getFuncHistory() { return &func_history; }
23
24         void print();
25
26 private:
27         uint32_t func_id;
28
29         /* map function names to integer ids */
30         HashTable<const char *, uint32_t, uintptr_t, 4> func_map;
31
32         HashTable<uint32_t, action_mlist_t *, uintptr_t, 4> func_history;
33
34         /* work_list stores a list of function ids for each thread
35          * SnapList<uint32_t> is intended to be used as a stack storing
36          * the functions that thread i has entered and yet to exit from
37          */
38         HashTable<thread_id_t, SnapList<uint32_t> *, uintptr_t, 4> work_list;
39 };