Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * call-path.h: Manipulate a tree data structure containing function call paths
0004  * Copyright (c) 2014, Intel Corporation.
0005  */
0006 
0007 #ifndef __PERF_CALL_PATH_H
0008 #define __PERF_CALL_PATH_H
0009 
0010 #include <sys/types.h>
0011 
0012 #include <linux/types.h>
0013 #include <linux/rbtree.h>
0014 
0015 /**
0016  * struct call_path - node in list of calls leading to a function call.
0017  * @parent: call path to the parent function call
0018  * @sym: symbol of function called
0019  * @ip: only if sym is null, the ip of the function
0020  * @db_id: id used for db-export
0021  * @in_kernel: whether function is a in the kernel
0022  * @rb_node: node in parent's tree of called functions
0023  * @children: tree of call paths of functions called
0024  *
0025  * In combination with the call_return structure, the call_path structure
0026  * defines a context-sensitive call-graph.
0027  */
0028 struct call_path {
0029     struct call_path *parent;
0030     struct symbol *sym;
0031     u64 ip;
0032     u64 db_id;
0033     bool in_kernel;
0034     struct rb_node rb_node;
0035     struct rb_root children;
0036 };
0037 
0038 #define CALL_PATH_BLOCK_SHIFT 8
0039 #define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT)
0040 #define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1)
0041 
0042 struct call_path_block {
0043     struct call_path cp[CALL_PATH_BLOCK_SIZE];
0044     struct list_head node;
0045 };
0046 
0047 /**
0048  * struct call_path_root - root of all call paths.
0049  * @call_path: root call path
0050  * @blocks: list of blocks to store call paths
0051  * @next: next free space
0052  * @sz: number of spaces
0053  */
0054 struct call_path_root {
0055     struct call_path call_path;
0056     struct list_head blocks;
0057     size_t next;
0058     size_t sz;
0059 };
0060 
0061 struct call_path_root *call_path_root__new(void);
0062 void call_path_root__free(struct call_path_root *cpr);
0063 
0064 struct call_path *call_path__findnew(struct call_path_root *cpr,
0065                      struct call_path *parent,
0066                      struct symbol *sym, u64 ip, u64 ks);
0067 
0068 #endif