libsysprof: ensure descendants view is categorized

This commit is contained in:
Christian Hergert
2023-07-20 15:31:50 -07:00
parent 516917d74b
commit dfa893f06a
6 changed files with 31 additions and 16 deletions

View File

@ -24,8 +24,6 @@
#include "sysprof-categories-private.h"
#include "sysprof-symbol-private.h"
static SysprofCategories *categories;
SysprofCallgraphCategory
_sysprof_callgraph_node_categorize (SysprofCallgraphNode *node)
{
@ -47,10 +45,7 @@ _sysprof_callgraph_node_categorize (SysprofCallgraphNode *node)
symbol->binary_nick == NULL)
return SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED;
if G_UNLIKELY (categories == NULL)
categories = sysprof_categories_new ();
category = sysprof_categories_lookup (categories, symbol->binary_nick, symbol->name);
category = sysprof_categories_lookup (NULL, symbol->binary_nick, symbol->name);
if (category == 0)
return SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED;

View File

@ -87,5 +87,7 @@ gpointer _sysprof_callgraph_get_symbol_augment (SysprofCallgrap
void _sysprof_callgraph_node_free (SysprofCallgraphNode *self,
gboolean free_self);
SysprofCallgraphCategory _sysprof_callgraph_node_categorize (SysprofCallgraphNode *node);
void _sysprof_callgraph_categorize (SysprofCallgraph *self,
SysprofCallgraphNode *node);
G_END_DECLS

View File

@ -283,15 +283,15 @@ reverse_symbols (SysprofSymbol **symbols,
}
}
static void
sysprof_callgraph_categorize (SysprofCallgraph *self,
SysprofCallgraphNode *node)
void
_sysprof_callgraph_categorize (SysprofCallgraph *self,
SysprofCallgraphNode *node)
{
if (node->category)
return;
if (node->parent && node->parent->category == 0)
sysprof_callgraph_categorize (self, node->parent);
_sysprof_callgraph_categorize (self, node->parent);
switch (node->summary->symbol->kind)
{
@ -437,7 +437,7 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self,
self->augment_func_data);
if ((self->flags & SYSPROF_CALLGRAPH_FLAGS_CATEGORIZE_FRAMES) != 0)
sysprof_callgraph_categorize (self, node);
_sysprof_callgraph_categorize (self, node);
}
static void

View File

@ -26,10 +26,11 @@ G_BEGIN_DECLS
typedef struct _SysprofCategories SysprofCategories;
SysprofCategories *sysprof_categories_new (void);
void sysprof_categories_free (SysprofCategories *categories);
SysprofCallgraphCategory sysprof_categories_lookup (SysprofCategories *categories,
const char *binary_nick,
const char *symbol);
SysprofCategories *sysprof_categories_get_default (void) G_GNUC_CONST;
SysprofCategories *sysprof_categories_new (void);
void sysprof_categories_free (SysprofCategories *categories);
SysprofCallgraphCategory sysprof_categories_lookup (SysprofCategories *categories,
const char *binary_nick,
const char *symbol);
G_END_DECLS

View File

@ -248,6 +248,9 @@ sysprof_categories_lookup (SysprofCategories *categories,
{
GArray *rules;
if (categories == NULL)
categories = sysprof_categories_get_default ();
if (binary_nick == NULL || symbol == NULL)
return 0;
@ -277,3 +280,14 @@ sysprof_categories_lookup (SysprofCategories *categories,
return 0;
}
SysprofCategories *
sysprof_categories_get_default (void)
{
static SysprofCategories *instance;
if (instance == NULL)
instance = sysprof_categories_new ();
return instance;
}

View File

@ -216,6 +216,9 @@ sysprof_descendants_model_add_traceable (SysprofDescendantsModel *self,
SYSPROF_DOCUMENT_FRAME (traceable),
FALSE,
self->callgraph->augment_func_data);
if ((self->callgraph->flags & SYSPROF_CALLGRAPH_FLAGS_CATEGORIZE_FRAMES) != 0)
_sysprof_callgraph_categorize (self->callgraph, node);
}
}