aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/newt.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r--tools/perf/util/newt.c46
1 files changed, 38 insertions, 8 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index ba6acd04c082..e74df1240ef6 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -9,6 +9,7 @@
9 9
10#include "cache.h" 10#include "cache.h"
11#include "hist.h" 11#include "hist.h"
12#include "pstack.h"
12#include "session.h" 13#include "session.h"
13#include "sort.h" 14#include "sort.h"
14#include "symbol.h" 15#include "symbol.h"
@@ -680,16 +681,18 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
680 struct ui_progress *progress; 681 struct ui_progress *progress;
681 struct rb_node *nd; 682 struct rb_node *nd;
682 u64 curr_hist = 0; 683 u64 curr_hist = 0;
683 char seq[] = "."; 684 char seq[] = ".", unit;
684 char str[256]; 685 char str[256];
686 unsigned long nr_events = hists->stats.nr_events[PERF_RECORD_SAMPLE];
685 687
686 if (self->form) { 688 if (self->form) {
687 newtFormDestroy(self->form); 689 newtFormDestroy(self->form);
688 newtPopWindow(); 690 newtPopWindow();
689 } 691 }
690 692
691 snprintf(str, sizeof(str), "Samples: %Ld ", 693 nr_events = convert_unit(nr_events, &unit);
692 hists->stats.total); 694 snprintf(str, sizeof(str), "Events: %lu%c ",
695 nr_events, unit);
693 newtDrawRootText(0, 0, str); 696 newtDrawRootText(0, 0, str);
694 697
695 newtGetScreenSize(NULL, &rows); 698 newtGetScreenSize(NULL, &rows);
@@ -718,12 +721,12 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
718 if (h->filtered) 721 if (h->filtered)
719 continue; 722 continue;
720 723
721 len = hist_entry__append_browser(h, self->tree, hists->stats.total); 724 len = hist_entry__append_browser(h, self->tree, hists->stats.total_period);
722 if (len > max_len) 725 if (len > max_len)
723 max_len = len; 726 max_len = len;
724 if (symbol_conf.use_callchain) 727 if (symbol_conf.use_callchain)
725 hist_entry__append_callchain_browser(h, self->tree, 728 hist_entry__append_callchain_browser(h, self->tree,
726 hists->stats.total, idx++); 729 hists->stats.total_period, idx++);
727 ++curr_hist; 730 ++curr_hist;
728 if (curr_hist % 5) 731 if (curr_hist % 5)
729 ui_progress__update(progress, curr_hist); 732 ui_progress__update(progress, curr_hist);
@@ -748,6 +751,7 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists
748 newtFormAddHotKey(self->form, 'A'); 751 newtFormAddHotKey(self->form, 'A');
749 newtFormAddHotKey(self->form, 'a'); 752 newtFormAddHotKey(self->form, 'a');
750 newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); 753 newtFormAddHotKey(self->form, NEWT_KEY_RIGHT);
754 newtFormAddHotKey(self->form, NEWT_KEY_LEFT);
751 newtFormAddComponents(self->form, self->tree, NULL); 755 newtFormAddComponents(self->form, self->tree, NULL);
752 self->selection = newt__symbol_tree_get_current(self->tree); 756 self->selection = newt__symbol_tree_get_current(self->tree);
753 757
@@ -799,6 +803,7 @@ static int hist_browser__title(char *bf, size_t size, const char *input_name,
799int hists__browse(struct hists *self, const char *helpline, const char *input_name) 803int hists__browse(struct hists *self, const char *helpline, const char *input_name)
800{ 804{
801 struct hist_browser *browser = hist_browser__new(); 805 struct hist_browser *browser = hist_browser__new();
806 struct pstack *fstack = pstack__new(2);
802 const struct thread *thread_filter = NULL; 807 const struct thread *thread_filter = NULL;
803 const struct dso *dso_filter = NULL; 808 const struct dso *dso_filter = NULL;
804 struct newtExitStruct es; 809 struct newtExitStruct es;
@@ -808,12 +813,16 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
808 if (browser == NULL) 813 if (browser == NULL)
809 return -1; 814 return -1;
810 815
816 fstack = pstack__new(2);
817 if (fstack == NULL)
818 goto out;
819
811 ui_helpline__push(helpline); 820 ui_helpline__push(helpline);
812 821
813 hist_browser__title(msg, sizeof(msg), input_name, 822 hist_browser__title(msg, sizeof(msg), input_name,
814 dso_filter, thread_filter); 823 dso_filter, thread_filter);
815 if (hist_browser__populate(browser, self, msg) < 0) 824 if (hist_browser__populate(browser, self, msg) < 0)
816 goto out; 825 goto out_free_stack;
817 826
818 while (1) { 827 while (1) {
819 const struct thread *thread; 828 const struct thread *thread;
@@ -834,6 +843,19 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
834 else 843 else
835 continue; 844 continue;
836 } 845 }
846
847 if (es.u.key == NEWT_KEY_LEFT) {
848 const void *top;
849
850 if (pstack__empty(fstack))
851 continue;
852 top = pstack__pop(fstack);
853 if (top == &dso_filter)
854 goto zoom_out_dso;
855 if (top == &thread_filter)
856 goto zoom_out_thread;
857 continue;
858 }
837 } 859 }
838 860
839 if (browser->selection->sym != NULL && 861 if (browser->selection->sym != NULL &&
@@ -886,12 +908,15 @@ do_annotate:
886 hist_entry__annotate_browser(he); 908 hist_entry__annotate_browser(he);
887 } else if (choice == zoom_dso) { 909 } else if (choice == zoom_dso) {
888 if (dso_filter) { 910 if (dso_filter) {
911 pstack__remove(fstack, &dso_filter);
912zoom_out_dso:
889 ui_helpline__pop(); 913 ui_helpline__pop();
890 dso_filter = NULL; 914 dso_filter = NULL;
891 } else { 915 } else {
892 ui_helpline__fpush("To zoom out press -> + \"Zoom out of %s DSO\"", 916 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s DSO\"",
893 dso->kernel ? "the Kernel" : dso->short_name); 917 dso->kernel ? "the Kernel" : dso->short_name);
894 dso_filter = dso; 918 dso_filter = dso;
919 pstack__push(fstack, &dso_filter);
895 } 920 }
896 hists__filter_by_dso(self, dso_filter); 921 hists__filter_by_dso(self, dso_filter);
897 hist_browser__title(msg, sizeof(msg), input_name, 922 hist_browser__title(msg, sizeof(msg), input_name,
@@ -900,13 +925,16 @@ do_annotate:
900 goto out; 925 goto out;
901 } else if (choice == zoom_thread) { 926 } else if (choice == zoom_thread) {
902 if (thread_filter) { 927 if (thread_filter) {
928 pstack__remove(fstack, &thread_filter);
929zoom_out_thread:
903 ui_helpline__pop(); 930 ui_helpline__pop();
904 thread_filter = NULL; 931 thread_filter = NULL;
905 } else { 932 } else {
906 ui_helpline__fpush("To zoom out press -> + \"Zoom out of %s(%d) thread\"", 933 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
907 thread->comm_set ? thread->comm : "", 934 thread->comm_set ? thread->comm : "",
908 thread->pid); 935 thread->pid);
909 thread_filter = thread; 936 thread_filter = thread;
937 pstack__push(fstack, &thread_filter);
910 } 938 }
911 hists__filter_by_thread(self, thread_filter); 939 hists__filter_by_thread(self, thread_filter);
912 hist_browser__title(msg, sizeof(msg), input_name, 940 hist_browser__title(msg, sizeof(msg), input_name,
@@ -916,6 +944,8 @@ do_annotate:
916 } 944 }
917 } 945 }
918 err = 0; 946 err = 0;
947out_free_stack:
948 pstack__delete(fstack);
919out: 949out:
920 hist_browser__delete(browser); 950 hist_browser__delete(browser);
921 return err; 951 return err;