6d68f3aa86b7ecf198b67c539b8b452d22d5fe63
[safe/jmp/linux-2.6] / Documentation / perf_counter / builtin-report.c
1 #include "util/util.h"
2 #include "builtin.h"
3
4 #include "util/list.h"
5 #include "util/cache.h"
6 #include "util/rbtree.h"
7 #include "util/symbol.h"
8 #include "util/string.h"
9
10 #include "perf.h"
11
12 #include "util/parse-options.h"
13 #include "util/parse-events.h"
14
15 #define SHOW_KERNEL     1
16 #define SHOW_USER       2
17 #define SHOW_HV         4
18
19 static char             const *input_name = "perf.data";
20 static char             *vmlinux = NULL;
21 static char             *sort_order = "comm,dso";
22 static int              input;
23 static int              show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
24
25 static int              dump_trace = 0;
26 static int              verbose;
27 static int              full_paths;
28
29 static unsigned long    page_size;
30 static unsigned long    mmap_window = 32;
31
32 const char *perf_event_names[] = {
33         [PERF_EVENT_MMAP]   = " PERF_EVENT_MMAP",
34         [PERF_EVENT_MUNMAP] = " PERF_EVENT_MUNMAP",
35         [PERF_EVENT_COMM]   = " PERF_EVENT_COMM",
36 };
37
38 struct ip_event {
39         struct perf_event_header header;
40         __u64 ip;
41         __u32 pid, tid;
42 };
43 struct mmap_event {
44         struct perf_event_header header;
45         __u32 pid, tid;
46         __u64 start;
47         __u64 len;
48         __u64 pgoff;
49         char filename[PATH_MAX];
50 };
51 struct comm_event {
52         struct perf_event_header header;
53         __u32 pid,tid;
54         char comm[16];
55 };
56
57 typedef union event_union {
58         struct perf_event_header header;
59         struct ip_event ip;
60         struct mmap_event mmap;
61         struct comm_event comm;
62 } event_t;
63
64 static LIST_HEAD(dsos);
65 static struct dso *kernel_dso;
66
67 static void dsos__add(struct dso *dso)
68 {
69         list_add_tail(&dso->node, &dsos);
70 }
71
72 static struct dso *dsos__find(const char *name)
73 {
74         struct dso *pos;
75
76         list_for_each_entry(pos, &dsos, node)
77                 if (strcmp(pos->name, name) == 0)
78                         return pos;
79         return NULL;
80 }
81
82 static struct dso *dsos__findnew(const char *name)
83 {
84         struct dso *dso = dsos__find(name);
85         int nr;
86
87         if (dso)
88                 return dso;
89
90         dso = dso__new(name, 0);
91         if (!dso)
92                 goto out_delete_dso;
93
94         nr = dso__load(dso, NULL);
95         if (nr < 0) {
96                 fprintf(stderr, "Failed to open: %s\n", name);
97                 goto out_delete_dso;
98         }
99         if (!nr && verbose) {
100                 fprintf(stderr,
101                 "No symbols found in: %s, maybe install a debug package?\n",
102                                 name);
103         }
104
105         dsos__add(dso);
106
107         return dso;
108
109 out_delete_dso:
110         dso__delete(dso);
111         return NULL;
112 }
113
114 static void dsos__fprintf(FILE *fp)
115 {
116         struct dso *pos;
117
118         list_for_each_entry(pos, &dsos, node)
119                 dso__fprintf(pos, fp);
120 }
121
122 static int load_kernel(void)
123 {
124         int err;
125
126         kernel_dso = dso__new("[kernel]", 0);
127         if (!kernel_dso)
128                 return -1;
129
130         err = dso__load_kernel(kernel_dso, vmlinux, NULL);
131         if (err) {
132                 dso__delete(kernel_dso);
133                 kernel_dso = NULL;
134         } else
135                 dsos__add(kernel_dso);
136
137         return err;
138 }
139
140 static int strcommon(const char *pathname, const char *cwd, int cwdlen)
141 {
142         int n = 0;
143
144         while (pathname[n] == cwd[n] && n < cwdlen)
145                 ++n;
146
147         return n;
148 }
149
150 struct map {
151         struct list_head node;
152         uint64_t         start;
153         uint64_t         end;
154         uint64_t         pgoff;
155         struct dso       *dso;
156 };
157
158 static struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen)
159 {
160         struct map *self = malloc(sizeof(*self));
161
162         if (self != NULL) {
163                 const char *filename = event->filename;
164                 char newfilename[PATH_MAX];
165
166                 if (cwd) {
167                         int n = strcommon(filename, cwd, cwdlen);
168                         if (n == cwdlen) {
169                                 snprintf(newfilename, sizeof(newfilename),
170                                          ".%s", filename + n);
171                                 filename = newfilename;
172                         }
173                 }
174
175                 self->start = event->start;
176                 self->end   = event->start + event->len;
177                 self->pgoff = event->pgoff;
178
179                 self->dso = dsos__findnew(filename);
180                 if (self->dso == NULL)
181                         goto out_delete;
182         }
183         return self;
184 out_delete:
185         free(self);
186         return NULL;
187 }
188
189 struct thread;
190
191 struct thread {
192         struct rb_node   rb_node;
193         struct list_head maps;
194         pid_t            pid;
195         char             *comm;
196 };
197
198 static struct thread *thread__new(pid_t pid)
199 {
200         struct thread *self = malloc(sizeof(*self));
201
202         if (self != NULL) {
203                 self->pid = pid;
204                 self->comm = NULL;
205                 INIT_LIST_HEAD(&self->maps);
206         }
207
208         return self;
209 }
210
211 static int thread__set_comm(struct thread *self, const char *comm)
212 {
213         self->comm = strdup(comm);
214         return self->comm ? 0 : -ENOMEM;
215 }
216
217 static struct rb_root threads;
218
219 static struct thread *threads__findnew(pid_t pid)
220 {
221         struct rb_node **p = &threads.rb_node;
222         struct rb_node *parent = NULL;
223         struct thread *th;
224
225         while (*p != NULL) {
226                 parent = *p;
227                 th = rb_entry(parent, struct thread, rb_node);
228
229                 if (th->pid == pid)
230                         return th;
231
232                 if (pid < th->pid)
233                         p = &(*p)->rb_left;
234                 else
235                         p = &(*p)->rb_right;
236         }
237
238         th = thread__new(pid);
239         if (th != NULL) {
240                 rb_link_node(&th->rb_node, parent, p);
241                 rb_insert_color(&th->rb_node, &threads);
242         }
243         return th;
244 }
245
246 static void thread__insert_map(struct thread *self, struct map *map)
247 {
248         list_add_tail(&map->node, &self->maps);
249 }
250
251 static struct map *thread__find_map(struct thread *self, uint64_t ip)
252 {
253         struct map *pos;
254
255         if (self == NULL)
256                 return NULL;
257
258         list_for_each_entry(pos, &self->maps, node)
259                 if (ip >= pos->start && ip <= pos->end)
260                         return pos;
261
262         return NULL;
263 }
264
265 /*
266  * histogram, sorted on item, collects counts
267  */
268
269 static struct rb_root hist;
270
271 struct hist_entry {
272         struct rb_node   rb_node;
273
274         struct thread    *thread;
275         struct map       *map;
276         struct dso       *dso;
277         struct symbol    *sym;
278         uint64_t         ip;
279         char             level;
280
281         uint32_t         count;
282 };
283
284 /*
285  * configurable sorting bits
286  */
287
288 struct sort_entry {
289         struct list_head list;
290
291         char *header;
292
293         int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
294         size_t  (*print)(FILE *fp, struct hist_entry *);
295 };
296
297 static int64_t
298 sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
299 {
300         return right->thread->pid - left->thread->pid;
301 }
302
303 static size_t
304 sort__thread_print(FILE *fp, struct hist_entry *self)
305 {
306         return fprintf(fp, "  %16s:%5d", self->thread->comm ?: "", self->thread->pid);
307 }
308
309 static struct sort_entry sort_thread = {
310         .header = "          Command: Pid ",
311         .cmp    = sort__thread_cmp,
312         .print  = sort__thread_print,
313 };
314
315 static int64_t
316 sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
317 {
318         char *comm_l = left->thread->comm;
319         char *comm_r = right->thread->comm;
320
321         if (!comm_l || !comm_r) {
322                 if (!comm_l && !comm_r)
323                         return 0;
324                 else if (!comm_l)
325                         return -1;
326                 else
327                         return 1;
328         }
329
330         return strcmp(comm_l, comm_r);
331 }
332
333 static size_t
334 sort__comm_print(FILE *fp, struct hist_entry *self)
335 {
336         return fprintf(fp, "  %16s", self->thread->comm ?: "<unknown>");
337 }
338
339 static struct sort_entry sort_comm = {
340         .header = "          Command",
341         .cmp    = sort__comm_cmp,
342         .print  = sort__comm_print,
343 };
344
345 static int64_t
346 sort__dso_cmp(struct hist_entry *left, struct hist_entry *right)
347 {
348         struct dso *dso_l = left->dso;
349         struct dso *dso_r = right->dso;
350
351         if (!dso_l || !dso_r) {
352                 if (!dso_l && !dso_r)
353                         return 0;
354                 else if (!dso_l)
355                         return -1;
356                 else
357                         return 1;
358         }
359
360         return strcmp(dso_l->name, dso_r->name);
361 }
362
363 static size_t
364 sort__dso_print(FILE *fp, struct hist_entry *self)
365 {
366         return fprintf(fp, "  %s", self->dso ? self->dso->name : "<unknown>");
367 }
368
369 static struct sort_entry sort_dso = {
370         .header = " Shared Object",
371         .cmp    = sort__dso_cmp,
372         .print  = sort__dso_print,
373 };
374
375 static int64_t
376 sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
377 {
378         uint64_t ip_l, ip_r;
379
380         if (left->sym == right->sym)
381                 return 0;
382
383         ip_l = left->sym ? left->sym->start : left->ip;
384         ip_r = right->sym ? right->sym->start : right->ip;
385
386         return (int64_t)(ip_r - ip_l);
387 }
388
389 static size_t
390 sort__sym_print(FILE *fp, struct hist_entry *self)
391 {
392         size_t ret = 0;
393
394         if (verbose)
395                 ret += fprintf(fp, "  %#018llx", (unsigned long long)self->ip);
396
397         ret += fprintf(fp, "  %s: %s",
398                         self->dso ? self->dso->name : "<unknown>",
399                         self->sym ? self->sym->name : "<unknown>");
400
401         return ret;
402 }
403
404 static struct sort_entry sort_sym = {
405         .header = " Shared Object: Symbol",
406         .cmp    = sort__sym_cmp,
407         .print  = sort__sym_print,
408 };
409
410 struct sort_dimension {
411         char *name;
412         struct sort_entry *entry;
413         int taken;
414 };
415
416 static struct sort_dimension sort_dimensions[] = {
417         { .name = "pid",        .entry = &sort_thread,  },
418         { .name = "comm",       .entry = &sort_comm,    },
419         { .name = "dso",        .entry = &sort_dso,     },
420         { .name = "symbol",     .entry = &sort_sym,     },
421 };
422
423 static LIST_HEAD(hist_entry__sort_list);
424
425 static int sort_dimension__add(char *tok)
426 {
427         int i;
428
429         for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
430                 struct sort_dimension *sd = &sort_dimensions[i];
431
432                 if (sd->taken)
433                         continue;
434
435                 if (strcmp(tok, sd->name))
436                         continue;
437
438                 list_add_tail(&sd->entry->list, &hist_entry__sort_list);
439                 sd->taken = 1;
440                 return 0;
441         }
442
443         return -ESRCH;
444 }
445
446 static void setup_sorting(void)
447 {
448         char *tmp, *tok, *str = strdup(sort_order);
449
450         for (tok = strtok_r(str, ", ", &tmp);
451                         tok; tok = strtok_r(NULL, ", ", &tmp))
452                 sort_dimension__add(tok);
453
454         free(str);
455 }
456
457 static int64_t
458 hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
459 {
460         struct sort_entry *se;
461         int64_t cmp = 0;
462
463         list_for_each_entry(se, &hist_entry__sort_list, list) {
464                 cmp = se->cmp(left, right);
465                 if (cmp)
466                         break;
467         }
468
469         return cmp;
470 }
471
472 static size_t
473 hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
474 {
475         struct sort_entry *se;
476         size_t ret;
477
478         if (total_samples) {
479                 ret = fprintf(fp, "    %5.2f%%",
480                                 (self->count * 100.0) / total_samples);
481         } else
482                 ret = fprintf(fp, "%12d ", self->count);
483
484         list_for_each_entry(se, &hist_entry__sort_list, list)
485                 ret += se->print(fp, self);
486
487         ret += fprintf(fp, "\n");
488
489         return ret;
490 }
491
492 /*
493  * collect histogram counts
494  */
495
496 static int
497 hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
498                 struct symbol *sym, uint64_t ip, char level)
499 {
500         struct rb_node **p = &hist.rb_node;
501         struct rb_node *parent = NULL;
502         struct hist_entry *he;
503         struct hist_entry entry = {
504                 .thread = thread,
505                 .map    = map,
506                 .dso    = dso,
507                 .sym    = sym,
508                 .ip     = ip,
509                 .level  = level,
510                 .count  = 1,
511         };
512         int cmp;
513
514         while (*p != NULL) {
515                 parent = *p;
516                 he = rb_entry(parent, struct hist_entry, rb_node);
517
518                 cmp = hist_entry__cmp(&entry, he);
519
520                 if (!cmp) {
521                         he->count++;
522                         return 0;
523                 }
524
525                 if (cmp < 0)
526                         p = &(*p)->rb_left;
527                 else
528                         p = &(*p)->rb_right;
529         }
530
531         he = malloc(sizeof(*he));
532         if (!he)
533                 return -ENOMEM;
534         *he = entry;
535         rb_link_node(&he->rb_node, parent, p);
536         rb_insert_color(&he->rb_node, &hist);
537
538         return 0;
539 }
540
541 /*
542  * reverse the map, sort on count.
543  */
544
545 static struct rb_root output_hists;
546
547 static void output__insert_entry(struct hist_entry *he)
548 {
549         struct rb_node **p = &output_hists.rb_node;
550         struct rb_node *parent = NULL;
551         struct hist_entry *iter;
552
553         while (*p != NULL) {
554                 parent = *p;
555                 iter = rb_entry(parent, struct hist_entry, rb_node);
556
557                 if (he->count > iter->count)
558                         p = &(*p)->rb_left;
559                 else
560                         p = &(*p)->rb_right;
561         }
562
563         rb_link_node(&he->rb_node, parent, p);
564         rb_insert_color(&he->rb_node, &output_hists);
565 }
566
567 static void output__resort(void)
568 {
569         struct rb_node *next = rb_first(&hist);
570         struct hist_entry *n;
571
572         while (next) {
573                 n = rb_entry(next, struct hist_entry, rb_node);
574                 next = rb_next(&n->rb_node);
575
576                 rb_erase(&n->rb_node, &hist);
577                 output__insert_entry(n);
578         }
579 }
580
581 static size_t output__fprintf(FILE *fp, uint64_t total_samples)
582 {
583         struct hist_entry *pos;
584         struct sort_entry *se;
585         struct rb_node *nd;
586         size_t ret = 0;
587
588         fprintf(fp, "#\n");
589
590         fprintf(fp, "# Overhead");
591         list_for_each_entry(se, &hist_entry__sort_list, list)
592                 fprintf(fp, " %s", se->header);
593         fprintf(fp, "\n");
594
595         fprintf(fp, "# ........");
596         list_for_each_entry(se, &hist_entry__sort_list, list) {
597                 int i;
598
599                 fprintf(fp, "  ");
600                 for (i = 0; i < strlen(se->header)-1; i++)
601                         fprintf(fp, ".");
602         }
603         fprintf(fp, "\n");
604
605         fprintf(fp, "#\n");
606
607         for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
608                 pos = rb_entry(nd, struct hist_entry, rb_node);
609                 ret += hist_entry__fprintf(fp, pos, total_samples);
610         }
611
612         return ret;
613 }
614
615 static void register_idle_thread(void)
616 {
617         struct thread *thread = threads__findnew(0);
618
619         if (thread == NULL ||
620                         thread__set_comm(thread, "[idle]")) {
621                 fprintf(stderr, "problem inserting idle task.\n");
622                 exit(-1);
623         }
624 }
625
626
627 static int __cmd_report(void)
628 {
629         unsigned long offset = 0;
630         unsigned long head = 0;
631         struct stat stat;
632         char *buf;
633         event_t *event;
634         int ret, rc = EXIT_FAILURE;
635         uint32_t size;
636         unsigned long total = 0, total_mmap = 0, total_comm = 0, total_unknown = 0;
637         char cwd[PATH_MAX], *cwdp = cwd;
638         int cwdlen;
639
640         register_idle_thread();
641
642         input = open(input_name, O_RDONLY);
643         if (input < 0) {
644                 perror("failed to open file");
645                 exit(-1);
646         }
647
648         ret = fstat(input, &stat);
649         if (ret < 0) {
650                 perror("failed to stat file");
651                 exit(-1);
652         }
653
654         if (!stat.st_size) {
655                 fprintf(stderr, "zero-sized file, nothing to do!\n");
656                 exit(0);
657         }
658
659         if (load_kernel() < 0) {
660                 perror("failed to load kernel symbols");
661                 return EXIT_FAILURE;
662         }
663
664         if (!full_paths) {
665                 if (getcwd(cwd, sizeof(cwd)) == NULL) {
666                         perror("failed to get the current directory");
667                         return EXIT_FAILURE;
668                 }
669                 cwdlen = strlen(cwd);
670         } else {
671                 cwdp = NULL;
672                 cwdlen = 0;
673         }
674 remap:
675         buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
676                            MAP_SHARED, input, offset);
677         if (buf == MAP_FAILED) {
678                 perror("failed to mmap file");
679                 exit(-1);
680         }
681
682 more:
683         event = (event_t *)(buf + head);
684
685         size = event->header.size;
686         if (!size)
687                 size = 8;
688
689         if (head + event->header.size >= page_size * mmap_window) {
690                 unsigned long shift = page_size * (head / page_size);
691                 int ret;
692
693                 ret = munmap(buf, page_size * mmap_window);
694                 assert(ret == 0);
695
696                 offset += shift;
697                 head -= shift;
698                 goto remap;
699         }
700
701         size = event->header.size;
702         if (!size)
703                 goto broken_event;
704
705         if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) {
706                 char level;
707                 int show = 0;
708                 struct dso *dso = NULL;
709                 struct thread *thread = threads__findnew(event->ip.pid);
710                 uint64_t ip = event->ip.ip;
711                 struct map *map = NULL;
712
713                 if (dump_trace) {
714                         fprintf(stderr, "%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
715                                 (void *)(offset + head),
716                                 (void *)(long)(event->header.size),
717                                 event->header.misc,
718                                 event->ip.pid,
719                                 (void *)(long)ip);
720                 }
721
722                 if (thread == NULL) {
723                         fprintf(stderr, "problem processing %d event, skipping it.\n",
724                                 event->header.type);
725                         goto broken_event;
726                 }
727
728                 if (event->header.misc & PERF_EVENT_MISC_KERNEL) {
729                         show = SHOW_KERNEL;
730                         level = 'k';
731
732                         dso = kernel_dso;
733
734                 } else if (event->header.misc & PERF_EVENT_MISC_USER) {
735
736                         show = SHOW_USER;
737                         level = '.';
738
739                         map = thread__find_map(thread, ip);
740                         if (map != NULL) {
741                                 dso = map->dso;
742                                 ip -= map->start + map->pgoff;
743                         }
744
745                 } else {
746                         show = SHOW_HV;
747                         level = 'H';
748                 }
749
750                 if (show & show_mask) {
751                         struct symbol *sym = dso__find_symbol(dso, ip);
752
753                         if (hist_entry__add(thread, map, dso, sym, ip, level)) {
754                                 fprintf(stderr,
755                 "problem incrementing symbol count, skipping event\n");
756                                 goto broken_event;
757                         }
758                 }
759                 total++;
760         } else switch (event->header.type) {
761         case PERF_EVENT_MMAP: {
762                 struct thread *thread = threads__findnew(event->mmap.pid);
763                 struct map *map = map__new(&event->mmap, cwdp, cwdlen);
764
765                 if (dump_trace) {
766                         fprintf(stderr, "%p [%p]: PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n",
767                                 (void *)(offset + head),
768                                 (void *)(long)(event->header.size),
769                                 (void *)(long)event->mmap.start,
770                                 (void *)(long)event->mmap.len,
771                                 (void *)(long)event->mmap.pgoff,
772                                 event->mmap.filename);
773                 }
774                 if (thread == NULL || map == NULL) {
775                         fprintf(stderr, "problem processing PERF_EVENT_MMAP, skipping event.\n");
776                         goto broken_event;
777                 }
778                 thread__insert_map(thread, map);
779                 total_mmap++;
780                 break;
781         }
782         case PERF_EVENT_COMM: {
783                 struct thread *thread = threads__findnew(event->comm.pid);
784
785                 if (dump_trace) {
786                         fprintf(stderr, "%p [%p]: PERF_EVENT_COMM: %s:%d\n",
787                                 (void *)(offset + head),
788                                 (void *)(long)(event->header.size),
789                                 event->comm.comm, event->comm.pid);
790                 }
791                 if (thread == NULL ||
792                     thread__set_comm(thread, event->comm.comm)) {
793                         fprintf(stderr, "problem processing PERF_EVENT_COMM, skipping event.\n");
794                         goto broken_event;
795                 }
796                 total_comm++;
797                 break;
798         }
799         default: {
800 broken_event:
801                 if (dump_trace)
802                         fprintf(stderr, "%p [%p]: skipping unknown header type: %d\n",
803                                         (void *)(offset + head),
804                                         (void *)(long)(event->header.size),
805                                         event->header.type);
806
807                 total_unknown++;
808
809                 /*
810                  * assume we lost track of the stream, check alignment, and
811                  * increment a single u64 in the hope to catch on again 'soon'.
812                  */
813
814                 if (unlikely(head & 7))
815                         head &= ~7ULL;
816
817                 size = 8;
818         }
819         }
820
821         head += size;
822
823         if (offset + head < stat.st_size)
824                 goto more;
825
826         rc = EXIT_SUCCESS;
827         close(input);
828
829         if (dump_trace) {
830                 fprintf(stderr, "      IP events: %10ld\n", total);
831                 fprintf(stderr, "    mmap events: %10ld\n", total_mmap);
832                 fprintf(stderr, "    comm events: %10ld\n", total_comm);
833                 fprintf(stderr, " unknown events: %10ld\n", total_unknown);
834
835                 return 0;
836         }
837
838         if (verbose >= 2)
839                 dsos__fprintf(stdout);
840
841         output__resort();
842         output__fprintf(stdout, total);
843
844         return rc;
845 }
846
847 static const char * const report_usage[] = {
848         "perf report [<options>] <command>",
849         NULL
850 };
851
852 static const struct option options[] = {
853         OPT_STRING('i', "input", &input_name, "file",
854                     "input file name"),
855         OPT_BOOLEAN('v', "verbose", &verbose,
856                     "be more verbose (show symbol address, etc)"),
857         OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
858                     "dump raw trace in ASCII"),
859         OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
860         OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
861                    "sort by key(s): pid, comm, dso, symbol. Default: pid,symbol"),
862         OPT_BOOLEAN('P', "full-paths", &full_paths,
863                     "Don't shorten the pathnames taking into account the cwd"),
864         OPT_END()
865 };
866
867 int cmd_report(int argc, const char **argv, const char *prefix)
868 {
869         symbol__init();
870
871         page_size = getpagesize();
872
873         parse_options(argc, argv, options, report_usage, 0);
874
875         setup_sorting();
876
877         setup_pager();
878
879         return __cmd_report();
880 }