[sysprof/wip/chergert/sysprof-3] libsysprof-ui: setup profiler immediately on setup



commit c67c1ca572970b6fa13fca5222be5694c8621b52
Author: Christian Hergert <chergert redhat com>
Date:   Mon May 20 21:39:55 2019 -0700

    libsysprof-ui: setup profiler immediately on setup
    
    We want this set early so that tooling has access to it. We should probably
    also teach the local profiler about doing this earlier so that it isn't
    necessary to do this.

 src/libsysprof-ui/sysprof-profiler-assistant.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/libsysprof-ui/sysprof-profiler-assistant.c b/src/libsysprof-ui/sysprof-profiler-assistant.c
index 2506e11..d725bea 100644
--- a/src/libsysprof-ui/sysprof-profiler-assistant.c
+++ b/src/libsysprof-ui/sysprof-profiler-assistant.c
@@ -24,6 +24,8 @@
 
 #include <sysprof.h>
 
+#include "sysprof-platform.h"
+
 #include "sysprof-aid-icon.h"
 #include "sysprof-cpu-aid.h"
 #include "sysprof-environ-editor.h"
@@ -184,16 +186,28 @@ sysprof_profiler_assistant_record_clicked_cb (SysprofProfilerAssistant *self,
                                               GtkButton                *button)
 {
   g_autoptr(SysprofProfiler) profiler = NULL;
+  g_autoptr(SysprofCaptureWriter) writer = NULL;
 #ifdef __linux__
   g_autoptr(SysprofSource) proc_source = NULL;
 #endif
+  gint fd;
 
   g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self));
   g_assert (GTK_IS_BUTTON (button));
 
   gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE);
 
+  /* Setup a writer immediately */
+  if (-1 == (fd = sysprof_memfd_create ("[sysprof-capture]")) ||
+      !(writer = sysprof_capture_writer_new_from_fd (fd, 0)))
+    {
+      if (fd != -1)
+        close (fd);
+      return;
+    }
+
   profiler = sysprof_local_profiler_new ();
+  sysprof_profiler_set_writer (profiler, writer);
 
   /* Add pids to profiler */
   gtk_container_foreach (GTK_CONTAINER (self->process_list_box),


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