aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-11 17:01:23 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-11 17:01:23 -0400
commit3798ed7bc7ade26d3f59506cd06288615dfc7585 (patch)
treea7df9d321398edf6994dbfc10134add08f2621b3 /tools
parentd11c7addfe0fa501cb54c824c0fac3481d527433 (diff)
perf ui: Add ui_helpline methods
Initially this was just to be able to have a printf like method to prepare the formatted string and then pass to newtPushHelpLine, but as we already have for ui_progress, etc, its a step in identifying a restricted, highlevel set of widgets we can then have implementations for multiple widget sets (GTK, etc). Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/newt.c69
1 files changed, 50 insertions, 19 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 638b519e72b8..daa86efffce6 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -57,6 +57,43 @@ void ui_progress__delete(struct ui_progress *self)
57 free(self); 57 free(self);
58} 58}
59 59
60static void ui_helpline__pop(void)
61{
62 newtPopHelpLine();
63}
64
65static void ui_helpline__push(const char *msg)
66{
67 newtPushHelpLine(msg);
68}
69
70static void ui_helpline__vpush(const char *fmt, va_list ap)
71{
72 char *s;
73
74 if (vasprintf(&s, fmt, ap) < 0)
75 vfprintf(stderr, fmt, ap);
76 else {
77 ui_helpline__push(s);
78 free(s);
79 }
80}
81
82static void ui_helpline__fpush(const char *fmt, ...)
83{
84 va_list ap;
85
86 va_start(ap, fmt);
87 ui_helpline__vpush(fmt, ap);
88 va_end(ap);
89}
90
91static void ui_helpline__puts(const char *msg)
92{
93 ui_helpline__pop();
94 ui_helpline__push(msg);
95}
96
60static char browser__last_msg[1024]; 97static char browser__last_msg[1024];
61 98
62int browser__show_help(const char *format, va_list ap) 99int browser__show_help(const char *format, va_list ap)
@@ -69,8 +106,7 @@ int browser__show_help(const char *format, va_list ap)
69 backlog += ret; 106 backlog += ret;
70 107
71 if (browser__last_msg[backlog - 1] == '\n') { 108 if (browser__last_msg[backlog - 1] == '\n') {
72 newtPopHelpLine(); 109 ui_helpline__puts(browser__last_msg);
73 newtPushHelpLine(browser__last_msg);
74 newtRefresh(); 110 newtRefresh();
75 backlog = 0; 111 backlog = 0;
76 } 112 }
@@ -340,7 +376,7 @@ static void map_symbol__annotate_browser(const struct map_symbol *self,
340 if (fp == NULL) 376 if (fp == NULL)
341 goto out_free_str; 377 goto out_free_str;
342 378
343 newtPushHelpLine("Press ESC to exit"); 379 ui_helpline__push("Press ESC to exit");
344 newtGetScreenSize(&cols, &rows); 380 newtGetScreenSize(&cols, &rows);
345 tree = newtListbox(0, 0, rows - 5, NEWT_FLAG_SCROLL); 381 tree = newtListbox(0, 0, rows - 5, NEWT_FLAG_SCROLL);
346 382
@@ -370,7 +406,7 @@ static void map_symbol__annotate_browser(const struct map_symbol *self,
370 newtFormRun(form, &es); 406 newtFormRun(form, &es);
371 newtFormDestroy(form); 407 newtFormDestroy(form);
372 newtPopWindow(); 408 newtPopWindow();
373 newtPopHelpLine(); 409 ui_helpline__pop();
374out_free_str: 410out_free_str:
375 free(str); 411 free(str);
376} 412}
@@ -539,7 +575,7 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
539 if (browser == NULL) 575 if (browser == NULL)
540 return -1; 576 return -1;
541 577
542 newtPushHelpLine(helpline); 578 ui_helpline__push(helpline);
543 579
544 hist_browser__title(msg, sizeof(msg), input_name, 580 hist_browser__title(msg, sizeof(msg), input_name,
545 dso_filter, thread_filter); 581 dso_filter, thread_filter);
@@ -602,8 +638,7 @@ int hists__browse(struct hists *self, const char *helpline, const char *input_na
602do_annotate: 638do_annotate:
603 if (choice == annotate) { 639 if (choice == annotate) {
604 if (browser->selection->map->dso->origin == DSO__ORIG_KERNEL) { 640 if (browser->selection->map->dso->origin == DSO__ORIG_KERNEL) {
605 newtPopHelpLine(); 641 ui_helpline__puts("No vmlinux file found, can't "
606 newtPushHelpLine("No vmlinux file found, can't "
607 "annotate with just a " 642 "annotate with just a "
608 "kallsyms file"); 643 "kallsyms file");
609 continue; 644 continue;
@@ -611,13 +646,11 @@ do_annotate:
611 map_symbol__annotate_browser(browser->selection, input_name); 646 map_symbol__annotate_browser(browser->selection, input_name);
612 } else if (choice == zoom_dso) { 647 } else if (choice == zoom_dso) {
613 if (dso_filter) { 648 if (dso_filter) {
614 newtPopHelpLine(); 649 ui_helpline__pop();
615 dso_filter = NULL; 650 dso_filter = NULL;
616 } else { 651 } else {
617 snprintf(msg, sizeof(msg), 652 ui_helpline__fpush("To zoom out press -> + \"Zoom out of %s DSO\"",
618 "To zoom out press -> + \"Zoom out of %s DSO\"", 653 dso->kernel ? "the Kernel" : dso->short_name);
619 dso->kernel ? "the Kernel" : dso->short_name);
620 newtPushHelpLine(msg);
621 dso_filter = dso; 654 dso_filter = dso;
622 } 655 }
623 hists__filter_by_dso(self, dso_filter); 656 hists__filter_by_dso(self, dso_filter);
@@ -627,14 +660,12 @@ do_annotate:
627 goto out; 660 goto out;
628 } else if (choice == zoom_thread) { 661 } else if (choice == zoom_thread) {
629 if (thread_filter) { 662 if (thread_filter) {
630 newtPopHelpLine(); 663 ui_helpline__pop();
631 thread_filter = NULL; 664 thread_filter = NULL;
632 } else { 665 } else {
633 snprintf(msg, sizeof(msg), 666 ui_helpline__fpush("To zoom out press -> + \"Zoom out of %s(%d) thread\"",
634 "To zoom out press -> + \"Zoom out of %s(%d) thread\"", 667 thread->comm_set ? thread->comm : "",
635 (thread->comm_set ? thread->comm : ""), 668 thread->pid);
636 thread->pid);
637 newtPushHelpLine(msg);
638 thread_filter = thread; 669 thread_filter = thread;
639 } 670 }
640 hists__filter_by_thread(self, thread_filter); 671 hists__filter_by_thread(self, thread_filter);
@@ -658,7 +689,7 @@ void setup_browser(void)
658 use_browser = true; 689 use_browser = true;
659 newtInit(); 690 newtInit();
660 newtCls(); 691 newtCls();
661 newtPushHelpLine(" "); 692 ui_helpline__puts(" ");
662} 693}
663 694
664void exit_browser(bool wait_for_ok) 695void exit_browser(bool wait_for_ok)