]> git.siccegge.de Git - frida/frida.git/blob - src/core/InformationManager.hxx
Reenable Qt Signal keywords
[frida/frida.git] / src / core / InformationManager.hxx
1 #ifndef INCLUDE__InformationManager_hxx
2 #define INCLUDE__InformationManager_hxx
3
4 #include <log4cxx/logger.h>
5 #include <functional>
6 #include <string>
7 #include <map>
8 #include <vector>
9 #include <memory>
10
11 #include "qt.hxx"
12 #include "disassembler/Disassembler.hxx"
13
14 class Interpreter;
15
16 class Function;
17 class BasicBlock;
18 class Comment;
19
20 class RenameFunctionEvent;
21 class NewFunctionEvent;
22 class ChangeCommentEvent;
23
24 class QString;
25 class QTemporaryFile;
26 class QPluginLoader;
27
28 class InformationManager : public QObject {
29 #ifndef SWIG
30 Q_OBJECT
31 signals:
32 #else
33 public:
34 #endif
35 void renameFunctionEvent(RenameFunctionEvent* event);
36 void newFunctionEvent(NewFunctionEvent* event);
37 void changeCommentEvent(ChangeCommentEvent* event);
38 void reset();
39 public:
40 InformationManager();
41 ~InformationManager();
42
43 void reset(const std::string& filename);
44 void load(const std::string& filename);
45 void save(const std::string& filename);
46
47 Disassembler* getDisassembler()
48 { return disassembler.get(); }
49
50 // Accessors
51 Function* getFunction(uint64_t address);
52 bool hasFunctions() const {return functions.size() != 0;}
53 std::map<uint64_t, Function*>::const_iterator beginFunctions();
54 std::map<uint64_t, Function*>::const_iterator endFunctions();
55
56 BasicBlock* getBasicBlock(uint64_t address);
57 bool hasBasicBlocks() const {return blocks.size() != 0;}
58 std::map<uint64_t, BasicBlock*>::const_iterator beginBasicBlocks();
59 std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
60
61 std::pair<
62 std::multimap<uint64_t, Comment*>::const_iterator,
63 std::multimap<uint64_t, Comment*>::const_iterator>
64 getComments(uint64_t address);
65 bool hasComments() const {return ! comments.empty();}
66 std::multimap<uint64_t,Comment*>::const_iterator beginComments();
67 std::multimap<uint64_t,Comment*>::const_iterator endComments();
68
69 Interpreter* getInterpreter(const std::string& name);
70 bool hasInterpreters() const {return interpreters.size() != 0;}
71 std::map<std::string, Interpreter*>::const_iterator beginInterpreters();
72 std::map<std::string, Interpreter*>::const_iterator endInterpreters();
73
74 /* Protocoll:
75 *
76 * Users may allocate new Data containers with the new*()
77 * functions. Once they have populated the information they hand
78 * over the object to the information manager using the finish*()
79 * functions.
80 *
81 * if new*() returns NULL there already exists a function at the
82 * specified address. Users may then get the old object if they
83 * wish or (more likely) skip creating it. Uniqueness of the
84 * object is only guaranteed as compared to the finish()ed
85 * objects.
86 *
87 * Users are responsible for destroying functions iff they do not
88 * finish them using the delete*() functions. Once the objects are
89 * finished, the information manager is responsible for cleaning
90 * up the memory. If delete*() is called on a finished object, bad
91 * thingsmay happen.
92 */
93 Function* newFunction(uint64_t address);
94 Function* newDynamicFunction(uint64_t address);
95 BasicBlock* newBasicBlock(uint64_t address);
96 Comment* newGlobalComment(uint64_t address);
97 Comment* newLocalComment(uint64_t address, Function* f);
98 void finishFunction(Function* f);
99 void finishBasicBlock(BasicBlock* b);
100 void finishComment(Comment* c);
101 void deleteFunction(Function* f);
102 void deleteBasicBlock(BasicBlock* b);
103 void deleteComment(Comment* c);
104
105 private:
106 std::unique_ptr<Disassembler> disassembler;
107
108 std::map<std::string, Interpreter*> interpreters;
109 std::map<uint64_t, Function*> functions;
110 std::map<uint64_t, BasicBlock*> blocks;
111 std::multimap<uint64_t, Comment*> comments;
112
113 std::string filename;
114 std::unique_ptr<QTemporaryFile> tmpfile;
115 std::vector<QPluginLoader*> plugins;
116
117 log4cxx::LoggerPtr logger;
118 };
119
120 #endif /* INCLUDE__InformationManager_hxx */