]> git.siccegge.de Git - frida/frida.git/commitdiff
Make requestNewFunction pass a signal
authorChristoph Egger <christoph@christoph-egger.org>
Tue, 2 Jun 2015 19:31:28 +0000 (21:31 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Tue, 2 Jun 2015 19:31:28 +0000 (21:31 +0200)
With the Disassembler being assigned to a different thread soon, this
should allow the gui to stay alive while the disassembler is busy
working.

src/core/InformationManager.cxx
src/core/InformationManager.hxx
src/disassembler/Disassembler.hxx
src/gui/Mainwindow.cxx
src/gui/Mainwindow.hxx
src/gui/widgets/BasicBlockWidget.cxx

index c548a553507dbae95d56e52515f1c494fe6067be..b947a58933006373ff37968702a3e5e18d043769 100644 (file)
@@ -41,6 +41,7 @@ InformationManager::~InformationManager() {
 void InformationManager::reset(const std::string& filename) {
        this->filename = filename;
        disassembler.reset(createLLVMDisassembler(filename, this));
+       emit resetEvent();
        if (disassembler.get() != NULL)
                disassembler.get()->start();
 }
index 2f70d7365d7a27353ffc6ce843f47f99fae832f4..c7d6321cdbf1e2c5386ae1983bc1c6022388b723 100644 (file)
@@ -35,7 +35,7 @@ public:
        void renameFunctionEvent(RenameFunctionEvent* event);
        void newFunctionEvent(NewFunctionEvent* event);
        void changeCommentEvent(ChangeCommentEvent* event);
-       void reset();
+       void resetEvent();
 public:
        InformationManager();
        ~InformationManager();
index 7e1e3e1a2eb3574235dd1402b125858a3d14a50d..ad35018e870bab74ae33da162d290be30e3a7832 100644 (file)
@@ -5,13 +5,17 @@
 #include <functional>
 #include <vector>
 
+#include "qt.hxx"
 #include "Instruction.hxx"
 
 class Function;
 class BasicBlock;
 class InformationManager;
 
-class Disassembler {
+class Disassembler : public QObject {
+#ifndef SWIG
+       Q_OBJECT
+#endif
 public:
        Disassembler() {}
        virtual ~Disassembler() {}
@@ -20,7 +24,13 @@ public:
        virtual void getSymbols() = 0;
        virtual uint64_t entryAddress() = 0;
 
-       virtual Function * disassembleFunctionAt(uint64_t address, const std::string& name = "") = 0;
+#ifndef SWIG
+public slots:
+#endif
+       virtual Function * disassembleFunctionAt(uint64_t address) {
+               return disassembleFunctionAt(address, "");
+       }
+       virtual Function * disassembleFunctionAt(uint64_t address, const std::string& name) = 0;
        virtual std::vector<Instruction> getInstructions(const BasicBlock* block) = 0;
 };
 
index adadc0686a9a600d70f99b2e85dc9aae523a2499..850c0364b61ba1c4d5fc845586ba8913fe48f9d9 100644 (file)
@@ -90,6 +90,11 @@ Mainwindow::Mainwindow(InformationManager* mgr)
        QTreeWidgetItem * external = new QTreeWidgetItem(listWidget, QStringList("External Functions"));
        external->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
        external->setBackground(0, QBrush(QColor(0xff, 0xdd, 0xdd)));
+       connect(mgr, &InformationManager::resetEvent,
+               [this,mgr]() {
+                       connect(this, SIGNAL(requestNewFunctionByAddress(uint64_t)),
+                               mgr->getDisassembler(), SLOT(disassembleFunctionAt(uint64_t)));
+               });
        connect(mgr, &InformationManager::newFunctionEvent,
                [=] (NewFunctionEvent* event) {
                        std::string name = event->function->getName();
@@ -220,7 +225,7 @@ void Mainwindow::requestNewFunction() {
        NewFunctionDialog dialog;
        int result = dialog.exec();
        if (QDialog::Accepted == result) {
-               requestNewFunctionByAddress(dialog.result());
+               emit requestNewFunctionByAddress(dialog.result());
        } else {
                LOG4CXX_DEBUG(logger, "requestNewFunction aborted");
        }
@@ -238,12 +243,6 @@ void Mainwindow::requestNewGroup() {
        }
 }
 
-void Mainwindow::requestNewFunctionByAddress(uint64_t address) {
-       LOG4CXX_DEBUG(logger, "requesting Function at " << std::hex << address);
-       manager->getDisassembler()->disassembleFunctionAt(address);
-       switchMainPlaneToAddress(address);
-}
-
 void Mainwindow::renameFunction(Function* function) {
        SimpleStringDialog dialog("New name");
        int result = dialog.exec();
index 1b497dfce301d3d2d2015d3b0dce96cf4b64cd5d..3a3a94d3b2388377ea5de3317924fe7cca6f02c9 100644 (file)
@@ -28,6 +28,8 @@ public:
 
 public slots:
        void switchMainPlaneToAddress(uint64_t);
+
+signals:
        void requestNewFunctionByAddress(uint64_t address);
 
 private:
index e08cba5e86ac394751f7e3db3d6ac88f14ab88fc..21f432fa0245670d6fbab2e8e88828f977303bbb 100644 (file)
@@ -58,7 +58,7 @@ void CustomQGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent* e
                QAction* act = menu.addAction(c.selectedText() + " is a Function");
                QObject::connect(act, &QAction::triggered,
                                 [=]() {
-                                        parent->mainwindow->requestNewFunctionByAddress(address);
+                                        emit parent->mainwindow->requestNewFunctionByAddress(address);
                                         if (NULL == table) return;
                                         int row = table->cellAt(c).row();
                                         uint64_t insAddress = parent->instructions[row].getAddress();