Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
bf9e1876 IM |
2 | /* |
3 | * builtin-report.c | |
4 | * | |
5 | * Builtin report command: Analyze the perf.data input file, | |
6 | * look up and read DSOs and symbol information and display | |
7 | * a histogram of results, along various sorting keys. | |
8 | */ | |
16f762a2 | 9 | #include "builtin.h" |
53cb8bc2 | 10 | |
41840d21 | 11 | #include "util/config.h" |
bf9e1876 | 12 | |
78f7defe | 13 | #include "util/annotate.h" |
8fc0321f | 14 | #include "util/color.h" |
4a3cec84 | 15 | #include "util/dso.h" |
5da50258 | 16 | #include <linux/list.h> |
43cbcd8a | 17 | #include <linux/rbtree.h> |
930f8b34 | 18 | #include <linux/err.h> |
7f7c536f | 19 | #include <linux/zalloc.h> |
1101f69a | 20 | #include "util/map.h" |
a2928c42 | 21 | #include "util/symbol.h" |
d3300a3c ACM |
22 | #include "util/map_symbol.h" |
23 | #include "util/mem-events.h" | |
24 | #include "util/branch.h" | |
f55c5552 | 25 | #include "util/callchain.h" |
8d513270 | 26 | #include "util/values.h" |
8fa66bdc | 27 | |
53cb8bc2 | 28 | #include "perf.h" |
8f28827a | 29 | #include "util/debug.h" |
e248de33 ACM |
30 | #include "util/evlist.h" |
31 | #include "util/evsel.h" | |
ef4b1a53 | 32 | #include "util/evswitch.h" |
7c6a1c65 | 33 | #include "util/header.h" |
94c744b6 | 34 | #include "util/session.h" |
97b9d866 | 35 | #include "util/srcline.h" |
45694aa7 | 36 | #include "util/tool.h" |
53cb8bc2 | 37 | |
4b6ab94e | 38 | #include <subcmd/parse-options.h> |
34b7b0f9 | 39 | #include <subcmd/exec-cmd.h> |
53cb8bc2 IM |
40 | #include "util/parse-events.h" |
41 | ||
6baa0a5a | 42 | #include "util/thread.h" |
dd68ada2 | 43 | #include "util/sort.h" |
3d1d07ec | 44 | #include "util/hist.h" |
f5fc1412 | 45 | #include "util/data.h" |
68e94f4e | 46 | #include "arch/common.h" |
46690a80 | 47 | #include "util/time-utils.h" |
520a2ebc | 48 | #include "util/auxtrace.h" |
58db1d6e | 49 | #include "util/units.h" |
fb71c86c | 50 | #include "util/util.h" // perf_tip() |
8520a98d | 51 | #include "ui/ui.h" |
171f7474 | 52 | #include "ui/progress.h" |
6f7164fa | 53 | #include "util/block-info.h" |
520a2ebc | 54 | |
fc67297b | 55 | #include <dlfcn.h> |
a43783ae | 56 | #include <errno.h> |
fd20e811 | 57 | #include <inttypes.h> |
1eae20c1 | 58 | #include <regex.h> |
3052ba56 | 59 | #include <linux/ctype.h> |
9607ad3a | 60 | #include <signal.h> |
5d67be97 | 61 | #include <linux/bitmap.h> |
2f1e20fe | 62 | #include <linux/list_sort.h> |
8520a98d | 63 | #include <linux/string.h> |
531d2410 | 64 | #include <linux/stringify.h> |
2a1292cb | 65 | #include <linux/time64.h> |
7a8ef4c4 ACM |
66 | #include <sys/types.h> |
67 | #include <sys/stat.h> | |
68 | #include <unistd.h> | |
6439d7d1 | 69 | #include <linux/mman.h> |
5d67be97 | 70 | |
378ef0f5 IR |
71 | #ifdef HAVE_LIBTRACEEVENT |
72 | #include <traceevent/event-parse.h> | |
73 | #endif | |
74 | ||
28b21393 | 75 | struct report { |
45694aa7 | 76 | struct perf_tool tool; |
d20deb64 | 77 | struct perf_session *session; |
ef4b1a53 | 78 | struct evswitch evswitch; |
3402ae0a IR |
79 | #ifdef HAVE_SLANG_SUPPORT |
80 | bool use_tui; | |
81 | #endif | |
557cc18e | 82 | #ifdef HAVE_GTK2_SUPPORT |
3402ae0a | 83 | bool use_gtk; |
557cc18e | 84 | #endif |
3402ae0a | 85 | bool use_stdio; |
fa372aae ACM |
86 | bool show_full_info; |
87 | bool show_threads; | |
88 | bool inverted_callchain; | |
f4f7e28d | 89 | bool mem_mode; |
a4a4d0a7 | 90 | bool stats_mode; |
930f8b34 | 91 | bool tasks_mode; |
6439d7d1 | 92 | bool mmaps_mode; |
5cfe2c82 JO |
93 | bool header; |
94 | bool header_only; | |
98df858e | 95 | bool nonany_branch_mode; |
57b5de46 | 96 | bool group_set; |
b1d1429b | 97 | bool stitch_lbr; |
2e989f82 | 98 | bool disable_order; |
2775de0b | 99 | bool skip_empty; |
81e57dee | 100 | bool data_type; |
91e95617 | 101 | int max_stack; |
fa372aae ACM |
102 | struct perf_read_values show_threads_values; |
103 | const char *pretty_printing_style; | |
fa372aae | 104 | const char *cpu_list; |
b14ffaca | 105 | const char *symbol_filter_str; |
46690a80 | 106 | const char *time_str; |
0a3cc3ae JY |
107 | struct perf_time_interval *ptime_range; |
108 | int range_size; | |
5b969bc7 | 109 | int range_num; |
064f1981 | 110 | float min_percent; |
58c311da | 111 | u64 nr_entries; |
94786b67 | 112 | u64 queue_size; |
6f7164fa | 113 | u64 total_cycles; |
21394d94 | 114 | int socket_filter; |
fa372aae | 115 | DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
2d78b189 | 116 | struct branch_type_stat brtype_stat; |
ec6ae74f | 117 | bool symbol_ipc; |
6f7164fa JY |
118 | bool total_cycles_mode; |
119 | struct block_report *block_reports; | |
cca0cc76 | 120 | int nr_block_reports; |
d20deb64 | 121 | }; |
5d67be97 | 122 | |
28b21393 | 123 | static int report__config(const char *var, const char *value, void *cb) |
00c7e1f1 | 124 | { |
94786b67 JO |
125 | struct report *rep = cb; |
126 | ||
00c7e1f1 NK |
127 | if (!strcmp(var, "report.group")) { |
128 | symbol_conf.event_group = perf_config_bool(var, value); | |
129 | return 0; | |
130 | } | |
eec574e6 | 131 | if (!strcmp(var, "report.percent-limit")) { |
2665b452 NK |
132 | double pcnt = strtof(value, NULL); |
133 | ||
134 | rep->min_percent = pcnt; | |
135 | callchain_param.min_percent = pcnt; | |
eec574e6 NK |
136 | return 0; |
137 | } | |
8d8e645c NK |
138 | if (!strcmp(var, "report.children")) { |
139 | symbol_conf.cumulate_callchain = perf_config_bool(var, value); | |
140 | return 0; | |
141 | } | |
25ce4bb8 ACM |
142 | if (!strcmp(var, "report.queue-size")) |
143 | return perf_config_u64(&rep->queue_size, var, value); | |
144 | ||
fa1f4565 ACM |
145 | if (!strcmp(var, "report.sort_order")) { |
146 | default_sort_order = strdup(value); | |
8f08c363 IR |
147 | if (!default_sort_order) { |
148 | pr_err("Not enough memory for report.sort_order\n"); | |
149 | return -1; | |
150 | } | |
fa1f4565 ACM |
151 | return 0; |
152 | } | |
00c7e1f1 | 153 | |
8f08cf33 NK |
154 | if (!strcmp(var, "report.skip-empty")) { |
155 | rep->skip_empty = perf_config_bool(var, value); | |
156 | return 0; | |
157 | } | |
158 | ||
8f08c363 | 159 | pr_debug("%s variable unknown, ignoring...", var); |
b8cbb349 | 160 | return 0; |
00c7e1f1 NK |
161 | } |
162 | ||
9d3c02d7 NK |
163 | static int hist_iter__report_callback(struct hist_entry_iter *iter, |
164 | struct addr_location *al, bool single, | |
165 | void *arg) | |
166 | { | |
167 | int err = 0; | |
168 | struct report *rep = arg; | |
169 | struct hist_entry *he = iter->he; | |
32dcd021 | 170 | struct evsel *evsel = iter->evsel; |
bab89f6a | 171 | struct perf_sample *sample = iter->sample; |
9d3c02d7 NK |
172 | struct mem_info *mi; |
173 | struct branch_info *bi; | |
174 | ||
6cdd977e | 175 | if (!ui__has_annotation() && !rep->symbol_ipc) |
9d3c02d7 NK |
176 | return 0; |
177 | ||
178 | if (sort__mode == SORT_MODE__BRANCH) { | |
179 | bi = he->branch_info; | |
e345f3bd | 180 | err = addr_map_symbol__inc_samples(&bi->from, sample, evsel); |
9d3c02d7 NK |
181 | if (err) |
182 | goto out; | |
183 | ||
e345f3bd | 184 | err = addr_map_symbol__inc_samples(&bi->to, sample, evsel); |
9d3c02d7 NK |
185 | |
186 | } else if (rep->mem_mode) { | |
187 | mi = he->mem_info; | |
e345f3bd | 188 | err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel); |
9d3c02d7 NK |
189 | if (err) |
190 | goto out; | |
191 | ||
e345f3bd | 192 | err = hist_entry__inc_addr_samples(he, sample, evsel, al->addr); |
9d3c02d7 NK |
193 | |
194 | } else if (symbol_conf.cumulate_callchain) { | |
195 | if (single) | |
e345f3bd | 196 | err = hist_entry__inc_addr_samples(he, sample, evsel, al->addr); |
9d3c02d7 | 197 | } else { |
e345f3bd | 198 | err = hist_entry__inc_addr_samples(he, sample, evsel, al->addr); |
9d3c02d7 NK |
199 | } |
200 | ||
201 | out: | |
202 | return err; | |
f4f7e28d SE |
203 | } |
204 | ||
2d78b189 JY |
205 | static int hist_iter__branch_callback(struct hist_entry_iter *iter, |
206 | struct addr_location *al __maybe_unused, | |
207 | bool single __maybe_unused, | |
208 | void *arg) | |
209 | { | |
210 | struct hist_entry *he = iter->he; | |
211 | struct report *rep = arg; | |
c3b10649 | 212 | struct branch_info *bi = he->branch_info; |
40c39e30 | 213 | struct perf_sample *sample = iter->sample; |
32dcd021 | 214 | struct evsel *evsel = iter->evsel; |
40c39e30 JY |
215 | int err; |
216 | ||
c3b10649 JY |
217 | branch_type_count(&rep->brtype_stat, &bi->flags, |
218 | bi->from.addr, bi->to.addr); | |
219 | ||
ec6ae74f | 220 | if (!ui__has_annotation() && !rep->symbol_ipc) |
40c39e30 JY |
221 | return 0; |
222 | ||
e345f3bd | 223 | err = addr_map_symbol__inc_samples(&bi->from, sample, evsel); |
40c39e30 JY |
224 | if (err) |
225 | goto out; | |
226 | ||
e345f3bd | 227 | err = addr_map_symbol__inc_samples(&bi->to, sample, evsel); |
40c39e30 | 228 | |
40c39e30 JY |
229 | out: |
230 | return err; | |
2d78b189 JY |
231 | } |
232 | ||
57b5de46 | 233 | static void setup_forced_leader(struct report *report, |
63503dba | 234 | struct evlist *evlist) |
57b5de46 | 235 | { |
a26bb0ba | 236 | if (report->group_set) |
64b4778b | 237 | evlist__force_leader(evlist); |
57b5de46 JO |
238 | } |
239 | ||
89f1688a JO |
240 | static int process_feature_event(struct perf_session *session, |
241 | union perf_event *event) | |
57b5de46 | 242 | { |
89f1688a | 243 | struct report *rep = container_of(session->tool, struct report, tool); |
57b5de46 JO |
244 | |
245 | if (event->feat.feat_id < HEADER_LAST_FEATURE) | |
89f1688a | 246 | return perf_event__process_feature(session, event); |
57b5de46 JO |
247 | |
248 | if (event->feat.feat_id != HEADER_LAST_FEATURE) { | |
1b8896fb | 249 | pr_err("failed: wrong feature ID: %" PRI_lu64 "\n", |
57b5de46 JO |
250 | event->feat.feat_id); |
251 | return -1; | |
03de8656 NK |
252 | } else if (rep->header_only) { |
253 | session_done = 1; | |
57b5de46 JO |
254 | } |
255 | ||
256 | /* | |
92ead7ee RB |
257 | * (feat_id = HEADER_LAST_FEATURE) is the end marker which |
258 | * means all features are received, now we can force the | |
57b5de46 JO |
259 | * group if needed. |
260 | */ | |
261 | setup_forced_leader(rep, session->evlist); | |
262 | return 0; | |
263 | } | |
264 | ||
45694aa7 | 265 | static int process_sample_event(struct perf_tool *tool, |
d20deb64 | 266 | union perf_event *event, |
8115d60c | 267 | struct perf_sample *sample, |
32dcd021 | 268 | struct evsel *evsel, |
743eb868 | 269 | struct machine *machine) |
75051724 | 270 | { |
28b21393 | 271 | struct report *rep = container_of(tool, struct report, tool); |
1ed091c4 | 272 | struct addr_location al; |
69bcb019 | 273 | struct hist_entry_iter iter = { |
063bd936 NK |
274 | .evsel = evsel, |
275 | .sample = sample, | |
b49a8fe5 | 276 | .hide_unresolved = symbol_conf.hide_unresolved, |
063bd936 | 277 | .add_entry_cb = hist_iter__report_callback, |
69bcb019 | 278 | }; |
b91fc39f | 279 | int ret = 0; |
180f95e2 | 280 | |
5b969bc7 JY |
281 | if (perf_time__ranges_skip_sample(rep->ptime_range, rep->range_num, |
282 | sample->time)) { | |
46690a80 | 283 | return 0; |
5b969bc7 | 284 | } |
46690a80 | 285 | |
ef4b1a53 ACM |
286 | if (evswitch__discard(&rep->evswitch, evsel)) |
287 | return 0; | |
288 | ||
0dd5041c | 289 | addr_location__init(&al); |
bb3eb566 | 290 | if (machine__resolve(machine, &al, sample) < 0) { |
a4210141 NK |
291 | pr_debug("problem processing %d event, skipping it.\n", |
292 | event->header.type); | |
0dd5041c IR |
293 | ret = -1; |
294 | goto out_put; | |
75051724 | 295 | } |
e7fb08b1 | 296 | |
b1d1429b | 297 | if (rep->stitch_lbr) |
ee84a303 | 298 | thread__set_lbr_stitch_enable(al.thread, true); |
b1d1429b | 299 | |
b49a8fe5 | 300 | if (symbol_conf.hide_unresolved && al.sym == NULL) |
b91fc39f | 301 | goto out_put; |
7bec7a91 | 302 | |
fa372aae | 303 | if (rep->cpu_list && !test_bit(sample->cpu, rep->cpu_bitmap)) |
b91fc39f | 304 | goto out_put; |
5d67be97 | 305 | |
f86225db AH |
306 | if (sort__mode == SORT_MODE__BRANCH) { |
307 | /* | |
308 | * A non-synthesized event might not have a branch stack if | |
309 | * branch stacks have been synthesized (using itrace options). | |
310 | */ | |
311 | if (!sample->branch_stack) | |
312 | goto out_put; | |
2d78b189 JY |
313 | |
314 | iter.add_entry_cb = hist_iter__branch_callback; | |
69bcb019 | 315 | iter.ops = &hist_iter_branch; |
f86225db | 316 | } else if (rep->mem_mode) { |
69bcb019 | 317 | iter.ops = &hist_iter_mem; |
f86225db | 318 | } else if (symbol_conf.cumulate_callchain) { |
7a13aa28 | 319 | iter.ops = &hist_iter_cumulative; |
f86225db | 320 | } else { |
69bcb019 | 321 | iter.ops = &hist_iter_normal; |
f86225db | 322 | } |
69bcb019 NK |
323 | |
324 | if (al.map != NULL) | |
ee756ef7 | 325 | dso__set_hit(map__dso(al.map)); |
69bcb019 | 326 | |
6f7164fa | 327 | if (ui__has_annotation() || rep->symbol_ipc || rep->total_cycles_mode) { |
bdd1666b | 328 | hist__account_cycles(sample->branch_stack, &al, sample, |
6f7164fa JY |
329 | rep->nonany_branch_mode, |
330 | &rep->total_cycles); | |
bdd1666b JY |
331 | } |
332 | ||
063bd936 | 333 | ret = hist_entry_iter__add(&iter, &al, rep->max_stack, rep); |
69bcb019 NK |
334 | if (ret < 0) |
335 | pr_debug("problem adding hist entry, skipping event\n"); | |
b91fc39f | 336 | out_put: |
0dd5041c | 337 | addr_location__exit(&al); |
27a0dcb7 | 338 | return ret; |
75051724 | 339 | } |
3502973d | 340 | |
45694aa7 | 341 | static int process_read_event(struct perf_tool *tool, |
d20deb64 | 342 | union perf_event *event, |
1d037ca1 | 343 | struct perf_sample *sample __maybe_unused, |
32dcd021 | 344 | struct evsel *evsel, |
1d037ca1 | 345 | struct machine *machine __maybe_unused) |
e9ea2fde | 346 | { |
28b21393 | 347 | struct report *rep = container_of(tool, struct report, tool); |
743eb868 | 348 | |
fa372aae | 349 | if (rep->show_threads) { |
8ab2e96d | 350 | const char *name = evsel__name(evsel); |
89973506 | 351 | int err = perf_read_values_add_value(&rep->show_threads_values, |
8d513270 | 352 | event->read.pid, event->read.tid, |
38fe0e01 | 353 | evsel->core.idx, |
8d513270 BG |
354 | name, |
355 | event->read.value); | |
89973506 ACM |
356 | |
357 | if (err) | |
358 | return err; | |
8d513270 BG |
359 | } |
360 | ||
e9ea2fde PZ |
361 | return 0; |
362 | } | |
363 | ||
300aa941 | 364 | /* For pipe mode, sample_type is not currently set */ |
28b21393 | 365 | static int report__setup_sample_type(struct report *rep) |
d80d338d | 366 | { |
c824c433 | 367 | struct perf_session *session = rep->session; |
b3c2cc2b | 368 | u64 sample_type = evlist__combined_sample_type(session->evlist); |
8ceb41d7 | 369 | bool is_pipe = perf_data__is_pipe(session->data); |
ccb17cae | 370 | struct evsel *evsel; |
d20deb64 | 371 | |
d062ac16 | 372 | if (session->itrace_synth_opts->callchain || |
1c5c25b3 | 373 | session->itrace_synth_opts->add_callchain || |
d062ac16 AH |
374 | (!is_pipe && |
375 | perf_header__has_feat(&session->header, HEADER_AUXTRACE) && | |
376 | !session->itrace_synth_opts->set)) | |
377 | sample_type |= PERF_SAMPLE_CALLCHAIN; | |
378 | ||
ec90e42c AH |
379 | if (session->itrace_synth_opts->last_branch || |
380 | session->itrace_synth_opts->add_last_branch) | |
c7eced63 AH |
381 | sample_type |= PERF_SAMPLE_BRANCH_STACK; |
382 | ||
cc9784bd | 383 | if (!is_pipe && !(sample_type & PERF_SAMPLE_CALLCHAIN)) { |
de7e6a7c | 384 | if (perf_hpp_list.parent) { |
3780f488 | 385 | ui__error("Selected --sort parent, but no " |
00894ce9 ACM |
386 | "callchain data. Did you call " |
387 | "'perf record' without -g?\n"); | |
d549c769 | 388 | return -EINVAL; |
91b4eaea | 389 | } |
b49a821e JY |
390 | if (symbol_conf.use_callchain && |
391 | !symbol_conf.show_branchflag_count) { | |
392 | ui__error("Selected -g or --branch-history.\n" | |
393 | "But no callchain or branch data.\n" | |
394 | "Did you call 'perf record' without -g or -b?\n"); | |
016e92fb | 395 | return -1; |
91b4eaea | 396 | } |
1cc83815 | 397 | } else if (!callchain_param.enabled && |
fa372aae | 398 | callchain_param.mode != CHAIN_NONE && |
b9a63b9b | 399 | !symbol_conf.use_callchain) { |
d599db3f | 400 | symbol_conf.use_callchain = true; |
16537f13 | 401 | if (callchain_register_param(&callchain_param) < 0) { |
3780f488 | 402 | ui__error("Can't register callchain params.\n"); |
d549c769 | 403 | return -EINVAL; |
b1a88349 | 404 | } |
f5970550 PZ |
405 | } |
406 | ||
793aaaab NK |
407 | if (symbol_conf.cumulate_callchain) { |
408 | /* Silently ignore if callchain is missing */ | |
409 | if (!(sample_type & PERF_SAMPLE_CALLCHAIN)) { | |
410 | symbol_conf.cumulate_callchain = false; | |
411 | perf_hpp__cancel_cumulate(); | |
412 | } | |
413 | } | |
414 | ||
55369fc1 | 415 | if (sort__mode == SORT_MODE__BRANCH) { |
cc9784bd | 416 | if (!is_pipe && |
7f3be652 | 417 | !(sample_type & PERF_SAMPLE_BRANCH_STACK)) { |
3780f488 NK |
418 | ui__error("Selected -b but no branch data. " |
419 | "Did you call perf record without -b?\n"); | |
b50311dc RAV |
420 | return -1; |
421 | } | |
422 | } | |
423 | ||
bb30acae | 424 | if (sort__mode == SORT_MODE__MEMORY) { |
ccb17cae LY |
425 | /* |
426 | * FIXUP: prior to kernel 5.18, Arm SPE missed to set | |
427 | * PERF_SAMPLE_DATA_SRC bit in sample type. For backward | |
428 | * compatibility, set the bit if it's an old perf data file. | |
429 | */ | |
430 | evlist__for_each_entry(session->evlist, evsel) { | |
431 | if (strstr(evsel->name, "arm_spe") && | |
432 | !(sample_type & PERF_SAMPLE_DATA_SRC)) { | |
433 | evsel->core.attr.sample_type |= PERF_SAMPLE_DATA_SRC; | |
434 | sample_type |= PERF_SAMPLE_DATA_SRC; | |
435 | } | |
436 | } | |
437 | ||
bb30acae RB |
438 | if (!is_pipe && !(sample_type & PERF_SAMPLE_DATA_SRC)) { |
439 | ui__error("Selected --mem-mode but no mem data. " | |
440 | "Did you call perf record without -d?\n"); | |
441 | return -1; | |
442 | } | |
443 | } | |
444 | ||
aa8db3e4 | 445 | callchain_param_setup(sample_type, perf_env__arch(&rep->session->header.env)); |
98df858e | 446 | |
b1d1429b KL |
447 | if (rep->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { |
448 | ui__warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" | |
449 | "Please apply --call-graph lbr when recording.\n"); | |
450 | rep->stitch_lbr = false; | |
451 | } | |
452 | ||
98df858e | 453 | /* ??? handle more cases than just ANY? */ |
92c7d7cd | 454 | if (!(evlist__combined_branch_type(session->evlist) & PERF_SAMPLE_BRANCH_ANY)) |
98df858e AK |
455 | rep->nonany_branch_mode = true; |
456 | ||
c3314a74 | 457 | #if !defined(HAVE_LIBUNWIND_SUPPORT) && !defined(HAVE_DWARF_SUPPORT) |
800d3f56 | 458 | if (dwarf_callchain_users) { |
c3314a74 JY |
459 | ui__warning("Please install libunwind or libdw " |
460 | "development packages during the perf build.\n"); | |
800d3f56 JY |
461 | } |
462 | #endif | |
463 | ||
016e92fb FW |
464 | return 0; |
465 | } | |
6142f9ec | 466 | |
1d037ca1 | 467 | static void sig_handler(int sig __maybe_unused) |
46656ac7 TZ |
468 | { |
469 | session_done = 1; | |
470 | } | |
471 | ||
28b21393 | 472 | static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report *rep, |
c82ee828 ACM |
473 | const char *evname, FILE *fp) |
474 | { | |
475 | size_t ret; | |
476 | char unit; | |
0f0abbac | 477 | unsigned long nr_samples = hists->stats.nr_samples; |
c824c433 | 478 | u64 nr_events = hists->stats.total_period; |
32dcd021 | 479 | struct evsel *evsel = hists_to_evsel(hists); |
717e263f NK |
480 | char buf[512]; |
481 | size_t size = sizeof(buf); | |
84734b06 | 482 | int socked_id = hists->socket_filter; |
717e263f | 483 | |
27fafab5 NK |
484 | if (quiet) |
485 | return 0; | |
486 | ||
f2148330 NK |
487 | if (symbol_conf.filter_relative) { |
488 | nr_samples = hists->stats.nr_non_filtered_samples; | |
489 | nr_events = hists->stats.total_non_filtered_period; | |
490 | } | |
491 | ||
c754c382 | 492 | if (evsel__is_group_event(evsel)) { |
32dcd021 | 493 | struct evsel *pos; |
717e263f | 494 | |
347c751a | 495 | evsel__group_desc(evsel, buf, size); |
717e263f NK |
496 | evname = buf; |
497 | ||
498 | for_each_group_member(pos, evsel) { | |
4ea062ed ACM |
499 | const struct hists *pos_hists = evsel__hists(pos); |
500 | ||
f2148330 | 501 | if (symbol_conf.filter_relative) { |
4ea062ed ACM |
502 | nr_samples += pos_hists->stats.nr_non_filtered_samples; |
503 | nr_events += pos_hists->stats.total_non_filtered_period; | |
f2148330 | 504 | } else { |
0f0abbac | 505 | nr_samples += pos_hists->stats.nr_samples; |
4ea062ed | 506 | nr_events += pos_hists->stats.total_period; |
f2148330 | 507 | } |
717e263f NK |
508 | } |
509 | } | |
c82ee828 | 510 | |
cc686280 AR |
511 | nr_samples = convert_unit(nr_samples, &unit); |
512 | ret = fprintf(fp, "# Samples: %lu%c", nr_samples, unit); | |
8ef278bb JO |
513 | if (evname != NULL) { |
514 | ret += fprintf(fp, " of event%s '%s'", | |
5643b1a5 | 515 | evsel->core.nr_members > 1 ? "s" : "", evname); |
8ef278bb | 516 | } |
cc686280 | 517 | |
7425664b JY |
518 | if (rep->time_str) |
519 | ret += fprintf(fp, " (time slices: %s)", rep->time_str); | |
520 | ||
11b6e548 | 521 | if (symbol_conf.show_ref_callgraph && evname && strstr(evname, "call-graph=no")) { |
9e207ddf KL |
522 | ret += fprintf(fp, ", show reference callgraph"); |
523 | } | |
524 | ||
f4f7e28d SE |
525 | if (rep->mem_mode) { |
526 | ret += fprintf(fp, "\n# Total weight : %" PRIu64, nr_events); | |
228f14f2 | 527 | ret += fprintf(fp, "\n# Sort order : %s", sort_order ? : default_mem_sort_order); |
f4f7e28d SE |
528 | } else |
529 | ret += fprintf(fp, "\n# Event count (approx.): %" PRIu64, nr_events); | |
21394d94 | 530 | |
84734b06 KL |
531 | if (socked_id > -1) |
532 | ret += fprintf(fp, "\n# Processor Socket: %d", socked_id); | |
21394d94 | 533 | |
c82ee828 ACM |
534 | return ret + fprintf(fp, "\n#\n"); |
535 | } | |
536 | ||
f4bd0b4a | 537 | static int evlist__tui_block_hists_browse(struct evlist *evlist, struct report *rep) |
7fa46cbf JY |
538 | { |
539 | struct evsel *pos; | |
540 | int i = 0, ret; | |
541 | ||
542 | evlist__for_each_entry(evlist, pos) { | |
543 | ret = report__browse_block_hists(&rep->block_reports[i++].hist, | |
848a5e50 | 544 | rep->min_percent, pos, |
22197fb2 | 545 | &rep->session->header.env); |
7fa46cbf JY |
546 | if (ret != 0) |
547 | return ret; | |
548 | } | |
549 | ||
550 | return 0; | |
551 | } | |
552 | ||
f4bd0b4a | 553 | static int evlist__tty_browse_hists(struct evlist *evlist, struct report *rep, const char *help) |
d67f088e | 554 | { |
32dcd021 | 555 | struct evsel *pos; |
6f7164fa | 556 | int i = 0; |
d67f088e | 557 | |
27fafab5 NK |
558 | if (!quiet) { |
559 | fprintf(stdout, "#\n# Total Lost Samples: %" PRIu64 "\n#\n", | |
560 | evlist->stats.total_lost_samples); | |
561 | } | |
562 | ||
e5cadb93 | 563 | evlist__for_each_entry(evlist, pos) { |
4ea062ed | 564 | struct hists *hists = evsel__hists(pos); |
8ab2e96d | 565 | const char *evname = evsel__name(pos); |
d67f088e | 566 | |
c754c382 | 567 | if (symbol_conf.event_group && !evsel__is_group_leader(pos)) |
fc24d7c2 NK |
568 | continue; |
569 | ||
2775de0b NK |
570 | if (rep->skip_empty && !hists->stats.nr_samples) |
571 | continue; | |
572 | ||
28b21393 | 573 | hists__fprintf_nr_sample_events(hists, rep, evname, stdout); |
6f7164fa JY |
574 | |
575 | if (rep->total_cycles_mode) { | |
576 | report__browse_block_hists(&rep->block_reports[i++].hist, | |
22197fb2 | 577 | rep->min_percent, pos, NULL); |
6f7164fa JY |
578 | continue; |
579 | } | |
580 | ||
27fafab5 | 581 | hists__fprintf(hists, !quiet, 0, 0, rep->min_percent, stdout, |
e9de7e2f ACM |
582 | !(symbol_conf.use_callchain || |
583 | symbol_conf.show_branchflag_count)); | |
d67f088e | 584 | fprintf(stdout, "\n\n"); |
d67f088e ACM |
585 | } |
586 | ||
8b53dbef | 587 | if (!quiet) |
d67f088e ACM |
588 | fprintf(stdout, "#\n# (%s)\n#\n", help); |
589 | ||
021162cf NK |
590 | if (rep->show_threads) { |
591 | bool style = !strcmp(rep->pretty_printing_style, "raw"); | |
592 | perf_read_values_display(stdout, &rep->show_threads_values, | |
593 | style); | |
594 | perf_read_values_destroy(&rep->show_threads_values); | |
d67f088e ACM |
595 | } |
596 | ||
2d78b189 JY |
597 | if (sort__mode == SORT_MODE__BRANCH) |
598 | branch_type_stat_display(stdout, &rep->brtype_stat); | |
599 | ||
d67f088e ACM |
600 | return 0; |
601 | } | |
602 | ||
fad2918e ACM |
603 | static void report__warn_kptr_restrict(const struct report *rep) |
604 | { | |
a5e813c6 | 605 | struct map *kernel_map = machine__kernel_map(&rep->session->machines.host); |
f6fcc143 | 606 | struct kmap *kernel_kmap = kernel_map ? map__kmap(kernel_map) : NULL; |
fad2918e | 607 | |
78e1bc25 | 608 | if (evlist__exclude_kernel(rep->session->evlist)) |
9c39ed90 ACM |
609 | return; |
610 | ||
fad2918e | 611 | if (kernel_map == NULL || |
ee756ef7 | 612 | (dso__hit(map__dso(kernel_map)) && |
fad2918e ACM |
613 | (kernel_kmap->ref_reloc_sym == NULL || |
614 | kernel_kmap->ref_reloc_sym->addr == 0))) { | |
615 | const char *desc = | |
616 | "As no suitable kallsyms nor vmlinux was found, kernel samples\n" | |
617 | "can't be resolved."; | |
618 | ||
e94b861a ACM |
619 | if (kernel_map && map__has_symbols(kernel_map)) { |
620 | desc = "If some relocation was applied (e.g. " | |
621 | "kexec) symbols may be misresolved."; | |
fad2918e ACM |
622 | } |
623 | ||
624 | ui__warning( | |
625 | "Kernel address maps (/proc/{kallsyms,modules}) were restricted.\n\n" | |
626 | "Check /proc/sys/kernel/kptr_restrict before running 'perf record'.\n\n%s\n\n" | |
627 | "Samples in kernel modules can't be resolved as well.\n\n", | |
628 | desc); | |
629 | } | |
630 | } | |
631 | ||
8362951b ACM |
632 | static int report__gtk_browse_hists(struct report *rep, const char *help) |
633 | { | |
63503dba | 634 | int (*hist_browser)(struct evlist *evlist, const char *help, |
8362951b ACM |
635 | struct hist_browser_timer *timer, float min_pcnt); |
636 | ||
f4bd0b4a | 637 | hist_browser = dlsym(perf_gtk_handle, "evlist__gtk_browse_hists"); |
8362951b ACM |
638 | |
639 | if (hist_browser == NULL) { | |
640 | ui__error("GTK browser not found!\n"); | |
641 | return -1; | |
642 | } | |
643 | ||
644 | return hist_browser(rep->session->evlist, help, NULL, rep->min_percent); | |
645 | } | |
646 | ||
647 | static int report__browse_hists(struct report *rep) | |
648 | { | |
649 | int ret; | |
650 | struct perf_session *session = rep->session; | |
63503dba | 651 | struct evlist *evlist = session->evlist; |
d9fc7061 | 652 | char *help = NULL, *path = NULL; |
34b7b0f9 | 653 | |
d9fc7061 IR |
654 | path = system_path(TIPDIR); |
655 | if (perf_tip(&help, path) || help == NULL) { | |
34b7b0f9 | 656 | /* fallback for people who don't install perf ;-) */ |
d9fc7061 IR |
657 | free(path); |
658 | path = system_path(DOCDIR); | |
659 | if (perf_tip(&help, path) || help == NULL) | |
660 | help = strdup("Cannot load tips.txt file, please install perf!"); | |
34b7b0f9 | 661 | } |
d9fc7061 | 662 | free(path); |
8362951b ACM |
663 | |
664 | switch (use_browser) { | |
665 | case 1: | |
7fa46cbf | 666 | if (rep->total_cycles_mode) { |
f4bd0b4a | 667 | ret = evlist__tui_block_hists_browse(evlist, rep); |
7fa46cbf JY |
668 | break; |
669 | } | |
670 | ||
f4bd0b4a | 671 | ret = evlist__tui_browse_hists(evlist, help, NULL, rep->min_percent, |
22197fb2 | 672 | &session->header.env, true); |
8362951b ACM |
673 | /* |
674 | * Usually "ret" is the last pressed key, and we only | |
675 | * care if the key notifies us to switch data file. | |
676 | */ | |
5e3b810a | 677 | if (ret != K_SWITCH_INPUT_DATA && ret != K_RELOAD) |
8362951b ACM |
678 | ret = 0; |
679 | break; | |
680 | case 2: | |
681 | ret = report__gtk_browse_hists(rep, help); | |
682 | break; | |
683 | default: | |
f4bd0b4a | 684 | ret = evlist__tty_browse_hists(evlist, rep, help); |
8362951b ACM |
685 | break; |
686 | } | |
d9fc7061 | 687 | free(help); |
8362951b ACM |
688 | return ret; |
689 | } | |
690 | ||
5b2ea6f2 | 691 | static int report__collapse_hists(struct report *rep) |
f6d8b057 | 692 | { |
a6e4a4a1 NK |
693 | struct perf_session *session = rep->session; |
694 | struct evlist *evlist = session->evlist; | |
f6d8b057 | 695 | struct ui_progress prog; |
32dcd021 | 696 | struct evsel *pos; |
5b2ea6f2 | 697 | int ret = 0; |
f6d8b057 | 698 | |
a6e4a4a1 NK |
699 | /* |
700 | * The pipe data needs to setup hierarchy hpp formats now, because it | |
701 | * cannot know about evsels in the data before reading the data. The | |
702 | * normal file data saves the event (attribute) info in the header | |
703 | * section, but pipe does not have the luxury. | |
704 | */ | |
705 | if (perf_data__is_pipe(session->data)) { | |
706 | if (perf_hpp__setup_hists_formats(&perf_hpp_list, evlist) < 0) { | |
0e0f03d7 | 707 | ui__error("Failed to setup hierarchy output formats\n"); |
a6e4a4a1 NK |
708 | return -1; |
709 | } | |
710 | } | |
711 | ||
58c311da | 712 | ui_progress__init(&prog, rep->nr_entries, "Merging related events..."); |
f6d8b057 | 713 | |
e5cadb93 | 714 | evlist__for_each_entry(rep->session->evlist, pos) { |
4ea062ed | 715 | struct hists *hists = evsel__hists(pos); |
f6d8b057 | 716 | |
38fe0e01 | 717 | if (pos->core.idx == 0) |
f6d8b057 ACM |
718 | hists->symbol_filter_str = rep->symbol_filter_str; |
719 | ||
21394d94 KL |
720 | hists->socket_filter = rep->socket_filter; |
721 | ||
5b2ea6f2 NK |
722 | ret = hists__collapse_resort(hists, &prog); |
723 | if (ret < 0) | |
724 | break; | |
f6d8b057 ACM |
725 | |
726 | /* Non-group events are considered as leader */ | |
c754c382 | 727 | if (symbol_conf.event_group && !evsel__is_group_leader(pos)) { |
fba7c866 | 728 | struct hists *leader_hists = evsel__hists(evsel__leader(pos)); |
f6d8b057 ACM |
729 | |
730 | hists__match(leader_hists, hists); | |
731 | hists__link(leader_hists, hists); | |
732 | } | |
733 | } | |
734 | ||
735 | ui_progress__finish(); | |
5b2ea6f2 | 736 | return ret; |
f6d8b057 ACM |
737 | } |
738 | ||
dbd2a1d5 JO |
739 | static int hists__resort_cb(struct hist_entry *he, void *arg) |
740 | { | |
741 | struct report *rep = arg; | |
742 | struct symbol *sym = he->ms.sym; | |
743 | ||
744 | if (rep->symbol_ipc && sym && !sym->annotate2) { | |
32dcd021 | 745 | struct evsel *evsel = hists_to_evsel(he->hists); |
dbd2a1d5 | 746 | |
41fd3cac | 747 | symbol__annotate2(&he->ms, evsel, NULL); |
dbd2a1d5 JO |
748 | } |
749 | ||
750 | return 0; | |
751 | } | |
752 | ||
740b97f9 NK |
753 | static void report__output_resort(struct report *rep) |
754 | { | |
755 | struct ui_progress prog; | |
32dcd021 | 756 | struct evsel *pos; |
740b97f9 NK |
757 | |
758 | ui_progress__init(&prog, rep->nr_entries, "Sorting events for output..."); | |
759 | ||
dbd2a1d5 | 760 | evlist__for_each_entry(rep->session->evlist, pos) { |
10c513f7 | 761 | evsel__output_resort_cb(pos, &prog, hists__resort_cb, rep); |
dbd2a1d5 | 762 | } |
740b97f9 NK |
763 | |
764 | ui_progress__finish(); | |
765 | } | |
766 | ||
55f75444 NK |
767 | static int count_sample_event(struct perf_tool *tool __maybe_unused, |
768 | union perf_event *event __maybe_unused, | |
769 | struct perf_sample *sample __maybe_unused, | |
770 | struct evsel *evsel, | |
771 | struct machine *machine __maybe_unused) | |
772 | { | |
773 | struct hists *hists = evsel__hists(evsel); | |
774 | ||
775 | hists__inc_nr_events(hists); | |
776 | return 0; | |
777 | } | |
778 | ||
d7ba22d4 NK |
779 | static int count_lost_samples_event(struct perf_tool *tool, |
780 | union perf_event *event, | |
781 | struct perf_sample *sample, | |
782 | struct machine *machine __maybe_unused) | |
783 | { | |
784 | struct report *rep = container_of(tool, struct report, tool); | |
785 | struct evsel *evsel; | |
786 | ||
787 | evsel = evlist__id2evsel(rep->session->evlist, sample->id); | |
788 | if (evsel) { | |
789 | hists__inc_nr_lost_samples(evsel__hists(evsel), | |
790 | event->lost_samples.lost); | |
791 | } | |
792 | return 0; | |
793 | } | |
794 | ||
892ba7f1 NK |
795 | static int process_attr(struct perf_tool *tool __maybe_unused, |
796 | union perf_event *event, | |
797 | struct evlist **pevlist); | |
798 | ||
a4a4d0a7 JO |
799 | static void stats_setup(struct report *rep) |
800 | { | |
801 | memset(&rep->tool, 0, sizeof(rep->tool)); | |
892ba7f1 | 802 | rep->tool.attr = process_attr; |
55f75444 | 803 | rep->tool.sample = count_sample_event; |
d7ba22d4 | 804 | rep->tool.lost_samples = count_lost_samples_event; |
a4a4d0a7 JO |
805 | rep->tool.no_warn = true; |
806 | } | |
807 | ||
808 | static int stats_print(struct report *rep) | |
809 | { | |
810 | struct perf_session *session = rep->session; | |
811 | ||
2775de0b NK |
812 | perf_session__fprintf_nr_events(session, stdout, rep->skip_empty); |
813 | evlist__fprintf_nr_events(session->evlist, stdout, rep->skip_empty); | |
a4a4d0a7 JO |
814 | return 0; |
815 | } | |
816 | ||
930f8b34 JO |
817 | static void tasks_setup(struct report *rep) |
818 | { | |
819 | memset(&rep->tool, 0, sizeof(rep->tool)); | |
8614ada0 | 820 | rep->tool.ordered_events = true; |
6439d7d1 ACM |
821 | if (rep->mmaps_mode) { |
822 | rep->tool.mmap = perf_event__process_mmap; | |
823 | rep->tool.mmap2 = perf_event__process_mmap2; | |
824 | } | |
892ba7f1 | 825 | rep->tool.attr = process_attr; |
930f8b34 JO |
826 | rep->tool.comm = perf_event__process_comm; |
827 | rep->tool.exit = perf_event__process_exit; | |
828 | rep->tool.fork = perf_event__process_fork; | |
829 | rep->tool.no_warn = true; | |
830 | } | |
831 | ||
431be14b IR |
832 | struct maps__fprintf_task_args { |
833 | int indent; | |
834 | FILE *fp; | |
835 | size_t printed; | |
836 | }; | |
837 | ||
838 | static int maps__fprintf_task_cb(struct map *map, void *data) | |
6439d7d1 | 839 | { |
431be14b IR |
840 | struct maps__fprintf_task_args *args = data; |
841 | const struct dso *dso = map__dso(map); | |
842 | u32 prot = map__prot(map); | |
843 | int ret; | |
ff583dc4 | 844 | |
431be14b IR |
845 | ret = fprintf(args->fp, |
846 | "%*s %" PRIx64 "-%" PRIx64 " %c%c%c%c %08" PRIx64 " %" PRIu64 " %s\n", | |
847 | args->indent, "", map__start(map), map__end(map), | |
848 | prot & PROT_READ ? 'r' : '-', | |
849 | prot & PROT_WRITE ? 'w' : '-', | |
850 | prot & PROT_EXEC ? 'x' : '-', | |
851 | map__flags(map) ? 's' : 'p', | |
852 | map__pgoff(map), | |
ee756ef7 | 853 | dso__id_const(dso)->ino, dso__name(dso)); |
6439d7d1 | 854 | |
431be14b IR |
855 | if (ret < 0) |
856 | return ret; | |
857 | ||
858 | args->printed += ret; | |
859 | return 0; | |
860 | } | |
861 | ||
862 | static size_t maps__fprintf_task(struct maps *maps, int indent, FILE *fp) | |
863 | { | |
864 | struct maps__fprintf_task_args args = { | |
865 | .indent = indent, | |
866 | .fp = fp, | |
867 | .printed = 0, | |
868 | }; | |
869 | ||
870 | maps__for_each_map(maps, maps__fprintf_task_cb, &args); | |
6439d7d1 | 871 | |
431be14b | 872 | return args.printed; |
6439d7d1 ACM |
873 | } |
874 | ||
2f1e20fe | 875 | static int thread_level(struct machine *machine, const struct thread *thread) |
930f8b34 | 876 | { |
2f1e20fe IR |
877 | struct thread *parent_thread; |
878 | int res; | |
6439d7d1 | 879 | |
2f1e20fe IR |
880 | if (thread__tid(thread) <= 0) |
881 | return 0; | |
930f8b34 | 882 | |
2f1e20fe IR |
883 | if (thread__ppid(thread) <= 0) |
884 | return 1; | |
930f8b34 | 885 | |
2f1e20fe IR |
886 | parent_thread = machine__find_thread(machine, -1, thread__ppid(thread)); |
887 | if (!parent_thread) { | |
888 | pr_err("Missing parent thread of %d\n", thread__tid(thread)); | |
889 | return 0; | |
930f8b34 | 890 | } |
2f1e20fe IR |
891 | res = 1 + thread_level(machine, parent_thread); |
892 | thread__put(parent_thread); | |
893 | return res; | |
930f8b34 JO |
894 | } |
895 | ||
2f1e20fe | 896 | static void task__print_level(struct machine *machine, struct thread *thread, FILE *fp) |
930f8b34 | 897 | { |
2f1e20fe IR |
898 | int level = thread_level(machine, thread); |
899 | int comm_indent = fprintf(fp, " %8d %8d %8d |%*s", | |
900 | thread__pid(thread), thread__tid(thread), | |
901 | thread__ppid(thread), level, ""); | |
930f8b34 | 902 | |
2f1e20fe | 903 | fprintf(fp, "%s\n", thread__comm_str(thread)); |
930f8b34 | 904 | |
2f1e20fe IR |
905 | maps__fprintf_task(thread__maps(thread), comm_indent, fp); |
906 | } | |
930f8b34 | 907 | |
2f1e20fe IR |
908 | /* |
909 | * Sort two thread list nodes such that they form a tree. The first node is the | |
910 | * root of the tree, its children are ordered numerically after it. If a child | |
911 | * has children itself then they appear immediately after their parent. For | |
912 | * example, the 4 threads in the order they'd appear in the list: | |
913 | * - init with a TID 1 and a parent of 0 | |
914 | * - systemd with a TID 3000 and a parent of init/1 | |
915 | * - systemd child thread with TID 4000, the parent is 3000 | |
916 | * - NetworkManager is a child of init with a TID of 3500. | |
917 | */ | |
918 | static int task_list_cmp(void *priv, const struct list_head *la, const struct list_head *lb) | |
919 | { | |
920 | struct machine *machine = priv; | |
921 | struct thread_list *task_a = list_entry(la, struct thread_list, list); | |
922 | struct thread_list *task_b = list_entry(lb, struct thread_list, list); | |
923 | struct thread *a = task_a->thread; | |
924 | struct thread *b = task_b->thread; | |
925 | int level_a, level_b, res; | |
926 | ||
927 | /* Same thread? */ | |
928 | if (thread__tid(a) == thread__tid(b)) | |
929 | return 0; | |
930f8b34 | 930 | |
2f1e20fe IR |
931 | /* Compare a and b to root. */ |
932 | if (thread__tid(a) == 0) | |
933 | return -1; | |
930f8b34 | 934 | |
2f1e20fe IR |
935 | if (thread__tid(b) == 0) |
936 | return 1; | |
930f8b34 | 937 | |
2f1e20fe IR |
938 | /* If parents match sort by tid. */ |
939 | if (thread__ppid(a) == thread__ppid(b)) | |
940 | return thread__tid(a) < thread__tid(b) ? -1 : 1; | |
930f8b34 JO |
941 | |
942 | /* | |
2f1e20fe IR |
943 | * Find a and b such that if they are a child of each other a and b's |
944 | * tid's match, otherwise a and b have a common parent and distinct | |
945 | * tid's to sort by. First make the depths of the threads match. | |
930f8b34 | 946 | */ |
2f1e20fe IR |
947 | level_a = thread_level(machine, a); |
948 | level_b = thread_level(machine, b); | |
949 | a = thread__get(a); | |
950 | b = thread__get(b); | |
951 | for (int i = level_a; i > level_b; i--) { | |
952 | struct thread *parent = machine__find_thread(machine, -1, thread__ppid(a)); | |
953 | ||
954 | thread__put(a); | |
955 | if (!parent) { | |
956 | pr_err("Missing parent thread of %d\n", thread__tid(a)); | |
957 | thread__put(b); | |
958 | return -1; | |
959 | } | |
960 | a = parent; | |
961 | } | |
962 | for (int i = level_b; i > level_a; i--) { | |
963 | struct thread *parent = machine__find_thread(machine, -1, thread__ppid(b)); | |
964 | ||
965 | thread__put(b); | |
966 | if (!parent) { | |
967 | pr_err("Missing parent thread of %d\n", thread__tid(b)); | |
968 | thread__put(a); | |
969 | return 1; | |
970 | } | |
971 | b = parent; | |
972 | } | |
973 | /* Search up to a common parent. */ | |
974 | while (thread__ppid(a) != thread__ppid(b)) { | |
975 | struct thread *parent; | |
976 | ||
977 | parent = machine__find_thread(machine, -1, thread__ppid(a)); | |
978 | thread__put(a); | |
979 | if (!parent) | |
980 | pr_err("Missing parent thread of %d\n", thread__tid(a)); | |
981 | a = parent; | |
982 | parent = machine__find_thread(machine, -1, thread__ppid(b)); | |
983 | thread__put(b); | |
984 | if (!parent) | |
985 | pr_err("Missing parent thread of %d\n", thread__tid(b)); | |
986 | b = parent; | |
987 | if (!a || !b) { | |
988 | /* Handle missing parent (unexpected) with some sanity. */ | |
989 | thread__put(a); | |
990 | thread__put(b); | |
991 | return !a && !b ? 0 : (!a ? -1 : 1); | |
930f8b34 | 992 | } |
930f8b34 | 993 | } |
2f1e20fe IR |
994 | if (thread__tid(a) == thread__tid(b)) { |
995 | /* a is a child of b or vice-versa, deeper levels appear later. */ | |
996 | res = level_a < level_b ? -1 : (level_a > level_b ? 1 : 0); | |
997 | } else { | |
998 | /* Sort by tid now the parent is the same. */ | |
999 | res = thread__tid(a) < thread__tid(b) ? -1 : 1; | |
1000 | } | |
1001 | thread__put(a); | |
1002 | thread__put(b); | |
1003 | return res; | |
1004 | } | |
1005 | ||
1006 | static int tasks_print(struct report *rep, FILE *fp) | |
1007 | { | |
1008 | struct machine *machine = &rep->session->machines.host; | |
1009 | LIST_HEAD(tasks); | |
1010 | int ret; | |
930f8b34 | 1011 | |
2f1e20fe IR |
1012 | ret = machine__thread_list(machine, &tasks); |
1013 | if (!ret) { | |
1014 | struct thread_list *task; | |
930f8b34 | 1015 | |
2f1e20fe | 1016 | list_sort(machine, &tasks, task_list_cmp); |
930f8b34 | 1017 | |
2f1e20fe IR |
1018 | fprintf(fp, "# %8s %8s %8s %s\n", "pid", "tid", "ppid", "comm"); |
1019 | ||
1020 | list_for_each_entry(task, &tasks, list) | |
1021 | task__print_level(machine, task->thread, fp); | |
1022 | } | |
1023 | thread_list__delete(&tasks); | |
1024 | return ret; | |
930f8b34 JO |
1025 | } |
1026 | ||
28b21393 | 1027 | static int __cmd_report(struct report *rep) |
016e92fb | 1028 | { |
f6d8b057 | 1029 | int ret; |
993ac88d | 1030 | struct perf_session *session = rep->session; |
32dcd021 | 1031 | struct evsel *pos; |
8ceb41d7 | 1032 | struct perf_data *data = session->data; |
8fa66bdc | 1033 | |
46656ac7 TZ |
1034 | signal(SIGINT, sig_handler); |
1035 | ||
fa372aae ACM |
1036 | if (rep->cpu_list) { |
1037 | ret = perf_session__cpu_bitmap(session, rep->cpu_list, | |
1038 | rep->cpu_bitmap); | |
25b1606b NK |
1039 | if (ret) { |
1040 | ui__error("failed to set cpu bitmap\n"); | |
d4ae0a6f | 1041 | return ret; |
25b1606b | 1042 | } |
644e0840 | 1043 | session->itrace_synth_opts->cpu_bitmap = rep->cpu_bitmap; |
5d67be97 AB |
1044 | } |
1045 | ||
89973506 ACM |
1046 | if (rep->show_threads) { |
1047 | ret = perf_read_values_init(&rep->show_threads_values); | |
1048 | if (ret) | |
1049 | return ret; | |
1050 | } | |
f5970550 | 1051 | |
28b21393 | 1052 | ret = report__setup_sample_type(rep); |
25b1606b NK |
1053 | if (ret) { |
1054 | /* report__setup_sample_type() already showed error message */ | |
d4ae0a6f | 1055 | return ret; |
25b1606b | 1056 | } |
d549c769 | 1057 | |
a4a4d0a7 JO |
1058 | if (rep->stats_mode) |
1059 | stats_setup(rep); | |
1060 | ||
930f8b34 JO |
1061 | if (rep->tasks_mode) |
1062 | tasks_setup(rep); | |
1063 | ||
b7b61cbe | 1064 | ret = perf_session__process_events(session); |
25b1606b NK |
1065 | if (ret) { |
1066 | ui__error("failed to process sample\n"); | |
d4ae0a6f | 1067 | return ret; |
25b1606b | 1068 | } |
97b07b69 | 1069 | |
d5a8bd0f JY |
1070 | evlist__check_mem_load_aux(session->evlist); |
1071 | ||
a4a4d0a7 JO |
1072 | if (rep->stats_mode) |
1073 | return stats_print(rep); | |
1074 | ||
930f8b34 JO |
1075 | if (rep->tasks_mode) |
1076 | return tasks_print(rep, stdout); | |
1077 | ||
fad2918e | 1078 | report__warn_kptr_restrict(rep); |
ec80fde7 | 1079 | |
e5cadb93 | 1080 | evlist__for_each_entry(session->evlist, pos) |
590cd344 NK |
1081 | rep->nr_entries += evsel__hists(pos)->nr_entries; |
1082 | ||
150e465a NK |
1083 | if (use_browser == 0) { |
1084 | if (verbose > 3) | |
1085 | perf_session__fprintf(session, stdout); | |
9ac99545 | 1086 | |
150e465a NK |
1087 | if (verbose > 2) |
1088 | perf_session__fprintf_dsos(session, stdout); | |
16f762a2 | 1089 | |
150e465a | 1090 | if (dump_trace) { |
2775de0b NK |
1091 | perf_session__fprintf_nr_events(session, stdout, |
1092 | rep->skip_empty); | |
1093 | evlist__fprintf_nr_events(session->evlist, stdout, | |
1094 | rep->skip_empty); | |
150e465a NK |
1095 | return 0; |
1096 | } | |
71ad0f5e JO |
1097 | } |
1098 | ||
5b2ea6f2 NK |
1099 | ret = report__collapse_hists(rep); |
1100 | if (ret) { | |
1101 | ui__error("failed to process hist entry\n"); | |
1102 | return ret; | |
1103 | } | |
e248de33 | 1104 | |
33e940a2 ACM |
1105 | if (session_done()) |
1106 | return 0; | |
1107 | ||
740b97f9 NK |
1108 | /* |
1109 | * recalculate number of entries after collapsing since it | |
1110 | * might be changed during the collapse phase. | |
1111 | */ | |
1112 | rep->nr_entries = 0; | |
e5cadb93 | 1113 | evlist__for_each_entry(session->evlist, pos) |
740b97f9 NK |
1114 | rep->nr_entries += evsel__hists(pos)->nr_entries; |
1115 | ||
58c311da | 1116 | if (rep->nr_entries == 0) { |
2d4f2799 | 1117 | ui__error("The %s data has no samples!\n", data->path); |
d4ae0a6f | 1118 | return 0; |
cbbc79a5 EM |
1119 | } |
1120 | ||
740b97f9 | 1121 | report__output_resort(rep); |
6e1f601a | 1122 | |
6f7164fa | 1123 | if (rep->total_cycles_mode) { |
cca0cc76 JY |
1124 | int block_hpps[6] = { |
1125 | PERF_HPP_REPORT__BLOCK_TOTAL_CYCLES_PCT, | |
1126 | PERF_HPP_REPORT__BLOCK_LBR_CYCLES, | |
1127 | PERF_HPP_REPORT__BLOCK_CYCLES_PCT, | |
1128 | PERF_HPP_REPORT__BLOCK_AVG_CYCLES, | |
1129 | PERF_HPP_REPORT__BLOCK_RANGE, | |
1130 | PERF_HPP_REPORT__BLOCK_DSO, | |
1131 | }; | |
1132 | ||
6f7164fa | 1133 | rep->block_reports = block_info__create_report(session->evlist, |
cca0cc76 JY |
1134 | rep->total_cycles, |
1135 | block_hpps, 6, | |
1136 | &rep->nr_block_reports); | |
6f7164fa JY |
1137 | if (!rep->block_reports) |
1138 | return -1; | |
1139 | } | |
1140 | ||
8362951b | 1141 | return report__browse_hists(rep); |
8fa66bdc ACM |
1142 | } |
1143 | ||
4eb3e478 | 1144 | static int |
cff6bb46 | 1145 | report_parse_callchain_opt(const struct option *opt, const char *arg, int unset) |
4eb3e478 | 1146 | { |
1cc83815 | 1147 | struct callchain_param *callchain = opt->value; |
c20ab37e | 1148 | |
1cc83815 | 1149 | callchain->enabled = !unset; |
b9a63b9b ACM |
1150 | /* |
1151 | * --no-call-graph | |
1152 | */ | |
1153 | if (unset) { | |
1cc83815 ACM |
1154 | symbol_conf.use_callchain = false; |
1155 | callchain->mode = CHAIN_NONE; | |
b9a63b9b ACM |
1156 | return 0; |
1157 | } | |
1158 | ||
cff6bb46 | 1159 | return parse_callchain_report_opt(arg); |
4eb3e478 FW |
1160 | } |
1161 | ||
2a1292cb AK |
1162 | static int |
1163 | parse_time_quantum(const struct option *opt, const char *arg, | |
1164 | int unset __maybe_unused) | |
1165 | { | |
1166 | unsigned long *time_q = opt->value; | |
1167 | char *end; | |
1168 | ||
1169 | *time_q = strtoul(arg, &end, 0); | |
1170 | if (end == arg) | |
1171 | goto parse_err; | |
1172 | if (*time_q == 0) { | |
1173 | pr_err("time quantum cannot be 0"); | |
1174 | return -1; | |
1175 | } | |
526bbbdd | 1176 | end = skip_spaces(end); |
2a1292cb AK |
1177 | if (*end == 0) |
1178 | return 0; | |
1179 | if (!strcmp(end, "s")) { | |
1180 | *time_q *= NSEC_PER_SEC; | |
1181 | return 0; | |
1182 | } | |
1183 | if (!strcmp(end, "ms")) { | |
1184 | *time_q *= NSEC_PER_MSEC; | |
1185 | return 0; | |
1186 | } | |
1187 | if (!strcmp(end, "us")) { | |
1188 | *time_q *= NSEC_PER_USEC; | |
1189 | return 0; | |
1190 | } | |
1191 | if (!strcmp(end, "ns")) | |
1192 | return 0; | |
1193 | parse_err: | |
1194 | pr_err("Cannot parse time quantum `%s'\n", arg); | |
1195 | return -1; | |
1196 | } | |
1197 | ||
b21484f1 GP |
1198 | int |
1199 | report_parse_ignore_callees_opt(const struct option *opt __maybe_unused, | |
1200 | const char *arg, int unset __maybe_unused) | |
1201 | { | |
1202 | if (arg) { | |
1203 | int err = regcomp(&ignore_callees_regex, arg, REG_EXTENDED); | |
1204 | if (err) { | |
1205 | char buf[BUFSIZ]; | |
1206 | regerror(err, &ignore_callees_regex, buf, sizeof(buf)); | |
1207 | pr_err("Invalid --ignore-callees regex: %s\n%s", arg, buf); | |
1208 | return -1; | |
1209 | } | |
1210 | have_ignore_callees = 1; | |
1211 | } | |
1212 | ||
1213 | return 0; | |
1214 | } | |
1215 | ||
993ac88d | 1216 | static int |
7e6a7998 | 1217 | parse_branch_mode(const struct option *opt, |
1d037ca1 | 1218 | const char *str __maybe_unused, int unset) |
993ac88d | 1219 | { |
55369fc1 NK |
1220 | int *branch_mode = opt->value; |
1221 | ||
1222 | *branch_mode = !unset; | |
993ac88d SE |
1223 | return 0; |
1224 | } | |
1225 | ||
064f1981 NK |
1226 | static int |
1227 | parse_percent_limit(const struct option *opt, const char *str, | |
1228 | int unset __maybe_unused) | |
1229 | { | |
28b21393 | 1230 | struct report *rep = opt->value; |
2665b452 | 1231 | double pcnt = strtof(str, NULL); |
064f1981 | 1232 | |
2665b452 NK |
1233 | rep->min_percent = pcnt; |
1234 | callchain_param.min_percent = pcnt; | |
064f1981 NK |
1235 | return 0; |
1236 | } | |
1237 | ||
0d71a2b2 JO |
1238 | static int process_attr(struct perf_tool *tool __maybe_unused, |
1239 | union perf_event *event, | |
1240 | struct evlist **pevlist) | |
1241 | { | |
1242 | u64 sample_type; | |
1243 | int err; | |
1244 | ||
1245 | err = perf_event__process_attr(tool, event, pevlist); | |
1246 | if (err) | |
1247 | return err; | |
1248 | ||
1249 | /* | |
1250 | * Check if we need to enable callchains based | |
1251 | * on events sample_type. | |
1252 | */ | |
b3c2cc2b | 1253 | sample_type = evlist__combined_sample_type(*pevlist); |
aa8db3e4 | 1254 | callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env)); |
0d71a2b2 JO |
1255 | return 0; |
1256 | } | |
1257 | ||
b0ad8ea6 | 1258 | int cmd_report(int argc, const char **argv) |
d20deb64 | 1259 | { |
993ac88d | 1260 | struct perf_session *session; |
520a2ebc | 1261 | struct itrace_synth_opts itrace_synth_opts = { .set = 0, }; |
efad1415 | 1262 | struct stat st; |
993ac88d | 1263 | bool has_br_stack = false; |
55369fc1 | 1264 | int branch_mode = -1; |
0feba17b | 1265 | int last_key = 0; |
fa94c36c | 1266 | bool branch_call_mode = false; |
9d0199cd | 1267 | #define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent" |
49b8e2be RV |
1268 | static const char report_callchain_help[] = "Display call graph (stack chain/backtrace):\n\n" |
1269 | CALLCHAIN_REPORT_HELP | |
1270 | "\n\t\t\t\tDefault: " CALLCHAIN_DEFAULT_OPT; | |
76a26549 | 1271 | char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT; |
d20deb64 | 1272 | const char * const report_usage[] = { |
fb2baceb | 1273 | "perf report [<options>]", |
d20deb64 ACM |
1274 | NULL |
1275 | }; | |
28b21393 | 1276 | struct report report = { |
45694aa7 | 1277 | .tool = { |
d20deb64 ACM |
1278 | .sample = process_sample_event, |
1279 | .mmap = perf_event__process_mmap, | |
5c5e854b | 1280 | .mmap2 = perf_event__process_mmap2, |
d20deb64 | 1281 | .comm = perf_event__process_comm, |
f3b3614a | 1282 | .namespaces = perf_event__process_namespaces, |
ba78c1c5 | 1283 | .cgroup = perf_event__process_cgroup, |
f62d3f0f ACM |
1284 | .exit = perf_event__process_exit, |
1285 | .fork = perf_event__process_fork, | |
d20deb64 ACM |
1286 | .lost = perf_event__process_lost, |
1287 | .read = process_read_event, | |
0d71a2b2 | 1288 | .attr = process_attr, |
378ef0f5 | 1289 | #ifdef HAVE_LIBTRACEEVENT |
d20deb64 | 1290 | .tracing_data = perf_event__process_tracing_data, |
378ef0f5 | 1291 | #endif |
d20deb64 | 1292 | .build_id = perf_event__process_build_id, |
520a2ebc AH |
1293 | .id_index = perf_event__process_id_index, |
1294 | .auxtrace_info = perf_event__process_auxtrace_info, | |
1295 | .auxtrace = perf_event__process_auxtrace, | |
4ab8455f | 1296 | .event_update = perf_event__process_event_update, |
57b5de46 | 1297 | .feature = process_feature_event, |
0a8cb85c | 1298 | .ordered_events = true, |
d20deb64 ACM |
1299 | .ordering_requires_timestamps = true, |
1300 | }, | |
fe176085 | 1301 | .max_stack = PERF_MAX_STACK_DEPTH, |
d20deb64 | 1302 | .pretty_printing_style = "normal", |
21394d94 | 1303 | .socket_filter = -1, |
8f08cf33 | 1304 | .skip_empty = true, |
d20deb64 | 1305 | }; |
a37338aa RM |
1306 | char *sort_order_help = sort_help("sort by key(s):"); |
1307 | char *field_order_help = sort_help("output field(s): overhead period sample "); | |
57594454 | 1308 | const char *disassembler_style = NULL, *objdump_path = NULL, *addr2line_path = NULL; |
d20deb64 | 1309 | const struct option options[] = { |
70cb4e96 | 1310 | OPT_STRING('i', "input", &input_name, "file", |
53cb8bc2 | 1311 | "input file name"), |
c0555642 | 1312 | OPT_INCR('v', "verbose", &verbose, |
815e777f | 1313 | "be more verbose (show symbol address, etc)"), |
a527c2c1 | 1314 | OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any warnings or messages"), |
97b07b69 IM |
1315 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
1316 | "dump raw trace in ASCII"), | |
a4a4d0a7 | 1317 | OPT_BOOLEAN(0, "stats", &report.stats_mode, "Display event stats"), |
930f8b34 | 1318 | OPT_BOOLEAN(0, "tasks", &report.tasks_mode, "Display recorded tasks"), |
6439d7d1 | 1319 | OPT_BOOLEAN(0, "mmaps", &report.mmaps_mode, "Display recorded tasks memory maps"), |
b32d133a ACM |
1320 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, |
1321 | "file", "vmlinux pathname"), | |
91340c51 ACM |
1322 | OPT_BOOLEAN(0, "ignore-vmlinux", &symbol_conf.ignore_vmlinux, |
1323 | "don't load vmlinux even if found"), | |
b226a5a7 DA |
1324 | OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name, |
1325 | "file", "kallsyms pathname"), | |
2059fc7a | 1326 | OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"), |
b32d133a | 1327 | OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules, |
42976487 | 1328 | "load module symbols - WARNING: use only with -k and LIVE kernel"), |
d599db3f | 1329 | OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples, |
e3d7e183 | 1330 | "Show a column with the number of samples"), |
fa372aae | 1331 | OPT_BOOLEAN('T', "threads", &report.show_threads, |
8d513270 | 1332 | "Show per-thread event counters"), |
fa372aae | 1333 | OPT_STRING(0, "pretty", &report.pretty_printing_style, "key", |
9f866697 | 1334 | "pretty printing style key: normal raw"), |
3402ae0a | 1335 | #ifdef HAVE_SLANG_SUPPORT |
fa372aae | 1336 | OPT_BOOLEAN(0, "tui", &report.use_tui, "Use the TUI interface"), |
3402ae0a | 1337 | #endif |
557cc18e | 1338 | #ifdef HAVE_GTK2_SUPPORT |
c31a9457 | 1339 | OPT_BOOLEAN(0, "gtk", &report.use_gtk, "Use the GTK2 interface"), |
557cc18e | 1340 | #endif |
fa372aae ACM |
1341 | OPT_BOOLEAN(0, "stdio", &report.use_stdio, |
1342 | "Use the stdio interface"), | |
5cfe2c82 JO |
1343 | OPT_BOOLEAN(0, "header", &report.header, "Show data header."), |
1344 | OPT_BOOLEAN(0, "header-only", &report.header_only, | |
1345 | "Show only data header."), | |
63299f05 | 1346 | OPT_STRING('s', "sort", &sort_order, "key[,key2...]", |
a37338aa | 1347 | sort_order_help), |
a7d945bc | 1348 | OPT_STRING('F', "fields", &field_order, "key[,keys...]", |
a37338aa | 1349 | field_order_help), |
b272a59d | 1350 | OPT_BOOLEAN(0, "show-cpu-utilization", &symbol_conf.show_cpu_utilization, |
a1645ce1 | 1351 | "Show sample percentage for different cpu modes"), |
b272a59d NK |
1352 | OPT_BOOLEAN_FLAG(0, "showcpuutilization", &symbol_conf.show_cpu_utilization, |
1353 | "Show sample percentage for different cpu modes", PARSE_OPT_HIDDEN), | |
b25bcf2f IM |
1354 | OPT_STRING('p', "parent", &parent_pattern, "regex", |
1355 | "regex filter to identify parent, see: '--sort parent'"), | |
d599db3f | 1356 | OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other, |
b8e6d829 | 1357 | "Only display entries with parent-match"), |
1cc83815 | 1358 | OPT_CALLBACK_DEFAULT('g', "call-graph", &callchain_param, |
f2af0086 | 1359 | "print_type,threshold[,print_limit],order,sort_key[,branch],value", |
21cf6284 NK |
1360 | report_callchain_help, &report_parse_callchain_opt, |
1361 | callchain_default_opt), | |
793aaaab | 1362 | OPT_BOOLEAN(0, "children", &symbol_conf.cumulate_callchain, |
aa9d1f83 AK |
1363 | "Accumulate callchains of children and show total overhead as well. " |
1364 | "Enabled by default, use --no-children to disable."), | |
91e95617 WL |
1365 | OPT_INTEGER(0, "max-stack", &report.max_stack, |
1366 | "Set the maximum stack depth when parsing the callchain, " | |
1367 | "anything beyond the specified depth will be ignored. " | |
4cb93446 | 1368 | "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), |
fa372aae ACM |
1369 | OPT_BOOLEAN('G', "inverted", &report.inverted_callchain, |
1370 | "alias for inverted call graph"), | |
b21484f1 GP |
1371 | OPT_CALLBACK(0, "ignore-callees", NULL, "regex", |
1372 | "ignore callees of these functions in call graphs", | |
1373 | report_parse_ignore_callees_opt), | |
655000e7 | 1374 | OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]", |
25903407 | 1375 | "only consider symbols in these dsos"), |
c8e66720 | 1376 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
cc8b88b1 | 1377 | "only consider symbols in these comms"), |
e03eaa40 DA |
1378 | OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]", |
1379 | "only consider symbols in these pids"), | |
1380 | OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]", | |
1381 | "only consider symbols in these tids"), | |
655000e7 | 1382 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
7bec7a91 | 1383 | "only consider these symbols"), |
b14ffaca NK |
1384 | OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter", |
1385 | "only show symbols that (partially) match with this filter"), | |
655000e7 | 1386 | OPT_STRING('w', "column-widths", &symbol_conf.col_width_list_str, |
52d422de ACM |
1387 | "width[,width...]", |
1388 | "don't try to adjust column width, use these fixed values"), | |
0c8c2077 | 1389 | OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator", |
52d422de ACM |
1390 | "separator for columns, no spaces will be added between " |
1391 | "columns '.' is reserved."), | |
b49a8fe5 | 1392 | OPT_BOOLEAN('U', "hide-unresolved", &symbol_conf.hide_unresolved, |
71289be7 | 1393 | "Only display entries resolved to a symbol"), |
a7066709 HK |
1394 | OPT_CALLBACK(0, "symfs", NULL, "directory", |
1395 | "Look for files with symbols relative to this directory", | |
1396 | symbol__config_symfs), | |
c8e66720 | 1397 | OPT_STRING('C', "cpu", &report.cpu_list, "cpu", |
fa372aae ACM |
1398 | "list of cpus to profile"), |
1399 | OPT_BOOLEAN('I', "show-info", &report.show_full_info, | |
fbe96f29 | 1400 | "Display extended information about perf.data file"), |
14953f03 | 1401 | OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src, |
64c6f0c7 | 1402 | "Interleave source code with assembly code (default)"), |
14953f03 | 1403 | OPT_BOOLEAN(0, "asm-raw", &annotate_opts.show_asm_raw, |
64c6f0c7 | 1404 | "Display raw encoding of assembly instructions (default)"), |
56d9117c | 1405 | OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", |
f69b64f7 | 1406 | "Specify disassembler style (e.g. -M intel for intel syntax)"), |
14953f03 | 1407 | OPT_STRING(0, "prefix", &annotate_opts.prefix, "prefix", |
3b0b16bf | 1408 | "Add prefix to source file path names in programs (with --prefix-strip)"), |
14953f03 | 1409 | OPT_STRING(0, "prefix-strip", &annotate_opts.prefix_strip, "N", |
3b0b16bf | 1410 | "Strip first N entries of source file path name in programs (with --prefix)"), |
3f2728bd ACM |
1411 | OPT_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period, |
1412 | "Show a column with the sum of periods"), | |
57b5de46 | 1413 | OPT_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &report.group_set, |
01d14f16 | 1414 | "Show event group information together"), |
429a5f9d JY |
1415 | OPT_INTEGER(0, "group-sort-idx", &symbol_conf.group_sort_idx, |
1416 | "Sort the output by the event at the index n in group. " | |
1417 | "If n is invalid, sort by the first event. " | |
1418 | "WARNING: should be used on grouped events."), | |
55369fc1 | 1419 | OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "", |
fa94c36c AK |
1420 | "use branch records for per branch histogram filling", |
1421 | parse_branch_mode), | |
1422 | OPT_BOOLEAN(0, "branch-history", &branch_call_mode, | |
1423 | "add last branch records to call history"), | |
56d9117c | 1424 | OPT_STRING(0, "objdump", &objdump_path, "path", |
7a4ec938 | 1425 | "objdump binary to use for disassembly and annotations"), |
57594454 IR |
1426 | OPT_STRING(0, "addr2line", &addr2line_path, "path", |
1427 | "addr2line binary to use for line numbers"), | |
328ccdac NK |
1428 | OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle, |
1429 | "Disable symbol demangling"), | |
763122ad AK |
1430 | OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel, |
1431 | "Enable kernel symbol demangling"), | |
f4f7e28d | 1432 | OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"), |
4968ac8f AK |
1433 | OPT_INTEGER(0, "samples", &symbol_conf.res_sample, |
1434 | "Number of samples to save per histogram entry for individual browsing"), | |
064f1981 NK |
1435 | OPT_CALLBACK(0, "percent-limit", &report, "percent", |
1436 | "Don't show entries under that percent", parse_percent_limit), | |
f2148330 | 1437 | OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", |
33db4568 | 1438 | "how to display percentage of filtered entries", parse_filter_percentage), |
520a2ebc | 1439 | OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts", |
c12e039d | 1440 | "Instruction Tracing options\n" ITRACE_HELP, |
520a2ebc | 1441 | itrace_parse_synth_opts), |
a9710ba0 AK |
1442 | OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename, |
1443 | "Show full source file name path for source lines"), | |
9e207ddf KL |
1444 | OPT_BOOLEAN(0, "show-ref-call-graph", &symbol_conf.show_ref_callgraph, |
1445 | "Show callgraph from reference event"), | |
b1d1429b KL |
1446 | OPT_BOOLEAN(0, "stitch-lbr", &report.stitch_lbr, |
1447 | "Enable LBR callgraph stitching approach"), | |
21394d94 KL |
1448 | OPT_INTEGER(0, "socket-filter", &report.socket_filter, |
1449 | "only show processor socket that match with this filter"), | |
053a3989 NK |
1450 | OPT_BOOLEAN(0, "raw-trace", &symbol_conf.raw_trace, |
1451 | "Show raw trace event output (do not use print fmt or plugins)"), | |
7727d59d | 1452 | OPT_BOOLEAN('H', "hierarchy", &symbol_conf.report_hierarchy, |
4251446d | 1453 | "Show entries in a hierarchy"), |
175b968b ACM |
1454 | OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", |
1455 | "'always' (default), 'never' or 'auto' only applicable to --stdio mode", | |
1456 | stdio__config_color, "always"), | |
46690a80 DA |
1457 | OPT_STRING(0, "time", &report.time_str, "str", |
1458 | "Time span of interest (start,stop)"), | |
f3a60646 JY |
1459 | OPT_BOOLEAN(0, "inline", &symbol_conf.inline_name, |
1460 | "Show inline function"), | |
14953f03 | 1461 | OPT_CALLBACK(0, "percent-type", &annotate_opts, "local-period", |
e6902d1b JO |
1462 | "Set percent type local/global-period/hits", |
1463 | annotate_parse_percent_type), | |
52bab886 | 1464 | OPT_BOOLEAN(0, "ns", &symbol_conf.nanosecs, "Show times in nanosecs"), |
2a1292cb AK |
1465 | OPT_CALLBACK(0, "time-quantum", &symbol_conf.time_quantum, "time (ms|us|ns|s)", |
1466 | "Set time quantum for time sort key (default 100ms)", | |
1467 | parse_time_quantum), | |
ef4b1a53 | 1468 | OPTS_EVSWITCH(&report.evswitch), |
6f7164fa JY |
1469 | OPT_BOOLEAN(0, "total-cycles", &report.total_cycles_mode, |
1470 | "Sort all blocks by 'Sampled Cycles%'"), | |
2e989f82 JY |
1471 | OPT_BOOLEAN(0, "disable-order", &report.disable_order, |
1472 | "Disable raw trace ordering"), | |
2775de0b NK |
1473 | OPT_BOOLEAN(0, "skip-empty", &report.skip_empty, |
1474 | "Do not display empty (or dummy) events in the output"), | |
53cb8bc2 | 1475 | OPT_END() |
d20deb64 | 1476 | }; |
8ceb41d7 | 1477 | struct perf_data data = { |
f5fc1412 JO |
1478 | .mode = PERF_DATA_MODE_READ, |
1479 | }; | |
a635fc51 | 1480 | int ret = hists__init(); |
ec6ae74f | 1481 | char sort_tmp[128]; |
a635fc51 ACM |
1482 | |
1483 | if (ret < 0) | |
a37338aa | 1484 | goto exit; |
53cb8bc2 | 1485 | |
9ffa6c75 IR |
1486 | /* |
1487 | * tasks_mode require access to exited threads to list those that are in | |
1488 | * the data file. Off-cpu events are synthesized after other events and | |
1489 | * reference exited threads. | |
1490 | */ | |
1491 | symbol_conf.keep_exited_threads = true; | |
1492 | ||
7f929aea | 1493 | annotation_options__init(); |
217b7d41 | 1494 | |
ecc4c561 ACM |
1495 | ret = perf_config(report__config, &report); |
1496 | if (ret) | |
a37338aa | 1497 | goto exit; |
00c7e1f1 | 1498 | |
655000e7 | 1499 | argc = parse_options(argc, argv, options, report_usage, 0); |
b3f38fc2 NK |
1500 | if (argc) { |
1501 | /* | |
1502 | * Special case: if there's an argument left then assume that | |
1503 | * it's a symbol filter: | |
1504 | */ | |
1505 | if (argc > 1) | |
1506 | usage_with_options(report_usage, options); | |
1507 | ||
1508 | report.symbol_filter_str = argv[0]; | |
1509 | } | |
655000e7 | 1510 | |
56d9117c | 1511 | if (disassembler_style) { |
14953f03 NK |
1512 | annotate_opts.disassembler_style = strdup(disassembler_style); |
1513 | if (!annotate_opts.disassembler_style) | |
56d9117c IR |
1514 | return -ENOMEM; |
1515 | } | |
1516 | if (objdump_path) { | |
14953f03 NK |
1517 | annotate_opts.objdump_path = strdup(objdump_path); |
1518 | if (!annotate_opts.objdump_path) | |
56d9117c IR |
1519 | return -ENOMEM; |
1520 | } | |
57594454 IR |
1521 | if (addr2line_path) { |
1522 | symbol_conf.addr2line_path = strdup(addr2line_path); | |
1523 | if (!symbol_conf.addr2line_path) | |
1524 | return -ENOMEM; | |
1525 | } | |
56d9117c | 1526 | |
7f929aea | 1527 | if (annotate_check_args() < 0) { |
a37338aa RM |
1528 | ret = -EINVAL; |
1529 | goto exit; | |
1530 | } | |
3b0b16bf | 1531 | |
6439d7d1 ACM |
1532 | if (report.mmaps_mode) |
1533 | report.tasks_mode = true; | |
1534 | ||
2e989f82 | 1535 | if (dump_trace && report.disable_order) |
977f739b JO |
1536 | report.tool.ordered_events = false; |
1537 | ||
27fafab5 NK |
1538 | if (quiet) |
1539 | perf_quiet_option(); | |
1540 | ||
a3df50ab JC |
1541 | ret = symbol__validate_sym_arguments(); |
1542 | if (ret) | |
a37338aa | 1543 | goto exit; |
36c8bb56 | 1544 | |
fa372aae | 1545 | if (report.inverted_callchain) |
d797fdc5 | 1546 | callchain_param.order = ORDER_CALLER; |
792aeafa NK |
1547 | if (symbol_conf.cumulate_callchain && !callchain_param.order_set) |
1548 | callchain_param.order = ORDER_CALLER; | |
d797fdc5 | 1549 | |
1c5c25b3 | 1550 | if ((itrace_synth_opts.callchain || itrace_synth_opts.add_callchain) && |
188bb5e2 AH |
1551 | (int)itrace_synth_opts.callchain_sz > report.max_stack) |
1552 | report.max_stack = itrace_synth_opts.callchain_sz; | |
1553 | ||
70cb4e96 | 1554 | if (!input_name || !strlen(input_name)) { |
efad1415 | 1555 | if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode)) |
70cb4e96 | 1556 | input_name = "-"; |
efad1415 | 1557 | else |
70cb4e96 | 1558 | input_name = "perf.data"; |
efad1415 | 1559 | } |
ad0de097 | 1560 | |
2d4f2799 JO |
1561 | data.path = input_name; |
1562 | data.force = symbol_conf.force; | |
f5fc1412 | 1563 | |
ad0de097 | 1564 | repeat: |
2681bd85 | 1565 | session = perf_session__new(&data, &report.tool); |
a37338aa RM |
1566 | if (IS_ERR(session)) { |
1567 | ret = PTR_ERR(session); | |
1568 | goto exit; | |
1569 | } | |
993ac88d | 1570 | |
ef4b1a53 ACM |
1571 | ret = evswitch__init(&report.evswitch, session->evlist, stderr); |
1572 | if (ret) | |
a37338aa | 1573 | goto exit; |
ef4b1a53 | 1574 | |
cb62c6f1 AB |
1575 | if (zstd_init(&(session->zstd_data), 0) < 0) |
1576 | pr_warning("Decompression initialization failed. Reported data may be incomplete.\n"); | |
1577 | ||
94786b67 JO |
1578 | if (report.queue_size) { |
1579 | ordered_events__set_alloc_size(&session->ordered_events, | |
1580 | report.queue_size); | |
1581 | } | |
1582 | ||
520a2ebc AH |
1583 | session->itrace_synth_opts = &itrace_synth_opts; |
1584 | ||
993ac88d SE |
1585 | report.session = session; |
1586 | ||
1587 | has_br_stack = perf_header__has_feat(&session->header, | |
1588 | HEADER_BRANCH_STACK); | |
b3c2cc2b | 1589 | if (evlist__combined_sample_type(session->evlist) & PERF_SAMPLE_STACK_USER) |
10ccbc1c | 1590 | has_br_stack = false; |
efad1415 | 1591 | |
57b5de46 | 1592 | setup_forced_leader(&report, session->evlist); |
ad52b8cb | 1593 | |
9d2dc632 | 1594 | if (symbol_conf.group_sort_idx && evlist__nr_groups(session->evlist) == 0) { |
429a5f9d JY |
1595 | parse_options_usage(NULL, options, "group-sort-idx", 0); |
1596 | ret = -EINVAL; | |
1597 | goto error; | |
1598 | } | |
1599 | ||
ec90e42c | 1600 | if (itrace_synth_opts.last_branch || itrace_synth_opts.add_last_branch) |
fb9fab66 AH |
1601 | has_br_stack = true; |
1602 | ||
f9a7be7c JY |
1603 | if (has_br_stack && branch_call_mode) |
1604 | symbol_conf.show_branchflag_count = true; | |
1605 | ||
2d78b189 JY |
1606 | memset(&report.brtype_stat, 0, sizeof(struct branch_type_stat)); |
1607 | ||
fa94c36c AK |
1608 | /* |
1609 | * Branch mode is a tristate: | |
1610 | * -1 means default, so decide based on the file having branch data. | |
1611 | * 0/1 means the user chose a mode. | |
1612 | */ | |
1613 | if (((branch_mode == -1 && has_br_stack) || branch_mode == 1) && | |
fefd2d96 | 1614 | !branch_call_mode) { |
55369fc1 | 1615 | sort__mode = SORT_MODE__BRANCH; |
793aaaab NK |
1616 | symbol_conf.cumulate_callchain = false; |
1617 | } | |
fa94c36c | 1618 | if (branch_call_mode) { |
09a6a1b0 | 1619 | callchain_param.key = CCKEY_ADDRESS; |
6fa9c3e7 | 1620 | callchain_param.branch_callstack = true; |
fa94c36c AK |
1621 | symbol_conf.use_callchain = true; |
1622 | callchain_register_param(&callchain_param); | |
1623 | if (sort_order == NULL) | |
1624 | sort_order = "srcline,symbol,dso"; | |
1625 | } | |
993ac88d | 1626 | |
f4f7e28d | 1627 | if (report.mem_mode) { |
55369fc1 | 1628 | if (sort__mode == SORT_MODE__BRANCH) { |
a4210141 | 1629 | pr_err("branch and mem mode incompatible\n"); |
f4f7e28d SE |
1630 | goto error; |
1631 | } | |
afab87b9 | 1632 | sort__mode = SORT_MODE__MEMORY; |
793aaaab | 1633 | symbol_conf.cumulate_callchain = false; |
f4f7e28d | 1634 | } |
a68c2c58 | 1635 | |
4251446d NK |
1636 | if (symbol_conf.report_hierarchy) { |
1637 | /* disable incompatible options */ | |
4251446d NK |
1638 | symbol_conf.cumulate_callchain = false; |
1639 | ||
1640 | if (field_order) { | |
1641 | pr_err("Error: --hierarchy and --fields options cannot be used together\n"); | |
1642 | parse_options_usage(report_usage, options, "F", 1); | |
1643 | parse_options_usage(NULL, options, "hierarchy", 0); | |
1644 | goto error; | |
1645 | } | |
1646 | ||
52225036 | 1647 | perf_hpp_list.need_collapse = true; |
4251446d NK |
1648 | } |
1649 | ||
712d36db SS |
1650 | if (report.use_stdio) |
1651 | use_browser = 0; | |
3402ae0a | 1652 | #ifdef HAVE_SLANG_SUPPORT |
712d36db SS |
1653 | else if (report.use_tui) |
1654 | use_browser = 1; | |
3402ae0a | 1655 | #endif |
557cc18e | 1656 | #ifdef HAVE_GTK2_SUPPORT |
712d36db SS |
1657 | else if (report.use_gtk) |
1658 | use_browser = 2; | |
557cc18e | 1659 | #endif |
712d36db | 1660 | |
b138f42e NK |
1661 | /* Force tty output for header output and per-thread stat. */ |
1662 | if (report.header || report.header_only || report.show_threads) | |
5cfe2c82 | 1663 | use_browser = 0; |
114f709e DCC |
1664 | if (report.header || report.header_only) |
1665 | report.tool.show_feat_hdr = SHOW_FEAT_HEADER; | |
1666 | if (report.show_full_info) | |
1667 | report.tool.show_feat_hdr = SHOW_FEAT_HEADER_FULL_INFO; | |
930f8b34 | 1668 | if (report.stats_mode || report.tasks_mode) |
a4a4d0a7 | 1669 | use_browser = 0; |
930f8b34 | 1670 | if (report.stats_mode && report.tasks_mode) { |
6439d7d1 | 1671 | pr_err("Error: --tasks and --mmaps can't be used together with --stats\n"); |
930f8b34 JO |
1672 | goto error; |
1673 | } | |
5cfe2c82 | 1674 | |
6f7164fa JY |
1675 | if (report.total_cycles_mode) { |
1676 | if (sort__mode != SORT_MODE__BRANCH) | |
1677 | report.total_cycles_mode = false; | |
7fa46cbf | 1678 | else |
848a5e50 | 1679 | sort_order = NULL; |
6f7164fa JY |
1680 | } |
1681 | ||
81e57dee NK |
1682 | if (sort_order && strstr(sort_order, "type")) { |
1683 | report.data_type = true; | |
1684 | annotate_opts.annotate_src = false; | |
1685 | ||
1686 | #ifndef HAVE_DWARF_GETLOCATIONS_SUPPORT | |
1687 | pr_err("Error: Data type profiling is disabled due to missing DWARF support\n"); | |
1688 | goto error; | |
1689 | #endif | |
1690 | } | |
1691 | ||
4bceffbc NK |
1692 | if (strcmp(input_name, "-") != 0) |
1693 | setup_browser(true); | |
22af969e | 1694 | else |
4bceffbc | 1695 | use_browser = 0; |
4bceffbc | 1696 | |
0bfbe661 NK |
1697 | if (report.data_type && use_browser == 1) { |
1698 | symbol_conf.annotate_data_member = true; | |
1699 | symbol_conf.annotate_data_sample = true; | |
1700 | } | |
1701 | ||
ec6ae74f JY |
1702 | if (sort_order && strstr(sort_order, "ipc")) { |
1703 | parse_options_usage(report_usage, options, "s", 1); | |
1704 | goto error; | |
1705 | } | |
1706 | ||
1707 | if (sort_order && strstr(sort_order, "symbol")) { | |
1708 | if (sort__mode == SORT_MODE__BRANCH) { | |
1709 | snprintf(sort_tmp, sizeof(sort_tmp), "%s,%s", | |
1710 | sort_order, "ipc_lbr"); | |
1711 | report.symbol_ipc = true; | |
1712 | } else { | |
1713 | snprintf(sort_tmp, sizeof(sort_tmp), "%s,%s", | |
1714 | sort_order, "ipc_null"); | |
1715 | } | |
1716 | ||
1717 | sort_order = sort_tmp; | |
1718 | } | |
1719 | ||
5e3b810a | 1720 | if ((last_key != K_SWITCH_INPUT_DATA && last_key != K_RELOAD) && |
0feba17b | 1721 | (setup_sorting(session->evlist) < 0)) { |
9887804d JO |
1722 | if (sort_order) |
1723 | parse_options_usage(report_usage, options, "s", 1); | |
1724 | if (field_order) | |
1725 | parse_options_usage(sort_order ? NULL : report_usage, | |
1726 | options, "F", 1); | |
1727 | goto error; | |
1728 | } | |
1729 | ||
27fafab5 | 1730 | if ((report.header || report.header_only) && !quiet) { |
5cfe2c82 JO |
1731 | perf_session__fprintf_info(session, stdout, |
1732 | report.show_full_info); | |
07a716ff | 1733 | if (report.header_only) { |
03de8656 NK |
1734 | if (data.is_pipe) { |
1735 | /* | |
1736 | * we need to process first few records | |
1737 | * which contains PERF_RECORD_HEADER_FEATURE. | |
1738 | */ | |
1739 | perf_session__process_events(session); | |
1740 | } | |
07a716ff TS |
1741 | ret = 0; |
1742 | goto error; | |
1743 | } | |
930f8b34 JO |
1744 | } else if (use_browser == 0 && !quiet && |
1745 | !report.stats_mode && !report.tasks_mode) { | |
5cfe2c82 JO |
1746 | fputs("# To display the perf.data header info, please use --header/--header-only options.\n#\n", |
1747 | stdout); | |
1748 | } | |
1749 | ||
ef7b93a1 | 1750 | /* |
6692c262 | 1751 | * Only in the TUI browser we are doing integrated annotation, |
ef7b93a1 ACM |
1752 | * so don't allocate extra space that won't be used in the stdio |
1753 | * implementation. | |
1754 | */ | |
81e57dee | 1755 | if (ui__has_annotation() || report.symbol_ipc || report.data_type || |
6f7164fa | 1756 | report.total_cycles_mode) { |
b01141f4 ACM |
1757 | ret = symbol__annotation_init(); |
1758 | if (ret < 0) | |
1759 | goto error; | |
80d50cae ACM |
1760 | /* |
1761 | * For searching by name on the "Browse map details". | |
1762 | * providing it only in verbose mode not to bloat too | |
1763 | * much struct symbol. | |
1764 | */ | |
bb963e16 | 1765 | if (verbose > 0) { |
80d50cae ACM |
1766 | /* |
1767 | * XXX: Need to provide a less kludgy way to ask for | |
1768 | * more space per symbol, the u32 is for the index on | |
1769 | * the ui browser. | |
1770 | * See symbol__browser_index. | |
1771 | */ | |
1772 | symbol_conf.priv_size += sizeof(u32); | |
80d50cae | 1773 | } |
7f929aea | 1774 | annotation_config__init(); |
80d50cae | 1775 | } |
655000e7 | 1776 | |
0a7e6d1b | 1777 | if (symbol__init(&session->header.env) < 0) |
993ac88d | 1778 | goto error; |
53cb8bc2 | 1779 | |
284c4e18 JY |
1780 | if (report.time_str) { |
1781 | ret = perf_time__parse_for_ranges(report.time_str, session, | |
1782 | &report.ptime_range, | |
1783 | &report.range_size, | |
1784 | &report.range_num); | |
1785 | if (ret < 0) | |
0a3cc3ae | 1786 | goto error; |
4885c90c AH |
1787 | |
1788 | itrace_synth_opts__set_time_range(&itrace_synth_opts, | |
1789 | report.ptime_range, | |
1790 | report.range_num); | |
46690a80 DA |
1791 | } |
1792 | ||
378ef0f5 | 1793 | #ifdef HAVE_LIBTRACEEVENT |
ea85ab24 | 1794 | if (session->tevent.pevent && |
ece2a4f4 TSV |
1795 | tep_set_function_resolver(session->tevent.pevent, |
1796 | machine__resolve_kernel_addr, | |
1797 | &session->machines.host) < 0) { | |
ea85ab24 WY |
1798 | pr_err("%s: failed to set libtraceevent function resolver\n", |
1799 | __func__); | |
1800 | return -1; | |
1801 | } | |
378ef0f5 | 1802 | #endif |
08e71542 | 1803 | sort__setup_elide(stdout); |
25903407 | 1804 | |
993ac88d | 1805 | ret = __cmd_report(&report); |
5e3b810a | 1806 | if (ret == K_SWITCH_INPUT_DATA || ret == K_RELOAD) { |
ad0de097 | 1807 | perf_session__delete(session); |
0feba17b | 1808 | last_key = K_SWITCH_INPUT_DATA; |
ad0de097 FT |
1809 | goto repeat; |
1810 | } else | |
1811 | ret = 0; | |
1812 | ||
0bdfbd04 AH |
1813 | if (!use_browser && (verbose > 2 || debug_kmaps)) |
1814 | perf_session__dump_kmaps(session); | |
993ac88d | 1815 | error: |
4885c90c AH |
1816 | if (report.ptime_range) { |
1817 | itrace_synth_opts__clear_time_range(&itrace_synth_opts); | |
284c4e18 | 1818 | zfree(&report.ptime_range); |
4885c90c | 1819 | } |
6f7164fa | 1820 | |
cca0cc76 JY |
1821 | if (report.block_reports) { |
1822 | block_info__free_report(report.block_reports, | |
1823 | report.nr_block_reports); | |
1824 | report.block_reports = NULL; | |
1825 | } | |
6f7164fa | 1826 | |
cb62c6f1 | 1827 | zstd_fini(&(session->zstd_data)); |
993ac88d | 1828 | perf_session__delete(session); |
a37338aa | 1829 | exit: |
7f929aea | 1830 | annotation_options__exit(); |
a37338aa RM |
1831 | free(sort_order_help); |
1832 | free(field_order_help); | |
993ac88d | 1833 | return ret; |
53cb8bc2 | 1834 | } |