[sysprof/wip/chergert/sysprof-3] libsysprof: create hook for supplemental writer data



commit 0b8555360f399aba6f3d019679db98bf5102b550
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 27 20:54:41 2019 -0700

    libsysprof: create hook for supplemental writer data

 src/libsysprof/sysprof-local-profiler.c | 11 +++++++++++
 src/libsysprof/sysprof-source.c         | 11 +++++++++++
 src/libsysprof/sysprof-source.h         | 17 +++++++++++++++++
 3 files changed, 39 insertions(+)
---
diff --git a/src/libsysprof/sysprof-local-profiler.c b/src/libsysprof/sysprof-local-profiler.c
index 2637c97..e371e4f 100644
--- a/src/libsysprof/sysprof-local-profiler.c
+++ b/src/libsysprof/sysprof-local-profiler.c
@@ -185,12 +185,23 @@ static void
 sysprof_local_profiler_finish_stopping (SysprofLocalProfiler *self)
 {
   SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
+  g_autoptr(SysprofCaptureReader) reader = NULL;
 
   g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
   g_assert (priv->is_starting == FALSE);
   g_assert (priv->is_stopping == TRUE);
   g_assert (priv->stopping->len == 0);
 
+  reader = sysprof_capture_writer_create_reader (priv->writer, 0);
+
+  for (guint i = 0; i < priv->sources->len; i++)
+    {
+      SysprofSource *source = g_ptr_array_index (priv->sources, i);
+
+      sysprof_capture_reader_reset (reader);
+      sysprof_source_supplement (source, reader);
+    }
+
   if (priv->failures->len > 0)
     {
       const GError *error = g_ptr_array_index (priv->failures, 0);
diff --git a/src/libsysprof/sysprof-source.c b/src/libsysprof/sysprof-source.c
index bf0a23d..da26f0a 100644
--- a/src/libsysprof/sysprof-source.c
+++ b/src/libsysprof/sysprof-source.c
@@ -178,3 +178,14 @@ sysprof_source_deserialize (SysprofSource *self,
   if (SYSPROF_SOURCE_GET_IFACE (self)->deserialize)
     SYSPROF_SOURCE_GET_IFACE (self)->deserialize (self, keyfile, group);
 }
+
+void
+sysprof_source_supplement (SysprofSource        *self,
+                           SysprofCaptureReader *reader)
+{
+  g_return_if_fail (SYSPROF_IS_SOURCE (self));
+  g_return_if_fail (reader != NULL);
+
+  if (SYSPROF_SOURCE_GET_IFACE (self)->supplement)
+    SYSPROF_SOURCE_GET_IFACE (self)->supplement (self, reader);
+}
diff --git a/src/libsysprof/sysprof-source.h b/src/libsysprof/sysprof-source.h
index bc391b4..1321830 100644
--- a/src/libsysprof/sysprof-source.h
+++ b/src/libsysprof/sysprof-source.h
@@ -133,6 +133,20 @@ struct _SysprofSourceInterface
                         GSubprocessLauncher *launcher,
                         GPtrArray           *argv);
 
+  /**
+   * SysprofSource::supplement:
+   *
+   * The "supplement" vfunc is called when a source should attempt to add
+   * any additional data to the trace file based on existing data within
+   * the trace file. A #SysprofCaptureReader is provided to simplify this
+   * process for the vfunc. It should write to the writer provided in
+   * sysprof_source_set_writer().
+   *
+   * This function must finish synchronously.
+   */
+  void (*supplement) (SysprofSource        *self,
+                      SysprofCaptureReader *reader);
+
   /**
    * SysprofSource::serialize:
    * @self: a #SysprofSource
@@ -192,5 +206,8 @@ SYSPROF_AVAILABLE_IN_ALL
 void     sysprof_source_deserialize   (SysprofSource        *self,
                                        GKeyFile             *keyfile,
                                        const gchar          *group);
+SYSPROF_AVAILABLE_IN_ALL
+void     sysprof_source_supplement    (SysprofSource        *self,
+                                       SysprofCaptureReader *reader);
 
 G_END_DECLS


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