mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 23:20:54 +00:00
libsysprof-profile: add SysprofDiagnostic to recordings
This allows instruments to record a diagnostic and have it land as an object in a GListModel of diagnostics available to the API consumer. Such items may be used by recording UI to display issues with the recording to the user.
This commit is contained in:
@ -51,6 +51,23 @@ wait_cb (GObject *object,
|
||||
g_main_loop_quit (main_loop);
|
||||
}
|
||||
|
||||
static void
|
||||
diagnostics_items_changed_cb (GListModel *model,
|
||||
guint position,
|
||||
guint removed,
|
||||
guint added,
|
||||
gpointer user_data)
|
||||
{
|
||||
for (guint i = 0; i < added; i++)
|
||||
{
|
||||
g_autoptr(SysprofDiagnostic) diagnostic = g_list_model_get_item (model, position+i);
|
||||
|
||||
g_printerr ("%s: %s\n",
|
||||
sysprof_diagnostic_get_domain (diagnostic),
|
||||
sysprof_diagnostic_get_message (diagnostic));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
record_cb (GObject *object,
|
||||
GAsyncResult *result,
|
||||
@ -58,11 +75,23 @@ record_cb (GObject *object,
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(SysprofRecording) recording = sysprof_profiler_record_finish (SYSPROF_PROFILER (object), result, &error);
|
||||
g_autoptr(GListModel) diagnostics = NULL;
|
||||
|
||||
g_assert_no_error (error);
|
||||
g_assert_nonnull (recording);
|
||||
g_assert_true (SYSPROF_IS_RECORDING (recording));
|
||||
|
||||
diagnostics = sysprof_recording_list_diagnostics (recording);
|
||||
g_signal_connect (diagnostics,
|
||||
"items-changed",
|
||||
G_CALLBACK (diagnostics_items_changed_cb),
|
||||
NULL);
|
||||
diagnostics_items_changed_cb (diagnostics,
|
||||
0,
|
||||
0,
|
||||
g_list_model_get_n_items (diagnostics),
|
||||
NULL);
|
||||
|
||||
sysprof_recording_wait_async (recording, NULL, wait_cb, NULL);
|
||||
|
||||
active_recording = recording;
|
||||
|
||||
Reference in New Issue
Block a user