From 568fd6801188fb8c092c7820102824a572ec656e Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Tue, 2 Jun 2015 23:16:06 +0200 Subject: [PATCH] Run the disassembler in it's own thread Makes the gui responsive while the disassembler is working. Would also allow for severall worker threads in the disassembler in the future -- and more cool stuff! --- src/core/InformationManager.cxx | 10 ++++++++-- src/core/InformationManager.hxx | 1 + src/disassembler/Disassembler.hxx | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/InformationManager.cxx b/src/core/InformationManager.cxx index 500f79f..7044381 100644 --- a/src/core/InformationManager.cxx +++ b/src/core/InformationManager.cxx @@ -28,6 +28,7 @@ InformationManager::InformationManager() } InformationManager::~InformationManager() { + disassemblerThread.quit(); for (auto b : blocks) delete b.second; @@ -36,14 +37,19 @@ InformationManager::~InformationManager() { for (auto i : plugins) delete i; + disassemblerThread.wait(); } void InformationManager::reset(const std::string& filename) { this->filename = filename; disassembler.reset(createLLVMDisassembler(filename, this)); emit resetEvent(); - if (disassembler.get() != NULL) - disassembler.get()->start(); + if (disassembler.get() != NULL) { + disassembler.get()->moveToThread(&disassemblerThread); + connect(&disassemblerThread, &QThread::started, + disassembler.get(), &Disassembler::start); + disassemblerThread.start(); + } } void InformationManager::load(const std::string& filename) { diff --git a/src/core/InformationManager.hxx b/src/core/InformationManager.hxx index a866e0a..f39f6e4 100644 --- a/src/core/InformationManager.hxx +++ b/src/core/InformationManager.hxx @@ -116,6 +116,7 @@ private: std::unique_ptr tmpfile; std::vector plugins; + QThread disassemblerThread; log4cxx::LoggerPtr logger; }; diff --git a/src/disassembler/Disassembler.hxx b/src/disassembler/Disassembler.hxx index ad35018..6971177 100644 --- a/src/disassembler/Disassembler.hxx +++ b/src/disassembler/Disassembler.hxx @@ -20,13 +20,13 @@ public: Disassembler() {} virtual ~Disassembler() {} - virtual void start() = 0; virtual void getSymbols() = 0; virtual uint64_t entryAddress() = 0; #ifndef SWIG public slots: #endif + virtual void start() = 0; virtual Function * disassembleFunctionAt(uint64_t address) { return disassembleFunctionAt(address, ""); } -- 2.39.5