X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fcore%2FInformationManager.hxx;h=3407113e3324bd14c573a844780ed66926f01557;hp=9285d5fdd92658e3196ec7b340110b40d7bf4e5b;hb=c81c0d3dba088b302187d7862a62ca88d2306e24;hpb=6375df7c896a8a0e4be6959392848f28b021073c diff --git a/src/core/InformationManager.hxx b/src/core/InformationManager.hxx index 9285d5f..3407113 100644 --- a/src/core/InformationManager.hxx +++ b/src/core/InformationManager.hxx @@ -1,54 +1,140 @@ #ifndef INCLUDE__InformationManager_hxx #define INCLUDE__InformationManager_hxx +#include #include #include #include +#include +#include + +#include "disassembler/Disassembler.hxx" + +class Interpreter; -class Disassembler; class Function; +class BasicBlock; +class Comment; + +class RenameFunctionEvent; +class NewFunctionEvent; +class ChangeCommentEvent; + +class QString; +class QTemporaryFile; +class QPluginLoader; + +using boost::signals2::connection; class InformationManager { public: - boost::signals2::connection - connect_new_function_signal(std::function f) { - return new_function_signal.connect(f); - } + InformationManager(); + ~InformationManager(); + + void reset(const std::string& filename); + void load(const std::string& filename); + void save(const std::string& filename); - void signal_new_function(Function* f) { - new_function_signal(f); - } + Disassembler* getDisassembler() + { return disassembler.get(); } - boost::signals2::connection - connect_new_dyn_symbol_signal(std::function f) { - return new_dyn_symbol_signal.connect(f); - } + // Rename Function + typedef std::function RenameFunctionHandler; + connection registerRenameFunctionEvent(RenameFunctionHandler h) + { return renameFunctionSignal.connect(h); } + void dispatch(RenameFunctionEvent* event) + { renameFunctionSignal(event); } - void signal_new_dyn_symbol(const std::string& f) { - new_dyn_symbol_signal(f); - } + // New Function + typedef std::function NewFunctionHandler; + connection registerNewFunctionEvent(NewFunctionHandler h) + { return newFunctionSignal.connect(h); } + void dispatch(NewFunctionEvent* event) + { newFunctionSignal(event); } - boost::signals2::connection - connect_reset_signal(std::function f) { - return reset_signal.connect(f); - } + // Change Comment + typedef std::function ChangeCommentHandler; + connection registerChangeCommentEvent(ChangeCommentHandler h) + { return changeCommentSignal.connect(h); } + void dispatch(ChangeCommentEvent* event) + { changeCommentSignal(event); } - // boost::signals2::connection - // connect_information_added_signal(uint64_t begin, uint64_t end, - // std::function) { + connection connect_reset_signal(std::function f) + { return reset_signal.connect(f); } - // } + Function* getFunction(uint64_t address); + bool hasFunctions() const {return functions.size() != 0;} + std::map::const_iterator beginFunctions(); + std::map::const_iterator endFunctions(); - Disassembler* getDisassembler() { - return disassembler.get(); - } + BasicBlock* getBasicBlock(uint64_t address); + bool hasBasicBlocks() const {return blocks.size() != 0;} + std::map::const_iterator beginBasicBlocks(); + std::map::const_iterator endBasicBlocks(); + + std::pair< + std::multimap::const_iterator, + std::multimap::const_iterator> + getComments(uint64_t address); + bool hasComments() const {return ! comments.empty();} + std::multimap::const_iterator beginComments(); + std::multimap::const_iterator endComments(); + + Interpreter* getInterpreter(const std::string& name); + bool hasInterpreters() const {return interpreters.size() != 0;} + std::map::const_iterator beginInterpreters(); + std::map::const_iterator endInterpreters(); + + /* Protocoll: + * + * Users may allocate new Data containers with the new*() + * functions. Once they have populated the information they hand + * over the object to the information manager using the finish*() + * functions. + * + * if new*() returns NULL there already exists a function at the + * specified address. Users may then get the old object if they + * wish or (more likely) skip creating it. Uniqueness of the + * object is only guaranteed as compared to the finish()ed + * objects. + * + * Users are responsible for destroying functions iff they do not + * finish them using the delete*() functions. Once the objects are + * finished, the information manager is responsible for cleaning + * up the memory. If delete*() is called on a finished object, bad + * thingsmay happen. + */ + Function* newFunction(uint64_t address); + Function* newDynamicFunction(uint64_t address); + BasicBlock* newBasicBlock(uint64_t address); + Comment* newGlobalComment(uint64_t address); + Comment* newLocalComment(uint64_t address, Function* f); + void finishFunction(Function* f); + void finishBasicBlock(BasicBlock* b); + void finishComment(Comment* c); + void deleteFunction(Function* f); + void deleteBasicBlock(BasicBlock* b); + void deleteComment(Comment* c); - void reset(const std::string& filename); private: + boost::signals2::signal renameFunctionSignal; + boost::signals2::signal newFunctionSignal; + boost::signals2::signal changeCommentSignal; + boost::signals2::signal reset_signal; - boost::signals2::signal new_function_signal; - boost::signals2::signal new_dyn_symbol_signal; + std::unique_ptr disassembler; + + std::map interpreters; + std::map functions; + std::map blocks; + std::multimap comments; + + std::string filename; + std::unique_ptr tmpfile; + std::vector plugins; + + log4cxx::LoggerPtr logger; }; #endif /* INCLUDE__InformationManager_hxx */