From d5084161ca261d7fc0bd284621569440b6503eac Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Fri, 20 Feb 2015 17:06:32 +0100 Subject: [PATCH] Make InformationManager responsible for cleaning Blocks / Functions 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 | 15 +++++++++++++++ src/core/InformationManager.hxx | 8 ++++++-- src/disassembler/llvm/LLVMDisassembler.cxx | 16 ++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/core/InformationManager.cxx b/src/core/InformationManager.cxx index 7c1c5de..1234ac9 100644 --- a/src/core/InformationManager.cxx +++ b/src/core/InformationManager.cxx @@ -7,6 +7,14 @@ #include #include +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); +} diff --git a/src/core/InformationManager.hxx b/src/core/InformationManager.hxx index f8e4f04..a43b118 100644 --- a/src/core/InformationManager.hxx +++ b/src/core/InformationManager.hxx @@ -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 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 f) @@ -43,6 +46,7 @@ private: boost::signals2::signal new_dyn_symbol_signal; std::unique_ptr disassembler; std::set functions; + std::set blocks; }; #endif /* INCLUDE__InformationManager_hxx */ diff --git a/src/disassembler/llvm/LLVMDisassembler.cxx b/src/disassembler/llvm/LLVMDisassembler.cxx index 3147796..d2c68fd 100644 --- a/src/disassembler/llvm/LLVMDisassembler.cxx +++ b/src/disassembler/llvm/LLVMDisassembler.cxx @@ -162,14 +162,14 @@ void LLVMDisassembler::start() { template LLVMDisassembler::~LLVMDisassembler() { - std::for_each(functions.begin(), functions.end(), - [](std::pair it) { - delete it.second; - }); - std::for_each(blocks.begin(), blocks.end(), - [](std::pair it) { - delete it.second; - }); + // std::for_each(functions.begin(), functions.end(), + // [](std::pair it) { + // delete it.second; + // }); + // std::for_each(blocks.begin(), blocks.end(), + // [](std::pair it) { + // delete it.second; + // }); } template -- 2.39.5