[sysprof: 57/63] libsysprof: port UI to new ABI
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof: 57/63] libsysprof: port UI to new ABI
- Date: Sat, 4 Jul 2020 18:34:08 +0000 (UTC)
commit 97ddf5a0cc771e1673eec674c6a933a665ab6db2
Author: Christian Hergert <chergert redhat com>
Date: Thu Jul 2 12:11:44 2020 -0700
libsysprof: port UI to new ABI
Some minor changes were necessary so that we could change the ABI in
libsysprof-capture to be free from GLib (and therefore used by GLib).
This also adds some wrappers for capture API in libsysprof so that we
can continue to use GError from UI code.
src/libsysprof-ui/sysprof-battery-aid.c | 2 +-
src/libsysprof-ui/sysprof-callgraph-aid.c | 2 +-
src/libsysprof-ui/sysprof-counters-aid.c | 2 +-
src/libsysprof-ui/sysprof-cpu-aid.c | 2 +-
src/libsysprof-ui/sysprof-depth-visualizer.c | 4 +-
src/libsysprof-ui/sysprof-details-page.c | 2 +-
src/libsysprof-ui/sysprof-diskstat-aid.c | 2 +-
src/libsysprof-ui/sysprof-display.c | 6 +--
src/libsysprof-ui/sysprof-duplex-visualizer.c | 4 +-
src/libsysprof-ui/sysprof-line-visualizer.c | 4 +-
src/libsysprof-ui/sysprof-log-model.c | 2 +-
src/libsysprof-ui/sysprof-logs-aid.c | 2 +-
src/libsysprof-ui/sysprof-marks-aid.c | 2 +-
src/libsysprof-ui/sysprof-marks-model.c | 2 +-
src/libsysprof-ui/sysprof-memprof-aid.c | 2 +-
src/libsysprof-ui/sysprof-netdev-aid.c | 2 +-
src/libsysprof-ui/sysprof-procs-visualizer.c | 4 +-
src/libsysprof-ui/sysprof-rapl-aid.c | 2 +-
src/libsysprof-ui/sysprof-time-visualizer.c | 2 +-
src/libsysprof-ui/sysprof-visualizers-frame.c | 2 +-
src/libsysprof/sysprof-capture-gobject.c | 67 ++++++++++++++++++++++++++-
src/libsysprof/sysprof-capture-gobject.h | 14 ++++++
src/libsysprof/sysprof.h | 1 +
src/tests/test-capture-view.c | 2 +-
24 files changed, 107 insertions(+), 29 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-battery-aid.c b/src/libsysprof-ui/sysprof-battery-aid.c
index ab44a28..8bef197 100644
--- a/src/libsysprof-ui/sysprof-battery-aid.c
+++ b/src/libsysprof-ui/sysprof-battery-aid.c
@@ -81,7 +81,7 @@ sysprof_battery_aid_prepare (SysprofAid *self,
#endif
}
-static gboolean
+static bool
collect_battery_counters (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-callgraph-aid.c b/src/libsysprof-ui/sysprof-callgraph-aid.c
index 5b0ebb0..f12be76 100644
--- a/src/libsysprof-ui/sysprof-callgraph-aid.c
+++ b/src/libsysprof-ui/sysprof-callgraph-aid.c
@@ -114,7 +114,7 @@ sysprof_callgraph_aid_prepare (SysprofAid *self,
#endif
}
-static gboolean
+static bool
discover_samples_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-counters-aid.c b/src/libsysprof-ui/sysprof-counters-aid.c
index 2324569..c1d855b 100644
--- a/src/libsysprof-ui/sysprof-counters-aid.c
+++ b/src/libsysprof-ui/sysprof-counters-aid.c
@@ -123,7 +123,7 @@ build_title (const SysprofCaptureCounter *ctr)
return g_string_free (str, FALSE);
}
-static gboolean
+static bool
collect_counters (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-cpu-aid.c b/src/libsysprof-ui/sysprof-cpu-aid.c
index 3902957..5609488 100644
--- a/src/libsysprof-ui/sysprof-cpu-aid.c
+++ b/src/libsysprof-ui/sysprof-cpu-aid.c
@@ -85,7 +85,7 @@ sysprof_cpu_aid_prepare (SysprofAid *self,
#endif
}
-static gboolean
+static bool
collect_info (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-depth-visualizer.c b/src/libsysprof-ui/sysprof-depth-visualizer.c
index 118489d..a3a4df5 100644
--- a/src/libsysprof-ui/sysprof-depth-visualizer.c
+++ b/src/libsysprof-ui/sysprof-depth-visualizer.c
@@ -62,7 +62,7 @@ state_free (State *st)
g_slice_free (State, st);
}
-static gboolean
+static bool
discover_max_n_addr (const SysprofCaptureFrame *frame,
gpointer user_data)
{
@@ -78,7 +78,7 @@ discover_max_n_addr (const SysprofCaptureFrame *frame,
return TRUE;
}
-static gboolean
+static bool
build_point_cache_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-details-page.c b/src/libsysprof-ui/sysprof-details-page.c
index 3f9fcbd..0c41ec4 100644
--- a/src/libsysprof-ui/sysprof-details-page.c
+++ b/src/libsysprof-ui/sysprof-details-page.c
@@ -135,7 +135,7 @@ update_cpu_info_cb (GObject *object,
gtk_label_set_label (self->cpu_label, str);
}
-static gboolean
+static bool
cpu_info_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-diskstat-aid.c b/src/libsysprof-ui/sysprof-diskstat-aid.c
index aff40ec..c87cb3e 100644
--- a/src/libsysprof-ui/sysprof-diskstat-aid.c
+++ b/src/libsysprof-ui/sysprof-diskstat-aid.c
@@ -80,7 +80,7 @@ sysprof_diskstat_aid_prepare (SysprofAid *self,
sysprof_profiler_add_source (profiler, source);
}
-static gboolean
+static bool
collect_diskstat_counters (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index e9886d5..6be5faf 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -143,7 +143,7 @@ sysprof_display_profiler_stopped_cb (SysprofDisplay *self,
g_autoptr(SysprofCaptureReader) reader = NULL;
g_autoptr(GError) error = NULL;
- if (!(reader = sysprof_capture_writer_create_reader (writer, &error)))
+ if (!(reader = sysprof_capture_writer_create_reader_with_error (writer, &error)))
{
g_warning ("Failed to create capture creader: %s\n", error->message);
gtk_stack_set_visible_child (priv->stack, GTK_WIDGET (priv->failed_view));
@@ -1071,7 +1071,7 @@ sysprof_display_open (SysprofDisplay *self,
g_set_object (&priv->file, file);
- if (!(reader = sysprof_capture_reader_new (path, &error)))
+ if (!(reader = sysprof_capture_reader_new_with_error (path, &error)))
{
GtkWidget *dialog;
GtkWidget *window;
@@ -1229,7 +1229,7 @@ sysprof_display_save (SysprofDisplay *self)
g_autofree gchar *path = g_file_get_path (file);
g_autoptr(GError) error = NULL;
- if (!sysprof_capture_reader_save_as (priv->reader, path, &error))
+ if (!sysprof_capture_reader_save_as_with_error (priv->reader, path, &error))
{
GtkWidget *msg;
diff --git a/src/libsysprof-ui/sysprof-duplex-visualizer.c b/src/libsysprof-ui/sysprof-duplex-visualizer.c
index 82bdca0..1901258 100644
--- a/src/libsysprof-ui/sysprof-duplex-visualizer.c
+++ b/src/libsysprof-ui/sysprof-duplex-visualizer.c
@@ -73,7 +73,7 @@ typedef struct
G_DEFINE_TYPE (SysprofDuplexVisualizer, sysprof_duplex_visualizer, SYSPROF_TYPE_VISUALIZER)
-static gboolean
+static bool
collect_ranges_cb (const SysprofCaptureFrame *frame,
gpointer data)
{
@@ -126,7 +126,7 @@ collect_ranges_cb (const SysprofCaptureFrame *frame,
return TRUE;
}
-static gboolean
+static bool
collect_values_cb (const SysprofCaptureFrame *frame,
gpointer data)
{
diff --git a/src/libsysprof-ui/sysprof-line-visualizer.c b/src/libsysprof-ui/sysprof-line-visualizer.c
index 188b2e1..5075a4f 100644
--- a/src/libsysprof-ui/sysprof-line-visualizer.c
+++ b/src/libsysprof-ui/sysprof-line-visualizer.c
@@ -613,7 +613,7 @@ calc_y_int64 (gint64 lower,
return (gdouble)(value - lower) / (gdouble)(upper - lower);
}
-static gboolean
+static bool
sysprof_line_visualizer_load_data_frame_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
@@ -655,7 +655,7 @@ sysprof_line_visualizer_load_data_frame_cb (const SysprofCaptureFrame *frame,
return TRUE;
}
-static gboolean
+static bool
sysprof_line_visualizer_load_data_range_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-log-model.c b/src/libsysprof-ui/sysprof-log-model.c
index 276ea06..8d67254 100644
--- a/src/libsysprof-ui/sysprof-log-model.c
+++ b/src/libsysprof-ui/sysprof-log-model.c
@@ -289,7 +289,7 @@ sysprof_log_model_init (SysprofLogModel *self)
self->items = g_array_new (FALSE, FALSE, sizeof (Item));
}
-static gboolean
+static bool
cursor_foreach_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-logs-aid.c b/src/libsysprof-ui/sysprof-logs-aid.c
index 466eab3..8807cbe 100644
--- a/src/libsysprof-ui/sysprof-logs-aid.c
+++ b/src/libsysprof-ui/sysprof-logs-aid.c
@@ -80,7 +80,7 @@ sysprof_logs_aid_new (void)
return g_object_new (SYSPROF_TYPE_LOGS_AID, NULL);
}
-static gboolean
+static bool
find_marks_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-marks-aid.c b/src/libsysprof-ui/sysprof-marks-aid.c
index a8f79b4..66b2c25 100644
--- a/src/libsysprof-ui/sysprof-marks-aid.c
+++ b/src/libsysprof-ui/sysprof-marks-aid.c
@@ -84,7 +84,7 @@ sysprof_marks_aid_new (void)
return g_object_new (SYSPROF_TYPE_MARKS_AID, NULL);
}
-static gboolean
+static bool
find_marks_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-marks-model.c b/src/libsysprof-ui/sysprof-marks-model.c
index fa5772a..0800064 100644
--- a/src/libsysprof-ui/sysprof-marks-model.c
+++ b/src/libsysprof-ui/sysprof-marks-model.c
@@ -301,7 +301,7 @@ sysprof_marks_model_init (SysprofMarksModel *self)
self->items = g_array_new (FALSE, FALSE, sizeof (Item));
}
-static gboolean
+static bool
cursor_foreach_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-memprof-aid.c b/src/libsysprof-ui/sysprof-memprof-aid.c
index 6299b54..2132517 100644
--- a/src/libsysprof-ui/sysprof-memprof-aid.c
+++ b/src/libsysprof-ui/sysprof-memprof-aid.c
@@ -87,7 +87,7 @@ sysprof_memprof_aid_prepare (SysprofAid *self,
#endif
}
-static gboolean
+static bool
discover_samples_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-netdev-aid.c b/src/libsysprof-ui/sysprof-netdev-aid.c
index f4a75a7..c6970fd 100644
--- a/src/libsysprof-ui/sysprof-netdev-aid.c
+++ b/src/libsysprof-ui/sysprof-netdev-aid.c
@@ -79,7 +79,7 @@ sysprof_netdev_aid_prepare (SysprofAid *self,
sysprof_profiler_add_source (profiler, source);
}
-static gboolean
+static bool
collect_netdev_counters (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-procs-visualizer.c b/src/libsysprof-ui/sysprof-procs-visualizer.c
index b4d34d2..c82007e 100644
--- a/src/libsysprof-ui/sysprof-procs-visualizer.c
+++ b/src/libsysprof-ui/sysprof-procs-visualizer.c
@@ -65,7 +65,7 @@ discovery_ref (Discovery *d)
return d;
}
-static gboolean
+static bool
discover_max_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
@@ -85,7 +85,7 @@ discover_max_cb (const SysprofCaptureFrame *frame,
return TRUE;
}
-static gboolean
+static bool
calc_points_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-rapl-aid.c b/src/libsysprof-ui/sysprof-rapl-aid.c
index 9da61d5..c5d11e6 100644
--- a/src/libsysprof-ui/sysprof-rapl-aid.c
+++ b/src/libsysprof-ui/sysprof-rapl-aid.c
@@ -69,7 +69,7 @@ sysprof_rapl_aid_new (void)
return g_object_new (SYSPROF_TYPE_RAPL_AID, NULL);
}
-static gboolean
+static bool
collect_info (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-time-visualizer.c b/src/libsysprof-ui/sysprof-time-visualizer.c
index cb1d01a..01d32f2 100644
--- a/src/libsysprof-ui/sysprof-time-visualizer.c
+++ b/src/libsysprof-ui/sysprof-time-visualizer.c
@@ -382,7 +382,7 @@ calc_x (gint64 lower,
return (gdouble)(value - lower) / (gdouble)(upper - lower);
}
-static gboolean
+static bool
sysprof_time_visualizer_load_data_frame_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof-ui/sysprof-visualizers-frame.c b/src/libsysprof-ui/sysprof-visualizers-frame.c
index 95b990c..96da31b 100644
--- a/src/libsysprof-ui/sysprof-visualizers-frame.c
+++ b/src/libsysprof-ui/sysprof-visualizers-frame.c
@@ -608,7 +608,7 @@ compare_gint64 (const gint64 *a,
return 0;
}
-static gboolean
+static bool
index_frame_times_frame_cb (const SysprofCaptureFrame *frame,
gpointer user_data)
{
diff --git a/src/libsysprof/sysprof-capture-gobject.c b/src/libsysprof/sysprof-capture-gobject.c
index dbd7cf2..4e6f660 100644
--- a/src/libsysprof/sysprof-capture-gobject.c
+++ b/src/libsysprof/sysprof-capture-gobject.c
@@ -20,10 +20,73 @@
#include "config.h"
-#include "sysprof-capture-gobject.h"
-
+#include <errno.h>
#include <sysprof-capture.h>
+#include "sysprof-capture-gobject.h"
+
G_DEFINE_BOXED_TYPE (SysprofCaptureReader, sysprof_capture_reader,
(GBoxedCopyFunc)sysprof_capture_reader_ref, (GBoxedFreeFunc)sysprof_capture_reader_unref)
G_DEFINE_BOXED_TYPE (SysprofCaptureWriter, sysprof_capture_writer,
(GBoxedCopyFunc)sysprof_capture_writer_ref, (GBoxedFreeFunc)sysprof_capture_writer_unref)
G_DEFINE_BOXED_TYPE (SysprofCaptureCursor, sysprof_capture_cursor,
(GBoxedCopyFunc)sysprof_capture_cursor_ref, (GBoxedFreeFunc)sysprof_capture_cursor_unref)
+
+SysprofCaptureReader *
+sysprof_capture_reader_new_with_error (const char *filename,
+ GError **error)
+{
+ SysprofCaptureReader *ret;
+
+ if (!(ret = sysprof_capture_reader_new (filename)))
+ g_set_error_literal (error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ g_strerror (errno));
+
+ return ret;
+}
+
+SysprofCaptureReader *
+sysprof_capture_reader_new_from_fd_with_error (int fd,
+ GError **error)
+{
+ SysprofCaptureReader *ret;
+
+ if (!(ret = sysprof_capture_reader_new_from_fd (fd)))
+ g_set_error_literal (error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ g_strerror (errno));
+
+ return ret;
+}
+
+SysprofCaptureReader *
+sysprof_capture_writer_create_reader_with_error (SysprofCaptureWriter *self,
+ GError **error)
+{
+ SysprofCaptureReader *ret;
+
+ if (!(ret = sysprof_capture_writer_create_reader (self)))
+ g_set_error_literal (error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ g_strerror (errno));
+
+ return ret;
+}
+
+bool
+sysprof_capture_reader_save_as_with_error (SysprofCaptureReader *self,
+ const char *filename,
+ GError **error)
+{
+ if (!sysprof_capture_reader_save_as (self, filename))
+ {
+ g_set_error_literal (error,
+ G_FILE_ERROR,
+ g_file_error_from_errno (errno),
+ g_strerror (errno));
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/libsysprof/sysprof-capture-gobject.h b/src/libsysprof/sysprof-capture-gobject.h
index 80a2f4c..ca6fbe2 100644
--- a/src/libsysprof/sysprof-capture-gobject.h
+++ b/src/libsysprof/sysprof-capture-gobject.h
@@ -41,4 +41,18 @@ GType sysprof_capture_writer_get_type (void);
SYSPROF_AVAILABLE_IN_ALL
GType sysprof_capture_cursor_get_type (void);
+SYSPROF_AVAILABLE_IN_3_38
+SysprofCaptureReader *sysprof_capture_reader_new_with_error (const char *filename,
+ GError **error);
+SYSPROF_AVAILABLE_IN_3_38
+SysprofCaptureReader *sysprof_capture_reader_new_from_fd_with_error (int fd,
+ GError **error);
+SYSPROF_AVAILABLE_IN_3_38
+SysprofCaptureReader *sysprof_capture_writer_create_reader_with_error (SysprofCaptureWriter *self,
+ GError **error);
+SYSPROF_AVAILABLE_IN_3_38
+bool sysprof_capture_reader_save_as_with_error (SysprofCaptureReader *self,
+ const char *filename,
+ GError **error);
+
G_END_DECLS
diff --git a/src/libsysprof/sysprof.h b/src/libsysprof/sysprof.h
index c9164f7..5abe64b 100644
--- a/src/libsysprof/sysprof.h
+++ b/src/libsysprof/sysprof.h
@@ -18,6 +18,7 @@
#pragma once
+#include <glib.h>
#include <sysprof-capture.h>
G_BEGIN_DECLS
diff --git a/src/tests/test-capture-view.c b/src/tests/test-capture-view.c
index 1dca19a..9768ca1 100644
--- a/src/tests/test-capture-view.c
+++ b/src/tests/test-capture-view.c
@@ -37,7 +37,7 @@ main (gint argc,
return 1;
}
- if (!(reader = sysprof_capture_reader_new (argv[1], &error)))
+ if (!(reader = sysprof_capture_reader_new_with_error (argv[1], &error)))
{
g_printerr ("Failed to load reader: %s\n", error->message);
return 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]