Function wrapping implementation and Symtab extensions for undefined symbols
[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 // For debug
20 extern PATCHAPI_EXPORT bool debug_patchapi_flag;
21 #define patch_cerr if (debug_patchapi_flag) std::cerr
22
23 // For formating debug information
24 #define  ws2 "  "
25 #define  ws4 "    "
26 #define  ws6 "      "
27 #define  ws8 "        "
28 #define ws10 "          "
29 #define ws12 "            "
30 #define ws14 "              "
31 #define ws16 "                "
32 #define ws18 "                  "
33 #define ws20 "                    "
34
35 namespace Dyninst {
36 namespace PatchAPI {
37
38 class AddrSpace;
39 typedef dyn_detail::boost::shared_ptr<AddrSpace> AddrSpacePtr;
40
41 class CFGMaker;
42 typedef dyn_detail::boost::shared_ptr<CFGMaker> CFGMakerPtr;
43
44 class PatchObject;
45
46 class PointMaker;
47 typedef dyn_detail::boost::shared_ptr<PointMaker> PointMakerPtr;
48
49 class Point;
50 typedef std::set<Point*> PointSet;
51 typedef PointSet::iterator PointIter;
52
53 class Instance;
54 typedef dyn_detail::boost::shared_ptr<Instance> InstancePtr;
55 typedef std::set<InstancePtr> InstanceSet;
56 typedef std::list<InstancePtr> InstanceList;
57
58 class Instrumenter;
59 typedef dyn_detail::boost::shared_ptr<Instrumenter> InstrumenterPtr;
60
61 class Linker;
62 typedef dyn_detail::boost::shared_ptr<Linker> LinkerPtr;
63
64 class PatchMgr;
65 typedef dyn_detail::boost::shared_ptr<PatchMgr> PatchMgrPtr;
66
67 class PatchFunction;
68 class PatchBlock;
69 class PatchEdge;
70
71 class Relocator;
72 class Modificator;
73 class SnippetGenerator;
74
75 class Command;
76 typedef dyn_detail::boost::shared_ptr<Command> CommandPtr;
77 typedef std::list<CommandPtr> CommandList;
78
79 class BatchCommand;
80 typedef dyn_detail::boost::shared_ptr<BatchCommand> BatchCommandPtr;
81
82 class Patcher;
83 typedef dyn_detail::boost::shared_ptr<Patcher> PatcherPtr;
84
85 typedef dyn_detail::boost::shared_ptr<void> VoidPtr;
86 typedef VoidPtr SnippetPtr;
87
88 typedef std::map<PatchFunction*, PatchFunction*> FuncModMap;
89 typedef std::map<PatchFunction*, std::pair<PatchFunction*, std::string> > FuncWrapMap;
90
91 // This is a little complex, so let me explain my logic
92 // Map from B -> F_c -> F
93 // B identifies a call site
94 // F_c identifies an (optional) function context for the replacement
95 //   ... if F_c is not specified, we use NULL
96 // F specifies the replacement callee; if we want to remove the call entirely,
97 // also use NULL
98 typedef std::map<PatchBlock*, std::map<PatchFunction*, PatchFunction*> > CallModMap;
99
100 typedef std::set<ParseAPI::CodeObject*> CodeObjectSet;
101 typedef std::set<ParseAPI::CodeSource*> CodeSourceSet;
102 }
103 }
104
105 using std::map;
106 using std::list;
107 using std::set;
108 using std::vector;
109 using std::cerr;
110
111 #endif  // PATCHAPI_H_COMMON_H_