]> git.karo-electronics.de Git - linux-beck.git/blob - tools/perf/builtin-report.c
perf symbols: Move symbol filtering to event__preprocess_sample()
[linux-beck.git] / tools / perf / builtin-report.c
1 /*
2  * builtin-report.c
3  *
4  * Builtin report command: Analyze the perf.data input file,
5  * look up and read DSOs and symbol information and display
6  * a histogram of results, along various sorting keys.
7  */
8 #include "builtin.h"
9
10 #include "util/util.h"
11
12 #include "util/color.h"
13 #include <linux/list.h>
14 #include "util/cache.h"
15 #include <linux/rbtree.h>
16 #include "util/symbol.h"
17 #include "util/string.h"
18 #include "util/callchain.h"
19 #include "util/strlist.h"
20 #include "util/values.h"
21
22 #include "perf.h"
23 #include "util/debug.h"
24 #include "util/header.h"
25 #include "util/session.h"
26
27 #include "util/parse-options.h"
28 #include "util/parse-events.h"
29
30 #include "util/thread.h"
31 #include "util/sort.h"
32 #include "util/hist.h"
33
34 static char             const *input_name = "perf.data";
35
36 static int              force;
37 static bool             use_callchain;
38
39 static int              show_nr_samples;
40
41 static int              show_threads;
42 static struct perf_read_values  show_threads_values;
43
44 static char             default_pretty_printing_style[] = "normal";
45 static char             *pretty_printing_style = default_pretty_printing_style;
46
47 static int              exclude_other = 1;
48
49 static char             callchain_default_opt[] = "fractal,0.5";
50
51 static size_t
52 callchain__fprintf_left_margin(FILE *fp, int left_margin)
53 {
54         int i;
55         int ret;
56
57         ret = fprintf(fp, "            ");
58
59         for (i = 0; i < left_margin; i++)
60                 ret += fprintf(fp, " ");
61
62         return ret;
63 }
64
65 static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask,
66                                           int left_margin)
67 {
68         int i;
69         size_t ret = 0;
70
71         ret += callchain__fprintf_left_margin(fp, left_margin);
72
73         for (i = 0; i < depth; i++)
74                 if (depth_mask & (1 << i))
75                         ret += fprintf(fp, "|          ");
76                 else
77                         ret += fprintf(fp, "           ");
78
79         ret += fprintf(fp, "\n");
80
81         return ret;
82 }
83 static size_t
84 ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, int depth,
85                        int depth_mask, int count, u64 total_samples,
86                        int hits, int left_margin)
87 {
88         int i;
89         size_t ret = 0;
90
91         ret += callchain__fprintf_left_margin(fp, left_margin);
92         for (i = 0; i < depth; i++) {
93                 if (depth_mask & (1 << i))
94                         ret += fprintf(fp, "|");
95                 else
96                         ret += fprintf(fp, " ");
97                 if (!count && i == depth - 1) {
98                         double percent;
99
100                         percent = hits * 100.0 / total_samples;
101                         ret += percent_color_fprintf(fp, "--%2.2f%%-- ", percent);
102                 } else
103                         ret += fprintf(fp, "%s", "          ");
104         }
105         if (chain->sym)
106                 ret += fprintf(fp, "%s\n", chain->sym->name);
107         else
108                 ret += fprintf(fp, "%p\n", (void *)(long)chain->ip);
109
110         return ret;
111 }
112
113 static struct symbol *rem_sq_bracket;
114 static struct callchain_list rem_hits;
115
116 static void init_rem_hits(void)
117 {
118         rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
119         if (!rem_sq_bracket) {
120                 fprintf(stderr, "Not enough memory to display remaining hits\n");
121                 return;
122         }
123
124         strcpy(rem_sq_bracket->name, "[...]");
125         rem_hits.sym = rem_sq_bracket;
126 }
127
128 static size_t
129 __callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
130                            u64 total_samples, int depth, int depth_mask,
131                            int left_margin)
132 {
133         struct rb_node *node, *next;
134         struct callchain_node *child;
135         struct callchain_list *chain;
136         int new_depth_mask = depth_mask;
137         u64 new_total;
138         u64 remaining;
139         size_t ret = 0;
140         int i;
141
142         if (callchain_param.mode == CHAIN_GRAPH_REL)
143                 new_total = self->children_hit;
144         else
145                 new_total = total_samples;
146
147         remaining = new_total;
148
149         node = rb_first(&self->rb_root);
150         while (node) {
151                 u64 cumul;
152
153                 child = rb_entry(node, struct callchain_node, rb_node);
154                 cumul = cumul_hits(child);
155                 remaining -= cumul;
156
157                 /*
158                  * The depth mask manages the output of pipes that show
159                  * the depth. We don't want to keep the pipes of the current
160                  * level for the last child of this depth.
161                  * Except if we have remaining filtered hits. They will
162                  * supersede the last child
163                  */
164                 next = rb_next(node);
165                 if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
166                         new_depth_mask &= ~(1 << (depth - 1));
167
168                 /*
169                  * But we keep the older depth mask for the line seperator
170                  * to keep the level link until we reach the last child
171                  */
172                 ret += ipchain__fprintf_graph_line(fp, depth, depth_mask,
173                                                    left_margin);
174                 i = 0;
175                 list_for_each_entry(chain, &child->val, list) {
176                         if (chain->ip >= PERF_CONTEXT_MAX)
177                                 continue;
178                         ret += ipchain__fprintf_graph(fp, chain, depth,
179                                                       new_depth_mask, i++,
180                                                       new_total,
181                                                       cumul,
182                                                       left_margin);
183                 }
184                 ret += __callchain__fprintf_graph(fp, child, new_total,
185                                                   depth + 1,
186                                                   new_depth_mask | (1 << depth),
187                                                   left_margin);
188                 node = next;
189         }
190
191         if (callchain_param.mode == CHAIN_GRAPH_REL &&
192                 remaining && remaining != new_total) {
193
194                 if (!rem_sq_bracket)
195                         return ret;
196
197                 new_depth_mask &= ~(1 << (depth - 1));
198
199                 ret += ipchain__fprintf_graph(fp, &rem_hits, depth,
200                                               new_depth_mask, 0, new_total,
201                                               remaining, left_margin);
202         }
203
204         return ret;
205 }
206
207
208 static size_t
209 callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
210                          u64 total_samples, int left_margin)
211 {
212         struct callchain_list *chain;
213         bool printed = false;
214         int i = 0;
215         int ret = 0;
216
217         list_for_each_entry(chain, &self->val, list) {
218                 if (chain->ip >= PERF_CONTEXT_MAX)
219                         continue;
220
221                 if (!i++ && sort__first_dimension == SORT_SYM)
222                         continue;
223
224                 if (!printed) {
225                         ret += callchain__fprintf_left_margin(fp, left_margin);
226                         ret += fprintf(fp, "|\n");
227                         ret += callchain__fprintf_left_margin(fp, left_margin);
228                         ret += fprintf(fp, "---");
229
230                         left_margin += 3;
231                         printed = true;
232                 } else
233                         ret += callchain__fprintf_left_margin(fp, left_margin);
234
235                 if (chain->sym)
236                         ret += fprintf(fp, " %s\n", chain->sym->name);
237                 else
238                         ret += fprintf(fp, " %p\n", (void *)(long)chain->ip);
239         }
240
241         ret += __callchain__fprintf_graph(fp, self, total_samples, 1, 1, left_margin);
242
243         return ret;
244 }
245
246 static size_t
247 callchain__fprintf_flat(FILE *fp, struct callchain_node *self,
248                         u64 total_samples)
249 {
250         struct callchain_list *chain;
251         size_t ret = 0;
252
253         if (!self)
254                 return 0;
255
256         ret += callchain__fprintf_flat(fp, self->parent, total_samples);
257
258
259         list_for_each_entry(chain, &self->val, list) {
260                 if (chain->ip >= PERF_CONTEXT_MAX)
261                         continue;
262                 if (chain->sym)
263                         ret += fprintf(fp, "                %s\n", chain->sym->name);
264                 else
265                         ret += fprintf(fp, "                %p\n",
266                                         (void *)(long)chain->ip);
267         }
268
269         return ret;
270 }
271
272 static size_t
273 hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self,
274                               u64 total_samples, int left_margin)
275 {
276         struct rb_node *rb_node;
277         struct callchain_node *chain;
278         size_t ret = 0;
279
280         rb_node = rb_first(&self->sorted_chain);
281         while (rb_node) {
282                 double percent;
283
284                 chain = rb_entry(rb_node, struct callchain_node, rb_node);
285                 percent = chain->hit * 100.0 / total_samples;
286                 switch (callchain_param.mode) {
287                 case CHAIN_FLAT:
288                         ret += percent_color_fprintf(fp, "           %6.2f%%\n",
289                                                      percent);
290                         ret += callchain__fprintf_flat(fp, chain, total_samples);
291                         break;
292                 case CHAIN_GRAPH_ABS: /* Falldown */
293                 case CHAIN_GRAPH_REL:
294                         ret += callchain__fprintf_graph(fp, chain, total_samples,
295                                                         left_margin);
296                 case CHAIN_NONE:
297                 default:
298                         break;
299                 }
300                 ret += fprintf(fp, "\n");
301                 rb_node = rb_next(rb_node);
302         }
303
304         return ret;
305 }
306
307 static size_t hist_entry__fprintf(FILE *fp, struct hist_entry *self,
308                                   struct perf_session *session,
309                                   u64 total_samples)
310 {
311         struct sort_entry *se;
312         size_t ret;
313
314         if (exclude_other && !self->parent)
315                 return 0;
316
317         if (total_samples)
318                 ret = percent_color_fprintf(fp,
319                                             symbol_conf.field_sep ? "%.2f" : "   %6.2f%%",
320                                         (self->count * 100.0) / total_samples);
321         else
322                 ret = fprintf(fp, symbol_conf.field_sep ? "%lld" : "%12lld ", self->count);
323
324         if (show_nr_samples) {
325                 if (symbol_conf.field_sep)
326                         fprintf(fp, "%c%lld", *symbol_conf.field_sep, self->count);
327                 else
328                         fprintf(fp, "%11lld", self->count);
329         }
330
331         list_for_each_entry(se, &hist_entry__sort_list, list) {
332                 if (se->elide)
333                         continue;
334
335                 fprintf(fp, "%s", symbol_conf.field_sep ?: "  ");
336                 ret += se->print(fp, self, se->width ? *se->width : 0);
337         }
338
339         ret += fprintf(fp, "\n");
340
341         if (session->use_callchain) {
342                 int left_margin = 0;
343
344                 if (sort__first_dimension == SORT_COMM) {
345                         se = list_first_entry(&hist_entry__sort_list, typeof(*se),
346                                                 list);
347                         left_margin = se->width ? *se->width : 0;
348                         left_margin -= thread__comm_len(self->thread);
349                 }
350
351                 hist_entry_callchain__fprintf(fp, self, total_samples,
352                                               left_margin);
353         }
354
355         return ret;
356 }
357
358 static void thread__comm_adjust(struct thread *self)
359 {
360         char *comm = self->comm;
361
362         if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
363             (!symbol_conf.comm_list ||
364              strlist__has_entry(symbol_conf.comm_list, comm))) {
365                 unsigned int slen = strlen(comm);
366
367                 if (slen > comms__col_width) {
368                         comms__col_width = slen;
369                         threads__col_width = slen + 6;
370                 }
371         }
372 }
373
374 static int thread__set_comm_adjust(struct thread *self, const char *comm)
375 {
376         int ret = thread__set_comm(self, comm);
377
378         if (ret)
379                 return ret;
380
381         thread__comm_adjust(self);
382
383         return 0;
384 }
385
386 /*
387  * collect histogram counts
388  */
389
390 static int perf_session__add_hist_entry(struct perf_session *self,
391                                         struct addr_location *al,
392                                         struct ip_callchain *chain, u64 count)
393 {
394         struct symbol **syms = NULL, *parent = NULL;
395         bool hit;
396         struct hist_entry *he;
397
398         if ((sort__has_parent || self->use_callchain) && chain)
399                 syms = perf_session__resolve_callchain(self, al->thread,
400                                                        chain, &parent);
401         he = __perf_session__add_hist_entry(self, al, parent, count, &hit);
402         if (he == NULL)
403                 return -ENOMEM;
404
405         if (hit)
406                 he->count += count;
407
408         if (self->use_callchain) {
409                 if (!hit)
410                         callchain_init(&he->callchain);
411                 append_chain(&he->callchain, chain, syms);
412                 free(syms);
413         }
414
415         return 0;
416 }
417
418 static size_t perf_session__fprintf_hist_entries(struct perf_session *self,
419                                                  u64 total_samples, FILE *fp)
420 {
421         struct hist_entry *pos;
422         struct sort_entry *se;
423         struct rb_node *nd;
424         size_t ret = 0;
425         unsigned int width;
426         char *col_width = symbol_conf.col_width_list_str;
427         int raw_printing_style;
428
429         raw_printing_style = !strcmp(pretty_printing_style, "raw");
430
431         init_rem_hits();
432
433         fprintf(fp, "# Samples: %Ld\n", (u64)total_samples);
434         fprintf(fp, "#\n");
435
436         fprintf(fp, "# Overhead");
437         if (show_nr_samples) {
438                 if (symbol_conf.field_sep)
439                         fprintf(fp, "%cSamples", *symbol_conf.field_sep);
440                 else
441                         fputs("  Samples  ", fp);
442         }
443         list_for_each_entry(se, &hist_entry__sort_list, list) {
444                 if (se->elide)
445                         continue;
446                 if (symbol_conf.field_sep) {
447                         fprintf(fp, "%c%s", *symbol_conf.field_sep, se->header);
448                         continue;
449                 }
450                 width = strlen(se->header);
451                 if (se->width) {
452                         if (symbol_conf.col_width_list_str) {
453                                 if (col_width) {
454                                         *se->width = atoi(col_width);
455                                         col_width = strchr(col_width, ',');
456                                         if (col_width)
457                                                 ++col_width;
458                                 }
459                         }
460                         width = *se->width = max(*se->width, width);
461                 }
462                 fprintf(fp, "  %*s", width, se->header);
463         }
464         fprintf(fp, "\n");
465
466         if (symbol_conf.field_sep)
467                 goto print_entries;
468
469         fprintf(fp, "# ........");
470         if (show_nr_samples)
471                 fprintf(fp, " ..........");
472         list_for_each_entry(se, &hist_entry__sort_list, list) {
473                 unsigned int i;
474
475                 if (se->elide)
476                         continue;
477
478                 fprintf(fp, "  ");
479                 if (se->width)
480                         width = *se->width;
481                 else
482                         width = strlen(se->header);
483                 for (i = 0; i < width; i++)
484                         fprintf(fp, ".");
485         }
486         fprintf(fp, "\n");
487
488         fprintf(fp, "#\n");
489
490 print_entries:
491         for (nd = rb_first(&self->hists); nd; nd = rb_next(nd)) {
492                 pos = rb_entry(nd, struct hist_entry, rb_node);
493                 ret += hist_entry__fprintf(fp, pos, self, total_samples);
494         }
495
496         if (sort_order == default_sort_order &&
497                         parent_pattern == default_parent_pattern) {
498                 fprintf(fp, "#\n");
499                 fprintf(fp, "# (For a higher level overview, try: perf report --sort comm,dso)\n");
500                 fprintf(fp, "#\n");
501         }
502         fprintf(fp, "\n");
503
504         free(rem_sq_bracket);
505
506         if (show_threads)
507                 perf_read_values_display(fp, &show_threads_values,
508                                          raw_printing_style);
509
510         return ret;
511 }
512
513 static int validate_chain(struct ip_callchain *chain, event_t *event)
514 {
515         unsigned int chain_size;
516
517         chain_size = event->header.size;
518         chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
519
520         if (chain->nr*sizeof(u64) > chain_size)
521                 return -1;
522
523         return 0;
524 }
525
526 static int process_sample_event(event_t *event, struct perf_session *session)
527 {
528         struct sample_data data = { .period = 1, };
529         struct addr_location al;
530
531         event__parse_sample(event, session->sample_type, &data);
532
533         dump_printf("(IP, %d): %d/%d: %p period: %Ld\n",
534                 event->header.misc,
535                 data.pid, data.tid,
536                 (void *)(long)data.ip,
537                 (long long)data.period);
538
539         if (session->sample_type & PERF_SAMPLE_CALLCHAIN) {
540                 unsigned int i;
541
542                 dump_printf("... chain: nr:%Lu\n", data.callchain->nr);
543
544                 if (validate_chain(data.callchain, event) < 0) {
545                         pr_debug("call-chain problem with event, "
546                                  "skipping it.\n");
547                         return 0;
548                 }
549
550                 if (dump_trace) {
551                         for (i = 0; i < data.callchain->nr; i++)
552                                 dump_printf("..... %2d: %016Lx\n",
553                                             i, data.callchain->ips[i]);
554                 }
555         }
556
557         if (event__preprocess_sample(event, session, &al, NULL) < 0) {
558                 fprintf(stderr, "problem processing %d event, skipping it.\n",
559                         event->header.type);
560                 return -1;
561         }
562
563         if (al.filtered)
564                 return 0;
565
566         if (perf_session__add_hist_entry(session, &al, data.callchain, data.period)) {
567                 pr_debug("problem incrementing symbol count, skipping event\n");
568                 return -1;
569         }
570
571         session->events_stats.total += data.period;
572         return 0;
573 }
574
575 static int process_comm_event(event_t *event, struct perf_session *session)
576 {
577         struct thread *thread = perf_session__findnew(session, event->comm.pid);
578
579         dump_printf(": %s:%d\n", event->comm.comm, event->comm.pid);
580
581         if (thread == NULL ||
582             thread__set_comm_adjust(thread, event->comm.comm)) {
583                 dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
584                 return -1;
585         }
586
587         return 0;
588 }
589
590 static int process_read_event(event_t *event, struct perf_session *session __used)
591 {
592         struct perf_event_attr *attr;
593
594         attr = perf_header__find_attr(event->read.id, &session->header);
595
596         if (show_threads) {
597                 const char *name = attr ? __event_name(attr->type, attr->config)
598                                    : "unknown";
599                 perf_read_values_add_value(&show_threads_values,
600                                            event->read.pid, event->read.tid,
601                                            event->read.id,
602                                            name,
603                                            event->read.value);
604         }
605
606         dump_printf(": %d %d %s %Lu\n", event->read.pid, event->read.tid,
607                     attr ? __event_name(attr->type, attr->config) : "FAIL",
608                     event->read.value);
609
610         return 0;
611 }
612
613 static int sample_type_check(struct perf_session *session)
614 {
615         if (!(session->sample_type & PERF_SAMPLE_CALLCHAIN)) {
616                 if (sort__has_parent) {
617                         fprintf(stderr, "selected --sort parent, but no"
618                                         " callchain data. Did you call"
619                                         " perf record without -g?\n");
620                         return -1;
621                 }
622                 if (session->use_callchain) {
623                         fprintf(stderr, "selected -g but no callchain data."
624                                         " Did you call perf record without"
625                                         " -g?\n");
626                         return -1;
627                 }
628         } else if (callchain_param.mode != CHAIN_NONE && !session->use_callchain) {
629                         session->use_callchain = true;
630                         if (register_callchain_param(&callchain_param) < 0) {
631                                 fprintf(stderr, "Can't register callchain"
632                                                 " params\n");
633                                 return -1;
634                         }
635         }
636
637         return 0;
638 }
639
640 static struct perf_event_ops event_ops = {
641         .process_sample_event   = process_sample_event,
642         .process_mmap_event     = event__process_mmap,
643         .process_comm_event     = process_comm_event,
644         .process_exit_event     = event__process_task,
645         .process_fork_event     = event__process_task,
646         .process_lost_event     = event__process_lost,
647         .process_read_event     = process_read_event,
648         .sample_type_check      = sample_type_check,
649 };
650
651
652 static int __cmd_report(void)
653 {
654         int ret;
655         struct perf_session *session;
656
657         session = perf_session__new(input_name, O_RDONLY, force);
658         if (session == NULL)
659                 return -ENOMEM;
660
661         session->use_callchain = use_callchain;
662
663         if (show_threads)
664                 perf_read_values_init(&show_threads_values);
665
666         ret = perf_session__process_events(session, &event_ops);
667         if (ret)
668                 goto out_delete;
669
670         if (dump_trace) {
671                 event__print_totals();
672                 goto out_delete;
673         }
674
675         if (verbose > 3)
676                 perf_session__fprintf(session, stdout);
677
678         if (verbose > 2)
679                 dsos__fprintf(stdout);
680
681         perf_session__collapse_resort(session);
682         perf_session__output_resort(session, session->events_stats.total);
683         perf_session__fprintf_hist_entries(session, session->events_stats.total, stdout);
684
685         if (show_threads)
686                 perf_read_values_destroy(&show_threads_values);
687 out_delete:
688         perf_session__delete(session);
689         return ret;
690 }
691
692 static int
693 parse_callchain_opt(const struct option *opt __used, const char *arg,
694                     int unset __used)
695 {
696         char *tok;
697         char *endptr;
698
699         use_callchain = true;
700
701         if (!arg)
702                 return 0;
703
704         tok = strtok((char *)arg, ",");
705         if (!tok)
706                 return -1;
707
708         /* get the output mode */
709         if (!strncmp(tok, "graph", strlen(arg)))
710                 callchain_param.mode = CHAIN_GRAPH_ABS;
711
712         else if (!strncmp(tok, "flat", strlen(arg)))
713                 callchain_param.mode = CHAIN_FLAT;
714
715         else if (!strncmp(tok, "fractal", strlen(arg)))
716                 callchain_param.mode = CHAIN_GRAPH_REL;
717
718         else if (!strncmp(tok, "none", strlen(arg))) {
719                 callchain_param.mode = CHAIN_NONE;
720                 use_callchain = true;
721
722                 return 0;
723         }
724
725         else
726                 return -1;
727
728         /* get the min percentage */
729         tok = strtok(NULL, ",");
730         if (!tok)
731                 goto setup;
732
733         callchain_param.min_percent = strtod(tok, &endptr);
734         if (tok == endptr)
735                 return -1;
736
737 setup:
738         if (register_callchain_param(&callchain_param) < 0) {
739                 fprintf(stderr, "Can't register callchain params\n");
740                 return -1;
741         }
742         return 0;
743 }
744
745 //static const char * const report_usage[] = {
746 const char * const report_usage[] = {
747         "perf report [<options>] <command>",
748         NULL
749 };
750
751 static const struct option options[] = {
752         OPT_STRING('i', "input", &input_name, "file",
753                     "input file name"),
754         OPT_BOOLEAN('v', "verbose", &verbose,
755                     "be more verbose (show symbol address, etc)"),
756         OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
757                     "dump raw trace in ASCII"),
758         OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
759                    "file", "vmlinux pathname"),
760         OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
761         OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
762                     "load module symbols - WARNING: use only with -k and LIVE kernel"),
763         OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
764                     "Show a column with the number of samples"),
765         OPT_BOOLEAN('T', "threads", &show_threads,
766                     "Show per-thread event counters"),
767         OPT_STRING(0, "pretty", &pretty_printing_style, "key",
768                    "pretty printing style key: normal raw"),
769         OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
770                    "sort by key(s): pid, comm, dso, symbol, parent"),
771         OPT_BOOLEAN('P', "full-paths", &event_ops.full_paths,
772                     "Don't shorten the pathnames taking into account the cwd"),
773         OPT_STRING('p', "parent", &parent_pattern, "regex",
774                    "regex filter to identify parent, see: '--sort parent'"),
775         OPT_BOOLEAN('x', "exclude-other", &exclude_other,
776                     "Only display entries with parent-match"),
777         OPT_CALLBACK_DEFAULT('g', "call-graph", NULL, "output_type,min_percent",
778                      "Display callchains using output_type and min percent threshold. "
779                      "Default: fractal,0.5", &parse_callchain_opt, callchain_default_opt),
780         OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
781                    "only consider symbols in these dsos"),
782         OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
783                    "only consider symbols in these comms"),
784         OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
785                    "only consider these symbols"),
786         OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str,
787                    "width[,width...]",
788                    "don't try to adjust column width, use these fixed values"),
789         OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
790                    "separator for columns, no spaces will be added between "
791                    "columns '.' is reserved."),
792         OPT_END()
793 };
794
795 static void sort_entry__setup_elide(struct sort_entry *self,
796                                     struct strlist *list,
797                                     const char *list_name, FILE *fp)
798 {
799         if (list && strlist__nr_entries(list) == 1) {
800                 fprintf(fp, "# %s: %s\n", list_name, strlist__entry(list, 0)->s);
801                 self->elide = true;
802         }
803 }
804
805 int cmd_report(int argc, const char **argv, const char *prefix __used)
806 {
807         argc = parse_options(argc, argv, options, report_usage, 0);
808
809         setup_pager();
810
811         if (symbol__init() < 0)
812                 return -1;
813
814         setup_sorting(report_usage, options);
815
816         if (parent_pattern != default_parent_pattern) {
817                 sort_dimension__add("parent");
818                 sort_parent.elide = 1;
819         } else
820                 exclude_other = 0;
821
822         /*
823          * Any (unrecognized) arguments left?
824          */
825         if (argc)
826                 usage_with_options(report_usage, options);
827
828         sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
829         sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
830         sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
831
832         return __cmd_report();
833 }