]> git.siccegge.de Git - frida/frida.git/blobdiff - src/bindings/Guile.cxx
add logging to the Guile module
[frida/frida.git] / src / bindings / Guile.cxx
index 2552e7d215ab8b97e85edfc77a372a7fe13f6e2e..356757d095ccb7ffb6d4a7bc4575bf4a7e70b74a 100644 (file)
@@ -1,4 +1,5 @@
 #include "Guile.hxx"
+#include "Config.hxx"
 
 namespace {
        SCM handler (void*, SCM tag, SCM throw_args) {
@@ -7,22 +8,20 @@ namespace {
        }
 }
 
-GuileInterpreter::GuileInterpreter() {
+GuileInterpreter::GuileInterpreter()
+       : logger(log4cxx::Logger::getLogger("bindings.Guile")) {
        scm_init_guile();
 
-       scm_internal_catch(SCM_BOOL_T,
-                          (SCM (*)(void *))scm_c_eval_string,
-                          (void*)"(use-modules (system repl server))",
-                          handler, NULL);
-       scm_internal_catch(SCM_BOOL_T,
-                          (SCM (*)(void *))scm_c_eval_string,
-                          (void*)"(spawn-server)",
-                          handler, NULL);
+       scm_c_use_module("system repl server");
+       scm_call_0(scm_c_public_ref("system repl server", "spawn-server"));
+       scm_c_load_extension("libguile-frida-binding",
+                            "scm_init_frida_module");
 
        guile_output_port = scm_open_output_string();
        guile_error_port = scm_open_output_string();
        scm_set_current_output_port(guile_output_port);
        scm_set_current_error_port(guile_error_port);
+       LOG4CXX_INFO(logger, "Initializing GUILE finished");
 }
 
 int GuileInterpreter::evaluate(const std::string& command,
@@ -50,3 +49,13 @@ int GuileInterpreter::evaluate(const std::string& command,
 
        return 0;
 }
+
+int GuileInterpreter::loadFile(const std::string& filename,
+                               std::ostream& stdout,
+                               std::ostream& stderr,
+                               std::string& result) {
+       LOG4CXX_INFO(logger, "Loading file \"" << filename << "\"");
+       scm_c_primitive_load(filename.c_str());
+       LOG4CXX_INFO(logger, "Finished file \"" << filename << "\"");
+       return 0;
+}