Debian Codegraph @

src/libsysprof/sysprof-callgraph.h

raw
1 /* sysprof-callgraph.h
2 *
3 * Copyright 2023 Christian Hergert <[email protected]>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * SPDX-License-Identifier: GPL-3.0-or-later
19 */
20
21 #pragma once
22
23 #include <gio/gio.h>
24
25 #include <sysprof-capture.h>
26
27 #include "sysprof-callgraph-frame.h"
28 #include "sysprof-callgraph-symbol.h"
29 #include "sysprof-document-frame.h"
30
31 G_BEGIN_DECLS
32
33 #define SYSPROF_TYPE_CALLGRAPH (sysprof_callgraph_get_type())
34
35 SYSPROF_AVAILABLE_IN_ALL
36 G_DECLARE_FINAL_TYPE (SysprofCallgraph, sysprof_callgraph, SYSPROF, CALLGRAPH, GObject)
37
38 typedef struct _SysprofCallgraphNode SysprofCallgraphNode;
39
40 /**
41 * SysprofAugmentationFunc:
42 * @callgraph: the callgraph being augmented
43 * @node: the node within the callgraph
44 * @frame: the frame used to generate this node
45 * @summarize: if summaries should be generated
46 * @user_data: closure data for augmentation func
47 *
48 * This function is called for the bottom most node in a trace as it is added
49 * to a callgraph.
50 *
51 * The augmentation func should augment the node in whatever way it sees fit
52 * and generally will want to walk up the node tree to the root to augment the
53 * parents as it goes. Your augmentation function is not called for each node,
54 * only the deepest node.
55 *
56 * If @summarize is %TRUE, then you should also generate summary augmentation
57 * using sysprof_callgraph_get_summary_augment() or similar.
58 */
59 typedef void (*SysprofAugmentationFunc) (SysprofCallgraph *callgraph,
60 SysprofCallgraphNode *node,
61 SysprofDocumentFrame *frame,
62 gboolean summarize,
63 gpointer user_data);
64
65 typedef enum _SysprofCallgraphCategory
66 {
67 SYSPROF_CALLGRAPH_CATEGORY_UNCATEGORIZED = 1,
68 SYSPROF_CALLGRAPH_CATEGORY_PRESENTATION,
69 SYSPROF_CALLGRAPH_CATEGORY_A11Y,
70 SYSPROF_CALLGRAPH_CATEGORY_ACTIONS,
71 SYSPROF_CALLGRAPH_CATEGORY_CONTEXT_SWITCH,
72 SYSPROF_CALLGRAPH_CATEGORY_COREDUMP,
73 SYSPROF_CALLGRAPH_CATEGORY_CSS,
74 SYSPROF_CALLGRAPH_CATEGORY_GRAPHICS,
75 SYSPROF_CALLGRAPH_CATEGORY_ICONS,
76 SYSPROF_CALLGRAPH_CATEGORY_INPUT,
77 SYSPROF_CALLGRAPH_CATEGORY_IO,
78 SYSPROF_CALLGRAPH_CATEGORY_IPC,
79 SYSPROF_CALLGRAPH_CATEGORY_JAVASCRIPT,
80 SYSPROF_CALLGRAPH_CATEGORY_KERNEL,
81 SYSPROF_CALLGRAPH_CATEGORY_LAYOUT,
82 SYSPROF_CALLGRAPH_CATEGORY_LOCKING,
83 SYSPROF_CALLGRAPH_CATEGORY_MAIN_LOOP,
84 SYSPROF_CALLGRAPH_CATEGORY_MEMORY,
85 SYSPROF_CALLGRAPH_CATEGORY_PAINT,
86 SYSPROF_CALLGRAPH_CATEGORY_TYPE_SYSTEM,
87 SYSPROF_CALLGRAPH_CATEGORY_UNWINDABLE,
88 SYSPROF_CALLGRAPH_CATEGORY_WINDOWING,
89
90 /* Not part of ABI */
91 SYSPROF_CALLGRAPH_CATEGORY_LAST,
92 } SysprofCallgraphCategory;
93
94 typedef enum _SysprofCallgraphFlags
95 {
96 SYSPROF_CALLGRAPH_FLAGS_NONE = 0,
97 SYSPROF_CALLGRAPH_FLAGS_INCLUDE_THREADS = 1 << 1,
98 SYSPROF_CALLGRAPH_FLAGS_HIDE_SYSTEM_LIBRARIES = 1 << 2,
99 SYSPROF_CALLGRAPH_FLAGS_BOTTOM_UP = 1 << 3,
100 SYSPROF_CALLGRAPH_FLAGS_CATEGORIZE_FRAMES = 1 << 4,
101 SYSPROF_CALLGRAPH_FLAGS_IGNORE_PROCESS_0 = 1 << 5,
102 SYSPROF_CALLGRAPH_FLAGS_LEFT_HEAVY = 1 << 6,
103 SYSPROF_CALLGRAPH_FLAGS_MERGE_SIMILAR_PROCESSES = 1 << 7,
104 SYSPROF_CALLGRAPH_FLAGS_IGNORE_KERNEL_PROCESSES = 1 << 8,
105 } SysprofCallgraphFlags;
106
107 SYSPROF_AVAILABLE_IN_ALL
108 GListModel *sysprof_callgraph_list_symbols (SysprofCallgraph *self);
109 SYSPROF_AVAILABLE_IN_ALL
110 GListModel *sysprof_callgraph_list_callers (SysprofCallgraph *self,
111 SysprofSymbol *symbol);
112 SYSPROF_AVAILABLE_IN_ALL
113 GListModel *sysprof_callgraph_list_traceables_for_symbol (SysprofCallgraph *self,
114 SysprofSymbol *symbol);
115 SYSPROF_AVAILABLE_IN_ALL
116 GListModel *sysprof_callgraph_list_traceables_for_symbols_matching (SysprofCallgraph *self,
117 const char *pattern);
118 SYSPROF_AVAILABLE_IN_ALL
119 void sysprof_callgraph_descendants_async (SysprofCallgraph *self,
120 SysprofSymbol *symbol,
121 GCancellable *cancellable,
122 GAsyncReadyCallback callback,
123 gpointer user_data);
124 SYSPROF_AVAILABLE_IN_ALL
125 GListModel *sysprof_callgraph_descendants_finish (SysprofCallgraph *self,
126 GAsyncResult *result,
127 GError **error);
128 SYSPROF_AVAILABLE_IN_ALL
129 gpointer sysprof_callgraph_get_augment (SysprofCallgraph *self,
130 SysprofCallgraphNode *node);
131 SYSPROF_AVAILABLE_IN_ALL
132 gpointer sysprof_callgraph_get_summary_augment (SysprofCallgraph *self,
133 SysprofCallgraphNode *node);
134 SYSPROF_AVAILABLE_IN_ALL
135 SysprofCallgraphNode *sysprof_callgraph_node_parent (SysprofCallgraphNode *node);
136 SYSPROF_AVAILABLE_IN_ALL
137 SysprofCallgraph *sysprof_callgraph_frame_get_callgraph (SysprofCallgraphFrame *self);
138 SYSPROF_AVAILABLE_IN_ALL
139 SysprofCallgraphCategory sysprof_callgraph_frame_get_category (SysprofCallgraphFrame *self);
140 SYSPROF_AVAILABLE_IN_ALL
141 SysprofCallgraph *sysprof_callgraph_symbol_get_callgraph (SysprofCallgraphSymbol *self);
142 SYSPROF_AVAILABLE_IN_ALL
143 void sysprof_callgraph_list_traceables_for_node_async (SysprofCallgraph *self,
144 SysprofCallgraphNode *node,
145 GCancellable *cancellable,
146 GAsyncReadyCallback callback,
147 gpointer user_data);
148 SYSPROF_AVAILABLE_IN_ALL
149 GListModel *sysprof_callgraph_list_traceables_for_node_finish (SysprofCallgraph *self,
150 GAsyncResult *result,
151 GError **error);
152
153 G_END_DECLS