aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2012-03-12 11:13:30 -0400
committerIngo Molnar <mingo@elte.hu>2012-03-12 15:46:16 -0400
commit24bff2dc0f77b1f186b7bdf30060caf3df191a68 (patch)
tree8a29fe1cef00c5b93a4fd8b0b0e54ff62fa99dde /tools
parent8bcd65fd29e9abfb633bfd6eedaf24b22e211f3a (diff)
perf report: Fix annotate double quit issue in branch view mode
This patch fixes perf report to not go back two levels when pressing the 'q' key while annotating in branch view mode. When pressing 'q' in annotate mode and if the branch source and target belong to different functions, perf now brings up the annotation popup menu again to offer the option to annotate the other branch source or target. As part of the code restructuring in perf_evsel__hists_browse() we also fix a memory leak on options[] in case of error. Signed-off-by: Stephane Eranian <eranian@google.com> Cc: peterz@infradead.org Cc: acme@redhat.com Cc: asharma@fb.com Cc: ravitillo@lbl.gov Cc: vweaver1@eecs.utk.edu Cc: khandual@linux.vnet.ibm.com Cc: dsahern@gmail.com Link: http://lkml.kernel.org/r/1331565210-10865-3-git-send-email-eranian@google.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/ui/browsers/hists.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 40fd42470447..de8ece8bcce3 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -856,6 +856,16 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size,
856 return printed; 856 return printed;
857} 857}
858 858
859static inline void free_popup_options(char **options, int n)
860{
861 int i;
862
863 for (i = 0; i < n; ++i) {
864 free(options[i]);
865 options[i] = NULL;
866 }
867}
868
859static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, 869static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
860 const char *helpline, const char *ev_name, 870 const char *helpline, const char *ev_name,
861 bool left_exits, 871 bool left_exits,
@@ -866,6 +876,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
866 struct hist_browser *browser = hist_browser__new(self); 876 struct hist_browser *browser = hist_browser__new(self);
867 struct branch_info *bi; 877 struct branch_info *bi;
868 struct pstack *fstack; 878 struct pstack *fstack;
879 char *options[16];
880 int nr_options = 0;
869 int key = -1; 881 int key = -1;
870 882
871 if (browser == NULL) 883 if (browser == NULL)
@@ -877,14 +889,17 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
877 889
878 ui_helpline__push(helpline); 890 ui_helpline__push(helpline);
879 891
892 memset(options, 0, sizeof(options));
893
880 while (1) { 894 while (1) {
881 const struct thread *thread = NULL; 895 const struct thread *thread = NULL;
882 const struct dso *dso = NULL; 896 const struct dso *dso = NULL;
883 char *options[16]; 897 int choice = 0,
884 int nr_options = 0, choice = 0, i,
885 annotate = -2, zoom_dso = -2, zoom_thread = -2, 898 annotate = -2, zoom_dso = -2, zoom_thread = -2,
886 annotate_f = -2, annotate_t = -2, browse_map = -2; 899 annotate_f = -2, annotate_t = -2, browse_map = -2;
887 900
901 nr_options = 0;
902
888 key = hist_browser__run(browser, ev_name, timer, arg, delay_secs); 903 key = hist_browser__run(browser, ev_name, timer, arg, delay_secs);
889 904
890 if (browser->he_selection != NULL) { 905 if (browser->he_selection != NULL) {
@@ -1023,17 +1038,16 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1023 browse_map = nr_options++; 1038 browse_map = nr_options++;
1024add_exit_option: 1039add_exit_option:
1025 options[nr_options++] = (char *)"Exit"; 1040 options[nr_options++] = (char *)"Exit";
1026 1041retry_popup_menu:
1027 choice = ui__popup_menu(nr_options, options); 1042 choice = ui__popup_menu(nr_options, options);
1028 1043
1029 for (i = 0; i < nr_options - 1; ++i)
1030 free(options[i]);
1031
1032 if (choice == nr_options - 1) 1044 if (choice == nr_options - 1)
1033 break; 1045 break;
1034 1046
1035 if (choice == -1) 1047 if (choice == -1) {
1048 free_popup_options(options, nr_options - 1);
1036 continue; 1049 continue;
1050 }
1037 1051
1038 if (choice == annotate || choice == annotate_t || choice == annotate_f) { 1052 if (choice == annotate || choice == annotate_t || choice == annotate_f) {
1039 struct hist_entry *he; 1053 struct hist_entry *he;
@@ -1064,9 +1078,18 @@ do_annotate:
1064 err = hist_entry__tui_annotate(he, evsel->idx, 1078 err = hist_entry__tui_annotate(he, evsel->idx,
1065 timer, arg, delay_secs); 1079 timer, arg, delay_secs);
1066 he->used = false; 1080 he->used = false;
1081 /*
1082 * offer option to annotate the other branch source or target
1083 * (if they exists) when returning from annotate
1084 */
1085 if ((err == 'q' || err == CTRL('c'))
1086 && annotate_t != -2 && annotate_f != -2)
1087 goto retry_popup_menu;
1088
1067 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); 1089 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries);
1068 if (err) 1090 if (err)
1069 ui_browser__handle_resize(&browser->b); 1091 ui_browser__handle_resize(&browser->b);
1092
1070 } else if (choice == browse_map) 1093 } else if (choice == browse_map)
1071 map__browse(browser->selection->map); 1094 map__browse(browser->selection->map);
1072 else if (choice == zoom_dso) { 1095 else if (choice == zoom_dso) {
@@ -1112,6 +1135,7 @@ out_free_stack:
1112 pstack__delete(fstack); 1135 pstack__delete(fstack);
1113out: 1136out:
1114 hist_browser__delete(browser); 1137 hist_browser__delete(browser);
1138 free_popup_options(options, nr_options - 1);
1115 return key; 1139 return key;
1116} 1140}
1117 1141