[sysprof] libsysprof-ui: setup profiler immediately on setup



commit e2d5be5f524529d0cba3c9b5d2667b94d3d8bd66
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]