diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-08 10:22:07 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-13 08:06:25 -0500 |
commit | 8362951b7b0618687beddac90aeee43940d20659 (patch) | |
tree | 1cdb6b3d6d1cfd28f479f1573f77bb6f74a423da /tools/perf | |
parent | fad2918ed5171e6299a9b4b885d0459f35ee7377 (diff) |
perf report: Move hist browser selection code to separate function
To unclutter the main function.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-agvxwpazlucy6h5sejuttw9t@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-report.c | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index f2ff8609e98e..03941ad8fc46 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -441,13 +441,57 @@ static void report__warn_kptr_restrict(const struct report *rep) | |||
441 | } | 441 | } |
442 | } | 442 | } |
443 | 443 | ||
444 | static int report__gtk_browse_hists(struct report *rep, const char *help) | ||
445 | { | ||
446 | int (*hist_browser)(struct perf_evlist *evlist, const char *help, | ||
447 | struct hist_browser_timer *timer, float min_pcnt); | ||
448 | |||
449 | hist_browser = dlsym(perf_gtk_handle, "perf_evlist__gtk_browse_hists"); | ||
450 | |||
451 | if (hist_browser == NULL) { | ||
452 | ui__error("GTK browser not found!\n"); | ||
453 | return -1; | ||
454 | } | ||
455 | |||
456 | return hist_browser(rep->session->evlist, help, NULL, rep->min_percent); | ||
457 | } | ||
458 | |||
459 | static int report__browse_hists(struct report *rep) | ||
460 | { | ||
461 | int ret; | ||
462 | struct perf_session *session = rep->session; | ||
463 | struct perf_evlist *evlist = session->evlist; | ||
464 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; | ||
465 | |||
466 | switch (use_browser) { | ||
467 | case 1: | ||
468 | ret = perf_evlist__tui_browse_hists(evlist, help, NULL, | ||
469 | rep->min_percent, | ||
470 | &session->header.env); | ||
471 | /* | ||
472 | * Usually "ret" is the last pressed key, and we only | ||
473 | * care if the key notifies us to switch data file. | ||
474 | */ | ||
475 | if (ret != K_SWITCH_INPUT_DATA) | ||
476 | ret = 0; | ||
477 | break; | ||
478 | case 2: | ||
479 | ret = report__gtk_browse_hists(rep, help); | ||
480 | break; | ||
481 | default: | ||
482 | ret = perf_evlist__tty_browse_hists(evlist, rep, help); | ||
483 | break; | ||
484 | } | ||
485 | |||
486 | return ret; | ||
487 | } | ||
488 | |||
444 | static int __cmd_report(struct report *rep) | 489 | static int __cmd_report(struct report *rep) |
445 | { | 490 | { |
446 | int ret = -EINVAL; | 491 | int ret = -EINVAL; |
447 | u64 nr_samples; | 492 | u64 nr_samples; |
448 | struct perf_session *session = rep->session; | 493 | struct perf_session *session = rep->session; |
449 | struct perf_evsel *pos; | 494 | struct perf_evsel *pos; |
450 | const char *help = "For a higher level overview, try: perf report --sort comm,dso"; | ||
451 | struct ui_progress prog; | 495 | struct ui_progress prog; |
452 | struct perf_data_file *file = session->file; | 496 | struct perf_data_file *file = session->file; |
453 | 497 | ||
@@ -524,38 +568,7 @@ static int __cmd_report(struct report *rep) | |||
524 | list_for_each_entry(pos, &session->evlist->entries, node) | 568 | list_for_each_entry(pos, &session->evlist->entries, node) |
525 | hists__output_resort(&pos->hists); | 569 | hists__output_resort(&pos->hists); |
526 | 570 | ||
527 | if (use_browser > 0) { | 571 | return report__browse_hists(rep); |
528 | if (use_browser == 1) { | ||
529 | ret = perf_evlist__tui_browse_hists(session->evlist, | ||
530 | help, NULL, | ||
531 | rep->min_percent, | ||
532 | &session->header.env); | ||
533 | /* | ||
534 | * Usually "ret" is the last pressed key, and we only | ||
535 | * care if the key notifies us to switch data file. | ||
536 | */ | ||
537 | if (ret != K_SWITCH_INPUT_DATA) | ||
538 | ret = 0; | ||
539 | |||
540 | } else if (use_browser == 2) { | ||
541 | int (*hist_browser)(struct perf_evlist *, | ||
542 | const char *, | ||
543 | struct hist_browser_timer *, | ||
544 | float min_pcnt); | ||
545 | |||
546 | hist_browser = dlsym(perf_gtk_handle, | ||
547 | "perf_evlist__gtk_browse_hists"); | ||
548 | if (hist_browser == NULL) { | ||
549 | ui__error("GTK browser not found!\n"); | ||
550 | return ret; | ||
551 | } | ||
552 | hist_browser(session->evlist, help, NULL, | ||
553 | rep->min_percent); | ||
554 | } | ||
555 | } else | ||
556 | perf_evlist__tty_browse_hists(session->evlist, rep, help); | ||
557 | |||
558 | return ret; | ||
559 | } | 572 | } |
560 | 573 | ||
561 | static int | 574 | static int |