libsysprof: add API to categorize callgraph

This just gets the plumbing in place with some basic categorization for
callgraph information. The real work of categorizing by nick/symbol still
needs to be done (some can be copied from SysprofCategoryIcon).

This also adds a property and getter for SysprofCallgraphFrame which will
expose the node's category to the UI code.
This commit is contained in:
Christian Hergert
2023-07-20 11:26:10 -07:00
parent 5afb315be5
commit 92d2cedb8d
4 changed files with 132 additions and 28 deletions

View File

@ -283,6 +283,52 @@ reverse_symbols (SysprofSymbol **symbols,
}
}
static void
sysprof_callgraph_categorize (SysprofCallgraph *self,
SysprofCallgraphNode *node)
{
SysprofSymbol *symbol = node->summary->symbol;
if (node->category)
return;
if (node->parent && node->parent->category == 0)
sysprof_callgraph_categorize (self, node->parent);
switch (symbol->kind)
{
case SYSPROF_SYMBOL_KIND_ROOT:
case SYSPROF_SYMBOL_KIND_THREAD:
case SYSPROF_SYMBOL_KIND_PROCESS:
node->category = SYSPROF_CALLGRAPH_CATEGORY_PRESENTATION;
break;
case SYSPROF_SYMBOL_KIND_CONTEXT_SWITCH:
node->category = SYSPROF_CALLGRAPH_CATEGORY_CONTEXT_SWITCH;
break;
case SYSPROF_SYMBOL_KIND_KERNEL:
node->category = SYSPROF_CALLGRAPH_CATEGORY_KERNEL;
break;
case SYSPROF_SYMBOL_KIND_UNWINDABLE:
node->category = SYSPROF_CALLGRAPH_CATEGORY_UNWINDABLE;
break;
case SYSPROF_SYMBOL_KIND_USER:
G_GNUC_FALLTHROUGH;
default:
if (node->parent)
node->category = node->parent->category;
else
node->category = SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED;
break;
}
}
static void
sysprof_callgraph_add_traceable (SysprofCallgraph *self,
SysprofDocumentTraceable *traceable,
@ -370,6 +416,9 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self,
SYSPROF_DOCUMENT_FRAME (traceable),
TRUE,
self->augment_func_data);
if ((self->flags & SYSPROF_CALLGRAPH_FLAGS_CATEGORIZE_FRAMES) != 0)
sysprof_callgraph_categorize (self, node);
}
static void