gjs: add gjs source back

This sets various environment variables we need.
This commit is contained in:
Christian Hergert
2019-06-03 18:01:53 -07:00
parent d25975cf89
commit af32235541
6 changed files with 109 additions and 5 deletions

View File

@ -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">

View File

@ -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',

View File

@ -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);
}

View File

@ -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

View File

@ -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"

View File

@ -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);
}