]> git.siccegge.de Git - frida/frida.git/blob - src/core/InformationManager.hxx
Remove unused has* from InformationManager
[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 #include "core/events/NewFunctionEvent.hxx"
15
16 class Interpreter;
17
18 class Function;
19 class BasicBlock;
20 class Comment;
21
22 class RenameFunctionEvent;
23 class NewFunctionEvent;
24 class ChangeCommentEvent;
25
26 class QString;
27 class QTemporaryFile;
28 class QPluginLoader;
29
30 class InformationManager : public QObject {
31 #ifndef SWIG
32 Q_OBJECT
33 signals:
34 #else
35 public:
36 #endif
37 void renameFunctionEvent(RenameFunctionEvent* event);
38 void newFunctionEvent(NewFunctionEvent event);
39 void changeCommentEvent(ChangeCommentEvent* event);
40 void resetEvent();
41 public:
42 InformationManager();
43 ~InformationManager();
44
45 void reset(const std::string& filename);
46 void load(const std::string& filename);
47 void save(const std::string& filename);
48
49 Disassembler* getDisassembler()
50 { return disassembler.get(); }
51
52 // Accessors
53 Function* getFunction(uint64_t address);
54 bool hasFunctions() const {return functions.size() != 0;}
55 std::map<uint64_t, Function*>::const_iterator beginFunctions();
56 std::map<uint64_t, Function*>::const_iterator endFunctions();
57
58 BasicBlock* getBasicBlock(uint64_t address);
59 std::map<uint64_t, BasicBlock*>::const_iterator beginBasicBlocks();
60 std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
61
62 std::pair<
63 std::multimap<uint64_t, Comment*>::const_iterator,
64 std::multimap<uint64_t, Comment*>::const_iterator>
65 getComments(uint64_t address);
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 QThread disassemblerThread;
118 log4cxx::LoggerPtr logger;
119 };
120
121 #endif /* INCLUDE__InformationManager_hxx */