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