libsysprof-analyze: implement augmented callgraph

This creates a SysprofCallgraph object which is a GListModel of
SysprofCallgraphFrame. The SysprofCallgraphFrame is also a GListModel of
SysprofCallgraphFrame so that we can map this all into a GtkListView in
the future for tree-like visibility.

The augmentation allows for the same callgraph code to be used for multiple
scenarios such as CPU sampling as well as memory allocation tracking.

If your augmentation size is <=sizeof(void*) then you do not occur an extra
allocation and you can use the inline augmentation space.

The test-callgraph clearly shows that we still need to do the shuffling
of -- Kernel -- and -- User -- like the old callgraph code did. But that
will come soon enough.
This commit is contained in:
Christian Hergert
2023-05-24 17:11:30 -07:00
parent 5e9f745f38
commit 3ae108464d
10 changed files with 552 additions and 92 deletions

View File

@ -24,6 +24,8 @@
#include <sysprof-capture.h>
#include "sysprof-document-frame.h"
G_BEGIN_DECLS
#define SYSPROF_TYPE_CALLGRAPH (sysprof_callgraph_get_type())
@ -31,4 +33,32 @@ G_BEGIN_DECLS
SYSPROF_AVAILABLE_IN_ALL
G_DECLARE_FINAL_TYPE (SysprofCallgraph, sysprof_callgraph, SYSPROF, CALLGRAPH, GObject)
typedef struct _SysprofCallgraphNode SysprofCallgraphNode;
/**
* SysprofAugmentationFunc:
* @callgraph: the callgraph being augmented
* @node: the node within the callgraph
* @frame: the frame used to generate this node
* @user_data: closure data for augmentation func
*
* This function is called for the bottom most node in a trace as it is added
* to a callgraph.
*
* 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.
*/
typedef void (*SysprofAugmentationFunc) (SysprofCallgraph *callgraph,
SysprofCallgraphNode *node,
SysprofDocumentFrame *frame,
gpointer user_data);
SYSPROF_AVAILABLE_IN_ALL
gpointer sysprof_callgraph_get_augment (SysprofCallgraph *callgraph,
SysprofCallgraphNode *node);
SYSPROF_AVAILABLE_IN_ALL
SysprofCallgraphNode *sysprof_callgraph_node_parent (SysprofCallgraphNode *node);
G_END_DECLS