Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf ui browser: Handle K_RESIZE in dialog windows

Just provide wrappers for things like ui__warning, ui__dialog_yesno and
if they return K_RESIZE, refresh dimensions, redraw the entries, etc.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
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-3ih7hyk9weryxaxb501sfq4u@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+94 -26
+4 -3
tools/perf/util/debug.c
··· 47 47 } 48 48 49 49 #ifdef NO_NEWT_SUPPORT 50 - void ui__warning(const char *format, ...) 50 + int ui__warning(const char *format, ...) 51 51 { 52 52 va_list args; 53 53 54 54 va_start(args, format); 55 55 vfprintf(stderr, format, args); 56 56 va_end(args); 57 + return 0; 57 58 } 58 59 #endif 59 60 60 - void ui__error_paranoid(void) 61 + int ui__error_paranoid(void) 61 62 { 62 - ui__error("Permission error - are you root?\n" 63 + return ui__error("Permission error - are you root?\n" 63 64 "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n" 64 65 " -1 - Not paranoid at all\n" 65 66 " 0 - Disallow raw tracepoint access for unpriv\n"
+3 -3
tools/perf/util/debug.h
··· 27 27 extern char ui_helpline__last_msg[]; 28 28 int ui_helpline__show_help(const char *format, va_list ap); 29 29 #include "ui/progress.h" 30 - void ui__error(const char *format, ...) __attribute__((format(printf, 1, 2))); 30 + int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2))); 31 31 #endif 32 32 33 - void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); 34 - void ui__error_paranoid(void); 33 + int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); 34 + int ui__error_paranoid(void); 35 35 36 36 #endif /* __PERF_DEBUG_H */
+40
tools/perf/util/ui/browser.c
··· 169 169 self->x = 0; 170 170 } 171 171 172 + void ui_browser__handle_resize(struct ui_browser *browser) 173 + { 174 + ui__refresh_dimensions(false); 175 + ui_browser__show(browser, browser->title, ui_helpline__current); 176 + ui_browser__refresh(browser); 177 + } 178 + 179 + int ui_browser__warning(struct ui_browser *browser, const char *format, ...) 180 + { 181 + va_list args; 182 + int key; 183 + 184 + va_start(args, format); 185 + while ((key = __ui__warning("Warning!", format, args)) == K_RESIZE) 186 + ui_browser__handle_resize(browser); 187 + va_end(args); 188 + 189 + return key; 190 + } 191 + 192 + int ui_browser__help_window(struct ui_browser *browser, const char *text) 193 + { 194 + int key; 195 + 196 + while ((key = ui__help_window(text)) == K_RESIZE) 197 + ui_browser__handle_resize(browser); 198 + 199 + return key; 200 + } 201 + 202 + bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text) 203 + { 204 + int key; 205 + 206 + while ((key = ui__dialog_yesno(text)) == K_RESIZE) 207 + ui_browser__handle_resize(browser); 208 + 209 + return key == K_ENTER || toupper(key) == 'Y'; 210 + } 211 + 172 212 void ui_browser__reset_index(struct ui_browser *self) 173 213 { 174 214 self->index = self->top_idx = 0;
+5
tools/perf/util/ui/browser.h
··· 43 43 int ui_browser__refresh(struct ui_browser *self); 44 44 int ui_browser__run(struct ui_browser *browser, int delay_secs); 45 45 void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries); 46 + void ui_browser__handle_resize(struct ui_browser *browser); 47 + 48 + int ui_browser__warning(struct ui_browser *browser, const char *format, ...); 49 + int ui_browser__help_window(struct ui_browser *browser, const char *text); 50 + bool ui_browser__dialog_yesno(struct ui_browser *browser, const char *text); 46 51 47 52 void ui_browser__argv_seek(struct ui_browser *browser, off_t offset, int whence); 48 53 unsigned int ui_browser__argv_refresh(struct ui_browser *browser);
+15 -7
tools/perf/util/ui/browsers/hists.c
··· 17 17 #include "../browser.h" 18 18 #include "../helpline.h" 19 19 #include "../util.h" 20 + #include "../ui.h" 20 21 #include "map.h" 21 22 22 23 struct hist_browser { ··· 883 882 goto out_free_stack; 884 883 case 'a': 885 884 if (!browser->has_symbols) { 886 - ui__warning( 885 + ui_browser__warning(&browser->b, 887 886 "Annotation is only available for symbolic views, " 888 887 "include \"sym\" in --sort to use it."); 889 888 continue; ··· 901 900 case K_F1: 902 901 case 'h': 903 902 case '?': 904 - ui__help_window("h/?/F1 Show this window\n" 903 + ui_browser__help_window(&browser->b, 904 + "h/?/F1 Show this window\n" 905 905 "UP/DOWN/PGUP\n" 906 906 "PGDN/SPACE Navigate\n" 907 907 "q/ESC/CTRL+C Exit browser\n\n" ··· 941 939 } 942 940 case K_ESC: 943 941 if (!left_exits && 944 - !ui__dialog_yesno("Do you really want to exit?")) 942 + !ui_browser__dialog_yesno(&browser->b, 943 + "Do you really want to exit?")) 945 944 continue; 946 945 /* Fall thru */ 947 946 case 'q': ··· 995 992 996 993 if (choice == annotate) { 997 994 struct hist_entry *he; 995 + int err; 998 996 do_annotate: 999 997 he = hist_browser__selected_entry(browser); 1000 998 if (he == NULL) ··· 1004 1000 * Don't let this be freed, say, by hists__decay_entry. 1005 1001 */ 1006 1002 he->used = true; 1007 - hist_entry__tui_annotate(he, evsel->idx, nr_events, 1008 - timer, arg, delay_secs); 1003 + err = hist_entry__tui_annotate(he, evsel->idx, nr_events, 1004 + timer, arg, delay_secs); 1009 1005 he->used = false; 1010 1006 ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); 1007 + if (err) 1008 + ui_browser__handle_resize(&browser->b); 1011 1009 } else if (choice == browse_map) 1012 1010 map__browse(browser->selection->map); 1013 1011 else if (choice == zoom_dso) { ··· 1138 1132 pos = list_entry(pos->node.prev, struct perf_evsel, node); 1139 1133 goto browse_hists; 1140 1134 case K_ESC: 1141 - if (!ui__dialog_yesno("Do you really want to exit?")) 1135 + if (!ui_browser__dialog_yesno(&menu->b, 1136 + "Do you really want to exit?")) 1142 1137 continue; 1143 1138 /* Fall thru */ 1144 1139 case 'q': ··· 1151 1144 case K_LEFT: 1152 1145 continue; 1153 1146 case K_ESC: 1154 - if (!ui__dialog_yesno("Do you really want to exit?")) 1147 + if (!ui_browser__dialog_yesno(&menu->b, 1148 + "Do you really want to exit?")) 1155 1149 continue; 1156 1150 /* Fall thru */ 1157 1151 case 'q':
+6
tools/perf/util/ui/helpline.c
··· 1 1 #define _GNU_SOURCE 2 2 #include <stdio.h> 3 3 #include <stdlib.h> 4 + #include <string.h> 4 5 5 6 #include "../debug.h" 6 7 #include "helpline.h" ··· 12 11 { 13 12 } 14 13 14 + char ui_helpline__current[512]; 15 + 15 16 void ui_helpline__push(const char *msg) 16 17 { 18 + const size_t sz = sizeof(ui_helpline__current); 19 + 17 20 SLsmg_gotorc(SLtt_Screen_Rows - 1, 0); 18 21 SLsmg_set_color(0); 19 22 SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols); 20 23 SLsmg_refresh(); 24 + strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0'; 21 25 } 22 26 23 27 void ui_helpline__vpush(const char *fmt, va_list ap)
+2
tools/perf/util/ui/helpline.h
··· 11 11 void ui_helpline__fpush(const char *fmt, ...); 12 12 void ui_helpline__puts(const char *msg); 13 13 14 + extern char ui_helpline__current[]; 15 + 14 16 #endif /* _PERF_UI_HELPLINE_H_ */
+16 -11
tools/perf/util/ui/util.c
··· 121 121 return ui__question_window("Help", text, "Press any key...", 0); 122 122 } 123 123 124 - bool ui__dialog_yesno(const char *msg) 124 + int ui__dialog_yesno(const char *msg) 125 125 { 126 - int answer = ui__question_window(NULL, msg, "Enter: Yes, ESC: No", 0); 127 - 128 - return answer == K_ENTER; 126 + return ui__question_window(NULL, msg, "Enter: Yes, ESC: No", 0); 129 127 } 130 128 131 - static void __ui__warning(const char *title, const char *format, va_list args) 129 + int __ui__warning(const char *title, const char *format, va_list args) 132 130 { 133 131 char *s; 134 132 135 133 if (use_browser > 0 && vasprintf(&s, format, args) > 0) { 134 + int key; 135 + 136 136 pthread_mutex_lock(&ui__lock); 137 - ui__question_window(title, s, "Press any key...", 0); 137 + key = ui__question_window(title, s, "Press any key...", 0); 138 138 pthread_mutex_unlock(&ui__lock); 139 139 free(s); 140 - return; 140 + return key; 141 141 } 142 142 143 143 fprintf(stderr, "%s:\n", title); 144 144 vfprintf(stderr, format, args); 145 + return K_ESC; 145 146 } 146 147 147 - void ui__warning(const char *format, ...) 148 + int ui__warning(const char *format, ...) 148 149 { 150 + int key; 149 151 va_list args; 150 152 151 153 va_start(args, format); 152 - __ui__warning("Warning", format, args); 154 + key = __ui__warning("Warning", format, args); 153 155 va_end(args); 156 + return key; 154 157 } 155 158 156 - void ui__error(const char *format, ...) 159 + int ui__error(const char *format, ...) 157 160 { 161 + int key; 158 162 va_list args; 159 163 160 164 va_start(args, format); 161 - __ui__warning("Error", format, args); 165 + key = __ui__warning("Error", format, args); 162 166 va_end(args); 167 + return key; 163 168 }
+3 -2
tools/perf/util/ui/util.h
··· 1 1 #ifndef _PERF_UI_UTIL_H_ 2 2 #define _PERF_UI_UTIL_H_ 1 3 3 4 - #include <stdbool.h> 4 + #include <stdarg.h> 5 5 6 6 int ui__getch(int delay_secs); 7 7 int ui__popup_menu(int argc, char * const argv[]); 8 8 int ui__help_window(const char *text); 9 - bool ui__dialog_yesno(const char *msg); 9 + int ui__dialog_yesno(const char *msg); 10 10 int ui__question_window(const char *title, const char *text, 11 11 const char *exit_msg, int delay_secs); 12 + int __ui__warning(const char *title, const char *format, va_list args); 12 13 13 14 #endif /* _PERF_UI_UTIL_H_ */