aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2012-08-16 04:14:54 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-17 11:37:56 -0400
commit0985a94891c73740dea1e2697f9d598a4a7810ab (patch)
tree6cf8ceff2dad3e1f36415885c0aaf2e00f4a20cb /tools
parented70c609ae92e0cb03b746ab566c3cf8f2aaede4 (diff)
perf ui gtk: Add perf_gtk__show_helpline() for pr_*
Use helpline for printing error/debug messages. The code resembles a TUI counter part and only print the first line of the message. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1345104894-14205-5-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/ui/gtk/helpline.c26
-rw-r--r--tools/perf/ui/gtk/util.c5
-rw-r--r--tools/perf/ui/helpline.h23
-rw-r--r--tools/perf/ui/setup.c4
-rw-r--r--tools/perf/ui/tui/setup.c2
-rw-r--r--tools/perf/util/debug.c4
-rw-r--r--tools/perf/util/debug.h8
7 files changed, 57 insertions, 15 deletions
diff --git a/tools/perf/ui/gtk/helpline.c b/tools/perf/ui/gtk/helpline.c
index 2511b3746797..5db4432ff12a 100644
--- a/tools/perf/ui/gtk/helpline.c
+++ b/tools/perf/ui/gtk/helpline.c
@@ -1,5 +1,10 @@
1#include <stdio.h>
2#include <string.h>
3
1#include "gtk.h" 4#include "gtk.h"
5#include "../ui.h"
2#include "../helpline.h" 6#include "../helpline.h"
7#include "../../util/debug.h"
3 8
4static void gtk_helpline_pop(void) 9static void gtk_helpline_pop(void)
5{ 10{
@@ -28,3 +33,24 @@ void perf_gtk__init_helpline(void)
28{ 33{
29 helpline_fns = &gtk_helpline_fns; 34 helpline_fns = &gtk_helpline_fns;
30} 35}
36
37int perf_gtk__show_helpline(const char *fmt, va_list ap)
38{
39 int ret;
40 char *ptr;
41 static int backlog;
42
43 ret = vscnprintf(ui_helpline__current + backlog,
44 sizeof(ui_helpline__current) - backlog, fmt, ap);
45 backlog += ret;
46
47 /* only first line can be displayed */
48 ptr = strchr(ui_helpline__current, '\n');
49 if (ptr && (ptr - ui_helpline__current) <= backlog) {
50 *ptr = '\0';
51 ui_helpline__puts(ui_helpline__current);
52 backlog = 0;
53 }
54
55 return ret;
56}
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c
index 0ead373c0dfb..b8efb966f94c 100644
--- a/tools/perf/ui/gtk/util.c
+++ b/tools/perf/ui/gtk/util.c
@@ -117,11 +117,6 @@ struct perf_error_ops perf_gtk_eops = {
117 * For now, just add stubs for NO_NEWT=1 build. 117 * For now, just add stubs for NO_NEWT=1 build.
118 */ 118 */
119#ifdef NO_NEWT_SUPPORT 119#ifdef NO_NEWT_SUPPORT
120int ui_helpline__show_help(const char *format __used, va_list ap __used)
121{
122 return 0;
123}
124
125void ui_progress__update(u64 curr __used, u64 total __used, 120void ui_progress__update(u64 curr __used, u64 total __used,
126 const char *title __used) 121 const char *title __used)
127{ 122{
diff --git a/tools/perf/ui/helpline.h b/tools/perf/ui/helpline.h
index 61118b2bc242..a2487f93aa48 100644
--- a/tools/perf/ui/helpline.h
+++ b/tools/perf/ui/helpline.h
@@ -4,6 +4,8 @@
4#include <stdio.h> 4#include <stdio.h>
5#include <stdarg.h> 5#include <stdarg.h>
6 6
7#include "../util/cache.h"
8
7struct ui_helpline { 9struct ui_helpline {
8 void (*pop)(void); 10 void (*pop)(void);
9 void (*push)(const char *msg); 11 void (*push)(const char *msg);
@@ -21,4 +23,25 @@ void ui_helpline__puts(const char *msg);
21 23
22extern char ui_helpline__current[512]; 24extern char ui_helpline__current[512];
23 25
26#ifdef NO_NEWT_SUPPORT
27static inline int ui_helpline__show_help(const char *format __used,
28 va_list ap __used)
29{
30 return 0;
31}
32#else
33extern char ui_helpline__last_msg[];
34int ui_helpline__show_help(const char *format, va_list ap);
35#endif /* NO_NEWT_SUPPORT */
36
37#ifdef NO_GTK2_SUPPORT
38static inline int perf_gtk__show_helpline(const char *format __used,
39 va_list ap __used)
40{
41 return 0;
42}
43#else
44int perf_gtk__show_helpline(const char *format, va_list ap);
45#endif /* NO_GTK2_SUPPORT */
46
24#endif /* _PERF_UI_HELPLINE_H_ */ 47#endif /* _PERF_UI_HELPLINE_H_ */
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 791fb15ce350..c7820e569660 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -1,7 +1,11 @@
1#include <pthread.h>
2
1#include "../cache.h" 3#include "../cache.h"
2#include "../debug.h" 4#include "../debug.h"
3 5
4 6
7pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
8
5void setup_browser(bool fallback_to_pager) 9void setup_browser(bool fallback_to_pager)
6{ 10{
7 if (!isatty(1) || dump_trace) 11 if (!isatty(1) || dump_trace)
diff --git a/tools/perf/ui/tui/setup.c b/tools/perf/ui/tui/setup.c
index e813c1d17346..4c936e09931c 100644
--- a/tools/perf/ui/tui/setup.c
+++ b/tools/perf/ui/tui/setup.c
@@ -11,8 +11,6 @@
11#include "../libslang.h" 11#include "../libslang.h"
12#include "../keysyms.h" 12#include "../keysyms.h"
13 13
14pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
15
16static volatile int ui__need_resize; 14static volatile int ui__need_resize;
17 15
18extern struct perf_error_ops perf_tui_eops; 16extern struct perf_error_ops perf_tui_eops;
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 4dfe0bb3c322..66eb3828ceb5 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -23,8 +23,10 @@ int eprintf(int level, const char *fmt, ...)
23 23
24 if (verbose >= level) { 24 if (verbose >= level) {
25 va_start(args, fmt); 25 va_start(args, fmt);
26 if (use_browser > 0) 26 if (use_browser == 1)
27 ret = ui_helpline__show_help(fmt, args); 27 ret = ui_helpline__show_help(fmt, args);
28 else if (use_browser == 2)
29 ret = perf_gtk__show_helpline(fmt, args);
28 else 30 else
29 ret = vfprintf(stderr, fmt, args); 31 ret = vfprintf(stderr, fmt, args);
30 va_end(args); 32 va_end(args);
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 015c91dbc096..05e660cbf7e2 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -4,6 +4,7 @@
4 4
5#include <stdbool.h> 5#include <stdbool.h>
6#include "event.h" 6#include "event.h"
7#include "../ui/helpline.h"
7 8
8extern int verbose; 9extern int verbose;
9extern bool quiet, dump_trace; 10extern bool quiet, dump_trace;
@@ -15,11 +16,6 @@ struct ui_progress;
15struct perf_error_ops; 16struct perf_error_ops;
16 17
17#if defined(NO_NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) 18#if defined(NO_NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT)
18static inline int ui_helpline__show_help(const char *format __used, va_list ap __used)
19{
20 return 0;
21}
22
23static inline void ui_progress__update(u64 curr __used, u64 total __used, 19static inline void ui_progress__update(u64 curr __used, u64 total __used,
24 const char *title __used) {} 20 const char *title __used) {}
25 21
@@ -39,8 +35,6 @@ perf_error__unregister(struct perf_error_ops *eops __used)
39 35
40#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ 36#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */
41 37
42extern char ui_helpline__last_msg[];
43int ui_helpline__show_help(const char *format, va_list ap);
44#include "../ui/progress.h" 38#include "../ui/progress.h"
45int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2))); 39int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
46#include "../ui/util.h" 40#include "../ui/util.h"