static void
gum_v8_script_backend_emit_debug_message (const Debug::Message & message)
{
  Isolate * isolate = message.GetIsolate ();
  GumV8ScriptBackend * self = GUM_V8_SCRIPT_BACKEND (isolate->GetData (0));
  GumV8ScriptBackendPrivate * priv = self->priv;
  HandleScope scope (isolate);

  Local<String> json = message.GetJSON ();
  String::Utf8Value json_str (json);

  GUM_V8_SCRIPT_BACKEND_LOCK ();
  GMainContext * context = (priv->debug_handler_context != NULL)
      ? g_main_context_ref (priv->debug_handler_context)
      : NULL;
  GUM_V8_SCRIPT_BACKEND_UNLOCK ();

  if (context == NULL)
    return;

  GumEmitDebugMessageData * d = g_slice_new (GumEmitDebugMessageData);
  d->backend = self;
  g_object_ref (self);
  d->message = g_strdup (*json_str);

  GSource * source = g_idle_source_new ();
  g_source_set_callback (source,
      (GSourceFunc) gum_v8_script_backend_do_emit_debug_message,
      d,
      (GDestroyNotify) gum_emit_debug_message_data_free);
  g_source_attach (source, context);
  g_source_unref (source);

  g_main_context_unref (context);
}
Example #2
0
static void
gum_script_emit_debug_message (const Debug::Message & message)
{
  Isolate * isolate = message.GetIsolate ();
  HandleScope scope (isolate);

  Local<String> json = message.GetJSON ();
  String::Utf8Value json_str (json);

  G_LOCK (gum_debug);
  GMainContext * context = (gum_debug_handler_context != NULL)
      ? g_main_context_ref (gum_debug_handler_context)
      : NULL;
  G_UNLOCK (gum_debug);

  if (context == NULL)
    return;

  GSource * source = g_idle_source_new ();
  g_source_set_callback (source,
      (GSourceFunc) gum_script_do_emit_debug_message,
      g_strdup (*json_str),
      g_free);
  g_source_attach (source, context);
  g_source_unref (source);

  g_main_context_unref (context);
}