callchain.h 1.0 KB
Newer Older
1 2 3 4
#ifndef __PERF_CALLCHAIN_H
#define __PERF_CALLCHAIN_H

#include "../perf.h"
5
#include <linux/list.h>
6
#include <linux/rbtree.h>
7
#include "symbol.h"
8

9 10 11 12
enum chain_mode {
	FLAT,
	GRAPH
};
13 14 15 16

struct callchain_node {
	struct callchain_node	*parent;
	struct list_head	brothers;
17 18
	struct list_head	children;
	struct list_head	val;
19 20
	struct rb_node		rb_node; /* to sort nodes in an rbtree */
	struct rb_root		rb_root; /* sorted tree of children */
21 22
	unsigned int		val_nr;
	u64			hit;
23
	u64			cumul_hit; /* hit + hits of children */
24 25 26
};

struct callchain_list {
27
	u64			ip;
28
	struct symbol		*sym;
29 30 31 32 33 34 35 36 37 38
	struct list_head	list;
};

static inline void callchain_init(struct callchain_node *node)
{
	INIT_LIST_HEAD(&node->brothers);
	INIT_LIST_HEAD(&node->children);
	INIT_LIST_HEAD(&node->val);
}

39 40
void append_chain(struct callchain_node *root, struct ip_callchain *chain,
		  struct symbol **syms);
41 42 43 44
void sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node,
		     u64 min_hit);
void sort_chain_graph(struct rb_root *rb_root, struct callchain_node *node,
		      u64 min_hit);
45
#endif