Linux Audio

Check our new training course

Loading...
v4.17
 
 1/*
 2 * call-path.h: Manipulate a tree data structure containing function call paths
 3 * Copyright (c) 2014, Intel Corporation.
 4 *
 5 * This program is free software; you can redistribute it and/or modify it
 6 * under the terms and conditions of the GNU General Public License,
 7 * version 2, as published by the Free Software Foundation.
 8 *
 9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12 * more details.
13 *
14 */
15
16#ifndef __PERF_CALL_PATH_H
17#define __PERF_CALL_PATH_H
18
19#include <sys/types.h>
20
21#include <linux/types.h>
22#include <linux/rbtree.h>
23
24/**
25 * struct call_path - node in list of calls leading to a function call.
26 * @parent: call path to the parent function call
27 * @sym: symbol of function called
28 * @ip: only if sym is null, the ip of the function
29 * @db_id: id used for db-export
30 * @in_kernel: whether function is a in the kernel
31 * @rb_node: node in parent's tree of called functions
32 * @children: tree of call paths of functions called
33 *
34 * In combination with the call_return structure, the call_path structure
35 * defines a context-sensitve call-graph.
36 */
37struct call_path {
38	struct call_path *parent;
39	struct symbol *sym;
40	u64 ip;
41	u64 db_id;
42	bool in_kernel;
43	struct rb_node rb_node;
44	struct rb_root children;
45};
46
47#define CALL_PATH_BLOCK_SHIFT 8
48#define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT)
49#define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1)
50
51struct call_path_block {
52	struct call_path cp[CALL_PATH_BLOCK_SIZE];
53	struct list_head node;
54};
55
56/**
57 * struct call_path_root - root of all call paths.
58 * @call_path: root call path
59 * @blocks: list of blocks to store call paths
60 * @next: next free space
61 * @sz: number of spaces
62 */
63struct call_path_root {
64	struct call_path call_path;
65	struct list_head blocks;
66	size_t next;
67	size_t sz;
68};
69
70struct call_path_root *call_path_root__new(void);
71void call_path_root__free(struct call_path_root *cpr);
72
73struct call_path *call_path__findnew(struct call_path_root *cpr,
74				     struct call_path *parent,
75				     struct symbol *sym, u64 ip, u64 ks);
76
77#endif
v6.8
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * call-path.h: Manipulate a tree data structure containing function call paths
 4 * Copyright (c) 2014, Intel Corporation.
 
 
 
 
 
 
 
 
 
 
 5 */
 6
 7#ifndef __PERF_CALL_PATH_H
 8#define __PERF_CALL_PATH_H
 9
10#include <sys/types.h>
11
12#include <linux/types.h>
13#include <linux/rbtree.h>
14
15/**
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
24 *
25 * In combination with the call_return structure, the call_path structure
26 * defines a context-sensitive call-graph.
27 */
28struct call_path {
29	struct call_path *parent;
30	struct symbol *sym;
31	u64 ip;
32	u64 db_id;
33	bool in_kernel;
34	struct rb_node rb_node;
35	struct rb_root children;
36};
37
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)
41
42struct call_path_block {
43	struct call_path cp[CALL_PATH_BLOCK_SIZE];
44	struct list_head node;
45};
46
47/**
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
53 */
54struct call_path_root {
55	struct call_path call_path;
56	struct list_head blocks;
57	size_t next;
58	size_t sz;
59};
60
61struct call_path_root *call_path_root__new(void);
62void call_path_root__free(struct call_path_root *cpr);
63
64struct call_path *call_path__findnew(struct call_path_root *cpr,
65				     struct call_path *parent,
66				     struct symbol *sym, u64 ip, u64 ks);
67
68#endif