aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-report.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-report.c')
-rw-r--r--tools/perf/builtin-report.c64
1 files changed, 38 insertions, 26 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1d3c1003b43a..359205782964 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -116,7 +116,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
116 * so we don't allocated the extra space needed because the stdio 116 * so we don't allocated the extra space needed because the stdio
117 * code will not use it. 117 * code will not use it.
118 */ 118 */
119 if (use_browser) 119 if (use_browser > 0)
120 err = hist_entry__inc_addr_samples(he, al->addr); 120 err = hist_entry__inc_addr_samples(he, al->addr);
121out_free_syms: 121out_free_syms:
122 free(syms); 122 free(syms);
@@ -288,6 +288,38 @@ static size_t hists__fprintf_nr_sample_events(struct hists *self,
288 return ret + fprintf(fp, "\n#\n"); 288 return ret + fprintf(fp, "\n#\n");
289} 289}
290 290
291static int hists__tty_browse_tree(struct rb_root *tree, const char *help)
292{
293 struct rb_node *next = rb_first(tree);
294
295 while (next) {
296 struct hists *hists = rb_entry(next, struct hists, rb_node);
297 const char *evname = NULL;
298
299 if (rb_first(&hists->entries) != rb_last(&hists->entries))
300 evname = __event_name(hists->type, hists->config);
301
302 hists__fprintf_nr_sample_events(hists, evname, stdout);
303 hists__fprintf(hists, NULL, false, stdout);
304 fprintf(stdout, "\n\n");
305 next = rb_next(&hists->rb_node);
306 }
307
308 if (sort_order == default_sort_order &&
309 parent_pattern == default_parent_pattern) {
310 fprintf(stdout, "#\n# (%s)\n#\n", help);
311
312 if (show_threads) {
313 bool style = !strcmp(pretty_printing_style, "raw");
314 perf_read_values_display(stdout, &show_threads_values,
315 style);
316 perf_read_values_destroy(&show_threads_values);
317 }
318 }
319
320 return 0;
321}
322
291static int __cmd_report(void) 323static int __cmd_report(void)
292{ 324{
293 int ret = -EINVAL; 325 int ret = -EINVAL;
@@ -330,34 +362,14 @@ static int __cmd_report(void)
330 hists = rb_entry(next, struct hists, rb_node); 362 hists = rb_entry(next, struct hists, rb_node);
331 hists__collapse_resort(hists); 363 hists__collapse_resort(hists);
332 hists__output_resort(hists); 364 hists__output_resort(hists);
333 if (use_browser)
334 hists__browse(hists, help, input_name);
335 else {
336 const char *evname = NULL;
337 if (rb_first(&session->hists.entries) !=
338 rb_last(&session->hists.entries))
339 evname = __event_name(hists->type, hists->config);
340
341 hists__fprintf_nr_sample_events(hists, evname, stdout);
342
343 hists__fprintf(hists, NULL, false, stdout);
344 fprintf(stdout, "\n\n");
345 }
346
347 next = rb_next(&hists->rb_node); 365 next = rb_next(&hists->rb_node);
348 } 366 }
349 367
350 if (!use_browser && sort_order == default_sort_order && 368 if (use_browser > 0)
351 parent_pattern == default_parent_pattern) { 369 hists__tui_browse_tree(&session->hists_tree, help);
352 fprintf(stdout, "#\n# (%s)\n#\n", help); 370 else
371 hists__tty_browse_tree(&session->hists_tree, help);
353 372
354 if (show_threads) {
355 bool style = !strcmp(pretty_printing_style, "raw");
356 perf_read_values_display(stdout, &show_threads_values,
357 style);
358 perf_read_values_destroy(&show_threads_values);
359 }
360 }
361out_delete: 373out_delete:
362 perf_session__delete(session); 374 perf_session__delete(session);
363 return ret; 375 return ret;
@@ -491,7 +503,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
491 * so don't allocate extra space that won't be used in the stdio 503 * so don't allocate extra space that won't be used in the stdio
492 * implementation. 504 * implementation.
493 */ 505 */
494 if (use_browser) 506 if (use_browser > 0)
495 symbol_conf.priv_size = sizeof(struct sym_priv); 507 symbol_conf.priv_size = sizeof(struct sym_priv);
496 508
497 if (symbol__init() < 0) 509 if (symbol__init() < 0)