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