]> git.siccegge.de Git - frida/frida.git/commitdiff
Make signals from geiser work
authorChristoph Egger <christoph@christoph-egger.org>
Tue, 26 May 2015 13:48:21 +0000 (15:48 +0200)
committerChristoph Egger <christoph@christoph-egger.org>
Tue, 26 May 2015 13:48:27 +0000 (15:48 +0200)
Move geiser to a proper QThread instead of a guile-only thread. This
way it can properly send/receive signals. Also for some obscure reason
the QVector<int> hack is needed for things to work

Closes T24

src/bindings/Guile.cxx
src/bindings/Guile.hxx
src/main.cxx

index 863c9ccd23e43ecdbd3716d6b5ef9b9e6af387d7..18d12e95eef91b5edec0624b5797a68081678546 100644 (file)
@@ -12,16 +12,12 @@ namespace {
 GuileInterpreter::GuileInterpreter()
        : logger(log4cxx::Logger::getLogger("bindings.Guile")) {
 
-       QString socketpath = Settings::get()->getRuntimeDirectory()->canonicalPath()
-               + "/frida." + QString::number(QCoreApplication::applicationPid(), 16) + ".geiser.sock";
-
        scm_init_guile();
-
-       SCM scm_socketpath = scm_from_locale_string(socketpath.toStdString().c_str());
        scm_c_use_module("system repl server");
-       SCM socket = scm_call_2(scm_c_public_ref("system repl server", "make-unix-domain-server-socket"),
-                               scm_from_locale_keyword("path"), scm_socketpath);
-       scm_call_1(scm_c_public_ref("system repl server", "spawn-server"), socket);
+
+       guile::Geiser* geiser = new guile::Geiser(this);
+       geiser->start();
+
        scm_c_load_extension("libguile-frida-binding",
                             "scm_init_frida_module");
 
@@ -79,3 +75,17 @@ int GuileInterpreter::loadFile(const std::string& filename,
        LOG4CXX_DEBUG(logger, "Finished file \"" << filename << "\"");
        return 0;
 }
+
+namespace guile {
+       void Geiser::run() {
+               scm_init_guile();
+
+               QString socketpath = Settings::get()->getRuntimeDirectory()->canonicalPath()
+                       + "/frida." + QString::number(QCoreApplication::applicationPid(), 16) + ".geiser.sock";
+
+               SCM scm_socketpath = scm_from_locale_string(socketpath.toStdString().c_str());
+               SCM socket = scm_call_2(scm_c_public_ref("system repl server", "make-unix-domain-server-socket"),
+                                       scm_from_locale_keyword("path"), scm_socketpath);
+               scm_call_1(scm_c_public_ref("system repl server", "run-server"), socket);
+       }
+}
index 612f33bdfb1fb6b6170bf6d67caff9392b1ba93b..244bb1cc07ab620119e2f941f658453b26f6ff07 100644 (file)
@@ -4,6 +4,7 @@
 #include <libguile.h>
 #include <log4cxx/logger.h>
 
+#include "qt.hxx"
 #include "Interpreter.hxx"
 
 class GuileInterpreter : public QObject, public Interpreter {
@@ -36,4 +37,15 @@ private:
        log4cxx::LoggerPtr logger;
 };
 
+namespace guile {
+       class Geiser : public QThread {
+               Q_OBJECT
+       public:
+               Geiser(QObject* parent) : QThread(parent) {}
+       private:
+               void run() Q_DECL_OVERRIDE;
+       };
+}
+
+
 #endif /* INCLUDE__Guile_hxx_ */
index ccb2c52951ccd9639866f507f7c064c954ada0bd..b4b4ba80f6af5559d9606594eeb3d55b7921d78e 100644 (file)
@@ -11,6 +11,8 @@
 #include <QCommandLineParser>
 #endif
 #include <QTextEdit>
+#include <QMetaType>
+#include <QVector>
 
 #include "log4cxx/logger.h"
 #include "log4cxx/basicconfigurator.h"
@@ -35,6 +37,7 @@ int main(int argc, char** argv)
        QApplication::setApplicationName("frida");
        QApplication::setApplicationVersion("0.0");
        QApplication::addLibraryPath(CONFIG_LIBDIR "/frida/plugins/Interpreter");
+       qRegisterMetaType<QVector<int> >("QVector<int>");
 #ifdef ARGPARSE
        parser.addHelpOption();
        parser.addVersionOption();