diff --git a/src/libsysprof/sysprof-callgraph-categorize.c b/src/libsysprof/sysprof-callgraph-categorize.c index 207a9815..293c53d5 100644 --- a/src/libsysprof/sysprof-callgraph-categorize.c +++ b/src/libsysprof/sysprof-callgraph-categorize.c @@ -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; diff --git a/src/libsysprof/sysprof-callgraph-private.h b/src/libsysprof/sysprof-callgraph-private.h index b5c37122..b4d7ad3a 100644 --- a/src/libsysprof/sysprof-callgraph-private.h +++ b/src/libsysprof/sysprof-callgraph-private.h @@ -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 diff --git a/src/libsysprof/sysprof-callgraph.c b/src/libsysprof/sysprof-callgraph.c index a352e8a3..9055f846 100644 --- a/src/libsysprof/sysprof-callgraph.c +++ b/src/libsysprof/sysprof-callgraph.c @@ -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 diff --git a/src/libsysprof/sysprof-categories-private.h b/src/libsysprof/sysprof-categories-private.h index c1508bf8..ce46d9f4 100644 --- a/src/libsysprof/sysprof-categories-private.h +++ b/src/libsysprof/sysprof-categories-private.h @@ -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 diff --git a/src/libsysprof/sysprof-categories.c b/src/libsysprof/sysprof-categories.c index 8f597105..8bc121f1 100644 --- a/src/libsysprof/sysprof-categories.c +++ b/src/libsysprof/sysprof-categories.c @@ -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; +} diff --git a/src/libsysprof/sysprof-descendants-model.c b/src/libsysprof/sysprof-descendants-model.c index 88ac11b1..e7f6c1f8 100644 --- a/src/libsysprof/sysprof-descendants-model.c +++ b/src/libsysprof/sysprof-descendants-model.c @@ -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); } }