Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009, Frederic Weisbecker <fweisbec@gmail.com> |
| 3 | * |
| 4 | * Handle the callchains from the stream in an ad-hoc radix tree and then |
| 5 | * sort them in an rbtree. |
| 6 | * |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 7 | * Using a radix for code path provides a fast retrieval and factorizes |
| 8 | * memory use. Also that lets us use the paths in a hierarchical graph view. |
| 9 | * |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <stdlib.h> |
| 13 | #include <stdio.h> |
| 14 | #include <stdbool.h> |
| 15 | #include <errno.h> |
| 16 | |
| 17 | #include "callchain.h" |
| 18 | |
Frederic Weisbecker | 14f4654 | 2009-07-02 17:58:19 +0200 | [diff] [blame] | 19 | #define chain_for_each_child(child, parent) \ |
| 20 | list_for_each_entry(child, &parent->children, brothers) |
| 21 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 22 | static void |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 23 | rb_insert_callchain(struct rb_root *root, struct callchain_node *chain, |
| 24 | enum chain_mode mode) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 25 | { |
| 26 | struct rb_node **p = &root->rb_node; |
| 27 | struct rb_node *parent = NULL; |
| 28 | struct callchain_node *rnode; |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 29 | u64 chain_cumul = cumul_hits(chain); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 30 | |
| 31 | while (*p) { |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 32 | u64 rnode_cumul; |
| 33 | |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 34 | parent = *p; |
| 35 | rnode = rb_entry(parent, struct callchain_node, rb_node); |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 36 | rnode_cumul = cumul_hits(rnode); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 37 | |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 38 | switch (mode) { |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 39 | case CHAIN_FLAT: |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 40 | if (rnode->hit < chain->hit) |
| 41 | p = &(*p)->rb_left; |
| 42 | else |
| 43 | p = &(*p)->rb_right; |
| 44 | break; |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 45 | case CHAIN_GRAPH_ABS: /* Falldown */ |
| 46 | case CHAIN_GRAPH_REL: |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 47 | if (rnode_cumul < chain_cumul) |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 48 | p = &(*p)->rb_left; |
| 49 | else |
| 50 | p = &(*p)->rb_right; |
| 51 | break; |
| 52 | default: |
| 53 | break; |
| 54 | } |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | rb_link_node(&chain->rb_node, parent, p); |
| 58 | rb_insert_color(&chain->rb_node, root); |
| 59 | } |
| 60 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 61 | static void |
| 62 | __sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node, |
| 63 | u64 min_hit) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 64 | { |
| 65 | struct callchain_node *child; |
| 66 | |
Frederic Weisbecker | 14f4654 | 2009-07-02 17:58:19 +0200 | [diff] [blame] | 67 | chain_for_each_child(child, node) |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 68 | __sort_chain_flat(rb_root, child, min_hit); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 69 | |
Frederic Weisbecker | c20ab37 | 2009-07-02 20:14:33 +0200 | [diff] [blame] | 70 | if (node->hit && node->hit >= min_hit) |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 71 | rb_insert_callchain(rb_root, node, CHAIN_FLAT); |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 72 | } |
| 73 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 74 | /* |
| 75 | * Once we get every callchains from the stream, we can now |
| 76 | * sort them by hit |
| 77 | */ |
| 78 | static void |
| 79 | sort_chain_flat(struct rb_root *rb_root, struct callchain_node *node, |
| 80 | u64 min_hit, struct callchain_param *param __used) |
| 81 | { |
| 82 | __sort_chain_flat(rb_root, node, min_hit); |
| 83 | } |
| 84 | |
| 85 | static void __sort_chain_graph_abs(struct callchain_node *node, |
| 86 | u64 min_hit) |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 87 | { |
| 88 | struct callchain_node *child; |
| 89 | |
| 90 | node->rb_root = RB_ROOT; |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 91 | |
| 92 | chain_for_each_child(child, node) { |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 93 | __sort_chain_graph_abs(child, min_hit); |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 94 | if (cumul_hits(child) >= min_hit) |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 95 | rb_insert_callchain(&node->rb_root, child, |
| 96 | CHAIN_GRAPH_ABS); |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 97 | } |
| 98 | } |
| 99 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 100 | static void |
| 101 | sort_chain_graph_abs(struct rb_root *rb_root, struct callchain_node *chain_root, |
| 102 | u64 min_hit, struct callchain_param *param __used) |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 103 | { |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 104 | __sort_chain_graph_abs(chain_root, min_hit); |
Frederic Weisbecker | 4eb3e47 | 2009-07-02 17:58:21 +0200 | [diff] [blame] | 105 | rb_root->rb_node = chain_root->rb_root.rb_node; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 106 | } |
| 107 | |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 108 | static void __sort_chain_graph_rel(struct callchain_node *node, |
| 109 | double min_percent) |
| 110 | { |
| 111 | struct callchain_node *child; |
| 112 | u64 min_hit; |
| 113 | |
| 114 | node->rb_root = RB_ROOT; |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 115 | min_hit = node->children_hit * min_percent / 100.0; |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 116 | |
| 117 | chain_for_each_child(child, node) { |
| 118 | __sort_chain_graph_rel(child, min_percent); |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 119 | if (cumul_hits(child) >= min_hit) |
Frederic Weisbecker | 805d127 | 2009-07-05 07:39:21 +0200 | [diff] [blame] | 120 | rb_insert_callchain(&node->rb_root, child, |
| 121 | CHAIN_GRAPH_REL); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | static void |
| 126 | sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root, |
| 127 | u64 min_hit __used, struct callchain_param *param) |
| 128 | { |
| 129 | __sort_chain_graph_rel(chain_root, param->min_percent); |
| 130 | rb_root->rb_node = chain_root->rb_root.rb_node; |
| 131 | } |
| 132 | |
| 133 | int register_callchain_param(struct callchain_param *param) |
| 134 | { |
| 135 | switch (param->mode) { |
| 136 | case CHAIN_GRAPH_ABS: |
| 137 | param->sort = sort_chain_graph_abs; |
| 138 | break; |
| 139 | case CHAIN_GRAPH_REL: |
| 140 | param->sort = sort_chain_graph_rel; |
| 141 | break; |
| 142 | case CHAIN_FLAT: |
| 143 | param->sort = sort_chain_flat; |
| 144 | break; |
| 145 | default: |
| 146 | return -1; |
| 147 | } |
| 148 | return 0; |
| 149 | } |
| 150 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 151 | /* |
| 152 | * Create a child for a parent. If inherit_children, then the new child |
| 153 | * will become the new parent of it's parent children |
| 154 | */ |
| 155 | static struct callchain_node * |
| 156 | create_child(struct callchain_node *parent, bool inherit_children) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 157 | { |
| 158 | struct callchain_node *new; |
| 159 | |
| 160 | new = malloc(sizeof(*new)); |
| 161 | if (!new) { |
| 162 | perror("not enough memory to create child for code path tree"); |
| 163 | return NULL; |
| 164 | } |
| 165 | new->parent = parent; |
| 166 | INIT_LIST_HEAD(&new->children); |
| 167 | INIT_LIST_HEAD(&new->val); |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 168 | |
| 169 | if (inherit_children) { |
| 170 | struct callchain_node *next; |
| 171 | |
| 172 | list_splice(&parent->children, &new->children); |
| 173 | INIT_LIST_HEAD(&parent->children); |
| 174 | |
Frederic Weisbecker | 14f4654 | 2009-07-02 17:58:19 +0200 | [diff] [blame] | 175 | chain_for_each_child(next, new) |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 176 | next->parent = new; |
| 177 | } |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 178 | list_add_tail(&new->brothers, &parent->children); |
| 179 | |
| 180 | return new; |
| 181 | } |
| 182 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 183 | /* |
| 184 | * Fill the node with callchain values |
| 185 | */ |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 186 | static void |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 187 | fill_node(struct callchain_node *node, struct ip_callchain *chain, |
| 188 | int start, struct symbol **syms) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 189 | { |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 190 | unsigned int i; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 191 | |
| 192 | for (i = start; i < chain->nr; i++) { |
| 193 | struct callchain_list *call; |
| 194 | |
Frederic Weisbecker | 9198aa7 | 2009-07-01 05:35:13 +0200 | [diff] [blame] | 195 | call = malloc(sizeof(*call)); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 196 | if (!call) { |
| 197 | perror("not enough memory for the code path tree"); |
| 198 | return; |
| 199 | } |
| 200 | call->ip = chain->ips[i]; |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 201 | call->sym = syms[i]; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 202 | list_add_tail(&call->list, &node->val); |
| 203 | } |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 204 | node->val_nr = chain->nr - start; |
| 205 | if (!node->val_nr) |
| 206 | printf("Warning: empty node in callchain tree\n"); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 207 | } |
| 208 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 209 | static void |
| 210 | add_child(struct callchain_node *parent, struct ip_callchain *chain, |
| 211 | int start, struct symbol **syms) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 212 | { |
| 213 | struct callchain_node *new; |
| 214 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 215 | new = create_child(parent, false); |
| 216 | fill_node(new, chain, start, syms); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 217 | |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 218 | new->children_hit = 0; |
| 219 | new->hit = 1; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 220 | } |
| 221 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 222 | /* |
| 223 | * Split the parent in two parts (a new child is created) and |
| 224 | * give a part of its callchain to the created child. |
| 225 | * Then create another child to host the given callchain of new branch |
| 226 | */ |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 227 | static void |
| 228 | split_add_child(struct callchain_node *parent, struct ip_callchain *chain, |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 229 | struct callchain_list *to_split, int idx_parents, int idx_local, |
| 230 | struct symbol **syms) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 231 | { |
| 232 | struct callchain_node *new; |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 233 | struct list_head *old_tail; |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 234 | unsigned int idx_total = idx_parents + idx_local; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 235 | |
| 236 | /* split */ |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 237 | new = create_child(parent, true); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 238 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 239 | /* split the callchain and move a part to the new child */ |
| 240 | old_tail = parent->val.prev; |
| 241 | list_del_range(&to_split->list, old_tail); |
| 242 | new->val.next = &to_split->list; |
| 243 | new->val.prev = old_tail; |
| 244 | to_split->list.prev = &new->val; |
| 245 | old_tail->next = &new->val; |
| 246 | |
| 247 | /* split the hits */ |
| 248 | new->hit = parent->hit; |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 249 | new->children_hit = parent->children_hit; |
| 250 | parent->children_hit = cumul_hits(new); |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 251 | new->val_nr = parent->val_nr - idx_local; |
| 252 | parent->val_nr = idx_local; |
| 253 | |
| 254 | /* create a new child for the new branch if any */ |
| 255 | if (idx_total < chain->nr) { |
| 256 | parent->hit = 0; |
| 257 | add_child(parent, chain, idx_total, syms); |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 258 | parent->children_hit++; |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 259 | } else { |
| 260 | parent->hit = 1; |
| 261 | } |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static int |
| 265 | __append_chain(struct callchain_node *root, struct ip_callchain *chain, |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 266 | unsigned int start, struct symbol **syms); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 267 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 268 | static void |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 269 | __append_chain_children(struct callchain_node *root, struct ip_callchain *chain, |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 270 | struct symbol **syms, unsigned int start) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 271 | { |
| 272 | struct callchain_node *rnode; |
| 273 | |
| 274 | /* lookup in childrens */ |
Frederic Weisbecker | 14f4654 | 2009-07-02 17:58:19 +0200 | [diff] [blame] | 275 | chain_for_each_child(rnode, root) { |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 276 | unsigned int ret = __append_chain(rnode, chain, start, syms); |
| 277 | |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 278 | if (!ret) |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 279 | goto inc_children_hit; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 280 | } |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 281 | /* nothing in children, add to the current node */ |
| 282 | add_child(root, chain, start, syms); |
Frederic Weisbecker | e05b876 | 2009-07-05 07:39:20 +0200 | [diff] [blame] | 283 | |
Frederic Weisbecker | 1953287 | 2009-08-07 07:11:05 +0200 | [diff] [blame^] | 284 | inc_children_hit: |
| 285 | root->children_hit++; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static int |
| 289 | __append_chain(struct callchain_node *root, struct ip_callchain *chain, |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 290 | unsigned int start, struct symbol **syms) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 291 | { |
| 292 | struct callchain_list *cnode; |
Ingo Molnar | f37a291 | 2009-07-01 12:37:06 +0200 | [diff] [blame] | 293 | unsigned int i = start; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 294 | bool found = false; |
| 295 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 296 | /* |
| 297 | * Lookup in the current node |
| 298 | * If we have a symbol, then compare the start to match |
| 299 | * anywhere inside a function. |
| 300 | */ |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 301 | list_for_each_entry(cnode, &root->val, list) { |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 302 | if (i == chain->nr) |
| 303 | break; |
| 304 | if (cnode->sym && syms[i]) { |
| 305 | if (cnode->sym->start != syms[i]->start) |
| 306 | break; |
| 307 | } else if (cnode->ip != chain->ips[i]) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 308 | break; |
| 309 | if (!found) |
| 310 | found = true; |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 311 | i++; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /* matches not, relay on the parent */ |
| 315 | if (!found) |
| 316 | return -1; |
| 317 | |
| 318 | /* we match only a part of the node. Split it and add the new chain */ |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 319 | if (i - start < root->val_nr) { |
| 320 | split_add_child(root, chain, cnode, start, i - start, syms); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 321 | return 0; |
| 322 | } |
| 323 | |
| 324 | /* we match 100% of the path, increment the hit */ |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 325 | if (i - start == root->val_nr && i == chain->nr) { |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 326 | root->hit++; |
| 327 | return 0; |
| 328 | } |
| 329 | |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 330 | /* We match the node and still have a part remaining */ |
| 331 | __append_chain_children(root, chain, syms, i); |
| 332 | |
| 333 | return 0; |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 334 | } |
| 335 | |
Frederic Weisbecker | 4424961 | 2009-07-01 05:35:14 +0200 | [diff] [blame] | 336 | void append_chain(struct callchain_node *root, struct ip_callchain *chain, |
| 337 | struct symbol **syms) |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 338 | { |
Frederic Weisbecker | deac911 | 2009-07-01 05:35:15 +0200 | [diff] [blame] | 339 | __append_chain_children(root, chain, syms, 0); |
Frederic Weisbecker | 8cb76d9 | 2009-06-26 16:28:00 +0200 | [diff] [blame] | 340 | } |