Blame view
tools/perf/util/callchain.h
4.87 KB
8cb76d99d perf_counter tool... |
1 2 3 4 |
#ifndef __PERF_CALLCHAIN_H #define __PERF_CALLCHAIN_H #include "../perf.h" |
5da502585 perf_counter tool... |
5 |
#include <linux/list.h> |
43cbcd8ac perf_counter tool... |
6 |
#include <linux/rbtree.h> |
139633c6a perf callchain: M... |
7 |
#include "event.h" |
4424961ad perf_counter tool... |
8 |
#include "symbol.h" |
8cb76d99d perf_counter tool... |
9 |
|
2c83bc08e perf tools: Move ... |
10 11 12 13 14 15 |
enum perf_call_graph_mode { CALLCHAIN_NONE, CALLCHAIN_FP, CALLCHAIN_DWARF, CALLCHAIN_MAX }; |
4eb3e4788 perf report: Add ... |
16 |
enum chain_mode { |
b1a88349c perf tools: callc... |
17 |
CHAIN_NONE, |
805d127d6 perf report: Add ... |
18 19 20 |
CHAIN_FLAT, CHAIN_GRAPH_ABS, CHAIN_GRAPH_REL |
4eb3e4788 perf report: Add ... |
21 |
}; |
8cb76d99d perf_counter tool... |
22 |
|
d797fdc5c perf tools: Add i... |
23 24 25 26 |
enum chain_order { ORDER_CALLER, ORDER_CALLEE }; |
8cb76d99d perf_counter tool... |
27 28 |
struct callchain_node { struct callchain_node *parent; |
f37a291c5 perf_counter tool... |
29 |
struct list_head val; |
e369517ce perf callchain: C... |
30 31 32 33 |
struct rb_node rb_node_in; /* to insert nodes in an rbtree */ struct rb_node rb_node; /* to sort nodes in an output tree */ struct rb_root rb_root_in; /* input tree of children */ struct rb_root rb_root; /* sorted output tree of children */ |
f37a291c5 perf_counter tool... |
34 35 |
unsigned int val_nr; u64 hit; |
1953287bf perf tools: Fix c... |
36 |
u64 children_hit; |
8cb76d99d perf_counter tool... |
37 |
}; |
d2009c513 perf: Keep track ... |
38 39 40 41 |
struct callchain_root { u64 max_depth; struct callchain_node node; }; |
805d127d6 perf report: Add ... |
42 |
struct callchain_param; |
d2009c513 perf: Keep track ... |
43 |
typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_root *, |
805d127d6 perf report: Add ... |
44 |
u64, struct callchain_param *); |
99571ab3d perf tools: Suppo... |
45 46 47 48 |
enum chain_key { CCKEY_FUNCTION, CCKEY_ADDRESS }; |
805d127d6 perf report: Add ... |
49 |
struct callchain_param { |
72a128aa0 perf tools: Move ... |
50 51 52 |
bool enabled; enum perf_call_graph_mode record_mode; u32 dump_size; |
805d127d6 perf report: Add ... |
53 |
enum chain_mode mode; |
232a5c948 perf report: Allo... |
54 |
u32 print_limit; |
805d127d6 perf report: Add ... |
55 56 |
double min_percent; sort_chain_func_t sort; |
d797fdc5c perf tools: Add i... |
57 |
enum chain_order order; |
99571ab3d perf tools: Suppo... |
58 |
enum chain_key key; |
8b7bad58e perf callchain: S... |
59 |
bool branch_callstack; |
805d127d6 perf report: Add ... |
60 |
}; |
8f651eae1 perf callchain: M... |
61 |
extern struct callchain_param callchain_param; |
8cb76d99d perf_counter tool... |
62 |
struct callchain_list { |
f37a291c5 perf_counter tool... |
63 |
u64 ip; |
b3c9ac084 perf callchains: ... |
64 |
struct map_symbol ms; |
23f0981bb perf callchain: E... |
65 |
char *srcline; |
8cb76d99d perf_counter tool... |
66 67 |
struct list_head list; }; |
1b3a0e959 perf callchain: F... |
68 69 70 |
/* * A callchain cursor is a single linked list that * let one feed a callchain progressively. |
3fd44cd40 tools: perf: Fix ... |
71 |
* It keeps persistent allocated entries to minimize |
1b3a0e959 perf callchain: F... |
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
* allocations. */ struct callchain_cursor_node { u64 ip; struct map *map; struct symbol *sym; struct callchain_cursor_node *next; }; struct callchain_cursor { u64 nr; struct callchain_cursor_node *first; struct callchain_cursor_node **last; u64 pos; struct callchain_cursor_node *curr; }; |
472606458 perf callchain: M... |
88 |
extern __thread struct callchain_cursor callchain_cursor; |
d2009c513 perf: Keep track ... |
89 |
static inline void callchain_init(struct callchain_root *root) |
8cb76d99d perf_counter tool... |
90 |
{ |
d2009c513 perf: Keep track ... |
91 |
INIT_LIST_HEAD(&root->node.val); |
97aa10527 perf: Resurrect f... |
92 |
|
d2009c513 perf: Keep track ... |
93 94 |
root->node.parent = NULL; root->node.hit = 0; |
98ee74a75 Merge branch 'per... |
95 |
root->node.children_hit = 0; |
e369517ce perf callchain: C... |
96 |
root->node.rb_root_in = RB_ROOT; |
d2009c513 perf: Keep track ... |
97 |
root->max_depth = 0; |
8cb76d99d perf_counter tool... |
98 |
} |
f08c3154a perf callchain: R... |
99 |
static inline u64 callchain_cumul_hits(struct callchain_node *node) |
1953287bf perf tools: Fix c... |
100 101 102 |
{ return node->hit + node->children_hit; } |
16537f135 perf callchain: R... |
103 |
int callchain_register_param(struct callchain_param *param); |
1b3a0e959 perf callchain: F... |
104 105 106 107 108 109 |
int callchain_append(struct callchain_root *root, struct callchain_cursor *cursor, u64 period); int callchain_merge(struct callchain_cursor *cursor, struct callchain_root *dst, struct callchain_root *src); |
139633c6a perf callchain: M... |
110 |
|
1b3a0e959 perf callchain: F... |
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
/* * Initialize a cursor before adding entries inside, but keep * the previously allocated entries as a cache. */ static inline void callchain_cursor_reset(struct callchain_cursor *cursor) { cursor->nr = 0; cursor->last = &cursor->first; } int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, struct map *map, struct symbol *sym); /* Close a cursor writing session. Initialize for the reader */ static inline void callchain_cursor_commit(struct callchain_cursor *cursor) { cursor->curr = cursor->first; cursor->pos = 0; } /* Cursor reading iteration helpers */ static inline struct callchain_cursor_node * callchain_cursor_current(struct callchain_cursor *cursor) { if (cursor->pos == cursor->nr) return NULL; return cursor->curr; } static inline void callchain_cursor_advance(struct callchain_cursor *cursor) { cursor->curr = cursor->curr->next; cursor->pos++; } |
75d9a1085 perf record: Expo... |
146 147 |
struct option; |
2dc9fb1a7 perf tools: Facto... |
148 |
struct hist_entry; |
75d9a1085 perf record: Expo... |
149 150 |
int record_parse_callchain_opt(const struct option *opt, const char *arg, int unset); |
09b0fd45f perf record: Spli... |
151 |
int record_callchain_opt(const struct option *opt, const char *arg, int unset); |
2dc9fb1a7 perf tools: Facto... |
152 153 154 155 |
int sample__resolve_callchain(struct perf_sample *sample, struct symbol **parent, struct perf_evsel *evsel, struct addr_location *al, int max_stack); int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *sample); |
c7405d85d perf tools: Updat... |
156 157 |
int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node, bool hide_unresolved); |
2dc9fb1a7 perf tools: Facto... |
158 |
|
75d9a1085 perf record: Expo... |
159 |
extern const char record_callchain_help[]; |
f7f084f4d perf callchain: M... |
160 |
int parse_callchain_record_opt(const char *arg); |
cff6bb46d perf callchain: A... |
161 |
int parse_callchain_report_opt(const char *arg); |
2b9240caf perf tools: Intro... |
162 |
int perf_callchain_config(const char *var, const char *value); |
be1f13e30 perf callchain: A... |
163 164 165 166 167 168 169 170 171 |
static inline void callchain_cursor_snapshot(struct callchain_cursor *dest, struct callchain_cursor *src) { *dest = *src; dest->first = src->curr; dest->nr -= src->pos; } |
a60335ba3 perf tools powerp... |
172 173 |
#ifdef HAVE_SKIP_CALLCHAIN_IDX |
bb871a9c8 perf tools: A thr... |
174 |
extern int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain); |
a60335ba3 perf tools powerp... |
175 |
#else |
bb871a9c8 perf tools: A thr... |
176 |
static inline int arch_skip_callchain_idx(struct thread *thread __maybe_unused, |
a60335ba3 perf tools powerp... |
177 178 179 180 181 |
struct ip_callchain *chain __maybe_unused) { return -1; } #endif |
2989ccaac perf callchain: U... |
182 183 |
char *callchain_list__sym_name(struct callchain_list *cl, char *bf, size_t bfsize, bool show_dso); |
d114960c4 perf callchain: F... |
184 |
void free_callchain(struct callchain_root *root); |
8b40f521c perf tools: Prote... |
185 |
#endif /* __PERF_CALLCHAIN_H */ |