move code around
[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 typedef HashSet<uint64_t, uint64_t, 0, model_malloc, model_calloc, model_free> write_set_t;
11
12 class ModelHistory {
13 public:
14         ModelHistory();
15         ~ModelHistory();
16
17         void enter_function(const uint32_t func_id, thread_id_t tid);
18         void exit_function(const uint32_t func_id, thread_id_t tid);
19
20         uint32_t get_func_counter() { return func_counter; }
21         void incr_func_counter() { func_counter++; }
22
23         void resize_func_nodes(uint32_t max_func_id);
24         void process_action(ModelAction *act, thread_id_t tid);
25
26         HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> * getFuncMap() { return &func_map; }
27         ModelVector<const char *> * getFuncMapRev() { return &func_map_rev; }
28
29         ModelVector<FuncNode *> * getFuncNodes() { return &func_nodes; }
30         FuncNode * get_func_node(uint32_t func_id);
31         uint64_t query_last_read(void * location, thread_id_t tid);
32
33         void add_to_write_history(void * location, uint64_t write_val);
34
35         void print_write();
36         void print_func_node();
37
38         MEMALLOC
39 private:
40         uint32_t func_counter;
41
42         /* map function names to integer ids */
43         HashTable<const char *, uint32_t, uintptr_t, 4, model_malloc, model_calloc, model_free> func_map;
44         /* map integer ids to function names */
45         ModelVector<const char *> func_map_rev;
46
47         ModelVector<FuncNode *> func_nodes;
48
49         HashTable<void *, write_set_t *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_history;
50         HashSet<void *, uintptr_t, 4, model_malloc, model_calloc, model_free> write_locations;
51 };
52
53 #endif  /* __HISTORY_H__ */