From 83c63a09e92d7c8d8bf895301062f8e66875fa00 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 19 Jul 2023 15:15:56 -0700 Subject: [PATCH] libsysprof-analyze: add n-items property to callgraph frame Also add a ==0 helper in is_leaf(). --- .../sysprof-callgraph-frame.c | 18 ++++++++++++++++++ .../sysprof-callgraph-frame.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/libsysprof-analyze/sysprof-callgraph-frame.c b/src/libsysprof-analyze/sysprof-callgraph-frame.c index ed37dde3..b2c61293 100644 --- a/src/libsysprof-analyze/sysprof-callgraph-frame.c +++ b/src/libsysprof-analyze/sysprof-callgraph-frame.c @@ -44,6 +44,7 @@ enum { PROP_0, PROP_CALLGRAPH, PROP_SYMBOL, + PROP_N_ITEMS, N_PROPS }; @@ -122,6 +123,10 @@ sysprof_callgraph_frame_get_property (GObject *object, g_value_set_object (value, self->callgraph); break; + case PROP_N_ITEMS: + g_value_set_uint (value, g_list_model_get_n_items (G_LIST_MODEL (self))); + break; + case PROP_SYMBOL: g_value_set_object (value, sysprof_callgraph_frame_get_symbol (self)); break; @@ -144,6 +149,11 @@ sysprof_callgraph_frame_class_init (SysprofCallgraphFrameClass *klass) SYSPROF_TYPE_CALLGRAPH, (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + properties [PROP_N_ITEMS] = + g_param_spec_uint ("n-items", NULL, NULL, + 0, G_MAXUINT, 0, + (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + properties [PROP_SYMBOL] = g_param_spec_object ("symbol", NULL, NULL, SYSPROF_TYPE_SYMBOL, @@ -457,3 +467,11 @@ sysprof_callgraph_frame_list_traceables_finish (SysprofCallgraphFrame *self, return ret; } + +gboolean +sysprof_callgraph_frame_is_leaf (SysprofCallgraphFrame *self) +{ + g_return_val_if_fail (SYSPROF_IS_CALLGRAPH_FRAME (self), 0); + + return self->n_children == 0; +} diff --git a/src/libsysprof-analyze/sysprof-callgraph-frame.h b/src/libsysprof-analyze/sysprof-callgraph-frame.h index eac1c08b..083dd681 100644 --- a/src/libsysprof-analyze/sysprof-callgraph-frame.h +++ b/src/libsysprof-analyze/sysprof-callgraph-frame.h @@ -48,5 +48,7 @@ SYSPROF_AVAILABLE_IN_ALL GListModel *sysprof_callgraph_frame_list_traceables_finish (SysprofCallgraphFrame *self, GAsyncResult *result, GError **error); +SYSPROF_AVAILABLE_IN_ALL +gboolean sysprof_callgraph_frame_is_leaf (SysprofCallgraphFrame *self); G_END_DECLS