diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-05-21 11:49:57 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-05-21 11:49:57 -0400 |
commit | ff5f149b6aec8edbfa3698721667acd043009a33 (patch) | |
tree | d052553eb296dfee3f01b1cb2b717cb7ccf3127a /tools/perf/util/newt.c | |
parent | f0218b3e9974f06014b61be8987159f4a20e011e (diff) | |
parent | 580d607cd666dfabfc1c7b0fb08c8ac690c7c87f (diff) |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip into trace/tip/tracing/core-7
Conflicts:
include/linux/ftrace_event.h
include/trace/ftrace.h
kernel/trace/trace_event_perf.c
kernel/trace/trace_kprobe.c
kernel/trace/trace_syscalls.c
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r-- | tools/perf/util/newt.c | 115 |
1 files changed, 99 insertions, 16 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 6974431d212f..0b45658f7497 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
@@ -1,7 +1,15 @@ | |||
1 | #define _GNU_SOURCE | 1 | #define _GNU_SOURCE |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #undef _GNU_SOURCE | 3 | #undef _GNU_SOURCE |
4 | 4 | /* | |
5 | * slang versions <= 2.0.6 have a "#if HAVE_LONG_LONG" that breaks | ||
6 | * the build if it isn't defined. Use the equivalent one that glibc | ||
7 | * has on features.h. | ||
8 | */ | ||
9 | #include <features.h> | ||
10 | #ifndef HAVE_LONG_LONG | ||
11 | #define HAVE_LONG_LONG __GLIBC_HAVE_LONG_LONG | ||
12 | #endif | ||
5 | #include <slang.h> | 13 | #include <slang.h> |
6 | #include <stdlib.h> | 14 | #include <stdlib.h> |
7 | #include <newt.h> | 15 | #include <newt.h> |
@@ -14,6 +22,17 @@ | |||
14 | #include "sort.h" | 22 | #include "sort.h" |
15 | #include "symbol.h" | 23 | #include "symbol.h" |
16 | 24 | ||
25 | #if SLANG_VERSION < 20104 | ||
26 | #define slsmg_printf(msg, args...) SLsmg_printf((char *)msg, ##args) | ||
27 | #define slsmg_write_nstring(msg, len) SLsmg_write_nstring((char *)msg, len) | ||
28 | #define sltt_set_color(obj, name, fg, bg) SLtt_set_color(obj,(char *)name,\ | ||
29 | (char *)fg, (char *)bg) | ||
30 | #else | ||
31 | #define slsmg_printf SLsmg_printf | ||
32 | #define slsmg_write_nstring SLsmg_write_nstring | ||
33 | #define sltt_set_color SLtt_set_color | ||
34 | #endif | ||
35 | |||
17 | struct ui_progress { | 36 | struct ui_progress { |
18 | newtComponent form, scale; | 37 | newtComponent form, scale; |
19 | }; | 38 | }; |
@@ -118,6 +137,7 @@ int browser__show_help(const char *format, va_list ap) | |||
118 | 137 | ||
119 | static void newt_form__set_exit_keys(newtComponent self) | 138 | static void newt_form__set_exit_keys(newtComponent self) |
120 | { | 139 | { |
140 | newtFormAddHotKey(self, NEWT_KEY_LEFT); | ||
121 | newtFormAddHotKey(self, NEWT_KEY_ESCAPE); | 141 | newtFormAddHotKey(self, NEWT_KEY_ESCAPE); |
122 | newtFormAddHotKey(self, 'Q'); | 142 | newtFormAddHotKey(self, 'Q'); |
123 | newtFormAddHotKey(self, 'q'); | 143 | newtFormAddHotKey(self, 'q'); |
@@ -166,6 +186,48 @@ out_destroy_form: | |||
166 | return rc; | 186 | return rc; |
167 | } | 187 | } |
168 | 188 | ||
189 | static int ui__help_window(const char *text) | ||
190 | { | ||
191 | struct newtExitStruct es; | ||
192 | newtComponent tb, form = newt_form__new(); | ||
193 | int rc = -1; | ||
194 | int max_len = 0, nr_lines = 0; | ||
195 | const char *t; | ||
196 | |||
197 | if (form == NULL) | ||
198 | return -1; | ||
199 | |||
200 | t = text; | ||
201 | while (1) { | ||
202 | const char *sep = strchr(t, '\n'); | ||
203 | int len; | ||
204 | |||
205 | if (sep == NULL) | ||
206 | sep = strchr(t, '\0'); | ||
207 | len = sep - t; | ||
208 | if (max_len < len) | ||
209 | max_len = len; | ||
210 | ++nr_lines; | ||
211 | if (*sep == '\0') | ||
212 | break; | ||
213 | t = sep + 1; | ||
214 | } | ||
215 | |||
216 | tb = newtTextbox(0, 0, max_len, nr_lines, 0); | ||
217 | if (tb == NULL) | ||
218 | goto out_destroy_form; | ||
219 | |||
220 | newtTextboxSetText(tb, text); | ||
221 | newtFormAddComponent(form, tb); | ||
222 | newtCenteredWindow(max_len, nr_lines, NULL); | ||
223 | newtFormRun(form, &es); | ||
224 | newtPopWindow(); | ||
225 | rc = 0; | ||
226 | out_destroy_form: | ||
227 | newtFormDestroy(form); | ||
228 | return rc; | ||
229 | } | ||
230 | |||
169 | static bool dialog_yesno(const char *msg) | 231 | static bool dialog_yesno(const char *msg) |
170 | { | 232 | { |
171 | /* newtWinChoice should really be accepting const char pointers... */ | 233 | /* newtWinChoice should really be accepting const char pointers... */ |
@@ -249,21 +311,21 @@ static int objdump_line__show(struct objdump_line *self, struct list_head *head, | |||
249 | 311 | ||
250 | color = ui_browser__percent_color(percent, current_entry); | 312 | color = ui_browser__percent_color(percent, current_entry); |
251 | SLsmg_set_color(color); | 313 | SLsmg_set_color(color); |
252 | SLsmg_printf(" %7.2f ", percent); | 314 | slsmg_printf(" %7.2f ", percent); |
253 | if (!current_entry) | 315 | if (!current_entry) |
254 | SLsmg_set_color(HE_COLORSET_CODE); | 316 | SLsmg_set_color(HE_COLORSET_CODE); |
255 | } else { | 317 | } else { |
256 | int color = ui_browser__percent_color(0, current_entry); | 318 | int color = ui_browser__percent_color(0, current_entry); |
257 | SLsmg_set_color(color); | 319 | SLsmg_set_color(color); |
258 | SLsmg_write_nstring(" ", 9); | 320 | slsmg_write_nstring(" ", 9); |
259 | } | 321 | } |
260 | 322 | ||
261 | SLsmg_write_char(':'); | 323 | SLsmg_write_char(':'); |
262 | SLsmg_write_nstring(" ", 8); | 324 | slsmg_write_nstring(" ", 8); |
263 | if (!*self->line) | 325 | if (!*self->line) |
264 | SLsmg_write_nstring(" ", width - 18); | 326 | slsmg_write_nstring(" ", width - 18); |
265 | else | 327 | else |
266 | SLsmg_write_nstring(self->line, width - 18); | 328 | slsmg_write_nstring(self->line, width - 18); |
267 | 329 | ||
268 | return 0; | 330 | return 0; |
269 | } | 331 | } |
@@ -321,9 +383,9 @@ static int ui_browser__run(struct ui_browser *self, const char *title, | |||
321 | newtFormAddHotKey(self->form, NEWT_KEY_DOWN); | 383 | newtFormAddHotKey(self->form, NEWT_KEY_DOWN); |
322 | newtFormAddHotKey(self->form, NEWT_KEY_PGUP); | 384 | newtFormAddHotKey(self->form, NEWT_KEY_PGUP); |
323 | newtFormAddHotKey(self->form, NEWT_KEY_PGDN); | 385 | newtFormAddHotKey(self->form, NEWT_KEY_PGDN); |
386 | newtFormAddHotKey(self->form, ' '); | ||
324 | newtFormAddHotKey(self->form, NEWT_KEY_HOME); | 387 | newtFormAddHotKey(self->form, NEWT_KEY_HOME); |
325 | newtFormAddHotKey(self->form, NEWT_KEY_END); | 388 | newtFormAddHotKey(self->form, NEWT_KEY_END); |
326 | newtFormAddHotKey(self->form, NEWT_KEY_LEFT); | ||
327 | 389 | ||
328 | if (ui_browser__refresh_entries(self) < 0) | 390 | if (ui_browser__refresh_entries(self) < 0) |
329 | return -1; | 391 | return -1; |
@@ -358,6 +420,7 @@ static int ui_browser__run(struct ui_browser *self, const char *title, | |||
358 | } | 420 | } |
359 | break; | 421 | break; |
360 | case NEWT_KEY_PGDN: | 422 | case NEWT_KEY_PGDN: |
423 | case ' ': | ||
361 | if (self->first_visible_entry_idx + self->height > self->nr_entries - 1) | 424 | if (self->first_visible_entry_idx + self->height > self->nr_entries - 1) |
362 | break; | 425 | break; |
363 | 426 | ||
@@ -756,8 +819,11 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists | |||
756 | newtFormAddHotKey(self->form, 'd'); | 819 | newtFormAddHotKey(self->form, 'd'); |
757 | newtFormAddHotKey(self->form, 'T'); | 820 | newtFormAddHotKey(self->form, 'T'); |
758 | newtFormAddHotKey(self->form, 't'); | 821 | newtFormAddHotKey(self->form, 't'); |
822 | newtFormAddHotKey(self->form, '?'); | ||
823 | newtFormAddHotKey(self->form, 'H'); | ||
824 | newtFormAddHotKey(self->form, 'h'); | ||
825 | newtFormAddHotKey(self->form, NEWT_KEY_F1); | ||
759 | newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); | 826 | newtFormAddHotKey(self->form, NEWT_KEY_RIGHT); |
760 | newtFormAddHotKey(self->form, NEWT_KEY_LEFT); | ||
761 | newtFormAddComponents(self->form, self->tree, NULL); | 827 | newtFormAddComponents(self->form, self->tree, NULL); |
762 | self->selection = newt__symbol_tree_get_current(self->tree); | 828 | self->selection = newt__symbol_tree_get_current(self->tree); |
763 | 829 | ||
@@ -843,6 +909,9 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na | |||
843 | dso = browser->selection->map ? browser->selection->map->dso : NULL; | 909 | dso = browser->selection->map ? browser->selection->map->dso : NULL; |
844 | 910 | ||
845 | if (es.reason == NEWT_EXIT_HOTKEY) { | 911 | if (es.reason == NEWT_EXIT_HOTKEY) { |
912 | if (es.u.key == NEWT_KEY_F1) | ||
913 | goto do_help; | ||
914 | |||
846 | switch (toupper(es.u.key)) { | 915 | switch (toupper(es.u.key)) { |
847 | case 'A': | 916 | case 'A': |
848 | goto do_annotate; | 917 | goto do_annotate; |
@@ -850,6 +919,17 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na | |||
850 | goto zoom_dso; | 919 | goto zoom_dso; |
851 | case 'T': | 920 | case 'T': |
852 | goto zoom_thread; | 921 | goto zoom_thread; |
922 | case 'H': | ||
923 | case '?': | ||
924 | do_help: | ||
925 | ui__help_window("-> Zoom into DSO/Threads & Annotate current symbol\n" | ||
926 | "<- Zoom out\n" | ||
927 | "a Annotate current symbol\n" | ||
928 | "h/?/F1 Show this window\n" | ||
929 | "d Zoom into current DSO\n" | ||
930 | "t Zoom into current Thread\n" | ||
931 | "q/CTRL+C Exit browser"); | ||
932 | continue; | ||
853 | default:; | 933 | default:; |
854 | } | 934 | } |
855 | if (toupper(es.u.key) == 'Q' || | 935 | if (toupper(es.u.key) == 'Q' || |
@@ -988,23 +1068,26 @@ static struct newtPercentTreeColors { | |||
988 | void setup_browser(void) | 1068 | void setup_browser(void) |
989 | { | 1069 | { |
990 | struct newtPercentTreeColors *c = &defaultPercentTreeColors; | 1070 | struct newtPercentTreeColors *c = &defaultPercentTreeColors; |
991 | if (!isatty(1)) | 1071 | |
1072 | if (!isatty(1) || !use_browser) { | ||
1073 | setup_pager(); | ||
992 | return; | 1074 | return; |
1075 | } | ||
993 | 1076 | ||
994 | use_browser = true; | 1077 | use_browser = 1; |
995 | newtInit(); | 1078 | newtInit(); |
996 | newtCls(); | 1079 | newtCls(); |
997 | ui_helpline__puts(" "); | 1080 | ui_helpline__puts(" "); |
998 | SLtt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg); | 1081 | sltt_set_color(HE_COLORSET_TOP, NULL, c->topColorFg, c->topColorBg); |
999 | SLtt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg); | 1082 | sltt_set_color(HE_COLORSET_MEDIUM, NULL, c->mediumColorFg, c->mediumColorBg); |
1000 | SLtt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg); | 1083 | sltt_set_color(HE_COLORSET_NORMAL, NULL, c->normalColorFg, c->normalColorBg); |
1001 | SLtt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg); | 1084 | sltt_set_color(HE_COLORSET_SELECTED, NULL, c->selColorFg, c->selColorBg); |
1002 | SLtt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg); | 1085 | sltt_set_color(HE_COLORSET_CODE, NULL, c->codeColorFg, c->codeColorBg); |
1003 | } | 1086 | } |
1004 | 1087 | ||
1005 | void exit_browser(bool wait_for_ok) | 1088 | void exit_browser(bool wait_for_ok) |
1006 | { | 1089 | { |
1007 | if (use_browser) { | 1090 | if (use_browser > 0) { |
1008 | if (wait_for_ok) { | 1091 | if (wait_for_ok) { |
1009 | char title[] = "Fatal Error", ok[] = "Ok"; | 1092 | char title[] = "Fatal Error", ok[] = "Ok"; |
1010 | newtWinMessage(title, ok, browser__last_msg); | 1093 | newtWinMessage(title, ok, browser__last_msg); |