Adding support to return global segments of the process using the /proc/maps
[c11tester.git] / tree.h~
1 #ifndef __TREE_H__
2 #define __TREE_H__
3 #include "mymemory.h"
4 #include <set>
5 #include <map>
6 #include <cstddef>
7 #include "threads.h"
8
9 class ModelAction;
10
11 /*
12  * An n-ary tree
13  *
14  * A tree with n possible branches from each node - used for recording the
15  * execution paths we've executed / backtracked
16  */
17 class TreeNode {
18 public:
19         TreeNode(TreeNode *par = NULL, ModelAction *act = NULL);
20         ~TreeNode();
21         bool hasBeenExplored(thread_id_t id) { return children.find(id_to_int(id)) != children.end(); }
22         TreeNode * explore_child(ModelAction *act);
23         thread_id_t getNextBacktrack();
24
25         /* Return 1 if already in backtrack, 0 otherwise */
26         int setBacktrack(thread_id_t id);
27         TreeNode * getRoot();
28         static int getTotalNodes() { return TreeNode::totalNodes; }
29
30         bool is_enabled(Thread *t);
31   MEMALLOC
32 private:
33         TreeNode *parent;
34         std::map<int, class TreeNode *, std::less< int >, MyAlloc< std::pair< const int, class TreeNode * > > > children;
35         std::set<int, std::less< int >, MyAlloc< int > > backtrack;
36         static int totalNodes;
37         int num_threads;
38 };
39
40 #endif /* __TREE_H__ */