[sysprof] gjs: add gjs source back



commit af32235541b226ba0ea79fa176d4b74eb4350fed
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jun 3 18:01:53 2019 -0700

    gjs: add gjs source back
    
    This sets various environment variables we need.

 src/libsysprof-ui/ui/sysprof-profiler-assistant.ui |  4 +-
 src/libsysprof/meson.build                         |  2 +
 src/libsysprof/sysprof-gjs-source.c                | 69 ++++++++++++++++++++++
 src/libsysprof/sysprof-gjs-source.h                | 35 +++++++++++
 src/libsysprof/sysprof.h                           |  1 +
 src/tools/sysprof-cli.c                            |  3 +-
 6 files changed, 109 insertions(+), 5 deletions(-)
---
diff --git a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui 
b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
index a0606f0..9ac90c0 100644
--- a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
+++ b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui
@@ -25,9 +25,7 @@
     <property name="display-name">GJS</property>
     <property name="icon-name">org.gnome.Sysprof-symbolic</property>
     <child>
-      <object class="SysprofTracefdSource">
-        <property name="envvar">GJS_TRACE_FD</property>
-      </object>
+      <object class="SysprofGjsSource"/>
     </child>
   </object>
   <object class="SysprofAid" id="app_aid">
diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build
index 149d7bb..e27e586 100644
--- a/src/libsysprof/meson.build
+++ b/src/libsysprof/meson.build
@@ -7,6 +7,7 @@ libsysprof_public_sources = [
   'sysprof-capture-gobject.c',
   'sysprof-capture-symbol-resolver.c',
   'sysprof-elf-symbol-resolver.c',
+  'sysprof-gjs-source.c',
   'sysprof-hostinfo-source.c',
   'sysprof-jitmap-symbol-resolver.c',
   'sysprof-kernel-symbol.c',
@@ -30,6 +31,7 @@ libsysprof_public_headers = [
   'sysprof-capture-gobject.h',
   'sysprof-capture-symbol-resolver.h',
   'sysprof-elf-symbol-resolver.h',
+  'sysprof-gjs-source.h',
   'sysprof-hostinfo-source.h',
   'sysprof-jitmap-symbol-resolver.h',
   'sysprof-kernel-symbol.h',
diff --git a/src/libsysprof/sysprof-gjs-source.c b/src/libsysprof/sysprof-gjs-source.c
new file mode 100644
index 0000000..ea32409
--- /dev/null
+++ b/src/libsysprof/sysprof-gjs-source.c
@@ -0,0 +1,69 @@
+/* sysprof-gjs-source.c
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "sysprof-gjs-source"
+
+#include "config.h"
+
+#include "sysprof-gjs-source.h"
+
+struct _SysprofGjsSource
+{
+  SysprofTracefdSource parent_instance;
+};
+
+static SysprofSourceInterface *parent_iface;
+
+static void
+sysprof_gjs_source_modify_spawn (SysprofSource       *source,
+                                 GSubprocessLauncher *launcher,
+                                 GPtrArray           *argv)
+{
+  g_subprocess_launcher_setenv (launcher, "GJS_ENABLE_PROFILER", "1", FALSE);
+  parent_iface->modify_spawn (source, launcher, argv);
+}
+
+static void
+source_iface_init (SysprofSourceInterface *iface)
+{
+  parent_iface = g_type_interface_peek_parent (iface);
+
+  iface->modify_spawn = sysprof_gjs_source_modify_spawn;
+}
+
+G_DEFINE_TYPE_WITH_CODE (SysprofGjsSource, sysprof_gjs_source, SYSPROF_TYPE_TRACEFD_SOURCE,
+                         G_IMPLEMENT_INTERFACE (SYSPROF_TYPE_SOURCE, source_iface_init))
+
+static void
+sysprof_gjs_source_class_init (SysprofGjsSourceClass *klass)
+{
+}
+
+static void
+sysprof_gjs_source_init (SysprofGjsSource *self)
+{
+  sysprof_tracefd_source_set_envvar (SYSPROF_TRACEFD_SOURCE (self), "GJS_TRACE_FD");
+}
+
+SysprofSource *
+sysprof_gjs_source_new (void)
+{
+  return g_object_new (SYSPROF_TYPE_GJS_SOURCE, NULL);
+}
diff --git a/src/libsysprof/sysprof-gjs-source.h b/src/libsysprof/sysprof-gjs-source.h
new file mode 100644
index 0000000..02316d8
--- /dev/null
+++ b/src/libsysprof/sysprof-gjs-source.h
@@ -0,0 +1,35 @@
+/* sysprof-gjs-source.h
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "sysprof-tracefd-source.h"
+
+G_BEGIN_DECLS
+
+#define SYSPROF_TYPE_GJS_SOURCE (sysprof_gjs_source_get_type())
+
+SYSPROF_AVAILABLE_IN_ALL
+G_DECLARE_FINAL_TYPE (SysprofGjsSource, sysprof_gjs_source, SYSPROF, GJS_SOURCE, SysprofTracefdSource)
+
+SYSPROF_AVAILABLE_IN_ALL
+SysprofSource *sysprof_gjs_source_new (void);
+
+G_END_DECLS
diff --git a/src/libsysprof/sysprof.h b/src/libsysprof/sysprof.h
index 669b6e3..867c35b 100644
--- a/src/libsysprof/sysprof.h
+++ b/src/libsysprof/sysprof.h
@@ -28,6 +28,7 @@ G_BEGIN_DECLS
 # include "sysprof-capture-gobject.h"
 # include "sysprof-capture-symbol-resolver.h"
 # include "sysprof-elf-symbol-resolver.h"
+# include "sysprof-gjs-source.h"
 # include "sysprof-jitmap-symbol-resolver.h"
 # include "sysprof-kernel-symbol-resolver.h"
 # include "sysprof-kernel-symbol.h"
diff --git a/src/tools/sysprof-cli.c b/src/tools/sysprof-cli.c
index 0a96019..f1e86f0 100644
--- a/src/tools/sysprof-cli.c
+++ b/src/tools/sysprof-cli.c
@@ -221,8 +221,7 @@ main (gint   argc,
 
   if (gjs)
     {
-      source = sysprof_tracefd_source_new ();
-      sysprof_tracefd_source_set_envvar (SYSPROF_TRACEFD_SOURCE (source), "GJS_TRACE_FD");
+      source = sysprof_gjs_source_new ();
       sysprof_profiler_add_source (profiler, source);
       g_object_unref (source);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]