[sysprof] libsysprof: store some information about the profile in keyfile
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof] libsysprof: store some information about the profile in keyfile
- Date: Wed, 29 May 2019 22:44:23 +0000 (UTC)
commit 6a5c00b4462651a0386f4c17c158efdd73704e5e
Author: Christian Hergert <chergert redhat com>
Date: Thu May 23 14:53:39 2019 -0700
libsysprof: store some information about the profile in keyfile
This gets added as a metadata chunk to the capture file so that we can
use it later to recreate the session. The goal is to add something like
ctrl+r to run the capture again with identical settings to the previous
capture.
src/libsysprof/sysprof-local-profiler.c | 36 +++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
---
diff --git a/src/libsysprof/sysprof-local-profiler.c b/src/libsysprof/sysprof-local-profiler.c
index fb14083..bbd1fa3 100644
--- a/src/libsysprof/sysprof-local-profiler.c
+++ b/src/libsysprof/sysprof-local-profiler.c
@@ -494,7 +494,10 @@ sysprof_local_profiler_authorize_cb (GObject *object,
SysprofHelpers *helpers = (SysprofHelpers *)object;
g_autoptr(SysprofLocalProfiler) self = user_data;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
+ g_autofree gchar *keydata = NULL;
g_autoptr(GError) error = NULL;
+ g_autoptr(GKeyFile) keyfile = NULL;
+ gsize keylen = 0;
g_assert (SYSPROF_IS_HELPERS (helpers));
g_assert (G_IS_ASYNC_RESULT (result));
@@ -506,6 +509,8 @@ sysprof_local_profiler_authorize_cb (GObject *object,
return;
}
+ keyfile = g_key_file_new ();
+
if (priv->writer == NULL)
{
SysprofCaptureWriter *writer;
@@ -538,6 +543,14 @@ sysprof_local_profiler_authorize_cb (GObject *object,
if (priv->failures->len > 0)
g_ptr_array_remove_range (priv->failures, 0, priv->failures->len);
+ g_key_file_set_boolean (keyfile, "profiler", "whole-system", priv->whole_system);
+ if (priv->pids->len > 0)
+ g_key_file_set_integer_list (keyfile, "profiler", "pids",
+ (gint *)(gpointer)priv->pids->data,
+ priv->pids->len);
+ g_key_file_set_boolean (keyfile, "profiler", "spawn", priv->spawn);
+ g_key_file_set_boolean (keyfile, "profiler", "spawn-inherit-environ", priv->spawn_inherit_environ);
+
if (priv->spawn && priv->spawn_argv && priv->spawn_argv[0])
{
g_autoptr(GPtrArray) env = g_ptr_array_new_with_free_func (g_free);
@@ -557,6 +570,9 @@ sysprof_local_profiler_authorize_cb (GObject *object,
if (priv->spawn_env)
{
+ g_key_file_set_string_list (keyfile, "profiler", "spawn-env",
+ (const gchar * const *)priv->spawn_env,
+ g_strv_length (priv->spawn_env));
for (guint i = 0; priv->spawn_env[i]; i++)
g_ptr_array_add (env, g_strdup (priv->spawn_env[i]));
}
@@ -573,6 +589,13 @@ sysprof_local_profiler_authorize_cb (GObject *object,
g_ptr_array_add (argv, g_strdup (priv->spawn_argv[i]));
}
+ /* Save argv before modifying */
+ g_key_file_set_string_list (keyfile,
+ "profiler",
+ "spawn-argv",
+ (const gchar * const *)argv->pdata,
+ argv->len);
+
for (guint i = 0; i < priv->sources->len; i++)
{
SysprofSource *source = g_ptr_array_index (priv->sources, i);
@@ -602,6 +625,10 @@ sysprof_local_profiler_authorize_cb (GObject *object,
for (guint i = 0; i < priv->sources->len; i++)
{
SysprofSource *source = g_ptr_array_index (priv->sources, i);
+ g_autofree gchar *name = g_strdup_printf ("Source.%s", G_OBJECT_TYPE_NAME (source));
+
+ /* TODO: Allow sources to add information here */
+ g_key_file_set_boolean (keyfile, name, "enabled", TRUE);
if (priv->whole_system == FALSE)
{
@@ -625,6 +652,15 @@ sysprof_local_profiler_authorize_cb (GObject *object,
g_ptr_array_add (priv->starting, g_object_ref (source));
}
+ if ((keydata = g_key_file_to_data (keyfile, &keylen, NULL)))
+ sysprof_capture_writer_add_metadata (priv->writer,
+ SYSPROF_CAPTURE_CURRENT_TIME,
+ -1,
+ -1,
+ "local-profiler",
+ keydata,
+ keylen);
+
if (priv->starting->len == 0)
sysprof_local_profiler_finish_startup (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]