1 #ifndef INCLUDE__InformationManager_hxx
2 #define INCLUDE__InformationManager_hxx
4 #include <log4cxx/logger.h>
12 #include "disassembler/Disassembler.hxx"
14 #include "core/events/NewFunctionEvent.hxx"
22 class RenameFunctionEvent;
23 class NewFunctionEvent;
24 class ChangeCommentEvent;
30 class InformationManager : public QObject {
37 void renameFunctionEvent(RenameFunctionEvent* event);
38 void newFunctionEvent(NewFunctionEvent event);
39 void changeCommentEvent(ChangeCommentEvent* event);
43 ~InformationManager();
45 void reset(const std::string& filename);
46 void load(const std::string& filename);
47 void save(const std::string& filename);
49 Disassembler* getDisassembler()
50 { return disassembler.get(); }
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();
58 BasicBlock* getBasicBlock(uint64_t address);
59 bool hasBasicBlocks() const {return blocks.size() != 0;}
60 std::map<uint64_t, BasicBlock*>::const_iterator beginBasicBlocks();
61 std::map<uint64_t, BasicBlock*>::const_iterator endBasicBlocks();
64 std::multimap<uint64_t, Comment*>::const_iterator,
65 std::multimap<uint64_t, Comment*>::const_iterator>
66 getComments(uint64_t address);
67 bool hasComments() const {return ! comments.empty();}
68 std::multimap<uint64_t,Comment*>::const_iterator beginComments();
69 std::multimap<uint64_t,Comment*>::const_iterator endComments();
71 Interpreter* getInterpreter(const std::string& name);
72 bool hasInterpreters() const {return interpreters.size() != 0;}
73 std::map<std::string, Interpreter*>::const_iterator beginInterpreters();
74 std::map<std::string, Interpreter*>::const_iterator endInterpreters();
78 * Users may allocate new Data containers with the new*()
79 * functions. Once they have populated the information they hand
80 * over the object to the information manager using the finish*()
83 * if new*() returns NULL there already exists a function at the
84 * specified address. Users may then get the old object if they
85 * wish or (more likely) skip creating it. Uniqueness of the
86 * object is only guaranteed as compared to the finish()ed
89 * Users are responsible for destroying functions iff they do not
90 * finish them using the delete*() functions. Once the objects are
91 * finished, the information manager is responsible for cleaning
92 * up the memory. If delete*() is called on a finished object, bad
95 Function* newFunction(uint64_t address);
96 Function* newDynamicFunction(uint64_t address);
97 BasicBlock* newBasicBlock(uint64_t address);
98 Comment* newGlobalComment(uint64_t address);
99 Comment* newLocalComment(uint64_t address, Function* f);
100 void finishFunction(Function* f);
101 void finishBasicBlock(BasicBlock* b);
102 void finishComment(Comment* c);
103 void deleteFunction(Function* f);
104 void deleteBasicBlock(BasicBlock* b);
105 void deleteComment(Comment* c);
108 std::unique_ptr<Disassembler> disassembler;
110 std::map<std::string, Interpreter*> interpreters;
111 std::map<uint64_t, Function*> functions;
112 std::map<uint64_t, BasicBlock*> blocks;
113 std::multimap<uint64_t, Comment*> comments;
115 std::string filename;
116 std::unique_ptr<QTemporaryFile> tmpfile;
117 std::vector<QPluginLoader*> plugins;
119 QThread disassemblerThread;
120 log4cxx::LoggerPtr logger;
123 #endif /* INCLUDE__InformationManager_hxx */