blob: dfa56008d9ad03bcc3acf2f195609c9eea9316ed [file] [log] [blame]
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +02001#ifndef __PERF_CALLCHAIN_H
2#define __PERF_CALLCHAIN_H
3
4#include "../perf.h"
Arnaldo Carvalho de Melo5da50252009-07-01 14:46:08 -03005#include <linux/list.h>
Arnaldo Carvalho de Melo43cbcd82009-07-01 12:28:37 -03006#include <linux/rbtree.h>
Frederic Weisbecker44249612009-07-01 05:35:14 +02007#include "symbol.h"
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +02008
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +02009enum chain_mode {
10 FLAT,
11 GRAPH
12};
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020013
14struct callchain_node {
15 struct callchain_node *parent;
16 struct list_head brothers;
Ingo Molnarf37a2912009-07-01 12:37:06 +020017 struct list_head children;
18 struct list_head val;
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020019 struct rb_node rb_node; /* to sort nodes in an rbtree */
20 struct rb_root rb_root; /* sorted tree of children */
Ingo Molnarf37a2912009-07-01 12:37:06 +020021 unsigned int val_nr;
22 u64 hit;
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020023 u64 cumul_hit; /* hit + hits of children */
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020024};
25
26struct callchain_list {
Ingo Molnarf37a2912009-07-01 12:37:06 +020027 u64 ip;
Frederic Weisbecker44249612009-07-01 05:35:14 +020028 struct symbol *sym;
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020029 struct list_head list;
30};
31
32static inline void callchain_init(struct callchain_node *node)
33{
34 INIT_LIST_HEAD(&node->brothers);
35 INIT_LIST_HEAD(&node->children);
36 INIT_LIST_HEAD(&node->val);
37}
38
Frederic Weisbecker44249612009-07-01 05:35:14 +020039void append_chain(struct callchain_node *root, struct ip_callchain *chain,
40 struct symbol **syms);
Frederic Weisbecker4eb3e472009-07-02 17:58:21 +020041void sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node);
42void sort_chain_graph(struct rb_root *rb_root, struct callchain_node *node);
Frederic Weisbecker8cb76d92009-06-26 16:28:00 +020043#endif