diff --git a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui index a0606f0f..9ac90c0b 100644 --- a/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui +++ b/src/libsysprof-ui/ui/sysprof-profiler-assistant.ui @@ -25,9 +25,7 @@ GJS org.gnome.Sysprof-symbolic - - GJS_TRACE_FD - + diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build index 149d7bb4..e27e5868 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 00000000..ea32409f --- /dev/null +++ b/src/libsysprof/sysprof-gjs-source.c @@ -0,0 +1,69 @@ +/* sysprof-gjs-source.c + * + * Copyright 2019 Christian Hergert + * + * 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 . + * + * 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 00000000..02316d80 --- /dev/null +++ b/src/libsysprof/sysprof-gjs-source.h @@ -0,0 +1,35 @@ +/* sysprof-gjs-source.h + * + * Copyright 2019 Christian Hergert + * + * 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 . + * + * 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 669b6e39..867c35b4 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 0a960197..f1e86f05 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); }