X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fcore%2FInformationManager.hxx;h=555070abefd624cf6e19a5b84218a58ab3b73097;hp=dc781285f049de01b2200f6a2e852ee3f21d9353;hb=3d7b4d3a5f6c17823bb79490256661ddb5e7ab83;hpb=440c4598343d9e46d8963f7753c122b121826334 diff --git a/src/core/InformationManager.hxx b/src/core/InformationManager.hxx index dc78128..555070a 100644 --- a/src/core/InformationManager.hxx +++ b/src/core/InformationManager.hxx @@ -1,29 +1,35 @@ #ifndef INCLUDE__InformationManager_hxx #define INCLUDE__InformationManager_hxx +#include #include #include #include #include -class Disassembler; +#include "disassembler/Disassembler.hxx" + class Function; class BasicBlock; - -class QString; +class Comment; class RenameFunctionEvent; +class QString; +class QTemporaryFile; + class InformationManager { public: + InformationManager(); ~InformationManager(); void reset(const std::string& filename); - void save(const QString& filename); + void load(const std::string& filename); + void save(const std::string& filename); void signal_new_function(Function* f); void signal_new_dyn_symbol(const std::string& f) - { new_dyn_symbol_signal(f); } + { new_dyn_symbol_signal(f); } boost::signals2::connection connect_new_function_signal(std::function f) @@ -47,11 +53,47 @@ public: void dispatch(RenameFunctionEvent* event) { rename_function_signal(event); } - Function* getFunction(uint64_t address) - { return functions[address]; } - BasicBlock* getBlock(uint64_t address) - { return blocks[address]; } + Function* getFunction(uint64_t address); + bool hasFunctions() const {return functions.size() != 0;} + std::map::const_iterator beginFunctions(); + std::map::const_iterator endFunctions(); + + BasicBlock* getBasicBlock(uint64_t address); + bool hasBasicBlocks() const {return blocks.size() != 0;} + std::map::const_iterator beginBasicBlocks(); + std::map::const_iterator endBasicBlocks(); + + + /* 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); + 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 finnishComment(Comment* c); + void deleteFunction(Function* f); + void deleteBasicBlock(BasicBlock* b); + void deleteComment(Comment* c); private: boost::signals2::signal reset_signal; @@ -61,6 +103,10 @@ private: std::unique_ptr disassembler; std::map functions; std::map blocks; + std::string filename; + std::unique_ptr tmpfile; + + log4cxx::LoggerPtr logger; }; #endif /* INCLUDE__InformationManager_hxx */