]> git.siccegge.de Git - frida/frida.git/commitdiff
Make InformationManager responsible for cleaning Blocks / Functions
authorChristoph Egger <Christoph.Egger@fau.de>
Fri, 20 Feb 2015 16:06:32 +0000 (17:06 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Fri, 20 Feb 2015 16:06:32 +0000 (17:06 +0100)
As BasicBlocks and Functions are now considered part of the core, the
InformationManager should be responsible for cleaning them up
afterwards. Maybe it should generate them as well -- we will see.

src/core/InformationManager.cxx
src/core/InformationManager.hxx
src/disassembler/llvm/LLVMDisassembler.cxx

index 7c1c5dee207a4e9e1023a812858fec5e8ea67a9b..1234ac96aa64845775af2069a0bf73c901634d80 100644 (file)
@@ -7,6 +7,14 @@
 #include <quazip/quazip.h>
 #include <quazip/quazipfile.h>
 
+InformationManager::~InformationManager() {
+       for (BasicBlock * b : blocks)
+               delete b;
+
+       for (Function * f : functions)
+               delete f;
+}
+
 void InformationManager::reset(const std::string& filename) {
        disassembler.reset(createLLVMDisassembler(filename, this));
        if (disassembler.get() != NULL)
@@ -50,3 +58,10 @@ void InformationManager::save(const QString& filename) {
 
        zip.close();
 }
+
+void InformationManager::signal_new_function(Function* fun) {
+       functions.insert(fun);
+       for (auto b : fun->blocks())
+               blocks.insert(b.second);
+       new_function_signal(fun);
+}
index f8e4f04011bc666c5aff24e14f4d157b2ff66130..a43b1181281cd1deea73b4d8cb595a1128bd108b 100644 (file)
@@ -14,15 +14,18 @@ class QString;
 
 class InformationManager {
 public:
+       ~InformationManager();
+
        void reset(const std::string& filename);
        void save(const QString& filename);
 
+       void signal_new_function(Function* f);
+
        boost::signals2::connection
        connect_new_function_signal(std::function<void(Function*)> f)
                { return new_function_signal.connect(f); }
 
-       void signal_new_function(Function* f)
-               { functions.insert(f); new_function_signal(f); }
+
 
        boost::signals2::connection
        connect_new_dyn_symbol_signal(std::function<void(const std::string& name)> f)
@@ -43,6 +46,7 @@ private:
        boost::signals2::signal<void (const std::string& name)> new_dyn_symbol_signal;
        std::unique_ptr<Disassembler> disassembler;
        std::set<Function*> functions;
+       std::set<BasicBlock*> blocks;
 };
 
 #endif /* INCLUDE__InformationManager_hxx */
index 314779600481cb531e53f10096dd1b49d33b5df9..d2c68fdce4f4f48f803c90726a2707565007d8fc 100644 (file)
@@ -162,14 +162,14 @@ void LLVMDisassembler<ELFT>::start() {
 
 template <typename ELFT>
 LLVMDisassembler<ELFT>::~LLVMDisassembler() {
-       std::for_each(functions.begin(), functions.end(),
-                     [](std::pair<uint64_t,LLVMFunction*> it) {
-                             delete it.second;
-                     });
-       std::for_each(blocks.begin(), blocks.end(),
-                     [](std::pair<uint64_t, LLVMBasicBlock*> it) {
-                             delete it.second;
-                     });
+       // std::for_each(functions.begin(), functions.end(),
+       //               [](std::pair<uint64_t,LLVMFunction*> it) {
+       //                    delete it.second;
+       //               });
+       // std::for_each(blocks.begin(), blocks.end(),
+       //               [](std::pair<uint64_t, LLVMBasicBlock*> it) {
+       //                    delete it.second;
+       //               });
 }
 
 template <typename ELFT>