perf script python: Generate hooks with additional argument
[linux-2.6-block.git] / tools / perf / builtin-report.c
CommitLineData
bf9e1876
IM
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 */
16f762a2 8#include "builtin.h"
53cb8bc2 9
bf9e1876 10#include "util/util.h"
41840d21 11#include "util/config.h"
bf9e1876 12
78f7defe 13#include "util/annotate.h"
8fc0321f 14#include "util/color.h"
5da50258 15#include <linux/list.h>
43cbcd8a 16#include <linux/rbtree.h>
a2928c42 17#include "util/symbol.h"
f55c5552 18#include "util/callchain.h"
8d513270 19#include "util/values.h"
8fa66bdc 20
53cb8bc2 21#include "perf.h"
8f28827a 22#include "util/debug.h"
e248de33
ACM
23#include "util/evlist.h"
24#include "util/evsel.h"
7c6a1c65 25#include "util/header.h"
94c744b6 26#include "util/session.h"
45694aa7 27#include "util/tool.h"
53cb8bc2 28
4b6ab94e 29#include <subcmd/parse-options.h>
34b7b0f9 30#include <subcmd/exec-cmd.h>
53cb8bc2
IM
31#include "util/parse-events.h"
32
6baa0a5a 33#include "util/thread.h"
dd68ada2 34#include "util/sort.h"
3d1d07ec 35#include "util/hist.h"
f5fc1412 36#include "util/data.h"
68e94f4e 37#include "arch/common.h"
46690a80 38#include "util/time-utils.h"
520a2ebc 39#include "util/auxtrace.h"
58db1d6e 40#include "util/units.h"
2d78b189 41#include "util/branch.h"
520a2ebc 42
fc67297b 43#include <dlfcn.h>
a43783ae 44#include <errno.h>
fd20e811 45#include <inttypes.h>
1eae20c1 46#include <regex.h>
9607ad3a 47#include <signal.h>
5d67be97 48#include <linux/bitmap.h>
531d2410 49#include <linux/stringify.h>
7a8ef4c4
ACM
50#include <sys/types.h>
51#include <sys/stat.h>
52#include <unistd.h>
5d67be97 53
28b21393 54struct report {
45694aa7 55 struct perf_tool tool;
d20deb64 56 struct perf_session *session;
2059fc7a 57 bool use_tui, use_gtk, use_stdio;
fa372aae
ACM
58 bool show_full_info;
59 bool show_threads;
60 bool inverted_callchain;
f4f7e28d 61 bool mem_mode;
5cfe2c82
JO
62 bool header;
63 bool header_only;
98df858e 64 bool nonany_branch_mode;
91e95617 65 int max_stack;
fa372aae
ACM
66 struct perf_read_values show_threads_values;
67 const char *pretty_printing_style;
fa372aae 68 const char *cpu_list;
b14ffaca 69 const char *symbol_filter_str;
46690a80
DA
70 const char *time_str;
71 struct perf_time_interval ptime;
064f1981 72 float min_percent;
58c311da 73 u64 nr_entries;
94786b67 74 u64 queue_size;
21394d94 75 int socket_filter;
fa372aae 76 DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
2d78b189 77 struct branch_type_stat brtype_stat;
d20deb64 78};
5d67be97 79
28b21393 80static int report__config(const char *var, const char *value, void *cb)
00c7e1f1 81{
94786b67
JO
82 struct report *rep = cb;
83
00c7e1f1
NK
84 if (!strcmp(var, "report.group")) {
85 symbol_conf.event_group = perf_config_bool(var, value);
86 return 0;
87 }
eec574e6 88 if (!strcmp(var, "report.percent-limit")) {
2665b452
NK
89 double pcnt = strtof(value, NULL);
90
91 rep->min_percent = pcnt;
92 callchain_param.min_percent = pcnt;
eec574e6
NK
93 return 0;
94 }
8d8e645c
NK
95 if (!strcmp(var, "report.children")) {
96 symbol_conf.cumulate_callchain = perf_config_bool(var, value);
97 return 0;
98 }
25ce4bb8
ACM
99 if (!strcmp(var, "report.queue-size"))
100 return perf_config_u64(&rep->queue_size, var, value);
101
fa1f4565
ACM
102 if (!strcmp(var, "report.sort_order")) {
103 default_sort_order = strdup(value);
104 return 0;
105 }
00c7e1f1 106
b8cbb349 107 return 0;
00c7e1f1
NK
108}
109
9d3c02d7
NK
110static int hist_iter__report_callback(struct hist_entry_iter *iter,
111 struct addr_location *al, bool single,
112 void *arg)
113{
114 int err = 0;
115 struct report *rep = arg;
116 struct hist_entry *he = iter->he;
117 struct perf_evsel *evsel = iter->evsel;
bab89f6a 118 struct perf_sample *sample = iter->sample;
9d3c02d7
NK
119 struct mem_info *mi;
120 struct branch_info *bi;
121
9d3c02d7
NK
122 if (!ui__has_annotation())
123 return 0;
124
bab89f6a 125 hist__account_cycles(sample->branch_stack, al, sample,
57849998
AK
126 rep->nonany_branch_mode);
127
9d3c02d7
NK
128 if (sort__mode == SORT_MODE__BRANCH) {
129 bi = he->branch_info;
bab89f6a 130 err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
9d3c02d7
NK
131 if (err)
132 goto out;
133
bab89f6a 134 err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
9d3c02d7
NK
135
136 } else if (rep->mem_mode) {
137 mi = he->mem_info;
bab89f6a 138 err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel->idx);
9d3c02d7
NK
139 if (err)
140 goto out;
141
bab89f6a 142 err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
9d3c02d7
NK
143
144 } else if (symbol_conf.cumulate_callchain) {
145 if (single)
bab89f6a 146 err = hist_entry__inc_addr_samples(he, sample, evsel->idx,
9d3c02d7
NK
147 al->addr);
148 } else {
bab89f6a 149 err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
9d3c02d7
NK
150 }
151
152out:
153 return err;
f4f7e28d
SE
154}
155
2d78b189
JY
156static int hist_iter__branch_callback(struct hist_entry_iter *iter,
157 struct addr_location *al __maybe_unused,
158 bool single __maybe_unused,
159 void *arg)
160{
161 struct hist_entry *he = iter->he;
162 struct report *rep = arg;
163 struct branch_info *bi;
164
165 bi = he->branch_info;
166 branch_type_count(&rep->brtype_stat, &bi->flags,
167 bi->from.addr, bi->to.addr);
168
169 return 0;
170}
171
45694aa7 172static int process_sample_event(struct perf_tool *tool,
d20deb64 173 union perf_event *event,
8115d60c 174 struct perf_sample *sample,
9e69c210 175 struct perf_evsel *evsel,
743eb868 176 struct machine *machine)
75051724 177{
28b21393 178 struct report *rep = container_of(tool, struct report, tool);
1ed091c4 179 struct addr_location al;
69bcb019 180 struct hist_entry_iter iter = {
063bd936
NK
181 .evsel = evsel,
182 .sample = sample,
b49a8fe5 183 .hide_unresolved = symbol_conf.hide_unresolved,
063bd936 184 .add_entry_cb = hist_iter__report_callback,
69bcb019 185 };
b91fc39f 186 int ret = 0;
180f95e2 187
46690a80
DA
188 if (perf_time__skip_sample(&rep->ptime, sample->time))
189 return 0;
190
bb3eb566 191 if (machine__resolve(machine, &al, sample) < 0) {
a4210141
NK
192 pr_debug("problem processing %d event, skipping it.\n",
193 event->header.type);
75051724
IM
194 return -1;
195 }
e7fb08b1 196
b49a8fe5 197 if (symbol_conf.hide_unresolved && al.sym == NULL)
b91fc39f 198 goto out_put;
7bec7a91 199
fa372aae 200 if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap))
b91fc39f 201 goto out_put;
5d67be97 202
f86225db
AH
203 if (sort__mode == SORT_MODE__BRANCH) {
204 /*
205 * A non-synthesized event might not have a branch stack if
206 * branch stacks have been synthesized (using itrace options).
207 */
208 if (!sample->branch_stack)
209 goto out_put;
2d78b189
JY
210
211 iter.add_entry_cb = hist_iter__branch_callback;
69bcb019 212 iter.ops = &hist_iter_branch;
f86225db 213 } else if (rep->mem_mode) {
69bcb019 214 iter.ops = &hist_iter_mem;
f86225db 215 } else if (symbol_conf.cumulate_callchain) {
7a13aa28 216 iter.ops = &hist_iter_cumulative;
f86225db 217 } else {
69bcb019 218 iter.ops = &hist_iter_normal;
f86225db 219 }
69bcb019
NK
220
221 if (al.map != NULL)
222 al.map->dso->hit = 1;
223
063bd936 224 ret = hist_entry_iter__add(&iter, &al, rep->max_stack, rep);
69bcb019
NK
225 if (ret < 0)
226 pr_debug("problem adding hist entry, skipping event\n");
b91fc39f
ACM
227out_put:
228 addr_location__put(&al);
27a0dcb7 229 return ret;
75051724 230}
3502973d 231
45694aa7 232static int process_read_event(struct perf_tool *tool,
d20deb64 233 union perf_event *event,
1d037ca1 234 struct perf_sample *sample __maybe_unused,
743eb868 235 struct perf_evsel *evsel,
1d037ca1 236 struct machine *machine __maybe_unused)
e9ea2fde 237{
28b21393 238 struct report *rep = container_of(tool, struct report, tool);
743eb868 239
fa372aae 240 if (rep->show_threads) {
7289f83c 241 const char *name = evsel ? perf_evsel__name(evsel) : "unknown";
89973506 242 int err = perf_read_values_add_value(&rep->show_threads_values,
8d513270
BG
243 event->read.pid, event->read.tid,
244 event->read.id,
245 name,
246 event->read.value);
89973506
ACM
247
248 if (err)
249 return err;
8d513270
BG
250 }
251
9486aa38 252 dump_printf(": %d %d %s %" PRIu64 "\n", event->read.pid, event->read.tid,
7289f83c 253 evsel ? perf_evsel__name(evsel) : "FAIL",
62daacb5 254 event->read.value);
e9ea2fde
PZ
255
256 return 0;
257}
258
300aa941 259/* For pipe mode, sample_type is not currently set */
28b21393 260static int report__setup_sample_type(struct report *rep)
d80d338d 261{
c824c433
ACM
262 struct perf_session *session = rep->session;
263 u64 sample_type = perf_evlist__combined_sample_type(session->evlist);
264 bool is_pipe = perf_data_file__is_pipe(session->file);
d20deb64 265
d062ac16
AH
266 if (session->itrace_synth_opts->callchain ||
267 (!is_pipe &&
268 perf_header__has_feat(&session->header, HEADER_AUXTRACE) &&
269 !session->itrace_synth_opts->set))
270 sample_type |= PERF_SAMPLE_CALLCHAIN;
271
c7eced63
AH
272 if (session->itrace_synth_opts->last_branch)
273 sample_type |= PERF_SAMPLE_BRANCH_STACK;
274
cc9784bd 275 if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) {
de7e6a7c 276 if (perf_hpp_list.parent) {
3780f488 277 ui__error("Selected --sort parent, but no "
00894ce9
ACM
278 "callchain data. Did you call "
279 "'perf record' without -g?\n");
d549c769 280 return -EINVAL;
91b4eaea 281 }
d599db3f 282 if (symbol_conf.use_callchain) {
fa94c36c
AK
283 ui__error("Selected -g or --branch-history but no "
284 "callchain data. Did\n"
285 "you call 'perf record' without -g?\n");
016e92fb 286 return -1;
91b4eaea 287 }
1cc83815 288 } else if (!callchain_param.enabled &&
fa372aae 289 callchain_param.mode != CHAIN_NONE &&
b9a63b9b 290 !symbol_conf.use_callchain) {
d599db3f 291 symbol_conf.use_callchain = true;
16537f13 292 if (callchain_register_param(&callchain_param) < 0) {
3780f488 293 ui__error("Can't register callchain params.\n");
d549c769 294 return -EINVAL;
b1a88349 295 }
f5970550
PZ
296 }
297
793aaaab
NK
298 if (symbol_conf.cumulate_callchain) {
299 /* Silently ignore if callchain is missing */
300 if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) {
301 symbol_conf.cumulate_callchain = false;
302 perf_hpp__cancel_cumulate();
303 }
304 }
305
55369fc1 306 if (sort__mode == SORT_MODE__BRANCH) {
cc9784bd 307 if (!is_pipe &&
7f3be652 308 !(sample_type & PERF_SAMPLE_BRANCH_STACK)) {
3780f488
NK
309 ui__error("Selected -b but no branch data. "
310 "Did you call perf record without -b?\n");
b50311dc
RAV
311 return -1;
312 }
313 }
314
0cdccac6
NK
315 if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) {
316 if ((sample_type & PERF_SAMPLE_REGS_USER) &&
317 (sample_type & PERF_SAMPLE_STACK_USER))
318 callchain_param.record_mode = CALLCHAIN_DWARF;
aad2b21c
KL
319 else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
320 callchain_param.record_mode = CALLCHAIN_LBR;
0cdccac6
NK
321 else
322 callchain_param.record_mode = CALLCHAIN_FP;
323 }
98df858e
AK
324
325 /* ??? handle more cases than just ANY? */
326 if (!(perf_evlist__combined_branch_type(session->evlist) &
327 PERF_SAMPLE_BRANCH_ANY))
328 rep->nonany_branch_mode = true;
329
016e92fb
FW
330 return 0;
331}
6142f9ec 332
1d037ca1 333static void sig_handler(int sig __maybe_unused)
46656ac7
TZ
334{
335 session_done = 1;
336}
337
28b21393 338static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report *rep,
c82ee828
ACM
339 const char *evname, FILE *fp)
340{
341 size_t ret;
342 char unit;
c824c433
ACM
343 unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE];
344 u64 nr_events = hists->stats.total_period;
345 struct perf_evsel *evsel = hists_to_evsel(hists);
717e263f
NK
346 char buf[512];
347 size_t size = sizeof(buf);
84734b06 348 int socked_id = hists->socket_filter;
717e263f 349
27fafab5
NK
350 if (quiet)
351 return 0;
352
f2148330
NK
353 if (symbol_conf.filter_relative) {
354 nr_samples = hists->stats.nr_non_filtered_samples;
355 nr_events = hists->stats.total_non_filtered_period;
356 }
357
759ff497 358 if (perf_evsel__is_group_event(evsel)) {
717e263f
NK
359 struct perf_evsel *pos;
360
361 perf_evsel__group_desc(evsel, buf, size);
362 evname = buf;
363
364 for_each_group_member(pos, evsel) {
4ea062ed
ACM
365 const struct hists *pos_hists = evsel__hists(pos);
366
f2148330 367 if (symbol_conf.filter_relative) {
4ea062ed
ACM
368 nr_samples += pos_hists->stats.nr_non_filtered_samples;
369 nr_events += pos_hists->stats.total_non_filtered_period;
f2148330 370 } else {
4ea062ed
ACM
371 nr_samples += pos_hists->stats.nr_events[PERF_RECORD_SAMPLE];
372 nr_events += pos_hists->stats.total_period;
f2148330 373 }
717e263f
NK
374 }
375 }
c82ee828 376
cc686280
AR
377 nr_samples = convert_unit(nr_samples, &unit);
378 ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit);
c82ee828 379 if (evname != NULL)
cc686280
AR
380 ret += fprintf(fp, " of event '%s'", evname);
381
9e207ddf
KL
382 if (symbol_conf.show_ref_callgraph &&
383 strstr(evname, "call-graph=no")) {
384 ret += fprintf(fp, ", show reference callgraph");
385 }
386
f4f7e28d
SE
387 if (rep->mem_mode) {
388 ret += fprintf(fp, "\n# Total weight : %" PRIu64, nr_events);
228f14f2 389 ret += fprintf(fp, "\n# Sort order : %s", sort_order ? : default_mem_sort_order);
f4f7e28d
SE
390 } else
391 ret += fprintf(fp, "\n# Event count (approx.): %" PRIu64, nr_events);
21394d94 392
84734b06
KL
393 if (socked_id > -1)
394 ret += fprintf(fp, "\n# Processor Socket: %d", socked_id);
21394d94 395
c82ee828
ACM
396 return ret + fprintf(fp, "\n#\n");
397}
398
7f0030b2 399static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
28b21393 400 struct report *rep,
7f0030b2 401 const char *help)
d67f088e 402{
e248de33 403 struct perf_evsel *pos;
d67f088e 404
27fafab5
NK
405 if (!quiet) {
406 fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n",
407 evlist->stats.total_lost_samples);
408 }
409
e5cadb93 410 evlist__for_each_entry(evlist, pos) {
4ea062ed 411 struct hists *hists = evsel__hists(pos);
7289f83c 412 const char *evname = perf_evsel__name(pos);
d67f088e 413
fc24d7c2
NK
414 if (symbol_conf.event_group &&
415 !perf_evsel__is_group_leader(pos))
416 continue;
417
28b21393 418 hists__fprintf_nr_sample_events(hists, rep, evname, stdout);
27fafab5 419 hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout,
d05e3aae 420 symbol_conf.use_callchain);
d67f088e 421 fprintf(stdout, "\n\n");
d67f088e
ACM
422 }
423
8b53dbef 424 if (!quiet)
d67f088e
ACM
425 fprintf(stdout, "#\n# (%s)\n#\n", help);
426
021162cf
NK
427 if (rep->show_threads) {
428 bool style = !strcmp(rep->pretty_printing_style, "raw");
429 perf_read_values_display(stdout, &rep->show_threads_values,
430 style);
431 perf_read_values_destroy(&rep->show_threads_values);
d67f088e
ACM
432 }
433
2d78b189
JY
434 if (sort__mode == SORT_MODE__BRANCH)
435 branch_type_stat_display(stdout, &rep->brtype_stat);
436
d67f088e
ACM
437 return 0;
438}
439
fad2918e
ACM
440static void report__warn_kptr_restrict(const struct report *rep)
441{
a5e813c6 442 struct map *kernel_map = machine__kernel_map(&rep->session->machines.host);
f6fcc143 443 struct kmap *kernel_kmap = kernel_map ? map__kmap(kernel_map) : NULL;
fad2918e
ACM
444
445 if (kernel_map == NULL ||
446 (kernel_map->dso->hit &&
447 (kernel_kmap->ref_reloc_sym == NULL ||
448 kernel_kmap->ref_reloc_sym->addr == 0))) {
449 const char *desc =
450 "As no suitable kallsyms nor vmlinux was found, kernel samples\n"
451 "can't be resolved.";
452
453 if (kernel_map) {
454 const struct dso *kdso = kernel_map->dso;
455 if (!RB_EMPTY_ROOT(&kdso->symbols[MAP__FUNCTION])) {
456 desc = "If some relocation was applied (e.g. "
457 "kexec) symbols may be misresolved.";
458 }
459 }
460
461 ui__warning(
462"Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n"
463"Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n"
464"Samples in kernel modules can't be resolved as well.\n\n",
465 desc);
466 }
467}
468
8362951b
ACM
469static int report__gtk_browse_hists(struct report *rep, const char *help)
470{
471 int (*hist_browser)(struct perf_evlist *evlist, const char *help,
472 struct hist_browser_timer *timer, float min_pcnt);
473
474 hist_browser = dlsym(perf_gtk_handle, "perf_evlist__gtk_browse_hists");
475
476 if (hist_browser == NULL) {
477 ui__error("GTK browser not found!\n");
478 return -1;
479 }
480
481 return hist_browser(rep->session->evlist, help, NULL, rep->min_percent);
482}
483
484static int report__browse_hists(struct report *rep)
485{
486 int ret;
487 struct perf_session *session = rep->session;
488 struct perf_evlist *evlist = session->evlist;
34b7b0f9
NK
489 const char *help = perf_tip(system_path(TIPDIR));
490
491 if (help == NULL) {
492 /* fallback for people who don't install perf ;-) */
493 help = perf_tip(DOCDIR);
494 if (help == NULL)
495 help = "Cannot load tips.txt file, please install perf!";
496 }
8362951b
ACM
497
498 switch (use_browser) {
499 case 1:
500 ret = perf_evlist__tui_browse_hists(evlist, help, NULL,
501 rep->min_percent,
502 &session->header.env);
503 /*
504 * Usually "ret" is the last pressed key, and we only
505 * care if the key notifies us to switch data file.
506 */
507 if (ret != K_SWITCH_INPUT_DATA)
508 ret = 0;
509 break;
510 case 2:
511 ret = report__gtk_browse_hists(rep, help);
512 break;
513 default:
514 ret = perf_evlist__tty_browse_hists(evlist, rep, help);
515 break;
516 }
517
518 return ret;
519}
520
5b2ea6f2 521static int report__collapse_hists(struct report *rep)
f6d8b057
ACM
522{
523 struct ui_progress prog;
524 struct perf_evsel *pos;
5b2ea6f2 525 int ret = 0;
f6d8b057 526
58c311da 527 ui_progress__init(&prog, rep->nr_entries, "Merging related events...");
f6d8b057 528
e5cadb93 529 evlist__for_each_entry(rep->session->evlist, pos) {
4ea062ed 530 struct hists *hists = evsel__hists(pos);
f6d8b057
ACM
531
532 if (pos->idx == 0)
533 hists->symbol_filter_str = rep->symbol_filter_str;
534
21394d94
KL
535 hists->socket_filter = rep->socket_filter;
536
5b2ea6f2
NK
537 ret = hists__collapse_resort(hists, &prog);
538 if (ret < 0)
539 break;
f6d8b057
ACM
540
541 /* Non-group events are considered as leader */
542 if (symbol_conf.event_group &&
543 !perf_evsel__is_group_leader(pos)) {
4ea062ed 544 struct hists *leader_hists = evsel__hists(pos->leader);
f6d8b057
ACM
545
546 hists__match(leader_hists, hists);
547 hists__link(leader_hists, hists);
548 }
549 }
550
551 ui_progress__finish();
5b2ea6f2 552 return ret;
f6d8b057
ACM
553}
554
740b97f9
NK
555static void report__output_resort(struct report *rep)
556{
557 struct ui_progress prog;
558 struct perf_evsel *pos;
559
560 ui_progress__init(&prog, rep->nr_entries, "Sorting events for output...");
561
e5cadb93 562 evlist__for_each_entry(rep->session->evlist, pos)
452ce03b 563 perf_evsel__output_resort(pos, &prog);
740b97f9
NK
564
565 ui_progress__finish();
566}
567
28b21393 568static int __cmd_report(struct report *rep)
016e92fb 569{
f6d8b057 570 int ret;
993ac88d 571 struct perf_session *session = rep->session;
e248de33 572 struct perf_evsel *pos;
cc9784bd 573 struct perf_data_file *file = session->file;
8fa66bdc 574
46656ac7
TZ
575 signal(SIGINT, sig_handler);
576
fa372aae
ACM
577 if (rep->cpu_list) {
578 ret = perf_session__cpu_bitmap(session, rep->cpu_list,
579 rep->cpu_bitmap);
25b1606b
NK
580 if (ret) {
581 ui__error("failed to set cpu bitmap\n");
d4ae0a6f 582 return ret;
25b1606b 583 }
644e0840 584 session->itrace_synth_opts->cpu_bitmap = rep->cpu_bitmap;
5d67be97
AB
585 }
586
89973506
ACM
587 if (rep->show_threads) {
588 ret = perf_read_values_init(&rep->show_threads_values);
589 if (ret)
590 return ret;
591 }
f5970550 592
28b21393 593 ret = report__setup_sample_type(rep);
25b1606b
NK
594 if (ret) {
595 /* report__setup_sample_type() already showed error message */
d4ae0a6f 596 return ret;
25b1606b 597 }
d549c769 598
b7b61cbe 599 ret = perf_session__process_events(session);
25b1606b
NK
600 if (ret) {
601 ui__error("failed to process sample\n");
d4ae0a6f 602 return ret;
25b1606b 603 }
97b07b69 604
fad2918e 605 report__warn_kptr_restrict(rep);
ec80fde7 606
e5cadb93 607 evlist__for_each_entry(session->evlist, pos)
590cd344
NK
608 rep->nr_entries += evsel__hists(pos)->nr_entries;
609
150e465a
NK
610 if (use_browser == 0) {
611 if (verbose > 3)
612 perf_session__fprintf(session, stdout);
9ac99545 613
150e465a
NK
614 if (verbose > 2)
615 perf_session__fprintf_dsos(session, stdout);
16f762a2 616
150e465a
NK
617 if (dump_trace) {
618 perf_session__fprintf_nr_events(session, stdout);
2a1731fb 619 perf_evlist__fprintf_nr_events(session->evlist, stdout);
150e465a
NK
620 return 0;
621 }
71ad0f5e
JO
622 }
623
5b2ea6f2
NK
624 ret = report__collapse_hists(rep);
625 if (ret) {
626 ui__error("failed to process hist entry\n");
627 return ret;
628 }
e248de33 629
33e940a2
ACM
630 if (session_done())
631 return 0;
632
740b97f9
NK
633 /*
634 * recalculate number of entries after collapsing since it
635 * might be changed during the collapse phase.
636 */
637 rep->nr_entries = 0;
e5cadb93 638 evlist__for_each_entry(session->evlist, pos)
740b97f9
NK
639 rep->nr_entries += evsel__hists(pos)->nr_entries;
640
58c311da 641 if (rep->nr_entries == 0) {
cc9784bd 642 ui__error("The %s file has no samples!\n", file->path);
d4ae0a6f 643 return 0;
cbbc79a5
EM
644 }
645
740b97f9 646 report__output_resort(rep);
6e1f601a 647
8362951b 648 return report__browse_hists(rep);
8fa66bdc
ACM
649}
650
4eb3e478 651static int
cff6bb46 652report_parse_callchain_opt(const struct option *opt, const char *arg, int unset)
4eb3e478 653{
1cc83815 654 struct callchain_param *callchain = opt->value;
c20ab37e 655
1cc83815 656 callchain->enabled = !unset;
b9a63b9b
ACM
657 /*
658 * --no-call-graph
659 */
660 if (unset) {
1cc83815
ACM
661 symbol_conf.use_callchain = false;
662 callchain->mode = CHAIN_NONE;
b9a63b9b
ACM
663 return 0;
664 }
665
cff6bb46 666 return parse_callchain_report_opt(arg);
4eb3e478
FW
667}
668
b21484f1
GP
669int
670report_parse_ignore_callees_opt(const struct option *opt __maybe_unused,
671 const char *arg, int unset __maybe_unused)
672{
673 if (arg) {
674 int err = regcomp(&ignore_callees_regex, arg, REG_EXTENDED);
675 if (err) {
676 char buf[BUFSIZ];
677 regerror(err, &ignore_callees_regex, buf, sizeof(buf));
678 pr_err("Invalid --ignore-callees regex: %s\n%s", arg, buf);
679 return -1;
680 }
681 have_ignore_callees = 1;
682 }
683
684 return 0;
685}
686
993ac88d 687static int
7e6a7998 688parse_branch_mode(const struct option *opt,
1d037ca1 689 const char *str __maybe_unused, int unset)
993ac88d 690{
55369fc1
NK
691 int *branch_mode = opt->value;
692
693 *branch_mode = !unset;
993ac88d
SE
694 return 0;
695}
696
064f1981
NK
697static int
698parse_percent_limit(const struct option *opt, const char *str,
699 int unset __maybe_unused)
700{
28b21393 701 struct report *rep = opt->value;
2665b452 702 double pcnt = strtof(str, NULL);
064f1981 703
2665b452
NK
704 rep->min_percent = pcnt;
705 callchain_param.min_percent = pcnt;
064f1981
NK
706 return 0;
707}
708
f2af0086 709#define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent"
76a26549
NK
710
711const char report_callchain_help[] = "Display call graph (stack chain/backtrace):\n\n"
712 CALLCHAIN_REPORT_HELP
713 "\n\t\t\t\tDefault: " CALLCHAIN_DEFAULT_OPT;
21cf6284 714
b0ad8ea6 715int cmd_report(int argc, const char **argv)
d20deb64 716{
993ac88d 717 struct perf_session *session;
520a2ebc 718 struct itrace_synth_opts itrace_synth_opts = { .set = 0, };
efad1415 719 struct stat st;
993ac88d 720 bool has_br_stack = false;
55369fc1 721 int branch_mode = -1;
fa94c36c 722 bool branch_call_mode = false;
76a26549 723 char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT;
d20deb64 724 const char * const report_usage[] = {
fb2baceb 725 "perf report [<options>]",
d20deb64
ACM
726 NULL
727 };
28b21393 728 struct report report = {
45694aa7 729 .tool = {
d20deb64
ACM
730 .sample = process_sample_event,
731 .mmap = perf_event__process_mmap,
5c5e854b 732 .mmap2 = perf_event__process_mmap2,
d20deb64 733 .comm = perf_event__process_comm,
f3b3614a 734 .namespaces = perf_event__process_namespaces,
f62d3f0f
ACM
735 .exit = perf_event__process_exit,
736 .fork = perf_event__process_fork,
d20deb64
ACM
737 .lost = perf_event__process_lost,
738 .read = process_read_event,
739 .attr = perf_event__process_attr,
d20deb64
ACM
740 .tracing_data = perf_event__process_tracing_data,
741 .build_id = perf_event__process_build_id,
520a2ebc
AH
742 .id_index = perf_event__process_id_index,
743 .auxtrace_info = perf_event__process_auxtrace_info,
744 .auxtrace = perf_event__process_auxtrace,
e9def1b2 745 .feature = perf_event__process_feature,
0a8cb85c 746 .ordered_events = true,
d20deb64
ACM
747 .ordering_requires_timestamps = true,
748 },
fe176085 749 .max_stack = PERF_MAX_STACK_DEPTH,
d20deb64 750 .pretty_printing_style = "normal",
21394d94 751 .socket_filter = -1,
d20deb64
ACM
752 };
753 const struct option options[] = {
70cb4e96 754 OPT_STRING('i', "input", &input_name, "file",
53cb8bc2 755 "input file name"),
c0555642 756 OPT_INCR('v', "verbose", &verbose,
815e777f 757 "be more verbose (show symbol address, etc)"),
27fafab5 758 OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
97b07b69
IM
759 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
760 "dump raw trace in ASCII"),
b32d133a
ACM
761 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
762 "file", "vmlinux pathname"),
b226a5a7
DA
763 OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
764 "file", "kallsyms pathname"),
2059fc7a 765 OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
b32d133a 766 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
42976487 767 "load module symbols - WARNING: use only with -k and LIVE kernel"),
d599db3f 768 OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
e3d7e183 769 "Show a column with the number of samples"),
fa372aae 770 OPT_BOOLEAN('T', "threads", &report.show_threads,
8d513270 771 "Show per-thread event counters"),
fa372aae 772 OPT_STRING(0, "pretty", &report.pretty_printing_style, "key",
9f866697 773 "pretty printing style key: normal raw"),
fa372aae 774 OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"),
c31a9457 775 OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"),
fa372aae
ACM
776 OPT_BOOLEAN(0, "stdio", &report.use_stdio,
777 "Use the stdio interface"),
5cfe2c82
JO
778 OPT_BOOLEAN(0, "header", &report.header, "Show data header."),
779 OPT_BOOLEAN(0, "header-only", &report.header_only,
780 "Show only data header."),
63299f05 781 OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
a2ce067e
NK
782 "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
783 " Please refer the man page for the complete list."),
a7d945bc
NK
784 OPT_STRING('F', "fields", &field_order, "key[,keys...]",
785 "output field(s): overhead, period, sample plus all of sort keys"),
b272a59d 786 OPT_BOOLEAN(0, "show-cpu-utilization", &symbol_conf.show_cpu_utilization,
a1645ce1 787 "Show sample percentage for different cpu modes"),
b272a59d
NK
788 OPT_BOOLEAN_FLAG(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
789 "Show sample percentage for different cpu modes", PARSE_OPT_HIDDEN),
b25bcf2f
IM
790 OPT_STRING('p', "parent", &parent_pattern, "regex",
791 "regex filter to identify parent, see: '--sort parent'"),
d599db3f 792 OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other,
b8e6d829 793 "Only display entries with parent-match"),
1cc83815 794 OPT_CALLBACK_DEFAULT('g', "call-graph", &callchain_param,
f2af0086 795 "print_type,threshold[,print_limit],order,sort_key[,branch],value",
21cf6284
NK
796 report_callchain_help, &report_parse_callchain_opt,
797 callchain_default_opt),
793aaaab
NK
798 OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain,
799 "Accumulate callchains of children and show total overhead as well"),
91e95617
WL
800 OPT_INTEGER(0, "max-stack", &report.max_stack,
801 "Set the maximum stack depth when parsing the callchain, "
802 "anything beyond the specified depth will be ignored. "
4cb93446 803 "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)),
fa372aae
ACM
804 OPT_BOOLEAN('G', "inverted", &report.inverted_callchain,
805 "alias for inverted call graph"),
b21484f1
GP
806 OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
807 "ignore callees of these functions in call graphs",
808 report_parse_ignore_callees_opt),
655000e7 809 OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
25903407 810 "only consider symbols in these dsos"),
c8e66720 811 OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
cc8b88b1 812 "only consider symbols in these comms"),
e03eaa40
DA
813 OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]",
814 "only consider symbols in these pids"),
815 OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]",
816 "only consider symbols in these tids"),
655000e7 817 OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
7bec7a91 818 "only consider these symbols"),
b14ffaca
NK
819 OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter",
820 "only show symbols that (partially) match with this filter"),
655000e7 821 OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str,
52d422de
ACM
822 "width[,width...]",
823 "don't try to adjust column width, use these fixed values"),
0c8c2077 824 OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator",
52d422de
ACM
825 "separator for columns, no spaces will be added between "
826 "columns '.' is reserved."),
b49a8fe5 827 OPT_BOOLEAN('U', "hide-unresolved", &symbol_conf.hide_unresolved,
71289be7 828 "Only display entries resolved to a symbol"),
a7066709
HK
829 OPT_CALLBACK(0, "symfs", NULL, "directory",
830 "Look for files with symbols relative to this directory",
831 symbol__config_symfs),
c8e66720 832 OPT_STRING('C', "cpu", &report.cpu_list, "cpu",
fa372aae
ACM
833 "list of cpus to profile"),
834 OPT_BOOLEAN('I', "show-info", &report.show_full_info,
fbe96f29 835 "Display extended information about perf.data file"),
64c6f0c7
ACM
836 OPT_BOOLEAN(0, "source", &symbol_conf.annotate_src,
837 "Interleave source code with assembly code (default)"),
838 OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
839 "Display raw encoding of assembly instructions (default)"),
f69b64f7
AK
840 OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
841 "Specify disassembler style (e.g. -M intel for intel syntax)"),
3f2728bd
ACM
842 OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
843 "Show a column with the sum of periods"),
01d14f16
NK
844 OPT_BOOLEAN(0, "group", &symbol_conf.event_group,
845 "Show event group information together"),
55369fc1 846 OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "",
fa94c36c
AK
847 "use branch records for per branch histogram filling",
848 parse_branch_mode),
849 OPT_BOOLEAN(0, "branch-history", &branch_call_mode,
850 "add last branch records to call history"),
7a4ec938
MB
851 OPT_STRING(0, "objdump", &objdump_path, "path",
852 "objdump binary to use for disassembly and annotations"),
328ccdac
NK
853 OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
854 "Disable symbol demangling"),
763122ad
AK
855 OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
856 "Enable kernel symbol demangling"),
f4f7e28d 857 OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"),
064f1981
NK
858 OPT_CALLBACK(0, "percent-limit", &report, "percent",
859 "Don't show entries under that percent", parse_percent_limit),
f2148330 860 OPT_CALLBACK(0, "percentage", NULL, "relative|absolute",
33db4568 861 "how to display percentage of filtered entries", parse_filter_percentage),
520a2ebc
AH
862 OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
863 "Instruction Tracing options",
864 itrace_parse_synth_opts),
a9710ba0
AK
865 OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
866 "Show full source file name path for source lines"),
9e207ddf
KL
867 OPT_BOOLEAN(0, "show-ref-call-graph", &symbol_conf.show_ref_callgraph,
868 "Show callgraph from reference event"),
21394d94
KL
869 OPT_INTEGER(0, "socket-filter", &report.socket_filter,
870 "only show processor socket that match with this filter"),
053a3989
NK
871 OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace,
872 "Show raw trace event output (do not use print fmt or plugins)"),
4251446d
NK
873 OPT_BOOLEAN(0, "hierarchy", &symbol_conf.report_hierarchy,
874 "Show entries in a hierarchy"),
175b968b
ACM
875 OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode",
876 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
877 stdio__config_color, "always"),
46690a80
DA
878 OPT_STRING(0, "time", &report.time_str, "str",
879 "Time span of interest (start,stop)"),
f3a60646
JY
880 OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name,
881 "Show inline function"),
53cb8bc2 882 OPT_END()
d20deb64 883 };
f5fc1412
JO
884 struct perf_data_file file = {
885 .mode = PERF_DATA_MODE_READ,
886 };
a635fc51
ACM
887 int ret = hists__init();
888
889 if (ret < 0)
890 return ret;
53cb8bc2 891
ecc4c561
ACM
892 ret = perf_config(report__config, &report);
893 if (ret)
894 return ret;
00c7e1f1 895
655000e7 896 argc = parse_options(argc, argv, options, report_usage, 0);
b3f38fc2
NK
897 if (argc) {
898 /*
899 * Special case: if there's an argument left then assume that
900 * it's a symbol filter:
901 */
902 if (argc > 1)
903 usage_with_options(report_usage, options);
904
905 report.symbol_filter_str = argv[0];
906 }
655000e7 907
27fafab5
NK
908 if (quiet)
909 perf_quiet_option();
910
36c8bb56
LZ
911 if (symbol_conf.vmlinux_name &&
912 access(symbol_conf.vmlinux_name, R_OK)) {
913 pr_err("Invalid file: %s\n", symbol_conf.vmlinux_name);
914 return -EINVAL;
915 }
916 if (symbol_conf.kallsyms_name &&
917 access(symbol_conf.kallsyms_name, R_OK)) {
918 pr_err("Invalid file: %s\n", symbol_conf.kallsyms_name);
919 return -EINVAL;
920 }
921
fa372aae 922 if (report.use_stdio)
8b9e74eb 923 use_browser = 0;
fa372aae 924 else if (report.use_tui)
8b9e74eb 925 use_browser = 1;
c31a9457
PE
926 else if (report.use_gtk)
927 use_browser = 2;
8b9e74eb 928
fa372aae 929 if (report.inverted_callchain)
d797fdc5 930 callchain_param.order = ORDER_CALLER;
792aeafa
NK
931 if (symbol_conf.cumulate_callchain && !callchain_param.order_set)
932 callchain_param.order = ORDER_CALLER;
d797fdc5 933
188bb5e2
AH
934 if (itrace_synth_opts.callchain &&
935 (int)itrace_synth_opts.callchain_sz > report.max_stack)
936 report.max_stack = itrace_synth_opts.callchain_sz;
937
70cb4e96 938 if (!input_name || !strlen(input_name)) {
efad1415 939 if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
70cb4e96 940 input_name = "-";
efad1415 941 else
70cb4e96 942 input_name = "perf.data";
efad1415 943 }
ad0de097 944
f5fc1412 945 file.path = input_name;
2059fc7a 946 file.force = symbol_conf.force;
f5fc1412 947
ad0de097 948repeat:
f5fc1412 949 session = perf_session__new(&file, false, &report.tool);
993ac88d 950 if (session == NULL)
52e02834 951 return -1;
993ac88d 952
94786b67
JO
953 if (report.queue_size) {
954 ordered_events__set_alloc_size(&session->ordered_events,
955 report.queue_size);
956 }
957
520a2ebc
AH
958 session->itrace_synth_opts = &itrace_synth_opts;
959
993ac88d
SE
960 report.session = session;
961
962 has_br_stack = perf_header__has_feat(&session->header,
963 HEADER_BRANCH_STACK);
efad1415 964
fb9fab66
AH
965 if (itrace_synth_opts.last_branch)
966 has_br_stack = true;
967
f9a7be7c
JY
968 if (has_br_stack && branch_call_mode)
969 symbol_conf.show_branchflag_count = true;
970
2d78b189
JY
971 memset(&report.brtype_stat, 0, sizeof(struct branch_type_stat));
972
fa94c36c
AK
973 /*
974 * Branch mode is a tristate:
975 * -1 means default, so decide based on the file having branch data.
976 * 0/1 means the user chose a mode.
977 */
978 if (((branch_mode == -1 && has_br_stack) || branch_mode == 1) &&
fefd2d96 979 !branch_call_mode) {
55369fc1 980 sort__mode = SORT_MODE__BRANCH;
793aaaab
NK
981 symbol_conf.cumulate_callchain = false;
982 }
fa94c36c 983 if (branch_call_mode) {
09a6a1b0 984 callchain_param.key = CCKEY_ADDRESS;
fa94c36c
AK
985 callchain_param.branch_callstack = 1;
986 symbol_conf.use_callchain = true;
987 callchain_register_param(&callchain_param);
988 if (sort_order == NULL)
989 sort_order = "srcline,symbol,dso";
990 }
993ac88d 991
f4f7e28d 992 if (report.mem_mode) {
55369fc1 993 if (sort__mode == SORT_MODE__BRANCH) {
a4210141 994 pr_err("branch and mem mode incompatible\n");
f4f7e28d
SE
995 goto error;
996 }
afab87b9 997 sort__mode = SORT_MODE__MEMORY;
793aaaab 998 symbol_conf.cumulate_callchain = false;
f4f7e28d 999 }
a68c2c58 1000
4251446d
NK
1001 if (symbol_conf.report_hierarchy) {
1002 /* disable incompatible options */
4251446d
NK
1003 symbol_conf.cumulate_callchain = false;
1004
1005 if (field_order) {
1006 pr_err("Error: --hierarchy and --fields options cannot be used together\n");
1007 parse_options_usage(report_usage, options, "F", 1);
1008 parse_options_usage(NULL, options, "hierarchy", 0);
1009 goto error;
1010 }
1011
52225036 1012 perf_hpp_list.need_collapse = true;
4251446d
NK
1013 }
1014
b138f42e
NK
1015 /* Force tty output for header output and per-thread stat. */
1016 if (report.header || report.header_only || report.show_threads)
5cfe2c82 1017 use_browser = 0;
114f709e
DCC
1018 if (report.header || report.header_only)
1019 report.tool.show_feat_hdr = SHOW_FEAT_HEADER;
1020 if (report.show_full_info)
1021 report.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO;
5cfe2c82 1022
4bceffbc
NK
1023 if (strcmp(input_name, "-") != 0)
1024 setup_browser(true);
22af969e 1025 else
4bceffbc 1026 use_browser = 0;
4bceffbc 1027
9887804d
JO
1028 if (setup_sorting(session->evlist) < 0) {
1029 if (sort_order)
1030 parse_options_usage(report_usage, options, "s", 1);
1031 if (field_order)
1032 parse_options_usage(sort_order ? NULL : report_usage,
1033 options, "F", 1);
1034 goto error;
1035 }
1036
27fafab5 1037 if ((report.header || report.header_only) && !quiet) {
5cfe2c82
JO
1038 perf_session__fprintf_info(session, stdout,
1039 report.show_full_info);
07a716ff
TS
1040 if (report.header_only) {
1041 ret = 0;
1042 goto error;
1043 }
27fafab5 1044 } else if (use_browser == 0 && !quiet) {
5cfe2c82
JO
1045 fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n",
1046 stdout);
1047 }
1048
ef7b93a1 1049 /*
6692c262 1050 * Only in the TUI browser we are doing integrated annotation,
ef7b93a1
ACM
1051 * so don't allocate extra space that won't be used in the stdio
1052 * implementation.
1053 */
b9ce0c99 1054 if (ui__has_annotation()) {
b01141f4
ACM
1055 ret = symbol__annotation_init();
1056 if (ret < 0)
1057 goto error;
80d50cae
ACM
1058 /*
1059 * For searching by name on the "Browse map details".
1060 * providing it only in verbose mode not to bloat too
1061 * much struct symbol.
1062 */
bb963e16 1063 if (verbose > 0) {
80d50cae
ACM
1064 /*
1065 * XXX: Need to provide a less kludgy way to ask for
1066 * more space per symbol, the u32 is for the index on
1067 * the ui browser.
1068 * See symbol__browser_index.
1069 */
1070 symbol_conf.priv_size += sizeof(u32);
1071 symbol_conf.sort_by_name = true;
1072 }
1073 }
655000e7 1074
0a7e6d1b 1075 if (symbol__init(&session->header.env) < 0)
993ac88d 1076 goto error;
53cb8bc2 1077
46690a80
DA
1078 if (perf_time__parse_str(&report.ptime, report.time_str) != 0) {
1079 pr_err("Invalid time string\n");
1080 return -EINVAL;
1081 }
1082
08e71542 1083 sort__setup_elide(stdout);
25903407 1084
993ac88d 1085 ret = __cmd_report(&report);
ad0de097
FT
1086 if (ret == K_SWITCH_INPUT_DATA) {
1087 perf_session__delete(session);
1088 goto repeat;
1089 } else
1090 ret = 0;
1091
993ac88d
SE
1092error:
1093 perf_session__delete(session);
1094 return ret;
53cb8bc2 1095}