blob: 333d31269e3fc6daa3c5c3edaf93718c89a51b0d [file] [log] [blame]
Ingo Molnarbf9e1872009-06-02 23:37:05 +02001/*
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 */
Ingo Molnar16f762a2009-05-27 09:10:38 +02008#include "builtin.h"
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02009
Ingo Molnarbf9e1872009-06-02 23:37:05 +020010#include "util/util.h"
11
Arnaldo Carvalho de Melo35a50c82009-05-18 16:24:49 -030012#include "util/list.h"
Ingo Molnara930d2c2009-05-27 09:50:13 +020013#include "util/cache.h"
Arnaldo Carvalho de Melo35a50c82009-05-18 16:24:49 -030014#include "util/rbtree.h"
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -030015#include "util/symbol.h"
Arnaldo Carvalho de Meloa0055ae2009-06-01 17:50:19 -030016#include "util/string.h"
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030017
Ingo Molnar53cb8bc2009-05-26 09:17:18 +020018#include "perf.h"
19
20#include "util/parse-options.h"
21#include "util/parse-events.h"
22
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030023#define SHOW_KERNEL 1
24#define SHOW_USER 2
25#define SHOW_HV 4
26
Ingo Molnar23ac9cb2009-05-27 09:33:18 +020027static char const *input_name = "perf.data";
Peter Zijlstra450aaa22009-05-27 20:20:23 +020028static char *vmlinux = NULL;
Peter Zijlstraf70e87d2009-06-02 14:13:24 +020029static char *sort_order = "comm,dso";
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030030static int input;
31static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
32
Ingo Molnar97b07b62009-05-26 18:48:58 +020033static int dump_trace = 0;
Ingo Molnar35029732009-06-03 09:38:58 +020034#define dprintf(x...) do { if (dump_trace) printf(x); } while (0)
35
Ingo Molnar16f762a2009-05-27 09:10:38 +020036static int verbose;
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -030037static int full_paths;
Ingo Molnar97b07b62009-05-26 18:48:58 +020038
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030039static unsigned long page_size;
40static unsigned long mmap_window = 32;
41
Ingo Molnar53cb8bc2009-05-26 09:17:18 +020042const char *perf_event_names[] = {
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030043 [PERF_EVENT_MMAP] = " PERF_EVENT_MMAP",
44 [PERF_EVENT_MUNMAP] = " PERF_EVENT_MUNMAP",
45 [PERF_EVENT_COMM] = " PERF_EVENT_COMM",
46};
47
48struct ip_event {
49 struct perf_event_header header;
50 __u64 ip;
51 __u32 pid, tid;
52};
53struct mmap_event {
54 struct perf_event_header header;
55 __u32 pid, tid;
56 __u64 start;
57 __u64 len;
58 __u64 pgoff;
59 char filename[PATH_MAX];
60};
61struct comm_event {
62 struct perf_event_header header;
63 __u32 pid,tid;
64 char comm[16];
65};
66
67typedef union event_union {
68 struct perf_event_header header;
69 struct ip_event ip;
70 struct mmap_event mmap;
71 struct comm_event comm;
72} event_t;
73
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030074static LIST_HEAD(dsos);
75static struct dso *kernel_dso;
76
77static void dsos__add(struct dso *dso)
78{
79 list_add_tail(&dso->node, &dsos);
80}
81
82static struct dso *dsos__find(const char *name)
83{
84 struct dso *pos;
85
86 list_for_each_entry(pos, &dsos, node)
87 if (strcmp(pos->name, name) == 0)
88 return pos;
89 return NULL;
90}
91
92static struct dso *dsos__findnew(const char *name)
93{
94 struct dso *dso = dsos__find(name);
Peter Zijlstrab7a16ea2009-05-27 13:35:35 +020095 int nr;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030096
Ingo Molnar4593bba2009-06-02 15:34:25 +020097 if (dso)
98 return dso;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -030099
Ingo Molnar4593bba2009-06-02 15:34:25 +0200100 dso = dso__new(name, 0);
101 if (!dso)
102 goto out_delete_dso;
Peter Zijlstrab7a16ea2009-05-27 13:35:35 +0200103
Ingo Molnar4593bba2009-06-02 15:34:25 +0200104 nr = dso__load(dso, NULL);
105 if (nr < 0) {
106 fprintf(stderr, "Failed to open: %s\n", name);
107 goto out_delete_dso;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300108 }
Ingo Molnar4593bba2009-06-02 15:34:25 +0200109 if (!nr && verbose) {
110 fprintf(stderr,
111 "No symbols found in: %s, maybe install a debug package?\n",
112 name);
113 }
114
115 dsos__add(dso);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300116
117 return dso;
118
119out_delete_dso:
120 dso__delete(dso);
121 return NULL;
122}
123
Ingo Molnar16f762a2009-05-27 09:10:38 +0200124static void dsos__fprintf(FILE *fp)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300125{
126 struct dso *pos;
127
128 list_for_each_entry(pos, &dsos, node)
129 dso__fprintf(pos, fp);
130}
131
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200132static int load_kernel(void)
133{
Arnaldo Carvalho de Meloa827c872009-05-28 14:55:19 -0300134 int err;
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200135
Arnaldo Carvalho de Melo0085c9542009-05-28 14:55:13 -0300136 kernel_dso = dso__new("[kernel]", 0);
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200137 if (!kernel_dso)
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300138 return -1;
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200139
Arnaldo Carvalho de Melo69ee69f2009-05-28 14:55:26 -0300140 err = dso__load_kernel(kernel_dso, vmlinux, NULL);
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300141 if (err) {
142 dso__delete(kernel_dso);
143 kernel_dso = NULL;
144 } else
145 dsos__add(kernel_dso);
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200146
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -0300147 return err;
Peter Zijlstra450aaa22009-05-27 20:20:23 +0200148}
149
Ingo Molnard80d3382009-06-03 23:14:49 +0200150static char __cwd[PATH_MAX];
151static char *cwd = __cwd;
152static int cwdlen;
153
154static int strcommon(const char *pathname)
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300155{
156 int n = 0;
157
158 while (pathname[n] == cwd[n] && n < cwdlen)
159 ++n;
160
161 return n;
162}
163
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300164struct map {
165 struct list_head node;
166 uint64_t start;
167 uint64_t end;
168 uint64_t pgoff;
169 struct dso *dso;
170};
171
Ingo Molnard80d3382009-06-03 23:14:49 +0200172static struct map *map__new(struct mmap_event *event)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300173{
174 struct map *self = malloc(sizeof(*self));
175
176 if (self != NULL) {
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300177 const char *filename = event->filename;
178 char newfilename[PATH_MAX];
179
180 if (cwd) {
Ingo Molnard80d3382009-06-03 23:14:49 +0200181 int n = strcommon(filename);
182
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300183 if (n == cwdlen) {
184 snprintf(newfilename, sizeof(newfilename),
185 ".%s", filename + n);
186 filename = newfilename;
187 }
188 }
189
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300190 self->start = event->start;
191 self->end = event->start + event->len;
192 self->pgoff = event->pgoff;
193
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -0300194 self->dso = dsos__findnew(filename);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300195 if (self->dso == NULL)
196 goto out_delete;
197 }
198 return self;
199out_delete:
200 free(self);
201 return NULL;
202}
203
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300204struct thread;
205
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300206struct thread {
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300207 struct rb_node rb_node;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300208 struct list_head maps;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300209 pid_t pid;
210 char *comm;
211};
212
213static struct thread *thread__new(pid_t pid)
214{
215 struct thread *self = malloc(sizeof(*self));
216
217 if (self != NULL) {
218 self->pid = pid;
Peter Zijlstra82292892009-06-03 12:37:36 +0200219 self->comm = malloc(32);
Ingo Molnar0a520c62009-06-02 23:24:45 +0200220 if (self->comm)
Peter Zijlstra82292892009-06-03 12:37:36 +0200221 snprintf(self->comm, 32, ":%d", self->pid);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300222 INIT_LIST_HEAD(&self->maps);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300223 }
224
225 return self;
226}
227
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300228static int thread__set_comm(struct thread *self, const char *comm)
229{
Peter Zijlstra82292892009-06-03 12:37:36 +0200230 if (self->comm)
231 free(self->comm);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300232 self->comm = strdup(comm);
233 return self->comm ? 0 : -ENOMEM;
234}
235
Ingo Molnar16f762a2009-05-27 09:10:38 +0200236static struct rb_root threads;
Ingo Molnareed4dcd2009-06-03 19:59:24 +0200237static struct thread *last_match;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300238
239static struct thread *threads__findnew(pid_t pid)
240{
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300241 struct rb_node **p = &threads.rb_node;
242 struct rb_node *parent = NULL;
243 struct thread *th;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300244
Ingo Molnareed4dcd2009-06-03 19:59:24 +0200245 /*
246 * Font-end cache - PID lookups come in blocks,
247 * so most of the time we dont have to look up
248 * the full rbtree:
249 */
250 if (last_match && last_match->pid == pid)
251 return last_match;
252
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300253 while (*p != NULL) {
254 parent = *p;
255 th = rb_entry(parent, struct thread, rb_node);
256
Ingo Molnareed4dcd2009-06-03 19:59:24 +0200257 if (th->pid == pid) {
258 last_match = th;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300259 return th;
Ingo Molnareed4dcd2009-06-03 19:59:24 +0200260 }
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300261
262 if (pid < th->pid)
263 p = &(*p)->rb_left;
264 else
265 p = &(*p)->rb_right;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300266 }
267
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300268 th = thread__new(pid);
269 if (th != NULL) {
270 rb_link_node(&th->rb_node, parent, p);
271 rb_insert_color(&th->rb_node, &threads);
Ingo Molnareed4dcd2009-06-03 19:59:24 +0200272 last_match = th;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300273 }
Ingo Molnareed4dcd2009-06-03 19:59:24 +0200274
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300275 return th;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300276}
277
278static void thread__insert_map(struct thread *self, struct map *map)
279{
280 list_add_tail(&map->node, &self->maps);
281}
282
283static struct map *thread__find_map(struct thread *self, uint64_t ip)
284{
Ingo Molnar16f762a2009-05-27 09:10:38 +0200285 struct map *pos;
286
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300287 if (self == NULL)
288 return NULL;
289
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300290 list_for_each_entry(pos, &self->maps, node)
291 if (ip >= pos->start && ip <= pos->end)
292 return pos;
293
294 return NULL;
295}
296
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200297/*
298 * histogram, sorted on item, collects counts
299 */
300
301static struct rb_root hist;
302
303struct hist_entry {
304 struct rb_node rb_node;
305
306 struct thread *thread;
307 struct map *map;
308 struct dso *dso;
309 struct symbol *sym;
310 uint64_t ip;
311 char level;
312
313 uint32_t count;
314};
315
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200316/*
317 * configurable sorting bits
318 */
319
320struct sort_entry {
321 struct list_head list;
322
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200323 char *header;
324
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200325 int64_t (*cmp)(struct hist_entry *, struct hist_entry *);
Peter Zijlstra82292892009-06-03 12:37:36 +0200326 int64_t (*collapse)(struct hist_entry *, struct hist_entry *);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200327 size_t (*print)(FILE *fp, struct hist_entry *);
328};
329
Peter Zijlstra82292892009-06-03 12:37:36 +0200330/* --sort pid */
331
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200332static int64_t
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200333sort__thread_cmp(struct hist_entry *left, struct hist_entry *right)
334{
335 return right->thread->pid - left->thread->pid;
336}
337
338static size_t
339sort__thread_print(FILE *fp, struct hist_entry *self)
340{
Ingo Molnarcf25c632009-06-02 22:12:14 +0200341 return fprintf(fp, " %16s:%5d", self->thread->comm ?: "", self->thread->pid);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200342}
343
344static struct sort_entry sort_thread = {
Ingo Molnarcf25c632009-06-02 22:12:14 +0200345 .header = " Command: Pid ",
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200346 .cmp = sort__thread_cmp,
347 .print = sort__thread_print,
348};
349
Peter Zijlstra82292892009-06-03 12:37:36 +0200350/* --sort comm */
351
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200352static int64_t
Peter Zijlstra992444b2009-05-27 20:20:27 +0200353sort__comm_cmp(struct hist_entry *left, struct hist_entry *right)
354{
Peter Zijlstra82292892009-06-03 12:37:36 +0200355 return right->thread->pid - left->thread->pid;
356}
357
358static int64_t
359sort__comm_collapse(struct hist_entry *left, struct hist_entry *right)
360{
Peter Zijlstra992444b2009-05-27 20:20:27 +0200361 char *comm_l = left->thread->comm;
362 char *comm_r = right->thread->comm;
363
364 if (!comm_l || !comm_r) {
365 if (!comm_l && !comm_r)
366 return 0;
367 else if (!comm_l)
368 return -1;
369 else
370 return 1;
371 }
372
373 return strcmp(comm_l, comm_r);
374}
375
376static size_t
377sort__comm_print(FILE *fp, struct hist_entry *self)
378{
Ingo Molnar0a520c62009-06-02 23:24:45 +0200379 return fprintf(fp, " %16s", self->thread->comm);
Peter Zijlstra992444b2009-05-27 20:20:27 +0200380}
381
382static struct sort_entry sort_comm = {
Peter Zijlstra82292892009-06-03 12:37:36 +0200383 .header = " Command",
384 .cmp = sort__comm_cmp,
385 .collapse = sort__comm_collapse,
386 .print = sort__comm_print,
Peter Zijlstra992444b2009-05-27 20:20:27 +0200387};
388
Peter Zijlstra82292892009-06-03 12:37:36 +0200389/* --sort dso */
390
Peter Zijlstra992444b2009-05-27 20:20:27 +0200391static int64_t
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200392sort__dso_cmp(struct hist_entry *left, struct hist_entry *right)
393{
394 struct dso *dso_l = left->dso;
395 struct dso *dso_r = right->dso;
396
397 if (!dso_l || !dso_r) {
398 if (!dso_l && !dso_r)
399 return 0;
400 else if (!dso_l)
401 return -1;
402 else
403 return 1;
404 }
405
406 return strcmp(dso_l->name, dso_r->name);
407}
408
409static size_t
410sort__dso_print(FILE *fp, struct hist_entry *self)
411{
Ingo Molnar0a520c62009-06-02 23:24:45 +0200412 if (self->dso)
413 return fprintf(fp, " %-25s", self->dso->name);
414
415 return fprintf(fp, " %016llx", (__u64)self->ip);
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200416}
417
418static struct sort_entry sort_dso = {
Ingo Molnarcf25c632009-06-02 22:12:14 +0200419 .header = " Shared Object ",
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200420 .cmp = sort__dso_cmp,
421 .print = sort__dso_print,
422};
423
Peter Zijlstra82292892009-06-03 12:37:36 +0200424/* --sort symbol */
425
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200426static int64_t
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200427sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300428{
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200429 uint64_t ip_l, ip_r;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200430
431 if (left->sym == right->sym)
432 return 0;
433
434 ip_l = left->sym ? left->sym->start : left->ip;
435 ip_r = right->sym ? right->sym->start : right->ip;
436
437 return (int64_t)(ip_r - ip_l);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300438}
439
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200440static size_t
441sort__sym_print(FILE *fp, struct hist_entry *self)
442{
443 size_t ret = 0;
444
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200445 if (verbose)
Ingo Molnar0a520c62009-06-02 23:24:45 +0200446 ret += fprintf(fp, " %#018llx", (__u64)self->ip);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200447
Ingo Molnar0a520c62009-06-02 23:24:45 +0200448 if (self->dso)
449 ret += fprintf(fp, " %s: ", self->dso->name);
450 else
451 ret += fprintf(fp, " %#016llx: ", (__u64)self->ip);
452
453 if (self->sym)
454 ret += fprintf(fp, "%s", self->sym->name);
455 else
456 ret += fprintf(fp, "%#016llx", (__u64)self->ip);
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200457
458 return ret;
459}
460
461static struct sort_entry sort_sym = {
Ingo Molnar4593bba2009-06-02 15:34:25 +0200462 .header = " Shared Object: Symbol",
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200463 .cmp = sort__sym_cmp,
464 .print = sort__sym_print,
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200465};
466
Peter Zijlstra82292892009-06-03 12:37:36 +0200467static int sort__need_collapse = 0;
468
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200469struct sort_dimension {
470 char *name;
471 struct sort_entry *entry;
472 int taken;
473};
474
475static struct sort_dimension sort_dimensions[] = {
476 { .name = "pid", .entry = &sort_thread, },
Peter Zijlstra992444b2009-05-27 20:20:27 +0200477 { .name = "comm", .entry = &sort_comm, },
Peter Zijlstra55e5ec42009-05-27 20:20:28 +0200478 { .name = "dso", .entry = &sort_dso, },
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200479 { .name = "symbol", .entry = &sort_sym, },
480};
481
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200482static LIST_HEAD(hist_entry__sort_list);
483
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200484static int sort_dimension__add(char *tok)
485{
486 int i;
487
488 for (i = 0; i < ARRAY_SIZE(sort_dimensions); i++) {
489 struct sort_dimension *sd = &sort_dimensions[i];
490
491 if (sd->taken)
492 continue;
493
Ingo Molnar5352f352009-06-03 10:07:39 +0200494 if (strncasecmp(tok, sd->name, strlen(tok)))
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200495 continue;
496
Peter Zijlstra82292892009-06-03 12:37:36 +0200497 if (sd->entry->collapse)
498 sort__need_collapse = 1;
499
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200500 list_add_tail(&sd->entry->list, &hist_entry__sort_list);
501 sd->taken = 1;
Ingo Molnar5352f352009-06-03 10:07:39 +0200502
Peter Zijlstra37f440c2009-05-27 20:20:26 +0200503 return 0;
504 }
505
506 return -ESRCH;
507}
508
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200509static int64_t
510hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
511{
512 struct sort_entry *se;
513 int64_t cmp = 0;
514
515 list_for_each_entry(se, &hist_entry__sort_list, list) {
516 cmp = se->cmp(left, right);
517 if (cmp)
518 break;
519 }
520
521 return cmp;
522}
523
Peter Zijlstra82292892009-06-03 12:37:36 +0200524static int64_t
525hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
526{
527 struct sort_entry *se;
528 int64_t cmp = 0;
529
530 list_for_each_entry(se, &hist_entry__sort_list, list) {
531 int64_t (*f)(struct hist_entry *, struct hist_entry *);
532
533 f = se->collapse ?: se->cmp;
534
535 cmp = f(left, right);
536 if (cmp)
537 break;
538 }
539
540 return cmp;
541}
542
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200543static size_t
544hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
545{
546 struct sort_entry *se;
547 size_t ret;
548
549 if (total_samples) {
Ingo Molnare98e96f2009-06-03 19:30:38 +0200550 ret = fprintf(fp, " %6.2f%%",
Peter Zijlstra1aa16732009-05-27 20:20:25 +0200551 (self->count * 100.0) / total_samples);
552 } else
553 ret = fprintf(fp, "%12d ", self->count);
554
555 list_for_each_entry(se, &hist_entry__sort_list, list)
556 ret += se->print(fp, self);
557
558 ret += fprintf(fp, "\n");
559
560 return ret;
561}
562
563/*
564 * collect histogram counts
565 */
566
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200567static int
568hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
569 struct symbol *sym, uint64_t ip, char level)
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300570{
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200571 struct rb_node **p = &hist.rb_node;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300572 struct rb_node *parent = NULL;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200573 struct hist_entry *he;
574 struct hist_entry entry = {
575 .thread = thread,
576 .map = map,
577 .dso = dso,
578 .sym = sym,
579 .ip = ip,
580 .level = level,
581 .count = 1,
582 };
583 int cmp;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300584
585 while (*p != NULL) {
586 parent = *p;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200587 he = rb_entry(parent, struct hist_entry, rb_node);
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300588
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200589 cmp = hist_entry__cmp(&entry, he);
590
591 if (!cmp) {
592 he->count++;
593 return 0;
594 }
595
596 if (cmp < 0)
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300597 p = &(*p)->rb_left;
598 else
599 p = &(*p)->rb_right;
600 }
601
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200602 he = malloc(sizeof(*he));
603 if (!he)
604 return -ENOMEM;
605 *he = entry;
606 rb_link_node(&he->rb_node, parent, p);
607 rb_insert_color(&he->rb_node, &hist);
608
609 return 0;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300610}
611
Peter Zijlstra82292892009-06-03 12:37:36 +0200612static void hist_entry__free(struct hist_entry *he)
613{
614 free(he);
615}
616
617/*
618 * collapse the histogram
619 */
620
621static struct rb_root collapse_hists;
622
623static void collapse__insert_entry(struct hist_entry *he)
624{
625 struct rb_node **p = &collapse_hists.rb_node;
626 struct rb_node *parent = NULL;
627 struct hist_entry *iter;
628 int64_t cmp;
629
630 while (*p != NULL) {
631 parent = *p;
632 iter = rb_entry(parent, struct hist_entry, rb_node);
633
634 cmp = hist_entry__collapse(iter, he);
635
636 if (!cmp) {
637 iter->count += he->count;
638 hist_entry__free(he);
639 return;
640 }
641
642 if (cmp < 0)
643 p = &(*p)->rb_left;
644 else
645 p = &(*p)->rb_right;
646 }
647
648 rb_link_node(&he->rb_node, parent, p);
649 rb_insert_color(&he->rb_node, &collapse_hists);
650}
651
652static void collapse__resort(void)
653{
654 struct rb_node *next;
655 struct hist_entry *n;
656
657 if (!sort__need_collapse)
658 return;
659
660 next = rb_first(&hist);
661 while (next) {
662 n = rb_entry(next, struct hist_entry, rb_node);
663 next = rb_next(&n->rb_node);
664
665 rb_erase(&n->rb_node, &hist);
666 collapse__insert_entry(n);
667 }
668}
669
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200670/*
671 * reverse the map, sort on count.
672 */
673
674static struct rb_root output_hists;
675
676static void output__insert_entry(struct hist_entry *he)
677{
678 struct rb_node **p = &output_hists.rb_node;
679 struct rb_node *parent = NULL;
680 struct hist_entry *iter;
681
682 while (*p != NULL) {
683 parent = *p;
684 iter = rb_entry(parent, struct hist_entry, rb_node);
685
686 if (he->count > iter->count)
687 p = &(*p)->rb_left;
688 else
689 p = &(*p)->rb_right;
690 }
691
692 rb_link_node(&he->rb_node, parent, p);
693 rb_insert_color(&he->rb_node, &output_hists);
694}
695
696static void output__resort(void)
697{
Peter Zijlstra82292892009-06-03 12:37:36 +0200698 struct rb_node *next;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200699 struct hist_entry *n;
700
Peter Zijlstra82292892009-06-03 12:37:36 +0200701 if (sort__need_collapse)
702 next = rb_first(&collapse_hists);
703 else
704 next = rb_first(&hist);
705
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200706 while (next) {
707 n = rb_entry(next, struct hist_entry, rb_node);
708 next = rb_next(&n->rb_node);
709
710 rb_erase(&n->rb_node, &hist);
711 output__insert_entry(n);
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300712 }
713}
714
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200715static size_t output__fprintf(FILE *fp, uint64_t total_samples)
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300716{
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200717 struct hist_entry *pos;
Ingo Molnar2d655372009-05-27 21:36:22 +0200718 struct sort_entry *se;
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300719 struct rb_node *nd;
720 size_t ret = 0;
721
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200722 fprintf(fp, "#\n");
723
724 fprintf(fp, "# Overhead");
725 list_for_each_entry(se, &hist_entry__sort_list, list)
726 fprintf(fp, " %s", se->header);
727 fprintf(fp, "\n");
728
729 fprintf(fp, "# ........");
Ingo Molnar2d655372009-05-27 21:36:22 +0200730 list_for_each_entry(se, &hist_entry__sort_list, list) {
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200731 int i;
732
Ingo Molnar4593bba2009-06-02 15:34:25 +0200733 fprintf(fp, " ");
734 for (i = 0; i < strlen(se->header)-1; i++)
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200735 fprintf(fp, ".");
Ingo Molnar2d655372009-05-27 21:36:22 +0200736 }
Peter Zijlstraca8cdee2009-05-28 11:08:33 +0200737 fprintf(fp, "\n");
738
739 fprintf(fp, "#\n");
Ingo Molnar2d655372009-05-27 21:36:22 +0200740
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200741 for (nd = rb_first(&output_hists); nd; nd = rb_next(nd)) {
742 pos = rb_entry(nd, struct hist_entry, rb_node);
743 ret += hist_entry__fprintf(fp, pos, total_samples);
Arnaldo Carvalho de Melo3a4b8cc2009-05-26 16:19:04 -0300744 }
745
746 return ret;
747}
748
Peter Zijlstra436224a2009-06-02 21:02:36 +0200749static void register_idle_thread(void)
750{
751 struct thread *thread = threads__findnew(0);
752
753 if (thread == NULL ||
754 thread__set_comm(thread, "[idle]")) {
755 fprintf(stderr, "problem inserting idle task.\n");
756 exit(-1);
757 }
758}
759
Ingo Molnard80d3382009-06-03 23:14:49 +0200760static unsigned long total = 0, total_mmap = 0, total_comm = 0, total_unknown = 0;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200761
Ingo Molnard80d3382009-06-03 23:14:49 +0200762static int
763process_event(event_t *event, unsigned long offset, unsigned long head)
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300764{
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300765 if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) {
766 char level;
767 int show = 0;
768 struct dso *dso = NULL;
769 struct thread *thread = threads__findnew(event->ip.pid);
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200770 uint64_t ip = event->ip.ip;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200771 struct map *map = NULL;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300772
Ingo Molnar35029732009-06-03 09:38:58 +0200773 dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
774 (void *)(offset + head),
775 (void *)(long)(event->header.size),
776 event->header.misc,
777 event->ip.pid,
778 (void *)(long)ip);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200779
Ingo Molnared966aa2009-06-03 10:39:26 +0200780 dprintf(" ... thread: %s:%d\n", thread->comm, thread->pid);
781
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300782 if (thread == NULL) {
Ingo Molnar55717312009-05-27 22:13:17 +0200783 fprintf(stderr, "problem processing %d event, skipping it.\n",
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300784 event->header.type);
Ingo Molnard80d3382009-06-03 23:14:49 +0200785 return -1;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300786 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300787
788 if (event->header.misc & PERF_EVENT_MISC_KERNEL) {
789 show = SHOW_KERNEL;
790 level = 'k';
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200791
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300792 dso = kernel_dso;
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200793
Ingo Molnared966aa2009-06-03 10:39:26 +0200794 dprintf(" ...... dso: %s\n", dso->name);
795
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300796 } else if (event->header.misc & PERF_EVENT_MISC_USER) {
Ingo Molnar16f762a2009-05-27 09:10:38 +0200797
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300798 show = SHOW_USER;
799 level = '.';
Ingo Molnar16f762a2009-05-27 09:10:38 +0200800
801 map = thread__find_map(thread, ip);
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200802 if (map != NULL) {
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300803 dso = map->dso;
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200804 ip -= map->start + map->pgoff;
Ingo Molnared966aa2009-06-03 10:39:26 +0200805 } else {
806 /*
807 * If this is outside of all known maps,
808 * and is a negative address, try to look it
809 * up in the kernel dso, as it might be a
810 * vsyscall (which executes in user-mode):
811 */
812 if ((long long)ip < 0)
813 dso = kernel_dso;
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200814 }
Ingo Molnared966aa2009-06-03 10:39:26 +0200815 dprintf(" ...... dso: %s\n", dso ? dso->name : "<not found>");
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200816
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300817 } else {
818 show = SHOW_HV;
819 level = 'H';
Ingo Molnared966aa2009-06-03 10:39:26 +0200820 dprintf(" ...... dso: [hypervisor]\n");
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300821 }
822
823 if (show & show_mask) {
Peter Zijlstraf17e04a2009-05-26 15:30:22 +0200824 struct symbol *sym = dso__find_symbol(dso, ip);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300825
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200826 if (hist_entry__add(thread, map, dso, sym, ip, level)) {
827 fprintf(stderr,
Ingo Molnar55717312009-05-27 22:13:17 +0200828 "problem incrementing symbol count, skipping event\n");
Ingo Molnard80d3382009-06-03 23:14:49 +0200829 return -1;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300830 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300831 }
832 total++;
833 } else switch (event->header.type) {
834 case PERF_EVENT_MMAP: {
835 struct thread *thread = threads__findnew(event->mmap.pid);
Ingo Molnard80d3382009-06-03 23:14:49 +0200836 struct map *map = map__new(&event->mmap);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300837
Ingo Molnar35029732009-06-03 09:38:58 +0200838 dprintf("%p [%p]: PERF_EVENT_MMAP: [%p(%p) @ %p]: %s\n",
839 (void *)(offset + head),
840 (void *)(long)(event->header.size),
841 (void *)(long)event->mmap.start,
842 (void *)(long)event->mmap.len,
843 (void *)(long)event->mmap.pgoff,
844 event->mmap.filename);
845
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300846 if (thread == NULL || map == NULL) {
Ingo Molnar0a520c62009-06-02 23:24:45 +0200847 if (verbose)
848 fprintf(stderr, "problem processing PERF_EVENT_MMAP, skipping event.\n");
Ingo Molnard80d3382009-06-03 23:14:49 +0200849 return -1;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300850 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300851 thread__insert_map(thread, map);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200852 total_mmap++;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300853 break;
854 }
855 case PERF_EVENT_COMM: {
856 struct thread *thread = threads__findnew(event->comm.pid);
857
Ingo Molnar35029732009-06-03 09:38:58 +0200858 dprintf("%p [%p]: PERF_EVENT_COMM: %s:%d\n",
859 (void *)(offset + head),
860 (void *)(long)(event->header.size),
861 event->comm.comm, event->comm.pid);
862
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300863 if (thread == NULL ||
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300864 thread__set_comm(thread, event->comm.comm)) {
Ingo Molnar55717312009-05-27 22:13:17 +0200865 fprintf(stderr, "problem processing PERF_EVENT_COMM, skipping event.\n");
Ingo Molnard80d3382009-06-03 23:14:49 +0200866 return -1;
Arnaldo Carvalho de Meloce7e4362009-05-19 09:30:23 -0300867 }
Ingo Molnar97b07b62009-05-26 18:48:58 +0200868 total_comm++;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300869 break;
870 }
Ingo Molnard80d3382009-06-03 23:14:49 +0200871 default:
872 return -1;
873 }
874
875 return 0;
876}
877
878static int __cmd_report(void)
879{
880 unsigned long offset = 0;
881 unsigned long head = 0;
882 struct stat stat;
883 char *buf;
884 event_t *event;
885 int ret, rc = EXIT_FAILURE;
886 uint32_t size;
887
888 register_idle_thread();
889
890 input = open(input_name, O_RDONLY);
891 if (input < 0) {
892 perror("failed to open file");
893 exit(-1);
894 }
895
896 ret = fstat(input, &stat);
897 if (ret < 0) {
898 perror("failed to stat file");
899 exit(-1);
900 }
901
902 if (!stat.st_size) {
903 fprintf(stderr, "zero-sized file, nothing to do!\n");
904 exit(0);
905 }
906
907 if (load_kernel() < 0) {
908 perror("failed to load kernel symbols");
909 return EXIT_FAILURE;
910 }
911
912 if (!full_paths) {
913 if (getcwd(__cwd, sizeof(__cwd)) == NULL) {
914 perror("failed to get the current directory");
915 return EXIT_FAILURE;
916 }
917 cwdlen = strlen(cwd);
918 } else {
919 cwd = NULL;
920 cwdlen = 0;
921 }
922remap:
923 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
924 MAP_SHARED, input, offset);
925 if (buf == MAP_FAILED) {
926 perror("failed to mmap file");
927 exit(-1);
928 }
929
930more:
931 event = (event_t *)(buf + head);
932
933 size = event->header.size;
934 if (!size)
935 size = 8;
936
937 if (head + event->header.size >= page_size * mmap_window) {
938 unsigned long shift = page_size * (head / page_size);
939 int ret;
940
941 ret = munmap(buf, page_size * mmap_window);
942 assert(ret == 0);
943
944 offset += shift;
945 head -= shift;
946 goto remap;
947 }
948
949 size = event->header.size;
950
951 if (!size || process_event(event, offset, head) < 0) {
952
Ingo Molnar35029732009-06-03 09:38:58 +0200953 dprintf("%p [%p]: skipping unknown header type: %d\n",
954 (void *)(offset + head),
955 (void *)(long)(event->header.size),
956 event->header.type);
Peter Zijlstrab7a16ea2009-05-27 13:35:35 +0200957
Ingo Molnar3e706112009-05-26 18:53:17 +0200958 total_unknown++;
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200959
960 /*
961 * assume we lost track of the stream, check alignment, and
962 * increment a single u64 in the hope to catch on again 'soon'.
963 */
964
965 if (unlikely(head & 7))
966 head &= ~7ULL;
967
968 size = 8;
Ingo Molnar97b07b62009-05-26 18:48:58 +0200969 }
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300970
Peter Zijlstra6142f9e2009-05-26 20:51:47 +0200971 head += size;
Ingo Molnarf49515b2009-05-26 19:03:36 +0200972
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300973 if (offset + head < stat.st_size)
974 goto more;
975
976 rc = EXIT_SUCCESS;
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300977 close(input);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200978
Ingo Molnar35029732009-06-03 09:38:58 +0200979 dprintf(" IP events: %10ld\n", total);
980 dprintf(" mmap events: %10ld\n", total_mmap);
981 dprintf(" comm events: %10ld\n", total_comm);
982 dprintf(" unknown events: %10ld\n", total_unknown);
Ingo Molnar97b07b62009-05-26 18:48:58 +0200983
Ingo Molnar35029732009-06-03 09:38:58 +0200984 if (dump_trace)
Ingo Molnar97b07b62009-05-26 18:48:58 +0200985 return 0;
Ingo Molnar97b07b62009-05-26 18:48:58 +0200986
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200987 if (verbose >= 2)
Ingo Molnar16f762a2009-05-27 09:10:38 +0200988 dsos__fprintf(stdout);
Ingo Molnar16f762a2009-05-27 09:10:38 +0200989
Peter Zijlstra82292892009-06-03 12:37:36 +0200990 collapse__resort();
Peter Zijlstrae7fb08b2009-05-27 20:20:24 +0200991 output__resort();
992 output__fprintf(stdout, total);
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300993
Arnaldo Carvalho de Melo8fa66bd2009-05-18 12:45:42 -0300994 return rc;
995}
996
Ingo Molnar53cb8bc2009-05-26 09:17:18 +0200997static const char * const report_usage[] = {
998 "perf report [<options>] <command>",
999 NULL
1000};
1001
1002static const struct option options[] = {
1003 OPT_STRING('i', "input", &input_name, "file",
1004 "input file name"),
Arnaldo Carvalho de Melo815e7772009-05-26 19:46:14 -03001005 OPT_BOOLEAN('v', "verbose", &verbose,
1006 "be more verbose (show symbol address, etc)"),
Ingo Molnar97b07b62009-05-26 18:48:58 +02001007 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1008 "dump raw trace in ASCII"),
Peter Zijlstra450aaa22009-05-27 20:20:23 +02001009 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
Ingo Molnar63299f02009-05-28 10:52:00 +02001010 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
1011 "sort by key(s): pid, comm, dso, symbol. Default: pid,symbol"),
Arnaldo Carvalho de Melob78c07d2009-05-29 13:48:59 -03001012 OPT_BOOLEAN('P', "full-paths", &full_paths,
1013 "Don't shorten the pathnames taking into account the cwd"),
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001014 OPT_END()
1015};
1016
Ingo Molnar5352f352009-06-03 10:07:39 +02001017static void setup_sorting(void)
1018{
1019 char *tmp, *tok, *str = strdup(sort_order);
1020
1021 for (tok = strtok_r(str, ", ", &tmp);
1022 tok; tok = strtok_r(NULL, ", ", &tmp)) {
1023 if (sort_dimension__add(tok) < 0) {
1024 error("Unknown --sort key: `%s'", tok);
1025 usage_with_options(report_usage, options);
1026 }
1027 }
1028
1029 free(str);
1030}
1031
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001032int cmd_report(int argc, const char **argv, const char *prefix)
1033{
Arnaldo Carvalho de Meloa2928c42009-05-28 14:55:04 -03001034 symbol__init();
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001035
1036 page_size = getpagesize();
1037
1038 parse_options(argc, argv, options, report_usage, 0);
1039
Peter Zijlstra1aa16732009-05-27 20:20:25 +02001040 setup_sorting();
1041
Ingo Molnara930d2c2009-05-27 09:50:13 +02001042 setup_pager();
1043
Ingo Molnar53cb8bc2009-05-26 09:17:18 +02001044 return __cmd_report();
1045}