blob: 8bdb7a50018128feb120064bdf76e93572696372 [file] [log] [blame]
Namhyung Kim7ccf4f92012-08-20 13:52:05 +09001#include <stdio.h>
Arnaldo Carvalho de Melo8e99b6d2017-07-20 15:27:39 -03002#include <linux/string.h>
Namhyung Kim7ccf4f92012-08-20 13:52:05 +09003
4#include "../../util/util.h"
5#include "../../util/hist.h"
6#include "../../util/sort.h"
Namhyung Kim5b9e2142013-01-22 18:09:37 +09007#include "../../util/evsel.h"
Arnaldo Carvalho de Melo632a5ca2017-04-17 16:30:49 -03008#include "../../util/srcline.h"
Arnaldo Carvalho de Meloa0675582017-04-17 16:51:59 -03009#include "../../util/string2.h"
Arnaldo Carvalho de Meloe7ff8922017-04-19 21:34:35 -030010#include "../../util/thread.h"
Arnaldo Carvalho de Melo3d689ed2017-04-17 16:10:49 -030011#include "../../util/sane_ctype.h"
Namhyung Kim7ccf4f92012-08-20 13:52:05 +090012
13static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
14{
15 int i;
16 int ret = fprintf(fp, " ");
17
18 for (i = 0; i < left_margin; i++)
19 ret += fprintf(fp, " ");
20
21 return ret;
22}
23
Jin Yao0db64dd2017-03-26 04:34:28 +080024static size_t inline__fprintf(struct map *map, u64 ip, int left_margin,
25 int depth, int depth_mask, FILE *fp)
26{
27 struct dso *dso;
28 struct inline_node *node;
29 struct inline_list *ilist;
30 int ret = 0, i;
31
32 if (map == NULL)
33 return 0;
34
35 dso = map->dso;
36 if (dso == NULL)
37 return 0;
38
Jin Yao0db64dd2017-03-26 04:34:28 +080039 node = dso__parse_addr_inlines(dso,
40 map__rip_2objdump(map, ip));
41 if (node == NULL)
42 return 0;
43
44 list_for_each_entry(ilist, &node->val, list) {
45 if ((ilist->filename != NULL) || (ilist->funcname != NULL)) {
46 ret += callchain__fprintf_left_margin(fp, left_margin);
47
48 for (i = 0; i < depth; i++) {
49 if (depth_mask & (1 << i))
50 ret += fprintf(fp, "|");
51 else
52 ret += fprintf(fp, " ");
53 ret += fprintf(fp, " ");
54 }
55
Milian Wolff5dfa2102017-03-18 22:49:28 +010056 if (callchain_param.key == CCKEY_ADDRESS ||
57 callchain_param.key == CCKEY_SRCLINE) {
Jin Yao0db64dd2017-03-26 04:34:28 +080058 if (ilist->filename != NULL)
59 ret += fprintf(fp, "%s:%d (inline)",
60 ilist->filename,
61 ilist->line_nr);
62 else
63 ret += fprintf(fp, "??");
64 } else if (ilist->funcname != NULL)
65 ret += fprintf(fp, "%s (inline)",
66 ilist->funcname);
67 else if (ilist->filename != NULL)
68 ret += fprintf(fp, "%s:%d (inline)",
69 ilist->filename,
70 ilist->line_nr);
71 else
72 ret += fprintf(fp, "??");
73
74 ret += fprintf(fp, "\n");
75 }
76 }
77
78 inline_node__delete(node);
79 return ret;
80}
81
Namhyung Kim7ccf4f92012-08-20 13:52:05 +090082static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask,
83 int left_margin)
84{
85 int i;
86 size_t ret = callchain__fprintf_left_margin(fp, left_margin);
87
88 for (i = 0; i < depth; i++)
89 if (depth_mask & (1 << i))
90 ret += fprintf(fp, "| ");
91 else
92 ret += fprintf(fp, " ");
93
94 ret += fprintf(fp, "\n");
95
96 return ret;
97}
98
Namhyung Kim5ab250c2015-11-09 14:45:39 +090099static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_node *node,
100 struct callchain_list *chain,
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900101 int depth, int depth_mask, int period,
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900102 u64 total_samples, int left_margin)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900103{
104 int i;
105 size_t ret = 0;
Jin Yao8577ae62016-10-31 09:19:52 +0800106 char bf[1024], *alloc_str = NULL;
107 char buf[64];
108 const char *str;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900109
110 ret += callchain__fprintf_left_margin(fp, left_margin);
111 for (i = 0; i < depth; i++) {
112 if (depth_mask & (1 << i))
113 ret += fprintf(fp, "|");
114 else
115 ret += fprintf(fp, " ");
116 if (!period && i == depth - 1) {
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900117 ret += fprintf(fp, "--");
118 ret += callchain_node__fprintf_value(node, fp, total_samples);
119 ret += fprintf(fp, "--");
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900120 } else
121 ret += fprintf(fp, "%s", " ");
122 }
Jin Yao8577ae62016-10-31 09:19:52 +0800123
124 str = callchain_list__sym_name(chain, bf, sizeof(bf), false);
125
126 if (symbol_conf.show_branchflag_count) {
Jin Yaoc4ee0622017-08-07 21:05:15 +0800127 callchain_list_counts__printf_value(chain, NULL,
128 buf, sizeof(buf));
Jin Yao8577ae62016-10-31 09:19:52 +0800129
130 if (asprintf(&alloc_str, "%s%s", str, buf) < 0)
131 str = "Not enough memory!";
132 else
133 str = alloc_str;
134 }
135
136 fputs(str, fp);
Andi Kleen2989cca2014-11-12 18:05:23 -0800137 fputc('\n', fp);
Jin Yao8577ae62016-10-31 09:19:52 +0800138 free(alloc_str);
Jin Yao0db64dd2017-03-26 04:34:28 +0800139
140 if (symbol_conf.inline_name)
141 ret += inline__fprintf(chain->ms.map, chain->ip,
142 left_margin, depth, depth_mask, fp);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900143 return ret;
144}
145
146static struct symbol *rem_sq_bracket;
147static struct callchain_list rem_hits;
148
149static void init_rem_hits(void)
150{
151 rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
152 if (!rem_sq_bracket) {
153 fprintf(stderr, "Not enough memory to display remaining hits\n");
154 return;
155 }
156
157 strcpy(rem_sq_bracket->name, "[...]");
158 rem_hits.ms.sym = rem_sq_bracket;
159}
160
161static size_t __callchain__fprintf_graph(FILE *fp, struct rb_root *root,
162 u64 total_samples, int depth,
163 int depth_mask, int left_margin)
164{
165 struct rb_node *node, *next;
Namhyung Kimf2af0082015-11-09 14:45:41 +0900166 struct callchain_node *child = NULL;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900167 struct callchain_list *chain;
168 int new_depth_mask = depth_mask;
169 u64 remaining;
170 size_t ret = 0;
171 int i;
172 uint entries_printed = 0;
Namhyung Kimf2af0082015-11-09 14:45:41 +0900173 int cumul_count = 0;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900174
175 remaining = total_samples;
176
177 node = rb_first(root);
178 while (node) {
179 u64 new_total;
180 u64 cumul;
181
182 child = rb_entry(node, struct callchain_node, rb_node);
183 cumul = callchain_cumul_hits(child);
184 remaining -= cumul;
Namhyung Kimf2af0082015-11-09 14:45:41 +0900185 cumul_count += callchain_cumul_counts(child);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900186
187 /*
188 * The depth mask manages the output of pipes that show
189 * the depth. We don't want to keep the pipes of the current
190 * level for the last child of this depth.
191 * Except if we have remaining filtered hits. They will
192 * supersede the last child
193 */
194 next = rb_next(node);
195 if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
196 new_depth_mask &= ~(1 << (depth - 1));
197
198 /*
199 * But we keep the older depth mask for the line separator
200 * to keep the level link until we reach the last child
201 */
202 ret += ipchain__fprintf_graph_line(fp, depth, depth_mask,
203 left_margin);
204 i = 0;
205 list_for_each_entry(chain, &child->val, list) {
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900206 ret += ipchain__fprintf_graph(fp, child, chain, depth,
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900207 new_depth_mask, i++,
208 total_samples,
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900209 left_margin);
210 }
211
212 if (callchain_param.mode == CHAIN_GRAPH_REL)
213 new_total = child->children_hit;
214 else
215 new_total = total_samples;
216
217 ret += __callchain__fprintf_graph(fp, &child->rb_root, new_total,
218 depth + 1,
219 new_depth_mask | (1 << depth),
220 left_margin);
221 node = next;
222 if (++entries_printed == callchain_param.print_limit)
223 break;
224 }
225
226 if (callchain_param.mode == CHAIN_GRAPH_REL &&
227 remaining && remaining != total_samples) {
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900228 struct callchain_node rem_node = {
229 .hit = remaining,
230 };
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900231
232 if (!rem_sq_bracket)
233 return ret;
234
Namhyung Kimf2af0082015-11-09 14:45:41 +0900235 if (callchain_param.value == CCVAL_COUNT && child && child->parent) {
236 rem_node.count = child->parent->children_count - cumul_count;
237 if (rem_node.count <= 0)
238 return ret;
239 }
240
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900241 new_depth_mask &= ~(1 << (depth - 1));
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900242 ret += ipchain__fprintf_graph(fp, &rem_node, &rem_hits, depth,
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900243 new_depth_mask, 0, total_samples,
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900244 left_margin);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900245 }
246
247 return ret;
248}
249
Namhyung Kim7ed5d6e2016-01-28 00:40:53 +0900250/*
251 * If have one single callchain root, don't bother printing
252 * its percentage (100 % in fractal mode and the same percentage
253 * than the hist in graph mode). This also avoid one level of column.
254 *
255 * However when percent-limit applied, it's possible that single callchain
256 * node have different (non-100% in fractal mode) percentage.
257 */
258static bool need_percent_display(struct rb_node *node, u64 parent_samples)
259{
260 struct callchain_node *cnode;
261
262 if (rb_next(node))
263 return true;
264
265 cnode = rb_entry(node, struct callchain_node, rb_node);
266 return callchain_cumul_hits(cnode) != parent_samples;
267}
268
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900269static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
Namhyung Kim54d27b32016-01-28 00:40:52 +0900270 u64 total_samples, u64 parent_samples,
271 int left_margin)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900272{
273 struct callchain_node *cnode;
274 struct callchain_list *chain;
275 u32 entries_printed = 0;
276 bool printed = false;
277 struct rb_node *node;
278 int i = 0;
279 int ret = 0;
Andi Kleen2989cca2014-11-12 18:05:23 -0800280 char bf[1024];
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900281
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900282 node = rb_first(root);
Namhyung Kim7ed5d6e2016-01-28 00:40:53 +0900283 if (node && !need_percent_display(node, parent_samples)) {
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900284 cnode = rb_entry(node, struct callchain_node, rb_node);
285 list_for_each_entry(chain, &cnode->val, list) {
286 /*
287 * If we sort by symbol, the first entry is the same than
288 * the symbol. No need to print it otherwise it appears as
289 * displayed twice.
290 */
Namhyung Kimcfaa1542014-05-19 14:19:30 +0900291 if (!i++ && field_order == NULL &&
Arnaldo Carvalho de Melo8e99b6d2017-07-20 15:27:39 -0300292 sort_order && strstarts(sort_order, "sym"))
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900293 continue;
Jin Yao0db64dd2017-03-26 04:34:28 +0800294
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900295 if (!printed) {
296 ret += callchain__fprintf_left_margin(fp, left_margin);
297 ret += fprintf(fp, "|\n");
298 ret += callchain__fprintf_left_margin(fp, left_margin);
299 ret += fprintf(fp, "---");
300 left_margin += 3;
301 printed = true;
302 } else
303 ret += callchain__fprintf_left_margin(fp, left_margin);
304
Jin Yao8577ae62016-10-31 09:19:52 +0800305 ret += fprintf(fp, "%s",
306 callchain_list__sym_name(chain, bf,
307 sizeof(bf),
308 false));
309
310 if (symbol_conf.show_branchflag_count)
311 ret += callchain_list_counts__printf_value(
Jin Yaoc4ee0622017-08-07 21:05:15 +0800312 chain, fp, NULL, 0);
Jin Yao8577ae62016-10-31 09:19:52 +0800313 ret += fprintf(fp, "\n");
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900314
315 if (++entries_printed == callchain_param.print_limit)
316 break;
Jin Yao0db64dd2017-03-26 04:34:28 +0800317
318 if (symbol_conf.inline_name)
319 ret += inline__fprintf(chain->ms.map,
320 chain->ip,
321 left_margin,
322 0, 0,
323 fp);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900324 }
325 root = &cnode->rb_root;
326 }
327
Namhyung Kim54d27b32016-01-28 00:40:52 +0900328 if (callchain_param.mode == CHAIN_GRAPH_REL)
329 total_samples = parent_samples;
330
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900331 ret += __callchain__fprintf_graph(fp, root, total_samples,
332 1, 1, left_margin);
Namhyung Kim3848c232016-01-28 21:24:54 +0900333 if (ret) {
334 /* do not add a blank line if it printed nothing */
335 ret += fprintf(fp, "\n");
336 }
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900337
338 return ret;
339}
340
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300341static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node,
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900342 u64 total_samples)
343{
344 struct callchain_list *chain;
345 size_t ret = 0;
Andi Kleen2989cca2014-11-12 18:05:23 -0800346 char bf[1024];
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900347
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300348 if (!node)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900349 return 0;
350
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300351 ret += __callchain__fprintf_flat(fp, node->parent, total_samples);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900352
353
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300354 list_for_each_entry(chain, &node->val, list) {
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900355 if (chain->ip >= PERF_CONTEXT_MAX)
356 continue;
Andi Kleen2989cca2014-11-12 18:05:23 -0800357 ret += fprintf(fp, " %s\n", callchain_list__sym_name(chain,
358 bf, sizeof(bf), false));
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900359 }
360
361 return ret;
362}
363
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300364static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree,
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900365 u64 total_samples)
366{
367 size_t ret = 0;
368 u32 entries_printed = 0;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900369 struct callchain_node *chain;
Arnaldo Carvalho de Melo316c7132013-11-05 15:32:36 -0300370 struct rb_node *rb_node = rb_first(tree);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900371
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900372 while (rb_node) {
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900373 chain = rb_entry(rb_node, struct callchain_node, rb_node);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900374
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900375 ret += fprintf(fp, " ");
376 ret += callchain_node__fprintf_value(chain, fp, total_samples);
377 ret += fprintf(fp, "\n");
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900378 ret += __callchain__fprintf_flat(fp, chain, total_samples);
379 ret += fprintf(fp, "\n");
380 if (++entries_printed == callchain_param.print_limit)
381 break;
382
383 rb_node = rb_next(rb_node);
384 }
385
386 return ret;
387}
388
Namhyung Kim26e77922015-11-09 14:45:37 +0900389static size_t __callchain__fprintf_folded(FILE *fp, struct callchain_node *node)
390{
391 const char *sep = symbol_conf.field_sep ?: ";";
392 struct callchain_list *chain;
393 size_t ret = 0;
394 char bf[1024];
395 bool first;
396
397 if (!node)
398 return 0;
399
400 ret += __callchain__fprintf_folded(fp, node->parent);
401
402 first = (ret == 0);
403 list_for_each_entry(chain, &node->val, list) {
404 if (chain->ip >= PERF_CONTEXT_MAX)
405 continue;
406 ret += fprintf(fp, "%s%s", first ? "" : sep,
407 callchain_list__sym_name(chain,
408 bf, sizeof(bf), false));
409 first = false;
410 }
411
412 return ret;
413}
414
415static size_t callchain__fprintf_folded(FILE *fp, struct rb_root *tree,
416 u64 total_samples)
417{
418 size_t ret = 0;
419 u32 entries_printed = 0;
420 struct callchain_node *chain;
421 struct rb_node *rb_node = rb_first(tree);
422
423 while (rb_node) {
Namhyung Kim26e77922015-11-09 14:45:37 +0900424
425 chain = rb_entry(rb_node, struct callchain_node, rb_node);
Namhyung Kim26e77922015-11-09 14:45:37 +0900426
Namhyung Kim5ab250c2015-11-09 14:45:39 +0900427 ret += callchain_node__fprintf_value(chain, fp, total_samples);
428 ret += fprintf(fp, " ");
Namhyung Kim26e77922015-11-09 14:45:37 +0900429 ret += __callchain__fprintf_folded(fp, chain);
430 ret += fprintf(fp, "\n");
431 if (++entries_printed == callchain_param.print_limit)
432 break;
433
434 rb_node = rb_next(rb_node);
435 }
436
437 return ret;
438}
439
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900440static size_t hist_entry_callchain__fprintf(struct hist_entry *he,
441 u64 total_samples, int left_margin,
442 FILE *fp)
443{
Namhyung Kim54d27b32016-01-28 00:40:52 +0900444 u64 parent_samples = he->stat.period;
445
446 if (symbol_conf.cumulate_callchain)
447 parent_samples = he->stat_acc->period;
448
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900449 switch (callchain_param.mode) {
450 case CHAIN_GRAPH_REL:
Namhyung Kim54d27b32016-01-28 00:40:52 +0900451 return callchain__fprintf_graph(fp, &he->sorted_chain, total_samples,
452 parent_samples, left_margin);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900453 break;
454 case CHAIN_GRAPH_ABS:
455 return callchain__fprintf_graph(fp, &he->sorted_chain, total_samples,
Namhyung Kim54d27b32016-01-28 00:40:52 +0900456 parent_samples, left_margin);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900457 break;
458 case CHAIN_FLAT:
459 return callchain__fprintf_flat(fp, &he->sorted_chain, total_samples);
460 break;
Namhyung Kim26e77922015-11-09 14:45:37 +0900461 case CHAIN_FOLDED:
462 return callchain__fprintf_folded(fp, &he->sorted_chain, total_samples);
463 break;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900464 case CHAIN_NONE:
465 break;
466 default:
467 pr_err("Bad callchain mode\n");
468 }
469
470 return 0;
471}
472
Jiri Olsabd28d0c2016-09-22 17:36:36 +0200473int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp,
474 struct perf_hpp_list *hpp_list)
Jiri Olsabe0e6d12013-02-04 16:33:19 +0100475{
476 const char *sep = symbol_conf.field_sep;
477 struct perf_hpp_fmt *fmt;
478 char *start = hpp->buf;
479 int ret;
480 bool first = true;
481
482 if (symbol_conf.exclude_other && !he->parent)
483 return 0;
484
Jiri Olsa9da44db2016-09-22 17:36:29 +0200485 perf_hpp_list__for_each_format(hpp_list, fmt) {
Namhyung Kim361459f2015-12-23 02:07:08 +0900486 if (perf_hpp__should_skip(fmt, he->hists))
Namhyung Kime67d49a2014-03-18 13:00:59 +0900487 continue;
488
Jiri Olsabe0e6d12013-02-04 16:33:19 +0100489 /*
490 * If there's no field_sep, we still need
491 * to display initial ' '.
492 */
493 if (!sep || !first) {
494 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
495 advance_hpp(hpp, ret);
496 } else
497 first = false;
498
Jiri Olsa9754c4f2013-10-25 13:24:53 +0200499 if (perf_hpp__use_color() && fmt->color)
Jiri Olsabe0e6d12013-02-04 16:33:19 +0100500 ret = fmt->color(fmt, hpp, he);
501 else
502 ret = fmt->entry(fmt, hpp, he);
503
Arnaldo Carvalho de Melo89fee702016-02-11 17:14:13 -0300504 ret = hist_entry__snprintf_alignment(he, hpp, fmt, ret);
Jiri Olsabe0e6d12013-02-04 16:33:19 +0100505 advance_hpp(hpp, ret);
506 }
507
508 return hpp->buf - start;
509}
510
Jiri Olsa9da44db2016-09-22 17:36:29 +0200511static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
512{
513 return __hist_entry__snprintf(he, hpp, he->hists->hpp_list);
514}
515
Namhyung Kimef86d682016-02-25 00:13:41 +0900516static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
517 struct perf_hpp *hpp,
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300518 struct hists *hists,
Namhyung Kimef86d682016-02-25 00:13:41 +0900519 FILE *fp)
520{
521 const char *sep = symbol_conf.field_sep;
522 struct perf_hpp_fmt *fmt;
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300523 struct perf_hpp_list_node *fmt_node;
Namhyung Kimef86d682016-02-25 00:13:41 +0900524 char *buf = hpp->buf;
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900525 size_t size = hpp->size;
Namhyung Kimef86d682016-02-25 00:13:41 +0900526 int ret, printed = 0;
527 bool first = true;
528
529 if (symbol_conf.exclude_other && !he->parent)
530 return 0;
531
532 ret = scnprintf(hpp->buf, hpp->size, "%*s", he->depth * HIERARCHY_INDENT, "");
533 advance_hpp(hpp, ret);
534
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300535 /* the first hpp_list_node is for overhead columns */
536 fmt_node = list_first_entry(&hists->hpp_formats,
537 struct perf_hpp_list_node, list);
538 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
Namhyung Kimef86d682016-02-25 00:13:41 +0900539 /*
540 * If there's no field_sep, we still need
541 * to display initial ' '.
542 */
543 if (!sep || !first) {
544 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
545 advance_hpp(hpp, ret);
546 } else
547 first = false;
548
549 if (perf_hpp__use_color() && fmt->color)
550 ret = fmt->color(fmt, hpp, he);
551 else
552 ret = fmt->entry(fmt, hpp, he);
553
554 ret = hist_entry__snprintf_alignment(he, hpp, fmt, ret);
555 advance_hpp(hpp, ret);
556 }
557
Namhyung Kim1b2dbbf2016-03-07 16:44:46 -0300558 if (!sep)
Namhyung Kimef86d682016-02-25 00:13:41 +0900559 ret = scnprintf(hpp->buf, hpp->size, "%*s",
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300560 (hists->nr_hpp_node - 2) * HIERARCHY_INDENT, "");
Namhyung Kimef86d682016-02-25 00:13:41 +0900561 advance_hpp(hpp, ret);
562
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900563 printed += fprintf(fp, "%s", buf);
564
Namhyung Kim1b2dbbf2016-03-07 16:44:46 -0300565 perf_hpp_list__for_each_format(he->hpp_list, fmt) {
566 hpp->buf = buf;
567 hpp->size = size;
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900568
Namhyung Kim1b2dbbf2016-03-07 16:44:46 -0300569 /*
570 * No need to call hist_entry__snprintf_alignment() since this
571 * fmt is always the last column in the hierarchy mode.
572 */
573 if (perf_hpp__use_color() && fmt->color)
574 fmt->color(fmt, hpp, he);
575 else
576 fmt->entry(fmt, hpp, he);
Namhyung Kimef86d682016-02-25 00:13:41 +0900577
Namhyung Kim1b2dbbf2016-03-07 16:44:46 -0300578 /*
579 * dynamic entries are right-aligned but we want left-aligned
580 * in the hierarchy mode
581 */
582 printed += fprintf(fp, "%s%s", sep ?: " ", ltrim(buf));
583 }
584 printed += putc('\n', fp);
Namhyung Kimef86d682016-02-25 00:13:41 +0900585
586 if (symbol_conf.use_callchain && he->leaf) {
587 u64 total = hists__total_period(hists);
588
589 printed += hist_entry_callchain__fprintf(he, total, 0, fp);
590 goto out;
591 }
592
593out:
594 return printed;
595}
596
Namhyung Kim000078b2012-08-20 13:52:06 +0900597static int hist_entry__fprintf(struct hist_entry *he, size_t size,
Jiri Olsad05e3aa2016-06-14 20:19:18 +0200598 char *bf, size_t bfsz, FILE *fp,
599 bool use_callchain)
Namhyung Kim000078b2012-08-20 13:52:06 +0900600{
Namhyung Kim000078b2012-08-20 13:52:06 +0900601 int ret;
Jin Yao0db64dd2017-03-26 04:34:28 +0800602 int callchain_ret = 0;
603 int inline_ret = 0;
Namhyung Kimea251d52012-09-03 11:53:06 +0900604 struct perf_hpp hpp = {
605 .buf = bf,
606 .size = size,
Namhyung Kimea251d52012-09-03 11:53:06 +0900607 };
Jiri Olsa8f1d1b42016-06-14 20:19:17 +0200608 struct hists *hists = he->hists;
Namhyung Kim7e597d32016-01-28 00:40:51 +0900609 u64 total_period = hists->stats.total_period;
Namhyung Kim000078b2012-08-20 13:52:06 +0900610
Arnaldo Carvalho de Melo99cf6662013-09-05 15:39:12 -0300611 if (size == 0 || size > bfsz)
612 size = hpp.size = bfsz;
Namhyung Kim000078b2012-08-20 13:52:06 +0900613
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300614 if (symbol_conf.report_hierarchy)
615 return hist_entry__hierarchy_fprintf(he, &hpp, hists, fp);
Namhyung Kimef86d682016-02-25 00:13:41 +0900616
Namhyung Kim26d8b332014-03-03 16:16:20 +0900617 hist_entry__snprintf(he, &hpp);
Namhyung Kim000078b2012-08-20 13:52:06 +0900618
619 ret = fprintf(fp, "%s\n", bf);
620
Jiri Olsad05e3aa2016-06-14 20:19:18 +0200621 if (use_callchain)
Jin Yao0db64dd2017-03-26 04:34:28 +0800622 callchain_ret = hist_entry_callchain__fprintf(he, total_period,
623 0, fp);
624
625 if (callchain_ret == 0 && symbol_conf.inline_name) {
626 inline_ret = inline__fprintf(he->ms.map, he->ip, 0, 0, 0, fp);
627 ret += inline_ret;
628 if (inline_ret > 0)
629 ret += fprintf(fp, "\n");
630 } else
631 ret += callchain_ret;
Namhyung Kim000078b2012-08-20 13:52:06 +0900632
633 return ret;
634}
635
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300636static int print_hierarchy_indent(const char *sep, int indent,
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900637 const char *line, FILE *fp)
638{
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300639 if (sep != NULL || indent < 2)
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900640 return 0;
641
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300642 return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line);
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900643}
644
Namhyung Kim195bc0f2016-09-13 16:45:50 +0900645static int hists__fprintf_hierarchy_headers(struct hists *hists,
646 struct perf_hpp *hpp, FILE *fp)
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900647{
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300648 bool first_node, first_col;
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300649 int indent;
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900650 int depth;
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900651 unsigned width = 0;
652 unsigned header_width = 0;
653 struct perf_hpp_fmt *fmt;
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300654 struct perf_hpp_list_node *fmt_node;
Namhyung Kim195bc0f2016-09-13 16:45:50 +0900655 const char *sep = symbol_conf.field_sep;
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900656
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300657 indent = hists->nr_hpp_node;
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900658
659 /* preserve max indent depth for column headers */
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300660 print_hierarchy_indent(sep, indent, spaces, fp);
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900661
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300662 /* the first hpp_list_node is for overhead columns */
663 fmt_node = list_first_entry(&hists->hpp_formats,
664 struct perf_hpp_list_node, list);
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900665
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300666 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
Jiri Olsa29659ab2016-08-07 17:28:30 +0200667 fmt->header(fmt, hpp, hists, 0, NULL);
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300668 fprintf(fp, "%s%s", hpp->buf, sep ?: " ");
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900669 }
670
671 /* combine sort headers with ' / ' */
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300672 first_node = true;
673 list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {
674 if (!first_node)
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900675 header_width += fprintf(fp, " / ");
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300676 first_node = false;
677
678 first_col = true;
679 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
680 if (perf_hpp__should_skip(fmt, hists))
681 continue;
682
683 if (!first_col)
684 header_width += fprintf(fp, "+");
685 first_col = false;
686
Jiri Olsa29659ab2016-08-07 17:28:30 +0200687 fmt->header(fmt, hpp, hists, 0, NULL);
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300688
Jiri Olsa7d6a7e72016-04-07 09:11:11 +0200689 header_width += fprintf(fp, "%s", trim(hpp->buf));
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900690 }
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900691 }
692
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900693 fprintf(fp, "\n# ");
694
695 /* preserve max indent depth for initial dots */
Namhyung Kim2dbbe9f2016-03-07 16:44:48 -0300696 print_hierarchy_indent(sep, indent, dots, fp);
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900697
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300698 /* the first hpp_list_node is for overhead columns */
699 fmt_node = list_first_entry(&hists->hpp_formats,
700 struct perf_hpp_list_node, list);
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900701
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300702 first_col = true;
703 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
704 if (!first_col)
705 fprintf(fp, "%s", sep ?: "..");
706 first_col = false;
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900707
Jiri Olsada1b0402016-06-14 20:19:20 +0200708 width = fmt->width(fmt, hpp, hists);
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900709 fprintf(fp, "%.*s", width, dots);
710 }
711
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900712 depth = 0;
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300713 list_for_each_entry_continue(fmt_node, &hists->hpp_formats, list) {
714 first_col = true;
715 width = depth * HIERARCHY_INDENT;
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900716
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300717 perf_hpp_list__for_each_format(&fmt_node->hpp, fmt) {
718 if (perf_hpp__should_skip(fmt, hists))
719 continue;
720
721 if (!first_col)
722 width++; /* for '+' sign between column header */
723 first_col = false;
724
Jiri Olsada1b0402016-06-14 20:19:20 +0200725 width += fmt->width(fmt, hpp, hists);
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300726 }
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900727
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900728 if (width > header_width)
729 header_width = width;
Namhyung Kimcb1fab92016-02-27 03:52:45 +0900730
731 depth++;
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900732 }
733
734 fprintf(fp, "%s%-.*s", sep ?: " ", header_width, dots);
735
Namhyung Kim8e2fc442016-02-25 00:13:42 +0900736 fprintf(fp, "\n#\n");
737
738 return 2;
739}
740
Jiri Olsaf3705b02016-08-07 17:28:29 +0200741static void fprintf_line(struct hists *hists, struct perf_hpp *hpp,
742 int line, FILE *fp)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900743{
Jiri Olsa12400052012-10-13 00:06:16 +0200744 struct perf_hpp_fmt *fmt;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900745 const char *sep = symbol_conf.field_sep;
Jiri Olsa5395a042012-10-04 21:49:37 +0900746 bool first = true;
Jiri Olsa29659ab2016-08-07 17:28:30 +0200747 int span = 0;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900748
Jiri Olsaf0786af2016-01-18 10:24:23 +0100749 hists__for_each_format(hists, fmt) {
Namhyung Kim361459f2015-12-23 02:07:08 +0900750 if (perf_hpp__should_skip(fmt, hists))
Namhyung Kime67d49a2014-03-18 13:00:59 +0900751 continue;
752
Jiri Olsa29659ab2016-08-07 17:28:30 +0200753 if (!first && !span)
Namhyung Kimea251d52012-09-03 11:53:06 +0900754 fprintf(fp, "%s", sep ?: " ");
Jiri Olsa5395a042012-10-04 21:49:37 +0900755 else
756 first = false;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900757
Jiri Olsa29659ab2016-08-07 17:28:30 +0200758 fmt->header(fmt, hpp, hists, line, &span);
759
760 if (!span)
761 fprintf(fp, "%s", hpp->buf);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900762 }
Jiri Olsaf3705b02016-08-07 17:28:29 +0200763}
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900764
Jiri Olsaf3705b02016-08-07 17:28:29 +0200765static int
766hists__fprintf_standard_headers(struct hists *hists,
767 struct perf_hpp *hpp,
768 FILE *fp)
769{
770 struct perf_hpp_list *hpp_list = hists->hpp_list;
771 struct perf_hpp_fmt *fmt;
772 unsigned int width;
773 const char *sep = symbol_conf.field_sep;
774 bool first = true;
775 int line;
776
777 for (line = 0; line < hpp_list->nr_header_lines; line++) {
778 /* first # is displayed one level up */
779 if (line)
780 fprintf(fp, "# ");
781 fprintf_line(hists, hpp, line, fp);
782 fprintf(fp, "\n");
783 }
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900784
785 if (sep)
Jiri Olsaf3705b02016-08-07 17:28:29 +0200786 return hpp_list->nr_header_lines;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900787
Jiri Olsa5395a042012-10-04 21:49:37 +0900788 first = true;
789
Namhyung Kimea251d52012-09-03 11:53:06 +0900790 fprintf(fp, "# ");
Namhyung Kimea251d52012-09-03 11:53:06 +0900791
Jiri Olsaf0786af2016-01-18 10:24:23 +0100792 hists__for_each_format(hists, fmt) {
Jiri Olsa12400052012-10-13 00:06:16 +0200793 unsigned int i;
Namhyung Kimea251d52012-09-03 11:53:06 +0900794
Namhyung Kim361459f2015-12-23 02:07:08 +0900795 if (perf_hpp__should_skip(fmt, hists))
Namhyung Kime67d49a2014-03-18 13:00:59 +0900796 continue;
797
Jiri Olsa5395a042012-10-04 21:49:37 +0900798 if (!first)
Namhyung Kimea251d52012-09-03 11:53:06 +0900799 fprintf(fp, "%s", sep ?: " ");
Jiri Olsa5395a042012-10-04 21:49:37 +0900800 else
801 first = false;
Namhyung Kimea251d52012-09-03 11:53:06 +0900802
Jiri Olsada1b0402016-06-14 20:19:20 +0200803 width = fmt->width(fmt, hpp, hists);
Namhyung Kimea251d52012-09-03 11:53:06 +0900804 for (i = 0; i < width; i++)
805 fprintf(fp, ".");
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900806 }
Namhyung Kimea251d52012-09-03 11:53:06 +0900807
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900808 fprintf(fp, "\n");
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900809 fprintf(fp, "#\n");
Jiri Olsaf3705b02016-08-07 17:28:29 +0200810 return hpp_list->nr_header_lines + 2;
Jiri Olsa36592eb2016-06-14 20:19:14 +0200811}
812
Jiri Olsa2d831452016-09-22 17:36:37 +0200813int hists__fprintf_headers(struct hists *hists, FILE *fp)
Jiri Olsa7a72a2e2016-06-14 20:19:16 +0200814{
Jiri Olsad5278222016-09-19 15:09:13 +0200815 char bf[1024];
Jiri Olsa7a72a2e2016-06-14 20:19:16 +0200816 struct perf_hpp dummy_hpp = {
817 .buf = bf,
818 .size = sizeof(bf),
819 };
820
821 fprintf(fp, "# ");
822
823 if (symbol_conf.report_hierarchy)
824 return hists__fprintf_hierarchy_headers(hists, &dummy_hpp, fp);
825 else
826 return hists__fprintf_standard_headers(hists, &dummy_hpp, fp);
827
828}
829
Jiri Olsa36592eb2016-06-14 20:19:14 +0200830size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
Jiri Olsad05e3aa2016-06-14 20:19:18 +0200831 int max_cols, float min_pcnt, FILE *fp,
832 bool use_callchain)
Jiri Olsa36592eb2016-06-14 20:19:14 +0200833{
Jiri Olsa36592eb2016-06-14 20:19:14 +0200834 struct rb_node *nd;
835 size_t ret = 0;
836 const char *sep = symbol_conf.field_sep;
837 int nr_rows = 0;
838 size_t linesz;
839 char *line = NULL;
840 unsigned indent;
841
842 init_rem_hits();
843
Namhyung Kime3b60bc2016-09-20 14:30:24 +0900844 hists__reset_column_width(hists);
Jiri Olsa36592eb2016-06-14 20:19:14 +0200845
846 if (symbol_conf.col_width_list_str)
847 perf_hpp__set_user_width(symbol_conf.col_width_list_str);
848
849 if (show_header)
850 nr_rows += hists__fprintf_headers(hists, fp);
851
852 if (max_rows && nr_rows >= max_rows)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900853 goto out;
854
Arnaldo Carvalho de Melo99cf6662013-09-05 15:39:12 -0300855 linesz = hists__sort_list_width(hists) + 3 + 1;
Jiri Olsa9754c4f2013-10-25 13:24:53 +0200856 linesz += perf_hpp__color_overhead();
Arnaldo Carvalho de Melo99cf6662013-09-05 15:39:12 -0300857 line = malloc(linesz);
858 if (line == NULL) {
859 ret = -1;
860 goto out;
861 }
862
Namhyung Kimbd4abd32016-02-26 21:13:17 +0900863 indent = hists__overhead_width(hists) + 4;
864
Namhyung Kimef86d682016-02-25 00:13:41 +0900865 for (nd = rb_first(&hists->entries); nd; nd = __rb_hierarchy_next(nd, HMD_FORCE_CHILD)) {
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900866 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
Namhyung Kim14135662013-10-31 10:17:39 +0900867 float percent;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900868
869 if (h->filtered)
870 continue;
871
Namhyung Kim14135662013-10-31 10:17:39 +0900872 percent = hist_entry__get_percent_limit(h);
Namhyung Kim064f1982013-05-14 11:09:04 +0900873 if (percent < min_pcnt)
874 continue;
875
Jiri Olsad05e3aa2016-06-14 20:19:18 +0200876 ret += hist_entry__fprintf(h, max_cols, line, linesz, fp, use_callchain);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900877
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900878 if (max_rows && ++nr_rows >= max_rows)
Arnaldo Carvalho de Melo99cf6662013-09-05 15:39:12 -0300879 break;
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900880
Namhyung Kimbd4abd32016-02-26 21:13:17 +0900881 /*
882 * If all children are filtered out or percent-limited,
883 * display "no entry >= x.xx%" message.
884 */
885 if (!h->leaf && !hist_entry__has_hierarchy_children(h, min_pcnt)) {
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300886 int depth = hists->nr_hpp_node + h->depth + 1;
Namhyung Kimbd4abd32016-02-26 21:13:17 +0900887
Namhyung Kimf58c95e2016-03-07 16:44:49 -0300888 print_hierarchy_indent(sep, depth, spaces, fp);
Namhyung Kimbd4abd32016-02-26 21:13:17 +0900889 fprintf(fp, "%*sno entry >= %.2f%%\n", indent, "", min_pcnt);
890
891 if (max_rows && ++nr_rows >= max_rows)
892 break;
893 }
894
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900895 if (h->ms.map == NULL && verbose > 1) {
Arnaldo Carvalho de Melo93d57312014-03-21 17:57:01 -0300896 __map_groups__fprintf_maps(h->thread->mg,
Jiri Olsaacebd402014-07-14 23:46:47 +0200897 MAP__FUNCTION, fp);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900898 fprintf(fp, "%.10s end\n", graph_dotted_line);
899 }
900 }
Arnaldo Carvalho de Melo99cf6662013-09-05 15:39:12 -0300901
902 free(line);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900903out:
Arnaldo Carvalho de Melo74cf2492013-12-27 16:55:14 -0300904 zfree(&rem_sq_bracket);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900905
906 return ret;
907}
908
Arnaldo Carvalho de Melo52168ee2012-12-18 16:02:17 -0300909size_t events_stats__fprintf(struct events_stats *stats, FILE *fp)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900910{
911 int i;
912 size_t ret = 0;
913
914 for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
915 const char *name;
916
Arnaldo Carvalho de Melo52168ee2012-12-18 16:02:17 -0300917 if (stats->nr_events[i] == 0)
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900918 continue;
919
920 name = perf_event__name(i);
921 if (!strcmp(name, "UNKNOWN"))
922 continue;
923
924 ret += fprintf(fp, "%16s events: %10d\n", name,
Arnaldo Carvalho de Melo52168ee2012-12-18 16:02:17 -0300925 stats->nr_events[i]);
Namhyung Kim7ccf4f92012-08-20 13:52:05 +0900926 }
927
928 return ret;
929}