Commit ea790b9f authored by Philip Chimento's avatar Philip Chimento 🚮

Merge branch 'pwithnall/gjs-sysprof4'

See merge request !457
parents df83e380 d69f75bb
Pipeline #194913 passed with stages
in 8 minutes and 52 seconds
......@@ -48,7 +48,7 @@ stages:
build_recommended:
<<: *build
stage: source_check
image: registry.gitlab.gnome.org/gnome/gjs:job-745493_fedora.mozjs68-debug # pinned on purpose
image: registry.gitlab.gnome.org/gnome/gjs:job-801643_fedora.mozjs68-debug # pinned on purpose
variables:
TASK_ID: "fedora-x86_64-gcc-debug-default-check"
TEST_OPTS: --verbose --no-stdsplit --print-errorlogs
......@@ -60,7 +60,7 @@ sanitizer_gcc:
stage: test
tags:
- privileged # LSAN needs CAP_SYS_PTRACE
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68-debug
variables:
TASK_ID: "fedora-x86_64-gcc-default-ubsan_asan-check"
CONFIG_OPTS: -Db_sanitize=address,undefined
......@@ -225,7 +225,7 @@ sanitizer_clang:
stage: manual
tags:
- privileged # LSAN needs CAP_SYS_PTRACE
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68-debug
variables:
TASK_ID: "fedora-x86_64-clang_ubsan_asan-default-default-check"
CC: clang
......@@ -237,7 +237,7 @@ sanitizer_clang:
installed_tests:
<<: *build
stage: manual
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68-debug
variables:
TASK_ID: "fedora-x86_64-gcc-default-default-installed_tests"
CONFIG_OPTS: -Dinstalled_tests=true -Dprefix=/usr
......@@ -254,7 +254,7 @@ installed_tests:
valgrind:
<<: *build
stage: manual
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68
image: registry.gitlab.gnome.org/gnome/gjs:fedora.mozjs68-debug
variables:
TASK_ID: "fedora-x86_64-gcc-default-default-valgrind_check"
TEST_OPTS: --setup=valgrind
......
......@@ -105,6 +105,7 @@ struct _GjsProfiler {
/* Buffers and writes our sampled stacks */
SysprofCaptureWriter* capture;
GSource* periodic_flush;
#endif /* ENABLE_PROFILER */
/* The filename to write to */
......@@ -261,6 +262,7 @@ _gjs_profiler_free(GjsProfiler *self)
g_clear_pointer(&self->filename, g_free);
#ifdef ENABLE_PROFILER
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);
g_clear_pointer(&self->periodic_flush, g_source_destroy);
if (self->fd != -1)
close(self->fd);
......@@ -387,6 +389,17 @@ static void gjs_profiler_sigprof(int signum G_GNUC_UNUSED, siginfo_t* info,
gjs_profiler_stop(self);
}
static gboolean profiler_auto_flush_cb(void* user_data) {
auto* self = static_cast<GjsProfiler*>(user_data);
if (!self->running)
return G_SOURCE_REMOVE;
sysprof_capture_writer_flush(self->capture);
return G_SOURCE_CONTINUE;
}
#endif /* ENABLE_PROFILER */
/**
......@@ -437,13 +450,23 @@ gjs_profiler_start(GjsProfiler *self)
}
/* Automatically flush to be resilient against SIGINT, etc */
sysprof_capture_writer_set_flush_delay(self->capture,
g_main_context_get_thread_default(),
FLUSH_DELAY_SECONDS);
if (!self->periodic_flush) {
self->periodic_flush =
g_timeout_source_new_seconds(FLUSH_DELAY_SECONDS);
g_source_set_name(self->periodic_flush,
"[sysprof-capture-writer-flush]");
g_source_set_priority(self->periodic_flush, G_PRIORITY_LOW + 100);
g_source_set_callback(self->periodic_flush,
(GSourceFunc)profiler_auto_flush_cb, self,
nullptr);
g_source_attach(self->periodic_flush,
g_main_context_get_thread_default());
}
if (!gjs_profiler_extract_maps(self)) {
g_warning("Failed to extract proc maps");
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);
g_clear_pointer(&self->periodic_flush, g_source_destroy);
return;
}
......@@ -455,6 +478,7 @@ gjs_profiler_start(GjsProfiler *self)
if (sigaction(SIGPROF, &sa, nullptr) == -1) {
g_warning("Failed to register sigaction handler: %s", g_strerror(errno));
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);
g_clear_pointer(&self->periodic_flush, g_source_destroy);
return;
}
......@@ -475,6 +499,7 @@ gjs_profiler_start(GjsProfiler *self)
if (timer_create(CLOCK_MONOTONIC, &sev, &self->timer) == -1) {
g_warning("Failed to create profiler timer: %s", g_strerror(errno));
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);
g_clear_pointer(&self->periodic_flush, g_source_destroy);
return;
}
......@@ -489,6 +514,7 @@ gjs_profiler_start(GjsProfiler *self)
g_warning("Failed to enable profiler timer: %s", g_strerror(errno));
timer_delete(self->timer);
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);
g_clear_pointer(&self->periodic_flush, g_source_destroy);
return;
}
......@@ -546,6 +572,7 @@ gjs_profiler_stop(GjsProfiler *self)
sysprof_capture_writer_flush(self->capture);
g_clear_pointer(&self->capture, sysprof_capture_writer_unref);
g_clear_pointer(&self->periodic_flush, g_source_destroy);
g_message("Profiler stopped");
......
......@@ -132,9 +132,18 @@ if cxx.get_id() == 'msvc'
endif
endif
sysprof_capture = dependency('sysprof-capture-3', version: '>= 3.33.32',
sysprof_capture = dependency('sysprof-capture-4',
required: get_option('profiler'), include_type: 'system',
fallback: ['sysprof', 'libsysprof_capture_dep'])
fallback: ['sysprof', 'libsysprof_capture_dep'],
default_options: [
'enable_examples=false',
'enable_gtk=false',
'enable_tests=false',
'enable_tools=false',
'libsysprof=false',
'with_sysprofd=none',
'help=false',
])
readline = cxx.find_library('readline', required: get_option('readline'))
# On some systems we need to link readline to a termcap compatible library
......
[wrap-git]
directory=sysprof
url=https://gitlab.gnome.org/GNOME/sysprof.git
revision=master
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment