18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * call-path.h: Manipulate a tree data structure containing function call paths 48c2ecf20Sopenharmony_ci * Copyright (c) 2014, Intel Corporation. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __PERF_CALL_PATH_H 88c2ecf20Sopenharmony_ci#define __PERF_CALL_PATH_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <sys/types.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci#include <linux/rbtree.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/** 168c2ecf20Sopenharmony_ci * struct call_path - node in list of calls leading to a function call. 178c2ecf20Sopenharmony_ci * @parent: call path to the parent function call 188c2ecf20Sopenharmony_ci * @sym: symbol of function called 198c2ecf20Sopenharmony_ci * @ip: only if sym is null, the ip of the function 208c2ecf20Sopenharmony_ci * @db_id: id used for db-export 218c2ecf20Sopenharmony_ci * @in_kernel: whether function is a in the kernel 228c2ecf20Sopenharmony_ci * @rb_node: node in parent's tree of called functions 238c2ecf20Sopenharmony_ci * @children: tree of call paths of functions called 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * In combination with the call_return structure, the call_path structure 268c2ecf20Sopenharmony_ci * defines a context-sensitve call-graph. 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_cistruct call_path { 298c2ecf20Sopenharmony_ci struct call_path *parent; 308c2ecf20Sopenharmony_ci struct symbol *sym; 318c2ecf20Sopenharmony_ci u64 ip; 328c2ecf20Sopenharmony_ci u64 db_id; 338c2ecf20Sopenharmony_ci bool in_kernel; 348c2ecf20Sopenharmony_ci struct rb_node rb_node; 358c2ecf20Sopenharmony_ci struct rb_root children; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define CALL_PATH_BLOCK_SHIFT 8 398c2ecf20Sopenharmony_ci#define CALL_PATH_BLOCK_SIZE (1 << CALL_PATH_BLOCK_SHIFT) 408c2ecf20Sopenharmony_ci#define CALL_PATH_BLOCK_MASK (CALL_PATH_BLOCK_SIZE - 1) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct call_path_block { 438c2ecf20Sopenharmony_ci struct call_path cp[CALL_PATH_BLOCK_SIZE]; 448c2ecf20Sopenharmony_ci struct list_head node; 458c2ecf20Sopenharmony_ci}; 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/** 488c2ecf20Sopenharmony_ci * struct call_path_root - root of all call paths. 498c2ecf20Sopenharmony_ci * @call_path: root call path 508c2ecf20Sopenharmony_ci * @blocks: list of blocks to store call paths 518c2ecf20Sopenharmony_ci * @next: next free space 528c2ecf20Sopenharmony_ci * @sz: number of spaces 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_cistruct call_path_root { 558c2ecf20Sopenharmony_ci struct call_path call_path; 568c2ecf20Sopenharmony_ci struct list_head blocks; 578c2ecf20Sopenharmony_ci size_t next; 588c2ecf20Sopenharmony_ci size_t sz; 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistruct call_path_root *call_path_root__new(void); 628c2ecf20Sopenharmony_civoid call_path_root__free(struct call_path_root *cpr); 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct call_path *call_path__findnew(struct call_path_root *cpr, 658c2ecf20Sopenharmony_ci struct call_path *parent, 668c2ecf20Sopenharmony_ci struct symbol *sym, u64 ip, u64 ks); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#endif 69