1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * call-path.h: Manipulate a tree data structure containing function call paths
4 * Copyright (c) 2014, Intel Corporation.
7 #ifndef __PERF_CALL_PATH_H
8 #define __PERF_CALL_PATH_H
10 #include <sys/types.h>
12 #include <linux/types.h>
13 #include <linux/rbtree.h>
16 * struct call_path - node in list of calls leading to a function call.
17 * @parent: call path to the parent function call
18 * @sym: symbol of function called
19 * @ip: only if sym is null, the ip of the function
20 * @db_id: id used for db-export
21 * @in_kernel: whether function is a in the kernel
22 * @rb_node: node in parent's tree of called functions
23 * @children: tree of call paths of functions called
25 * In combination with the call_return structure, the call_path structure
26 * defines a context-sensitive call-graph.
29 struct call_path *parent;
34 struct rb_node rb_node;
35 struct rb_root children;
38 #define CALL_PATH_BLOCK_SHIFT 8
39 #define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT)
40 #define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1)
42 struct call_path_block {
43 struct call_path cp[CALL_PATH_BLOCK_SIZE];
44 struct list_head node;
48 * struct call_path_root - root of all call paths.
49 * @call_path: root call path
50 * @blocks: list of blocks to store call paths
51 * @next: next free space
52 * @sz: number of spaces
54 struct call_path_root {
55 struct call_path call_path;
56 struct list_head blocks;
61 struct call_path_root *call_path_root__new(void);
62 void call_path_root__free(struct call_path_root *cpr);
64 struct call_path *call_path__findnew(struct call_path_root *cpr,
65 struct call_path *parent,
66 struct symbol *sym, u64 ip, u64 ks);