]> git.siccegge.de Git - frida/frida.git/commitdiff
Export the Guile interpreter as QtPlugin
authorChristoph Egger <Christoph.Egger@fau.de>
Wed, 11 Mar 2015 13:31:26 +0000 (14:31 +0100)
committerChristoph Egger <Christoph.Egger@fau.de>
Wed, 11 Mar 2015 13:31:26 +0000 (14:31 +0100)
The Guile interpreter is now a proper Plugin. Next step is listing +
loading scripting plugins properly

Closes T10

CMakeLists.txt
src/bindings/Guile.hxx
src/bindings/Interpreter.hxx
src/gui/Mainwindow.cxx
src/gui/qt.hxx

index 3a4b943d6b81843f11f29a88e53a285d939c2aae..9d27f61b6add59a10607938575cb77303c5701e5 100644 (file)
@@ -39,7 +39,7 @@ SET(CMAKE_SWIG_FLAGS -Linkage passive)
 #INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
 SET_SOURCE_FILES_PROPERTIES(src/bindings/guile/frida.i PROPERTIES CPLUSPLUS ON)
 SWIG_ADD_MODULE(frida-guile guile src/bindings/guile/frida.i)
-SWIG_LINK_LIBRARIES(frida-guile)
+SWIG_LINK_LIBRARIES(frida-guile ${GUILE_LDFLAGS})
 
 
 #################
@@ -47,7 +47,6 @@ SWIG_LINK_LIBRARIES(frida-guile)
 #################
 
 SET(frida_SOURCES
-  src/bindings/Guile.cxx
   src/core/InformationManager.cxx
   src/core/BasicBlock.cxx
   src/core/Function.cxx
@@ -83,7 +82,32 @@ ADD_DEFINITIONS(${QT_DEFINITIONS})
 
 qt5_use_modules(frida Widgets)
 
-TARGET_LINK_LIBRARIES(frida ${QT_LIBRARIES} ${LLVM_LDFLAGS} -lLLVM-3.5 ${LLVM_SYSTEM_LIBS} ${LOG4CXX_LDFLAGS} ${GUILE_LDFLAGS} ${QUAZIP_LIBRARIES})
+TARGET_LINK_LIBRARIES(frida
+  ${QT_LIBRARIES}
+  ${LLVM_LDFLAGS}
+  -lLLVM-3.5
+  ${LLVM_SYSTEM_LIBS}
+  ${LOG4CXX_LDFLAGS}
+  ${QUAZIP_LIBRARIES})
+
+
+###########
+# Plugins #
+###########
+
+# GUILE
+
+set(plugin_guile_SOURCES
+  src/bindings/Interpreter.cxx
+  src/bindings/Guile.cxx)
+
+set(plugin_guile_HEADERS
+  src/bindings/Interpreter.hxx
+  src/bindings/Guile.hxx)
+
+add_library(guilePlugin MODULE ${plugin_guile_SOURCES} ${plugin_guile_HEADERS_MOC})
+qt5_use_modules(guilePlugin Core)
+target_link_libraries(guilePlugin ${QT_LIBRARIES} ${GUILE_LDFLAGS})
 
 ##################
 # TEST Framework #
index 7c45a9549c56fa52b822db552223ba47a2e1d88d..d67a0ddf0ac55dcc0d64de6ff3df312210f55a39 100644 (file)
@@ -5,7 +5,10 @@
 
 #include "Interpreter.hxx"
 
-class GuileInterpreter : public Interpreter {
+class GuileInterpreter : public QObject, public Interpreter {
+    Q_OBJECT
+    Q_PLUGIN_METADATA(IID "xyz.frida.Interpreter")
+    Q_INTERFACES(Interpreter)
 public:
        GuileInterpreter();
 
index 648301b926c1905229b1eb303d5edacca853d24f..898f0e0ea26c016d5615b9eda97d86d7e4222705 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <string>
 #include <sstream>
+#include <QtPlugin>
 
 class Interpreter {
 public:
@@ -20,4 +21,6 @@ public:
 private:
 };
 
+Q_DECLARE_INTERFACE(Interpreter, "xyz.frida.Interpreter")
+
 #endif /* INCLUDE__Interpreter_hxx_ */
index 47c78858e46314efbe448a1d185b1f7377e8e3d2..2036c486b705bb872ba51e037deeb3bb1cfb649b 100644 (file)
@@ -40,7 +40,10 @@ Mainwindow::Mainwindow(InformationManager* mgr)
 
        QMenu* interpretermenu = menuBar()->addMenu(tr("&Interpreter"));
 
-       interpreter["GUILE"] = new GuileInterpreter;
+       QPluginLoader* loader = new QPluginLoader("libguilePlugin", this);
+       if (!loader->load())
+               LOG4CXX_ERROR(logger, "Loading plugin failed: " << loader->errorString().toStdString());
+       interpreter["GUILE"] = qobject_cast<Interpreter*>(loader->instance());
        scripting = new ScriptingDock(interpreter["GUILE"], tr("Scripting"), this);
        scripting->setAllowedAreas(Qt::BottomDockWidgetArea);
        addDockWidget(Qt::BottomDockWidgetArea, scripting);
index ac08c0b6cf1d72556cb243cb0db18548f4c86acf..e0ff092abeb68bf751bcb846eadc72e17e9b0bf8 100644 (file)
@@ -28,5 +28,6 @@
 #include <QXmlStreamWriter>
 #include <QXmlStreamReader>
 #include <QApplication>
+#include <QPluginLoader>
 
 #endif /* INCLUDE__qt_hxx_ */