libsysprof-analyze: add n-items property to callgraph frame

Also add a ==0 helper in is_leaf().
This commit is contained in:
Christian Hergert
2023-07-19 15:15:56 -07:00
parent 69bcc6f200
commit 83c63a09e9
2 changed files with 20 additions and 0 deletions

View File

@ -44,6 +44,7 @@ enum {
PROP_0, PROP_0,
PROP_CALLGRAPH, PROP_CALLGRAPH,
PROP_SYMBOL, PROP_SYMBOL,
PROP_N_ITEMS,
N_PROPS N_PROPS
}; };
@ -122,6 +123,10 @@ sysprof_callgraph_frame_get_property (GObject *object,
g_value_set_object (value, self->callgraph); g_value_set_object (value, self->callgraph);
break; break;
case PROP_N_ITEMS:
g_value_set_uint (value, g_list_model_get_n_items (G_LIST_MODEL (self)));
break;
case PROP_SYMBOL: case PROP_SYMBOL:
g_value_set_object (value, sysprof_callgraph_frame_get_symbol (self)); g_value_set_object (value, sysprof_callgraph_frame_get_symbol (self));
break; break;
@ -144,6 +149,11 @@ sysprof_callgraph_frame_class_init (SysprofCallgraphFrameClass *klass)
SYSPROF_TYPE_CALLGRAPH, SYSPROF_TYPE_CALLGRAPH,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (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] = properties [PROP_SYMBOL] =
g_param_spec_object ("symbol", NULL, NULL, g_param_spec_object ("symbol", NULL, NULL,
SYSPROF_TYPE_SYMBOL, SYSPROF_TYPE_SYMBOL,
@ -457,3 +467,11 @@ sysprof_callgraph_frame_list_traceables_finish (SysprofCallgraphFrame *self,
return ret; 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;
}

View File

@ -48,5 +48,7 @@ SYSPROF_AVAILABLE_IN_ALL
GListModel *sysprof_callgraph_frame_list_traceables_finish (SysprofCallgraphFrame *self, GListModel *sysprof_callgraph_frame_list_traceables_finish (SysprofCallgraphFrame *self,
GAsyncResult *result, GAsyncResult *result,
GError **error); GError **error);
SYSPROF_AVAILABLE_IN_ALL
gboolean sysprof_callgraph_frame_is_leaf (SysprofCallgraphFrame *self);
G_END_DECLS G_END_DECLS