libsysprof-analyze: cleanup some helper code for symbolize

This commit is contained in:
Christian Hergert
2023-05-08 12:24:44 -07:00
parent c18b401ab6
commit f2479912e6
2 changed files with 30 additions and 4 deletions

View File

@ -91,10 +91,7 @@ sysprof_document_symbols_add_traceable (SysprofDocumentSymbols *self,
SysprofAddress address = addresses[i];
SysprofAddressContext context;
if (sysprof_address_is_context_switch (address, &context))
g_print ("%d: %s\n", i, sysprof_address_context_to_string (context));
else
g_print ("%d: %p\n", i, (gpointer)address);
/* TODO: */
}
}

View File

@ -11,7 +11,9 @@ symbolize_cb (GObject *object,
{
SysprofDocument *document = (SysprofDocument *)object;
g_autoptr(SysprofDocumentSymbols) symbols = NULL;
g_autoptr(GListModel) traceables = NULL;
g_autoptr(GError) error = NULL;
guint n_items;
g_assert (SYSPROF_IS_DOCUMENT (document));
g_assert (G_IS_ASYNC_RESULT (result));
@ -19,6 +21,33 @@ symbolize_cb (GObject *object,
if (!(symbols = sysprof_document_symbolize_finish (document, result, &error)))
g_error ("Failed to symbolize: %s", error->message);
traceables = sysprof_document_list_traceables (document);
n_items = g_list_model_get_n_items (traceables);
for (guint i = 0; i < n_items; i++)
{
g_autoptr(SysprofDocumentTraceable) traceable = g_list_model_get_item (traceables, i);
guint depth;
g_assert (traceable != NULL);
g_assert (SYSPROF_IS_DOCUMENT_TRACEABLE (traceable));
depth = sysprof_document_traceable_get_stack_depth (traceable);
g_print ("%s depth=%u\n", G_OBJECT_TYPE_NAME (traceable), depth);
for (guint j = 0; j < depth; j++)
{
SysprofAddress address = sysprof_document_traceable_get_stack_address (traceable, j);
g_print (" %02d: %p\n", j, GSIZE_TO_POINTER (address));
/* TODO: get symbol name from document symbols */
}
g_print (" ================\n");
}
g_print ("Document symbolized\n");
g_main_loop_quit (main_loop);