After tested under windows.
[dyninst.git] / patchAPI / h / common.h
1 #ifndef PATCHAPI_H_COMMON_H_
2 #define PATCHAPI_H_COMMON_H_
3
4 // C++
5 #include <list>
6 #include <set>
7 #include <map>
8 #include <iterator>
9 #include <iostream>
10
11 // ParseAPI
12 #include "CFG.h"
13 #include "CodeObject.h"
14
15 // InstructionAPI
16 #include "Instruction.h"
17 #include "InstructionDecoder.h"
18
19 // Old Dyninst
20 #include "dyn_detail/boost/shared_ptr.hpp"
21 #include "dyn_detail/boost/enable_shared_from_this.hpp"
22 #include "dyntypes.h"
23 #include "common/h/IntervalTree.h"
24 #include "common/h/Types.h"
25
26 // For debug
27 extern PATCHAPI_EXPORT bool debug_patchapi_flag;
28 #define patch_cerr if (debug_patchapi_flag) std::cerr
29
30 // For formating debug information
31 #define  ws2 "  "
32 #define  ws4 "    "
33 #define  ws6 "      "
34 #define  ws8 "        "
35 #define ws10 "          "
36 #define ws12 "            "
37 #define ws14 "              "
38 #define ws16 "                "
39 #define ws18 "                  "
40 #define ws20 "                    "
41
42 namespace Dyninst {
43 namespace PatchAPI {
44
45 class AddrSpace;
46 typedef dyn_detail::boost::shared_ptr<AddrSpace> AddrSpacePtr;
47
48 class CFGMaker;
49 typedef dyn_detail::boost::shared_ptr<CFGMaker> CFGMakerPtr;
50
51 class PatchObject;
52
53 class PointMaker;
54 typedef dyn_detail::boost::shared_ptr<PointMaker> PointMakerPtr;
55
56 class Point;
57 typedef std::set<Point*> PointSet;
58 typedef PointSet::iterator PointIter;
59
60 class Instance;
61 typedef dyn_detail::boost::shared_ptr<Instance> InstancePtr;
62 typedef std::set<InstancePtr> InstanceSet;
63 typedef std::list<InstancePtr> InstanceList;
64
65 class Instrumenter;
66 typedef dyn_detail::boost::shared_ptr<Instrumenter> InstrumenterPtr;
67
68 class Linker;
69 typedef dyn_detail::boost::shared_ptr<Linker> LinkerPtr;
70
71 class PatchMgr;
72 typedef dyn_detail::boost::shared_ptr<PatchMgr> PatchMgrPtr;
73
74 class Snippet;
75 typedef dyn_detail::boost::shared_ptr<Snippet> SnippetPtr;
76
77 class PatchFunction;
78 class PatchBlock;
79 class PatchEdge;
80
81 class Relocator;
82 class Modificator;
83 class SnippetGenerator;
84
85 typedef std::map<PatchFunction*, PatchFunction*> FuncModMap;
86
87 // This is a little complex, so let me explain my logic
88 // Map from B -> F_c -> F
89 // B identifies a call site
90 // F_c identifies an (optional) function context for the replacement
91 //   ... if F_c is not specified, we use NULL
92 // F specifies the replacement callee; if we want to remove the call entirely,
93 // also use NULL
94 typedef std::map<PatchBlock*, std::map<PatchFunction*, PatchFunction*> > CallModMap;
95
96 typedef std::set<ParseAPI::CodeObject*> CodeObjectSet;
97 typedef std::set<ParseAPI::CodeSource*> CodeSourceSet;
98 }
99 }
100
101 using std::map;
102 using std::list;
103 using std::set;
104 using std::vector;
105 using std::cerr;
106
107 #endif  // PATCHAPI_H_COMMON_H_