mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
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.
This commit is contained in:
committed by
Philip Withnall
parent
608582d3c4
commit
97ddf5a0cc
@ -81,7 +81,7 @@ sysprof_battery_aid_prepare (SysprofAid *self,
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static bool
|
||||
collect_battery_counters (const SysprofCaptureFrame *frame,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
@ -114,7 +114,7 @@ sysprof_callgraph_aid_prepare (SysprofAid *self,
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static bool
|
||||
discover_samples_cb (const SysprofCaptureFrame *frame,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -85,7 +85,7 @@ sysprof_cpu_aid_prepare (SysprofAid *self,
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static bool
|
||||
collect_info (const SysprofCaptureFrame *frame,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -87,7 +87,7 @@ sysprof_memprof_aid_prepare (SysprofAid *self,
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
static bool
|
||||
discover_samples_cb (const SysprofCaptureFrame *frame,
|
||||
gpointer user_data)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib.h>
|
||||
#include <sysprof-capture.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user