Merge branch 'master' into branch-weiyu
[c11tester.git] / history.h
1 #ifndef __HISTORY_H__
2 #define __HISTORY_H__
3
4 #include "stl-model.h"
5 #include "common.h"
6 #include "hashtable.h"
7 #include "hashset.h"
8 #include "threads-model.h"
9
10
11 class ModelHistory {
12 public:
13         ModelHistory();
14         ~ModelHistory();
15
16         void enter_function(const uint32_t func_id, thread_id_t tid);
17         void exit_function(const uint32_t func_id, thread_id_t tid);
18
19         uint32_t get_func_counter() { return func_counter; }
20         void incr_func_counter() { func_counter++; }
21
22         void resize_func_nodes(uint32_t max_func_id);
23         void process_action(ModelAction *act, thread_id_t tid);
24
25         HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> * getFuncMap() { return &func_map; }
26         ModelVector<const char *> * getFuncMapRev() { return &func_map_rev; }
27
28         ModelVector<FuncNode *> * getFuncNodes() { return &func_nodes; }
29         FuncNode * get_func_node(uint32_t func_id);
30         uint64_t query_last_read(void * location, thread_id_t tid);
31
32         void add_to_write_history(void * location, uint64_t write_val);
33         HashTable<void *, write_set_t *, uintptr_t, 4> * getWriteHistory() { return &write_history; }
34
35         void set_new_exec_flag();
36         void print_write();
37         void print_func_node();
38
39         MEMALLOC
40 private:
41         uint32_t func_counter;
42
43         /* map function names to integer ids */
44         HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> func_map;
45         /* map integer ids to function names */
46         ModelVector<const char *> func_map_rev;
47
48         ModelVector<FuncNode *> func_nodes;
49
50         HashTable<void *, write_set_t *, uintptr_t, 4> write_history;
51         HashSet<void *, uintptr_t, 4> write_locations;
52 };
53
54 #endif  /* __HISTORY_H__ */