libsysprof-analyze: include final address context

We may need to know the final address context so we can inject symbols as
necessary into the top of the callgraph. We know it when generating the
symbols, so just yield it to the caller too.
This commit is contained in:
Christian Hergert
2023-05-25 11:15:07 -07:00
parent 1b0434c854
commit 6f90a552e7
4 changed files with 19 additions and 5 deletions

View File

@ -209,6 +209,7 @@ static void
sysprof_callgraph_add_traceable (SysprofCallgraph *self,
SysprofDocumentTraceable *traceable)
{
SysprofAddressContext final_context;
SysprofCallgraphNode *node;
SysprofSymbol **symbols;
guint stack_depth;
@ -225,7 +226,11 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self,
return;
symbols = g_newa (SysprofSymbol *, stack_depth + 2);
n_symbols = sysprof_document_symbolize_traceable (self->document, traceable, symbols, stack_depth);
n_symbols = sysprof_document_symbolize_traceable (self->document,
traceable,
symbols,
stack_depth,
&final_context);
g_assert (n_symbols > 0);
g_assert (n_symbols <= stack_depth);

View File

@ -1062,6 +1062,8 @@ sysprof_document_list_jitmaps (SysprofDocument *self)
* @traceable: the traceable to extract symbols for
* @symbols: an array to store #SysprofSymbols
* @n_symbols: the number of elements in @symbols
* @final_context: (out) (nullable): a location to store the last address
* context of the stack trace.
*
* Batch symbolizing of a traceable.
*
@ -1074,7 +1076,8 @@ guint
sysprof_document_symbolize_traceable (SysprofDocument *self,
SysprofDocumentTraceable *traceable,
SysprofSymbol **symbols,
guint n_symbols)
guint n_symbols,
SysprofAddressContext *final_context)
{
SysprofAddressContext last_context = SYSPROF_ADDRESS_CONTEXT_NONE;
const SysprofProcessInfo *process_info;
@ -1087,7 +1090,7 @@ sysprof_document_symbolize_traceable (SysprofDocument *self,
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_TRACEABLE (traceable), 0);
if (n_symbols == 0 || symbols == NULL)
return 0;
goto finish;
pid = sysprof_document_frame_get_pid (SYSPROF_DOCUMENT_FRAME (traceable));
process_info = g_hash_table_lookup (self->pid_to_process_info, GINT_TO_POINTER (pid));
@ -1107,6 +1110,10 @@ sysprof_document_symbolize_traceable (SysprofDocument *self,
last_context = context;
}
finish:
if (final_context)
*final_context = last_context;
return n_symbolized;
}

View File

@ -55,7 +55,8 @@ SYSPROF_AVAILABLE_IN_ALL
guint sysprof_document_symbolize_traceable (SysprofDocument *self,
SysprofDocumentTraceable *traceable,
SysprofSymbol **symbols,
guint n_symbols);
guint n_symbols,
SysprofAddressContext *final_context);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_document_callgraph_async (SysprofDocument *self,
GListModel *traceables,

View File

@ -62,7 +62,8 @@ load_cb (GObject *object,
n_symbols = sysprof_document_symbolize_traceable (document,
traceable,
symbols,
G_N_ELEMENTS (symbols));
G_N_ELEMENTS (symbols),
NULL);
g_print ("%s depth=%u pid=%u\n",
G_OBJECT_TYPE_NAME (traceable),