libsysprof: add callgraph flag to merge similar processes

This is the backing implementation to allow for merging multiple processes
which have identical comm[] fields.
This commit is contained in:
Christian Hergert
2023-08-28 13:31:46 -07:00
parent 00c02f0f18
commit cdfae5f7b9
7 changed files with 36 additions and 15 deletions

View File

@ -345,7 +345,8 @@ _sysprof_callgraph_categorize (SysprofCallgraph *self,
static void
sysprof_callgraph_add_traceable (SysprofCallgraph *self,
SysprofDocumentTraceable *traceable,
guint list_model_index)
guint list_model_index,
gboolean merge_similar_processes)
{
SysprofAddressContext final_context;
SysprofCallgraphNode *node;
@ -421,7 +422,7 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self,
if ((self->flags & SYSPROF_CALLGRAPH_FLAGS_INCLUDE_THREADS) != 0)
symbols[n_symbols++] = _sysprof_document_thread_symbol (self->document, pid, tid);
symbols[n_symbols++] = _sysprof_document_process_symbol (self->document, pid);
symbols[n_symbols++] = _sysprof_document_process_symbol (self->document, pid, merge_similar_processes);
symbols[n_symbols++] = everything;
if (n_symbols > self->height)
@ -520,6 +521,7 @@ sysprof_callgraph_new_worker (GTask *task,
GCancellable *cancellable)
{
SysprofCallgraph *self = task_data;
gboolean merge_similar_processes;
guint n_items;
g_assert (G_IS_TASK (task));
@ -529,6 +531,8 @@ sysprof_callgraph_new_worker (GTask *task,
n_items = g_list_model_get_n_items (self->traceables);
merge_similar_processes = (self->flags & SYSPROF_CALLGRAPH_FLAGS_MERGE_SIMILAR_PROCESSES) != 0;
for (guint i = 0; i < n_items; i++)
{
g_autoptr(SysprofDocumentTraceable) traceable = g_list_model_get_item (self->traceables, i);
@ -540,7 +544,7 @@ sysprof_callgraph_new_worker (GTask *task,
if (traceable == NULL)
break;
sysprof_callgraph_add_traceable (self, traceable, i);
sysprof_callgraph_add_traceable (self, traceable, i, merge_similar_processes);
}
/* Sort callgraph nodes alphabetically so that we can use them in the