aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-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 40fd4247044..de8ece8bcce 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