diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-05 11:02:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-04-08 10:34:25 -0400 |
commit | 6e7ab4c649eb7ed403d970b8eda32ca3745e8024 (patch) | |
tree | 5f6dce0ccc9dfa112e76a7f88a679b71fae6bb5a /tools/perf/util/newt.c | |
parent | ca7e0c612005937a4a5a75d3fed90459993de65c (diff) |
perf TUI: Show filters on the title and add help line about how to zoom out
Suggested-by: Ingo Molnar <molnar@elte.hu>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r-- | tools/perf/util/newt.c | 96 |
1 files changed, 68 insertions, 28 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 6d6e022d7708..c0e71aacfc1b 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -411,7 +411,7 @@ static void hist_browser__delete(struct hist_browser *self) | |||
411 | } | 411 | } |
412 | 412 | ||
413 | static int hist_browser__populate(struct hist_browser *self, struct rb_root *hists, | 413 | static int hist_browser__populate(struct hist_browser *self, struct rb_root *hists, |
414 | u64 nr_hists, u64 session_total) | 414 | u64 nr_hists, u64 session_total, const char *title) |
415 | { | 415 | { |
416 | int max_len = 0, idx, cols, rows; | 416 | int max_len = 0, idx, cols, rows; |
417 | struct ui_progress *progress; | 417 | struct ui_progress *progress; |
@@ -476,7 +476,7 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his | |||
476 | newtListboxSetWidth(self->tree, max_len); | 476 | newtListboxSetWidth(self->tree, max_len); |
477 | 477 | ||
478 | newtCenteredWindow(max_len + (symbol_conf.use_callchain ? 5 : 0), | 478 | newtCenteredWindow(max_len + (symbol_conf.use_callchain ? 5 : 0), |
479 | rows - 5, "Report"); | 479 | rows - 5, title); |
480 | self->form = newt_form__new(); | 480 | self->form = newt_form__new(); |
481 | if (self->form == NULL) | 481 | if (self->form == NULL) |
482 | return -1; | 482 | return -1; |
@@ -495,7 +495,7 @@ enum hist_filter { | |||
495 | HIST_FILTER__THREAD, | 495 | HIST_FILTER__THREAD, |
496 | }; | 496 | }; |
497 | 497 | ||
498 | static u64 hists__filter_by_dso(struct rb_root *hists, struct dso *dso, | 498 | static u64 hists__filter_by_dso(struct rb_root *hists, const struct dso *dso, |
499 | u64 *session_total) | 499 | u64 *session_total) |
500 | { | 500 | { |
501 | struct rb_node *nd; | 501 | struct rb_node *nd; |
@@ -560,25 +560,47 @@ out: | |||
560 | return *(struct thread **)(self->selection + 1); | 560 | return *(struct thread **)(self->selection + 1); |
561 | } | 561 | } |
562 | 562 | ||
563 | static int hist_browser__title(char *bf, size_t size, const char *input_name, | ||
564 | const struct dso *dso, const struct thread *thread) | ||
565 | { | ||
566 | int printed = 0; | ||
567 | |||
568 | if (thread) | ||
569 | printed += snprintf(bf + printed, size - printed, | ||
570 | "Thread: %s(%d)", | ||
571 | (thread->comm_set ? thread->comm : ""), | ||
572 | thread->pid); | ||
573 | if (dso) | ||
574 | printed += snprintf(bf + printed, size - printed, | ||
575 | "%sDSO: %s", thread ? " " : "", | ||
576 | dso->short_name); | ||
577 | return printed ?: snprintf(bf, size, "Report: %s", input_name); | ||
578 | } | ||
579 | |||
563 | int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, | 580 | int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, |
564 | u64 session_total, const char *helpline, | 581 | u64 session_total, const char *helpline, |
565 | const char *input_name) | 582 | const char *input_name) |
566 | { | 583 | { |
584 | struct hist_browser *browser = hist_browser__new(); | ||
585 | const struct thread *thread_filter = NULL; | ||
586 | const struct dso *dso_filter = NULL; | ||
567 | struct newtExitStruct es; | 587 | struct newtExitStruct es; |
568 | bool dso_filtered = false, thread_filtered = false; | 588 | char msg[160]; |
569 | int err = -1; | 589 | int err = -1; |
570 | struct hist_browser *browser = hist_browser__new(); | ||
571 | 590 | ||
572 | if (browser == NULL) | 591 | if (browser == NULL) |
573 | return -1; | 592 | return -1; |
574 | 593 | ||
575 | newtPushHelpLine(helpline); | 594 | newtPushHelpLine(helpline); |
576 | 595 | ||
577 | if (hist_browser__populate(browser, hists, nr_hists, session_total) < 0) | 596 | hist_browser__title(msg, sizeof(msg), input_name, |
597 | dso_filter, thread_filter); | ||
598 | if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0) | ||
578 | goto out; | 599 | goto out; |
579 | 600 | ||
580 | while (1) { | 601 | while (1) { |
581 | const struct thread *thread; | 602 | const struct thread *thread; |
603 | const struct dso *dso; | ||
582 | char *options[16]; | 604 | char *options[16]; |
583 | int nr_options = 0, choice = 0, i, | 605 | int nr_options = 0, choice = 0, i, |
584 | annotate = -2, zoom_dso = -2, zoom_thread = -2; | 606 | annotate = -2, zoom_dso = -2, zoom_thread = -2; |
@@ -602,20 +624,21 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, | |||
602 | browser->selection->sym->name) > 0) | 624 | browser->selection->sym->name) > 0) |
603 | annotate = nr_options++; | 625 | annotate = nr_options++; |
604 | 626 | ||
605 | if (browser->selection->map != NULL && | ||
606 | asprintf(&options[nr_options], "Zoom %s %s DSO", | ||
607 | dso_filtered ? "out of" : "into", | ||
608 | (browser->selection->map->dso->kernel ? "the Kernel" : | ||
609 | browser->selection->map->dso->short_name)) > 0) | ||
610 | zoom_dso = nr_options++; | ||
611 | |||
612 | thread = hist_browser__selected_thread(browser); | 627 | thread = hist_browser__selected_thread(browser); |
613 | if (thread != NULL && | 628 | if (thread != NULL && |
614 | asprintf(&options[nr_options], "Zoom %s %s(%d) thread", | 629 | asprintf(&options[nr_options], "Zoom %s %s(%d) thread", |
615 | (thread_filtered ? "out of" : "into"), | 630 | (thread_filter ? "out of" : "into"), |
616 | (thread->comm_set ? thread->comm : ""), thread->pid) > 0) | 631 | (thread->comm_set ? thread->comm : ""), |
632 | thread->pid) > 0) | ||
617 | zoom_thread = nr_options++; | 633 | zoom_thread = nr_options++; |
618 | 634 | ||
635 | dso = browser->selection->map ? browser->selection->map->dso : NULL; | ||
636 | if (dso != NULL && | ||
637 | asprintf(&options[nr_options], "Zoom %s %s DSO", | ||
638 | (dso_filter ? "out of" : "into"), | ||
639 | (dso->kernel ? "the Kernel" : dso->short_name)) > 0) | ||
640 | zoom_dso = nr_options++; | ||
641 | |||
619 | options[nr_options++] = (char *)"Exit"; | 642 | options[nr_options++] = (char *)"Exit"; |
620 | 643 | ||
621 | choice = popup_menu(nr_options, options); | 644 | choice = popup_menu(nr_options, options); |
@@ -637,22 +660,39 @@ do_annotate: | |||
637 | "kallsyms file"); | 660 | "kallsyms file"); |
638 | continue; | 661 | continue; |
639 | } | 662 | } |
640 | map_symbol__annotate_browser(browser->selection, | 663 | map_symbol__annotate_browser(browser->selection, input_name); |
641 | input_name); | ||
642 | } else if (choice == zoom_dso) { | 664 | } else if (choice == zoom_dso) { |
643 | nr_hists = hists__filter_by_dso(hists, | 665 | if (dso_filter) { |
644 | (dso_filtered ? NULL : | 666 | newtPopHelpLine(); |
645 | browser->selection->map->dso), | 667 | dso_filter = NULL; |
646 | &session_total); | 668 | } else { |
647 | dso_filtered = !dso_filtered; | 669 | snprintf(msg, sizeof(msg), |
648 | if (hist_browser__populate(browser, hists, nr_hists, session_total) < 0) | 670 | "To zoom out press -> + \"Zoom out of %s DSO\"", |
671 | dso->kernel ? "the Kernel" : dso->short_name); | ||
672 | newtPushHelpLine(msg); | ||
673 | dso_filter = dso; | ||
674 | } | ||
675 | nr_hists = hists__filter_by_dso(hists, dso_filter, &session_total); | ||
676 | hist_browser__title(msg, sizeof(msg), input_name, | ||
677 | dso_filter, thread_filter); | ||
678 | if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0) | ||
649 | goto out; | 679 | goto out; |
650 | } else if (choice == zoom_thread) { | 680 | } else if (choice == zoom_thread) { |
651 | nr_hists = hists__filter_by_thread(hists, | 681 | if (thread_filter) { |
652 | (thread_filtered ? NULL : thread), | 682 | newtPopHelpLine(); |
653 | &session_total); | 683 | thread_filter = NULL; |
654 | thread_filtered = !thread_filtered; | 684 | } else { |
655 | if (hist_browser__populate(browser, hists, nr_hists, session_total) < 0) | 685 | snprintf(msg, sizeof(msg), |
686 | "To zoom out press -> + \"Zoom out of %s(%d) thread\"", | ||
687 | (thread->comm_set ? thread->comm : ""), | ||
688 | thread->pid); | ||
689 | newtPushHelpLine(msg); | ||
690 | thread_filter = thread; | ||
691 | } | ||
692 | nr_hists = hists__filter_by_thread(hists, thread_filter, &session_total); | ||
693 | hist_browser__title(msg, sizeof(msg), input_name, | ||
694 | dso_filter, thread_filter); | ||
695 | if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0) | ||
656 | goto out; | 696 | goto out; |
657 | } | 697 | } |
658 | } | 698 | } |