libsysprof-analyze: make summary augmentation optional

That way the descendant graphs can generate the self values but ignore the
summary augmentation (as that would mess up the generated values).

This fixes it so that showing the descendants tree keeps proper Total
and Self values.
This commit is contained in:
Christian Hergert
2023-06-13 10:31:42 -07:00
parent 662cc65bb9
commit 6ab28ff641
6 changed files with 22 additions and 12 deletions

View File

@ -329,6 +329,7 @@ sysprof_callgraph_add_traceable (SysprofCallgraph *self,
self->augment_func (self,
node,
SYSPROF_DOCUMENT_FRAME (traceable),
TRUE,
self->augment_func_data);
}

View File

@ -42,6 +42,7 @@ typedef struct _SysprofCallgraphNode SysprofCallgraphNode;
* @callgraph: the callgraph being augmented
* @node: the node within the callgraph
* @frame: the frame used to generate this node
* @summarize: if summaries should be generated
* @user_data: closure data for augmentation func
*
* This function is called for the bottom most node in a trace as it is added
@ -50,11 +51,15 @@ typedef struct _SysprofCallgraphNode SysprofCallgraphNode;
* The augmentation func should augment the node in whatever way it sees fit
* and generally will want to walk up the node tree to the root to augment the
* parents as it goes. Your augmentation function is not called for each node,
* only the last node.
* only the deepest node.
*
* If @summarize is %TRUE, then you should also generate summary augmentation
* using sysprof_callgraph_get_summary_augment() or similar.
*/
typedef void (*SysprofAugmentationFunc) (SysprofCallgraph *callgraph,
SysprofCallgraphNode *node,
SysprofDocumentFrame *frame,
gboolean summarize,
gpointer user_data);
SYSPROF_AVAILABLE_IN_ALL

View File

@ -192,12 +192,11 @@ sysprof_descendants_model_add_traceable (SysprofDescendantsModel *self,
node = sysprof_descendants_model_add_trace (self, symbols, n_symbols);
/* TODO: This will fuck up summaries */
if (node && self->callgraph->augment_func)
self->callgraph->augment_func (self->callgraph,
node,
SYSPROF_DOCUMENT_FRAME (traceable),
FALSE,
self->callgraph->augment_func_data);
}
}

View File

@ -91,6 +91,7 @@ static void
augment_cb (SysprofCallgraph *callgraph,
SysprofCallgraphNode *node,
SysprofDocumentFrame *frame,
gboolean summarize,
gpointer user_data)
{
Augment *aug;

View File

@ -54,10 +54,7 @@ struct _SysprofCallgraphViewClass
GtkWidgetClass parent_class;
gsize augment_size;
void (*augment_func) (SysprofCallgraph *callgraph,
SysprofCallgraphNode *node,
SysprofDocumentFrame *frame,
gpointer user_data);
SysprofAugmentationFunc augment_func;
void (*load) (SysprofCallgraphView *self,
SysprofCallgraph *callgraph);

View File

@ -61,6 +61,7 @@ static void
augment_weight (SysprofCallgraph *callgraph,
SysprofCallgraphNode *node,
SysprofDocumentFrame *frame,
gboolean summarize,
gpointer user_data)
{
AugmentWeight *cur;
@ -75,9 +76,12 @@ augment_weight (SysprofCallgraph *callgraph,
cur->size += 1;
cur->total += 1;
sum = sysprof_callgraph_get_summary_augment (callgraph, node);
sum->size += 1;
sum->total += 1;
if (summarize)
{
sum = sysprof_callgraph_get_summary_augment (callgraph, node);
sum->size += 1;
sum->total += 1;
}
for (node = sysprof_callgraph_node_parent (node);
node != NULL;
@ -86,8 +90,11 @@ augment_weight (SysprofCallgraph *callgraph,
cur = sysprof_callgraph_get_augment (callgraph, node);
cur->total += 1;
sum = sysprof_callgraph_get_summary_augment (callgraph, node);
sum->total += 1;
if (summarize)
{
sum = sysprof_callgraph_get_summary_augment (callgraph, node);
sum->total += 1;
}
}
}