linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object
@ 2012-11-14 16:47 Namhyung Kim
  2012-11-14 16:47 ` [PATCH 1/5] perf ui: Always compile error printing code Namhyung Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Namhyung Kim @ 2012-11-14 16:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Steven Rostedt, David Ahern,
	Jiri Olsa, Pekka Enberg, Andi Kleen, LKML

Hi,

This is an RFC patchset to separate GTK GUI codes to a shared object,
called libperf-gtk.so and use it with libdl.  It's in an early-stage
so probably has some rough edges, but I'd like to get some comments.

For now, the libperf-gtk.so (I'm open to a better name suggestion)
contains whole libperf.a and libtraceevent.a for simplicity.  And
because of that, every single object in perf tools needs to be built
as a PIC like libtraceevent does.

As a result, library dependency of the perf itself reduced like this:

  $ ldd perf
	linux-vdso.so.1 =>  (0x00007fff375d5000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00007f75218ef000)
	librt.so.1 => /lib/librt.so.1 (0x00007f75216e7000)
	libelf.so.1 => /usr/lib/libelf.so.1 (0x00007f75214d2000)
	libm.so.6 => /lib/libm.so.6 (0x00007f752124f000)
	libdw.so.1 => /usr/lib/libdw.so.1 (0x00007f752101d000)
	libaudit.so.0 => /lib/libaudit.so.0 (0x00007f7520e02000)
	libnewt.so.0.52 => /usr/lib/libnewt.so.0.52 (0x00007f7520bec000)
	libslang.so.2 => /lib/libslang.so.2 (0x00007f7520888000)
	libperl.so.5.10 => /usr/lib/libperl.so.5.10 (0x00007f752051c000)
	libdl.so.2 => /lib/libdl.so.2 (0x00007f7520318000)
	libc.so.6 => /lib/libc.so.6 (0x00007f751ff92000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f7521b30000)
	libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007f751fd58000)
	libutil.so.1 => /lib/libutil.so.1 (0x00007f751fb55000)
	libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007f751f6a4000)
	libbfd-2.20.1-system.20100303.so => /usr/lib/libbfd-2.20.1-system.20100303.so (0x00007f751f3bd000)
	libbz2.so.1.0 => /lib/libbz2.so.1.0 (0x00007f751f1ac000)
	libz.so.1 => /lib/libz.so.1 (0x00007f751ef95000)
	libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007f751ed42000)
	libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007f751e9b1000)

  $ ldd libperf-gtk.so
	linux-vdso.so.1 =>  (0x00007ffffa1e8000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x00007f82dd32e000)
	librt.so.1 => /lib/librt.so.1 (0x00007f82dd126000)
	libelf.so.1 => /usr/lib/libelf.so.1 (0x00007f82dcf11000)
	libm.so.6 => /lib/libm.so.6 (0x00007f82dcc8e000)
	libdw.so.1 => /usr/lib/libdw.so.1 (0x00007f82dca5c000)
	libaudit.so.0 => /lib/libaudit.so.0 (0x00007f82dc841000)
	libnewt.so.0.52 => /usr/lib/libnewt.so.0.52 (0x00007f82dc62b000)
	libslang.so.2 => /lib/libslang.so.2 (0x00007f82dc2c7000)
	libperl.so.5.10 => /usr/lib/libperl.so.5.10 (0x00007f82dbf5b000)
	libdl.so.2 => /lib/libdl.so.2 (0x00007f82dbd57000)
	libc.so.6 => /lib/libc.so.6 (0x00007f82db9d1000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f82dd8b8000)
	libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007f82db797000)
	libutil.so.1 => /lib/libutil.so.1 (0x00007f82db594000)
	libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007f82db0e3000)
	libbfd-2.20.1-system.20100303.so => /usr/lib/libbfd-2.20.1-system.20100303.so (0x00007f82dadfc000)
	libgtk-x11-2.0.so.0 => /usr/lib/libgtk-x11-2.0.so.0 (0x00007f82da7da000)
	libgdk-x11-2.0.so.0 => /usr/lib/libgdk-x11-2.0.so.0 (0x00007f82da52d000)
	libatk-1.0.so.0 => /usr/lib/libatk-1.0.so.0 (0x00007f82da30b000)
	libgio-2.0.so.0 => /usr/lib/libgio-2.0.so.0 (0x00007f82da058000)
	libpangoft2-1.0.so.0 => /usr/lib/libpangoft2-1.0.so.0 (0x00007f82d9e2e000)
	libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0 (0x00007f82d9c11000)
	libpangocairo-1.0.so.0 => /usr/lib/libpangocairo-1.0.so.0 (0x00007f82d9a04000)
	libcairo.so.2 => /usr/lib/libcairo.so.2 (0x00007f82d9781000)
	libpango-1.0.so.0 => /usr/lib/libpango-1.0.so.0 (0x00007f82d9536000)
	libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x00007f82d92b0000)
	libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x00007f82d907b000)
	libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x00007f82d8e32000)
	libgmodule-2.0.so.0 => /usr/lib/libgmodule-2.0.so.0 (0x00007f82d8c2e000)
	libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00007f82d8a29000)
	libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00007f82d874a000)
	libbz2.so.1.0 => /lib/libbz2.so.1.0 (0x00007f82d8539000)
	libz.so.1 => /lib/libz.so.1 (0x00007f82d8322000)
	libssl.so.0.9.8 => /lib/libssl.so.0.9.8 (0x00007f82d80cf000)
	libcrypto.so.0.9.8 => /lib/libcrypto.so.0.9.8 (0x00007f82d7d3e000)
	libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f82d7b2b000)
	libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00007f82d7921000)
	libXi.so.6 => /usr/lib/libXi.so.6 (0x00007f82d750d000)
	libXrandr.so.2 => /usr/lib/libXrandr.so.2 (0x00007f82d7304000)
	libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x00007f82d70fa000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f82d6dc3000)
	libXcomposite.so.1 => /usr/lib/libXcomposite.so.1 (0x00007f82d6bc0000)
	libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x00007f82d69bd000)
	libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x00007f82d67b6000)
	libpcre.so.3 => /lib/libpcre.so.3 (0x00007f82d6588000)
	libresolv.so.2 => /lib/libresolv.so.2 (0x00007f82d636e000)
	libselinux.so.1 => /lib/libselinux.so.1 (0x00007f82d6150000)
	libpixman-1.so.0 => /usr/lib/libpixman-1.so.0 (0x00007f82d5ef6000)
	libdirectfb-1.2.so.0 => /usr/lib/libdirectfb-1.2.so.0 (0x00007f82d5c73000)
	libfusion-1.2.so.0 => /usr/lib/libfusion-1.2.so.0 (0x00007f82d5a69000)
	libdirect-1.2.so.0 => /usr/lib/libdirect-1.2.so.0 (0x00007f82d584f000)
	libpng12.so.0 => /lib/libpng12.so.0 (0x00007f82d5628000)
	libxcb-render-util.so.0 => /usr/lib/libxcb-render-util.so.0 (0x00007f82d5424000)
	libxcb-render.so.0 => /usr/lib/libxcb-render.so.0 (0x00007f82d521a000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f82d4ffe000)
	libexpat.so.1 => /lib/libexpat.so.1 (0x00007f82d4dd4000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f82d4bcf000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f82d49c9000)

To run GTK report browser, you can do it with usual --gtk option but
you might need to setup LD_LIBRARY_PATH.

  $ LD_LIBRARY_PATH=$PWD ./perf report --gtk

Missing LD_LIBRARY_PATH will lead to a fallback TUI or stdio (for 
NO_NEWT=1 build) report browser.

Patch 0001 is a resend version of my previous series, and
Patch 0002 is a preparation for smooth transition to libperf-gtk.so.
Patch 0003-0005 separate out the libperf-gtk.so and use it with libdl.

You can get this at my perf/separate branch:

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git  perf/separate-v1

Any comments are welcome, thanks.
Namhyung


Namhyung Kim (5):
  perf ui: Always compile error printing code
  perf ui/helpline: Introduce ui_helpline__vshow()
  perf tools: Separate out GTK codes to libperf-gtk.so
  perf tools: Setup GTK browser dynamically
  perf report: Run dynamic loaded GTK browser

 tools/perf/Makefile          |   49 +++++++++++++++++++++++-----------------
 tools/perf/builtin-report.c  |   16 ++++++++++---
 tools/perf/ui/gtk/gtk.h      |    8 +++++++
 tools/perf/ui/gtk/helpline.c |   23 ++++++++++---------
 tools/perf/ui/helpline.c     |   12 ++++++++++
 tools/perf/ui/helpline.h     |   22 ++----------------
 tools/perf/ui/setup.c        |   51 ++++++++++++++++++++++++++++++++++++++++--
 tools/perf/ui/tui/helpline.c |   29 ++++++++++++------------
 tools/perf/ui/ui.h           |   12 +---------
 tools/perf/ui/util.c         |   10 +++++++++
 tools/perf/util/debug.c      |   28 ++---------------------
 tools/perf/util/debug.h      |   33 ++-------------------------
 tools/perf/util/hist.h       |   13 -----------
 13 files changed, 154 insertions(+), 152 deletions(-)

-- 
1.7.9.2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/5] perf ui: Always compile error printing code
  2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
@ 2012-11-14 16:47 ` Namhyung Kim
  2013-01-24 18:36   ` [tip:perf/core] " tip-bot for Namhyung Kim
  2012-11-14 16:47 ` [PATCH 2/5] perf ui/helpline: Introduce ui_helpline__vshow() Namhyung Kim
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2012-11-14 16:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Steven Rostedt, David Ahern,
	Jiri Olsa, Pekka Enberg, Andi Kleen, LKML, Namhyung Kim

From: Namhyung Kim <namhyung.kim@lge.com>

It is used everywhere so always build it regardless of ui engine.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Makefile     |   14 +++++---------
 tools/perf/ui/util.c    |   10 ++++++++++
 tools/perf/util/debug.c |   22 ----------------------
 tools/perf/util/debug.h |   33 ++-------------------------------
 4 files changed, 17 insertions(+), 62 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index a7c6aa8d4a8b..cd1f346a9f8b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -350,8 +350,11 @@ LIB_H += util/rblist.h
 LIB_H += util/intlist.h
 LIB_H += util/perf_regs.h
 LIB_H += util/unwind.h
-LIB_H += ui/helpline.h
 LIB_H += util/vdso.h
+LIB_H += ui/helpline.h
+LIB_H += ui/progress.h
+LIB_H += ui/util.h
+LIB_H += ui/ui.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -425,6 +428,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
 LIB_OBJS += $(OUTPUT)ui/progress.o
+LIB_OBJS += $(OUTPUT)ui/util.o
 LIB_OBJS += $(OUTPUT)ui/hist.o
 LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
 
@@ -618,7 +622,6 @@ ifndef NO_NEWT
 		LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
 		LIB_OBJS += $(OUTPUT)ui/browsers/map.o
 		LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
-		LIB_OBJS += $(OUTPUT)ui/util.o
 		LIB_OBJS += $(OUTPUT)ui/tui/setup.o
 		LIB_OBJS += $(OUTPUT)ui/tui/util.o
 		LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
@@ -627,9 +630,6 @@ ifndef NO_NEWT
 		LIB_H += ui/browsers/map.h
 		LIB_H += ui/keysyms.h
 		LIB_H += ui/libslang.h
-		LIB_H += ui/progress.h
-		LIB_H += ui/util.h
-		LIB_H += ui/ui.h
 	endif
 endif
 
@@ -649,10 +649,6 @@ ifndef NO_GTK2
 		LIB_OBJS += $(OUTPUT)ui/gtk/util.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
-		# Make sure that it'd be included only once.
-		ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
-			LIB_OBJS += $(OUTPUT)ui/util.o
-		endif
 	endif
 endif
 
diff --git a/tools/perf/ui/util.c b/tools/perf/ui/util.c
index 4f989774c8c6..3014a7cd5271 100644
--- a/tools/perf/ui/util.c
+++ b/tools/perf/ui/util.c
@@ -52,6 +52,16 @@ int ui__warning(const char *format, ...)
 	return ret;
 }
 
+int ui__error_paranoid(void)
+{
+	return ui__error("Permission error - are you root?\n"
+		    "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
+		    " -1 - Not paranoid at all\n"
+		    "  0 - Disallow raw tracepoint access for unpriv\n"
+		    "  1 - Disallow cpu events for unpriv\n"
+		    "  2 - Disallow kernel profiling for unpriv\n");
+}
+
 
 /**
  * perf_error__register - Register error logging functions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 03f830b48148..39861a2a7d18 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -49,28 +49,6 @@ int dump_printf(const char *fmt, ...)
 	return ret;
 }
 
-#if !defined(NEWT_SUPPORT) && !defined(GTK2_SUPPORT)
-int ui__warning(const char *format, ...)
-{
-	va_list args;
-
-	va_start(args, format);
-	vfprintf(stderr, format, args);
-	va_end(args);
-	return 0;
-}
-#endif
-
-int ui__error_paranoid(void)
-{
-	return ui__error("Permission error - are you root?\n"
-		    "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
-		    " -1 - Not paranoid at all\n"
-		    "  0 - Disallow raw tracepoint access for unpriv\n"
-		    "  1 - Disallow cpu events for unpriv\n"
-		    "  2 - Disallow kernel profiling for unpriv\n");
-}
-
 void trace_event(union perf_event *event)
 {
 	unsigned char *raw_event = (void *)event;
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 83e8d234af6b..6e2667fb8211 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -5,6 +5,8 @@
 #include <stdbool.h>
 #include "event.h"
 #include "../ui/helpline.h"
+#include "../ui/progress.h"
+#include "../ui/util.h"
 
 extern int verbose;
 extern bool quiet, dump_trace;
@@ -12,38 +14,7 @@ extern bool quiet, dump_trace;
 int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
 void trace_event(union perf_event *event);
 
-struct ui_progress;
-struct perf_error_ops;
-
-#if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
-
-#include "../ui/progress.h"
 int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-#include "../ui/util.h"
-
-#else
-
-static inline void ui_progress__update(u64 curr __maybe_unused,
-				       u64 total __maybe_unused,
-				       const char *title __maybe_unused) {}
-static inline void ui_progress__finish(void) {}
-
-#define ui__error(format, arg...) ui__warning(format, ##arg)
-
-static inline int
-perf_error__register(struct perf_error_ops *eops __maybe_unused)
-{
-	return 0;
-}
-
-static inline int
-perf_error__unregister(struct perf_error_ops *eops __maybe_unused)
-{
-	return 0;
-}
-
-#endif /* NEWT_SUPPORT || GTK2_SUPPORT */
-
 int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
 int ui__error_paranoid(void);
 
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/5] perf ui/helpline: Introduce ui_helpline__vshow()
  2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
  2012-11-14 16:47 ` [PATCH 1/5] perf ui: Always compile error printing code Namhyung Kim
@ 2012-11-14 16:47 ` Namhyung Kim
  2013-01-24 18:37   ` [tip:perf/core] " tip-bot for Namhyung Kim
  2012-11-14 16:47 ` [PATCH 3/5] perf tools: Separate out GTK codes to libperf-gtk.so Namhyung Kim
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Namhyung Kim @ 2012-11-14 16:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Steven Rostedt, David Ahern,
	Jiri Olsa, Pekka Enberg, Andi Kleen, LKML, Namhyung Kim

From: Namhyung Kim <namhyung.kim@lge.com>

The ui_helpline__vshow() will be used for pr_* functions.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/gtk/helpline.c |   23 ++++++++++++-----------
 tools/perf/ui/helpline.c     |   12 ++++++++++++
 tools/perf/ui/helpline.h     |   22 ++--------------------
 tools/perf/ui/tui/helpline.c |   29 +++++++++++++++--------------
 tools/perf/util/debug.c      |    6 ++----
 5 files changed, 43 insertions(+), 49 deletions(-)

diff --git a/tools/perf/ui/gtk/helpline.c b/tools/perf/ui/gtk/helpline.c
index 5db4432ff12a..3388cbd12186 100644
--- a/tools/perf/ui/gtk/helpline.c
+++ b/tools/perf/ui/gtk/helpline.c
@@ -24,17 +24,7 @@ static void gtk_helpline_push(const char *msg)
 			   pgctx->statbar_ctx_id, msg);
 }
 
-static struct ui_helpline gtk_helpline_fns = {
-	.pop	= gtk_helpline_pop,
-	.push	= gtk_helpline_push,
-};
-
-void perf_gtk__init_helpline(void)
-{
-	helpline_fns = &gtk_helpline_fns;
-}
-
-int perf_gtk__show_helpline(const char *fmt, va_list ap)
+static int gtk_helpline_show(const char *fmt, va_list ap)
 {
 	int ret;
 	char *ptr;
@@ -54,3 +44,14 @@ int perf_gtk__show_helpline(const char *fmt, va_list ap)
 
 	return ret;
 }
+
+static struct ui_helpline gtk_helpline_fns = {
+	.pop	= gtk_helpline_pop,
+	.push	= gtk_helpline_push,
+	.show	= gtk_helpline_show,
+};
+
+void perf_gtk__init_helpline(void)
+{
+	helpline_fns = &gtk_helpline_fns;
+}
diff --git a/tools/perf/ui/helpline.c b/tools/perf/ui/helpline.c
index a49bcf3c190b..700fb3cfa1c7 100644
--- a/tools/perf/ui/helpline.c
+++ b/tools/perf/ui/helpline.c
@@ -16,9 +16,16 @@ static void nop_helpline__push(const char *msg __maybe_unused)
 {
 }
 
+static int nop_helpline__show(const char *fmt __maybe_unused,
+			       va_list ap __maybe_unused)
+{
+	return 0;
+}
+
 static struct ui_helpline default_helpline_fns = {
 	.pop	= nop_helpline__pop,
 	.push	= nop_helpline__push,
+	.show	= nop_helpline__show,
 };
 
 struct ui_helpline *helpline_fns = &default_helpline_fns;
@@ -59,3 +66,8 @@ void ui_helpline__puts(const char *msg)
 	ui_helpline__pop();
 	ui_helpline__push(msg);
 }
+
+int ui_helpline__vshow(const char *fmt, va_list ap)
+{
+	return helpline_fns->show(fmt, ap);
+}
diff --git a/tools/perf/ui/helpline.h b/tools/perf/ui/helpline.h
index baa28a4d16b9..46181f4fc07e 100644
--- a/tools/perf/ui/helpline.h
+++ b/tools/perf/ui/helpline.h
@@ -9,6 +9,7 @@
 struct ui_helpline {
 	void (*pop)(void);
 	void (*push)(const char *msg);
+	int  (*show)(const char *fmt, va_list ap);
 };
 
 extern struct ui_helpline *helpline_fns;
@@ -20,28 +21,9 @@ void ui_helpline__push(const char *msg);
 void ui_helpline__vpush(const char *fmt, va_list ap);
 void ui_helpline__fpush(const char *fmt, ...);
 void ui_helpline__puts(const char *msg);
+int  ui_helpline__vshow(const char *fmt, va_list ap);
 
 extern char ui_helpline__current[512];
-
-#ifdef NEWT_SUPPORT
 extern char ui_helpline__last_msg[];
-int ui_helpline__show_help(const char *format, va_list ap);
-#else
-static inline int ui_helpline__show_help(const char *format __maybe_unused,
-					 va_list ap __maybe_unused)
-{
-	return 0;
-}
-#endif /* NEWT_SUPPORT */
-
-#ifdef GTK2_SUPPORT
-int perf_gtk__show_helpline(const char *format, va_list ap);
-#else
-static inline int perf_gtk__show_helpline(const char *format __maybe_unused,
-					  va_list ap __maybe_unused)
-{
-	return 0;
-}
-#endif /* GTK2_SUPPORT */
 
 #endif /* _PERF_UI_HELPLINE_H_ */
diff --git a/tools/perf/ui/tui/helpline.c b/tools/perf/ui/tui/helpline.c
index 2884d2f41e33..1c8b9afd5d6e 100644
--- a/tools/perf/ui/tui/helpline.c
+++ b/tools/perf/ui/tui/helpline.c
@@ -8,6 +8,8 @@
 #include "../ui.h"
 #include "../libslang.h"
 
+char ui_helpline__last_msg[1024];
+
 static void tui_helpline__pop(void)
 {
 }
@@ -23,20 +25,7 @@ static void tui_helpline__push(const char *msg)
 	strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0';
 }
 
-struct ui_helpline tui_helpline_fns = {
-	.pop	= tui_helpline__pop,
-	.push	= tui_helpline__push,
-};
-
-void ui_helpline__init(void)
-{
-	helpline_fns = &tui_helpline_fns;
-	ui_helpline__puts(" ");
-}
-
-char ui_helpline__last_msg[1024];
-
-int ui_helpline__show_help(const char *format, va_list ap)
+static int tui_helpline__show(const char *format, va_list ap)
 {
 	int ret;
 	static int backlog;
@@ -55,3 +44,15 @@ int ui_helpline__show_help(const char *format, va_list ap)
 
 	return ret;
 }
+
+struct ui_helpline tui_helpline_fns = {
+	.pop	= tui_helpline__pop,
+	.push	= tui_helpline__push,
+	.show	= tui_helpline__show,
+};
+
+void ui_helpline__init(void)
+{
+	helpline_fns = &tui_helpline_fns;
+	ui_helpline__puts(" ");
+}
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 39861a2a7d18..391c9a9e946f 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -23,10 +23,8 @@ int eprintf(int level, const char *fmt, ...)
 
 	if (verbose >= level) {
 		va_start(args, fmt);
-		if (use_browser == 1)
-			ret = ui_helpline__show_help(fmt, args);
-		else if (use_browser == 2)
-			ret = perf_gtk__show_helpline(fmt, args);
+		if (use_browser > 1)
+			ui_helpline__vshow(fmt, args);
 		else
 			ret = vfprintf(stderr, fmt, args);
 		va_end(args);
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/5] perf tools: Separate out GTK codes to libperf-gtk.so
  2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
  2012-11-14 16:47 ` [PATCH 1/5] perf ui: Always compile error printing code Namhyung Kim
  2012-11-14 16:47 ` [PATCH 2/5] perf ui/helpline: Introduce ui_helpline__vshow() Namhyung Kim
@ 2012-11-14 16:47 ` Namhyung Kim
  2012-11-14 16:47 ` [PATCH 4/5] perf tools: Setup GTK browser dynamically Namhyung Kim
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Namhyung Kim @ 2012-11-14 16:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Steven Rostedt, David Ahern,
	Jiri Olsa, Pekka Enberg, Andi Kleen, LKML

Separate out GTK codes to a shared object called libperf-gtk.so.
In order to do that all objects are compiled as PIC like libtraceevent.
For now whole libperf and libtraceevent are built into it.

Cc: Andi Kleen <ak@linux.intel.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Makefile |   36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index cd1f346a9f8b..502080cc1b3d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -105,7 +105,7 @@ endif
 
 CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
 EXTLIBS = -lpthread -lrt -lelf -lm
-ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
+ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -fPIC
 ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
@@ -639,17 +639,27 @@ ifndef NO_GTK2
 		msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
 	else
 		ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y)
-			BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR
+			GTK_CFLAGS = -DHAVE_GTK_INFO_BAR
 		endif
-		BASIC_CFLAGS += -DGTK2_SUPPORT
-		BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
-		EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
-		LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
-		LIB_OBJS += $(OUTPUT)ui/gtk/setup.o
-		LIB_OBJS += $(OUTPUT)ui/gtk/util.o
-		LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
-		LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
-	endif
+		GTK_CFLAGS += $(ALL_CFLAGS) -DGTK2_SUPPORT
+		GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
+		GTK_LIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
+		GTK_OBJS := $(OUTPUT)ui/gtk/browser.o
+		GTK_OBJS += $(OUTPUT)ui/gtk/setup.o
+		GTK_OBJS += $(OUTPUT)ui/gtk/util.o
+		GTK_OBJS += $(OUTPUT)ui/gtk/helpline.o
+		GTK_OBJS += $(OUTPUT)ui/gtk/progress.o
+		GTK_H := ui/gtk/gtk.h
+
+$(GTK_OBJS): %.o: %.c $(LIB_H) $(GTK_H)
+	$(QUIET_CC)$(CC) -o $@ -c $(GTK_CFLAGS) $<
+
+$(OUTPUT)libperf-gtk.so: $(GTK_OBJS) $(PERFLIBS)
+	$(QUIET_LINK)$(CC) -o $@ -shared $(GTK_CFLAGS) $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) $(GTK_LIBS)
+
+all: $(OUTPUT)libperf-gtk.so
+
+endif
 endif
 
 ifdef NO_LIBPERL
@@ -1098,8 +1108,8 @@ $(INSTALL_DOC_TARGETS):
 ### Cleaning rules
 
 clean: $(LIBTRACEEVENT)-clean
-	$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
-	$(RM) $(ALL_PROGRAMS) perf
+	$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(GTK_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
+	$(RM) $(ALL_PROGRAMS) $(OUTPUT)libperf-gtk.so
 	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
 	$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
 	$(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/5] perf tools: Setup GTK browser dynamically
  2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
                   ` (2 preceding siblings ...)
  2012-11-14 16:47 ` [PATCH 3/5] perf tools: Separate out GTK codes to libperf-gtk.so Namhyung Kim
@ 2012-11-14 16:47 ` Namhyung Kim
  2012-11-14 16:47 ` [PATCH 5/5] perf report: Run dynamic loaded GTK browser Namhyung Kim
  2012-11-15  7:43 ` [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Pekka Enberg
  5 siblings, 0 replies; 10+ messages in thread
From: Namhyung Kim @ 2012-11-14 16:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Steven Rostedt, David Ahern,
	Jiri Olsa, Pekka Enberg, Andi Kleen, LKML

Call setup/exit GTK browser function using libdl.

Cc: Andi Kleen <ak@linux.intel.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/gtk/gtk.h |    3 +++
 tools/perf/ui/setup.c   |   51 +++++++++++++++++++++++++++++++++++++++++++++--
 tools/perf/ui/ui.h      |   12 +----------
 3 files changed, 53 insertions(+), 13 deletions(-)

diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 856320e2cc05..8ed6a1288969 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -19,6 +19,9 @@ struct perf_gtk_context {
 	guint statbar_ctx_id;
 };
 
+int perf_gtk__init(void);
+void perf_gtk__exit(bool wait_for_ok);
+
 extern struct perf_gtk_context *pgctx;
 
 static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index ebb4cc107876..731c3e4c8156 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -1,4 +1,5 @@
 #include <pthread.h>
+#include <dlfcn.h>
 
 #include "../util/cache.h"
 #include "../util/debug.h"
@@ -6,6 +7,52 @@
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 
+#ifdef GTK2_SUPPORT
+void *perf_gtk_handle;
+
+static int setup_gtk_browser(void)
+{
+	int (*perf_ui_init)(void);
+
+	perf_gtk_handle = dlopen("libperf-gtk.so", RTLD_LAZY);
+	if (perf_gtk_handle == NULL)
+		return -1;
+
+	perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
+	if (perf_ui_init == NULL)
+		goto out_close;
+
+	if (perf_ui_init() == 0)
+		return 0;
+
+out_close:
+	dlclose(perf_gtk_handle);
+	return -1;
+}
+
+static void exit_gtk_browser(bool wait_for_ok)
+{
+	void (*perf_ui_exit)(bool);
+
+	if (perf_gtk_handle == NULL)
+		return;
+
+	perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit");
+	if (perf_ui_exit == NULL)
+		goto out_close;
+
+	perf_ui_exit(wait_for_ok);
+
+out_close:
+	dlclose(perf_gtk_handle);
+
+	perf_gtk_handle = NULL;
+}
+#else
+static inline int setup_gtk_browser(void) { return -1; }
+static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
+#endif
+
 void setup_browser(bool fallback_to_pager)
 {
 	if (!isatty(1) || dump_trace)
@@ -17,7 +64,7 @@ void setup_browser(bool fallback_to_pager)
 
 	switch (use_browser) {
 	case 2:
-		if (perf_gtk__init() == 0)
+		if (setup_gtk_browser() == 0)
 			break;
 		/* fall through */
 	case 1:
@@ -39,7 +86,7 @@ void exit_browser(bool wait_for_ok)
 {
 	switch (use_browser) {
 	case 2:
-		perf_gtk__exit(wait_for_ok);
+		exit_gtk_browser(wait_for_ok);
 		break;
 
 	case 1:
diff --git a/tools/perf/ui/ui.h b/tools/perf/ui/ui.h
index d86359c99907..0e5e0c01a3ee 100644
--- a/tools/perf/ui/ui.h
+++ b/tools/perf/ui/ui.h
@@ -6,6 +6,7 @@
 #include <linux/compiler.h>
 
 extern pthread_mutex_t ui__lock;
+extern void *perf_gtk_handle;
 
 extern int use_browser;
 
@@ -23,17 +24,6 @@ static inline int ui__init(void)
 static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
 #endif
 
-#ifdef GTK2_SUPPORT
-int perf_gtk__init(void);
-void perf_gtk__exit(bool wait_for_ok);
-#else
-static inline int perf_gtk__init(void)
-{
-	return -1;
-}
-static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
-#endif
-
 void ui__refresh_dimensions(bool force);
 
 #endif /* _PERF_UI_H_ */
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/5] perf report: Run dynamic loaded GTK browser
  2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
                   ` (3 preceding siblings ...)
  2012-11-14 16:47 ` [PATCH 4/5] perf tools: Setup GTK browser dynamically Namhyung Kim
@ 2012-11-14 16:47 ` Namhyung Kim
  2012-11-15  7:43 ` [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Pekka Enberg
  5 siblings, 0 replies; 10+ messages in thread
From: Namhyung Kim @ 2012-11-14 16:47 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Steven Rostedt, David Ahern,
	Jiri Olsa, Pekka Enberg, Andi Kleen, LKML

Run GTK hist browser using libdl.

Cc: Andi Kleen <ak@linux.intel.com>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/Makefile         |    3 ++-
 tools/perf/builtin-report.c |   16 +++++++++++++---
 tools/perf/ui/gtk/gtk.h     |    5 +++++
 tools/perf/util/hist.h      |   13 -------------
 4 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 502080cc1b3d..af4c88311371 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -641,7 +641,8 @@ ifndef NO_GTK2
 		ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y)
 			GTK_CFLAGS = -DHAVE_GTK_INFO_BAR
 		endif
-		GTK_CFLAGS += $(ALL_CFLAGS) -DGTK2_SUPPORT
+		BASIC_CFLAGS += -DGTK2_SUPPORT
+		GTK_CFLAGS += $(ALL_CFLAGS)
 		GTK_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
 		GTK_LIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
 		GTK_OBJS := $(OUTPUT)ui/gtk/browser.o
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index fc251005dd3d..ac5d8915d8c5 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -7,8 +7,9 @@
  */
 #include "builtin.h"
 
-#include "util/util.h"
+#include <dlfcn.h>
 
+#include "util/util.h"
 #include "util/annotate.h"
 #include "util/color.h"
 #include <linux/list.h>
@@ -431,8 +432,17 @@ static int __cmd_report(struct perf_report *rep)
 						      NULL,
 						      &session->header.env);
 		} else if (use_browser == 2) {
-			perf_evlist__gtk_browse_hists(session->evlist, help,
-						      NULL);
+			int (*hist_browser)(struct perf_evlist *,
+					    const char *,
+					    struct hist_browser_timer *);
+
+			hist_browser = dlsym(perf_gtk_handle,
+					     "perf_evlist__gtk_browse_hists");
+			if (hist_browser == NULL) {
+				ui__error("GTK browser not found!\n");
+				goto out_delete;
+			}
+			hist_browser(session->evlist, help, NULL);
 		}
 	} else
 		perf_evlist__tty_browse_hists(session->evlist, rep, help);
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h
index 8ed6a1288969..bcd7a10d9525 100644
--- a/tools/perf/ui/gtk/gtk.h
+++ b/tools/perf/ui/gtk/gtk.h
@@ -43,4 +43,9 @@ static inline GtkWidget *perf_gtk__setup_info_bar(void)
 }
 #endif
 
+struct perf_evlist;
+struct hist_browser_timer;
+
+int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
+				  struct hist_browser_timer *hbt);
 #endif /* _PERF_GTK_H_ */
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 8b091a51e4a2..1e9b6f2ba48e 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -204,19 +204,6 @@ static inline int script_browse(const char *script_opt __maybe_unused)
 #define K_RIGHT -2
 #endif
 
-#ifdef GTK2_SUPPORT
-int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
-				  struct hist_browser_timer *hbt __maybe_unused);
-#else
-static inline
-int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused,
-				  const char *help __maybe_unused,
-				  struct hist_browser_timer *hbt __maybe_unused)
-{
-	return 0;
-}
-#endif
-
 unsigned int hists__sort_list_width(struct hists *self);
 
 double perf_diff__compute_delta(struct hist_entry *he);
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object
  2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
                   ` (4 preceding siblings ...)
  2012-11-14 16:47 ` [PATCH 5/5] perf report: Run dynamic loaded GTK browser Namhyung Kim
@ 2012-11-15  7:43 ` Pekka Enberg
  2012-11-15  8:51   ` Namhyung Kim
  5 siblings, 1 reply; 10+ messages in thread
From: Pekka Enberg @ 2012-11-15  7:43 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
	Steven Rostedt, David Ahern, Jiri Olsa, Andi Kleen, LKML

On Thu, 15 Nov 2012, Namhyung Kim wrote:
> This is an RFC patchset to separate GTK GUI codes to a shared object,
> called libperf-gtk.so and use it with libdl.  It's in an early-stage
> so probably has some rough edges, but I'd like to get some comments.
> 
> For now, the libperf-gtk.so (I'm open to a better name suggestion)
> contains whole libperf.a and libtraceevent.a for simplicity.  And
> because of that, every single object in perf tools needs to be built
> as a PIC like libtraceevent does.
> 
> As a result, library dependency of the perf itself reduced like this:

[snip]

> To run GTK report browser, you can do it with usual --gtk option but
> you might need to setup LD_LIBRARY_PATH.
> 
>   $ LD_LIBRARY_PATH=$PWD ./perf report --gtk
> 
> Missing LD_LIBRARY_PATH will lead to a fallback TUI or stdio (for 
> NO_NEWT=1 build) report browser.

What's the benefit of doing this? Requiring users to specify 
LD_LIBRARY_PATH seems like a major PITA.

			Pekka

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object
  2012-11-15  7:43 ` [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Pekka Enberg
@ 2012-11-15  8:51   ` Namhyung Kim
  0 siblings, 0 replies; 10+ messages in thread
From: Namhyung Kim @ 2012-11-15  8:51 UTC (permalink / raw)
  To: Pekka Enberg
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra,
	Steven Rostedt, David Ahern, Jiri Olsa, Andi Kleen, LKML

On Thu, 15 Nov 2012 09:43:07 +0200 (EET), Pekka Enberg wrote:
> On Thu, 15 Nov 2012, Namhyung Kim wrote:
>> This is an RFC patchset to separate GTK GUI codes to a shared object,
>> called libperf-gtk.so and use it with libdl.  It's in an early-stage
>> so probably has some rough edges, but I'd like to get some comments.
>> 
>> For now, the libperf-gtk.so (I'm open to a better name suggestion)
>> contains whole libperf.a and libtraceevent.a for simplicity.  And
>> because of that, every single object in perf tools needs to be built
>> as a PIC like libtraceevent does.
>> 
>> As a result, library dependency of the perf itself reduced like this:
>
> [snip]
>
>> To run GTK report browser, you can do it with usual --gtk option but
>> you might need to setup LD_LIBRARY_PATH.
>> 
>>   $ LD_LIBRARY_PATH=$PWD ./perf report --gtk
>> 
>> Missing LD_LIBRARY_PATH will lead to a fallback TUI or stdio (for 
>> NO_NEWT=1 build) report browser.
>
> What's the benefit of doing this? Requiring users to specify 
> LD_LIBRARY_PATH seems like a major PITA.

Nothing. ;-)  

It should be installed to a proper place - I just missed to do it before
sending it.  And with this RFC patches, I wanted to be confirmed that I
was going to the right direction before doing something silly. :)

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [tip:perf/core] perf ui: Always compile error printing code
  2012-11-14 16:47 ` [PATCH 1/5] perf ui: Always compile error printing code Namhyung Kim
@ 2013-01-24 18:36   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-01-24 18:36 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
	namhyung, jolsa, rostedt, ak, dsahern, tglx

Commit-ID:  752914208ada0d9ae0a6b3bf2906d43f3605832f
Gitweb:     http://git.kernel.org/tip/752914208ada0d9ae0a6b3bf2906d43f3605832f
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Thu, 15 Nov 2012 01:47:40 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sun, 9 Dec 2012 08:46:04 -0300

perf ui: Always compile error printing code

It is used everywhere so always build it regardless of ui engine.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1352911664-24620-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile     | 14 +++++---------
 tools/perf/ui/util.c    | 10 ++++++++++
 tools/perf/util/debug.c | 22 ----------------------
 tools/perf/util/debug.h | 33 ++-------------------------------
 4 files changed, 17 insertions(+), 62 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 891bc77..8fca560 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -378,8 +378,11 @@ LIB_H += util/rblist.h
 LIB_H += util/intlist.h
 LIB_H += util/perf_regs.h
 LIB_H += util/unwind.h
-LIB_H += ui/helpline.h
 LIB_H += util/vdso.h
+LIB_H += ui/helpline.h
+LIB_H += ui/progress.h
+LIB_H += ui/util.h
+LIB_H += ui/ui.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
@@ -453,6 +456,7 @@ LIB_OBJS += $(OUTPUT)util/stat.o
 LIB_OBJS += $(OUTPUT)ui/setup.o
 LIB_OBJS += $(OUTPUT)ui/helpline.o
 LIB_OBJS += $(OUTPUT)ui/progress.o
+LIB_OBJS += $(OUTPUT)ui/util.o
 LIB_OBJS += $(OUTPUT)ui/hist.o
 LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
 
@@ -646,7 +650,6 @@ ifndef NO_NEWT
 		LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
 		LIB_OBJS += $(OUTPUT)ui/browsers/map.o
 		LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o
-		LIB_OBJS += $(OUTPUT)ui/util.o
 		LIB_OBJS += $(OUTPUT)ui/tui/setup.o
 		LIB_OBJS += $(OUTPUT)ui/tui/util.o
 		LIB_OBJS += $(OUTPUT)ui/tui/helpline.o
@@ -655,9 +658,6 @@ ifndef NO_NEWT
 		LIB_H += ui/browsers/map.h
 		LIB_H += ui/keysyms.h
 		LIB_H += ui/libslang.h
-		LIB_H += ui/progress.h
-		LIB_H += ui/util.h
-		LIB_H += ui/ui.h
 	endif
 endif
 
@@ -677,10 +677,6 @@ ifndef NO_GTK2
 		LIB_OBJS += $(OUTPUT)ui/gtk/util.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o
 		LIB_OBJS += $(OUTPUT)ui/gtk/progress.o
-		# Make sure that it'd be included only once.
-		ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),)
-			LIB_OBJS += $(OUTPUT)ui/util.o
-		endif
 	endif
 endif
 
diff --git a/tools/perf/ui/util.c b/tools/perf/ui/util.c
index 4f98977..3014a7c 100644
--- a/tools/perf/ui/util.c
+++ b/tools/perf/ui/util.c
@@ -52,6 +52,16 @@ int ui__warning(const char *format, ...)
 	return ret;
 }
 
+int ui__error_paranoid(void)
+{
+	return ui__error("Permission error - are you root?\n"
+		    "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
+		    " -1 - Not paranoid at all\n"
+		    "  0 - Disallow raw tracepoint access for unpriv\n"
+		    "  1 - Disallow cpu events for unpriv\n"
+		    "  2 - Disallow kernel profiling for unpriv\n");
+}
+
 
 /**
  * perf_error__register - Register error logging functions
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 03f830b..39861a2a 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -49,28 +49,6 @@ int dump_printf(const char *fmt, ...)
 	return ret;
 }
 
-#if !defined(NEWT_SUPPORT) && !defined(GTK2_SUPPORT)
-int ui__warning(const char *format, ...)
-{
-	va_list args;
-
-	va_start(args, format);
-	vfprintf(stderr, format, args);
-	va_end(args);
-	return 0;
-}
-#endif
-
-int ui__error_paranoid(void)
-{
-	return ui__error("Permission error - are you root?\n"
-		    "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
-		    " -1 - Not paranoid at all\n"
-		    "  0 - Disallow raw tracepoint access for unpriv\n"
-		    "  1 - Disallow cpu events for unpriv\n"
-		    "  2 - Disallow kernel profiling for unpriv\n");
-}
-
 void trace_event(union perf_event *event)
 {
 	unsigned char *raw_event = (void *)event;
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 83e8d23..6e2667f 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -5,6 +5,8 @@
 #include <stdbool.h>
 #include "event.h"
 #include "../ui/helpline.h"
+#include "../ui/progress.h"
+#include "../ui/util.h"
 
 extern int verbose;
 extern bool quiet, dump_trace;
@@ -12,38 +14,7 @@ extern bool quiet, dump_trace;
 int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
 void trace_event(union perf_event *event);
 
-struct ui_progress;
-struct perf_error_ops;
-
-#if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
-
-#include "../ui/progress.h"
 int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-#include "../ui/util.h"
-
-#else
-
-static inline void ui_progress__update(u64 curr __maybe_unused,
-				       u64 total __maybe_unused,
-				       const char *title __maybe_unused) {}
-static inline void ui_progress__finish(void) {}
-
-#define ui__error(format, arg...) ui__warning(format, ##arg)
-
-static inline int
-perf_error__register(struct perf_error_ops *eops __maybe_unused)
-{
-	return 0;
-}
-
-static inline int
-perf_error__unregister(struct perf_error_ops *eops __maybe_unused)
-{
-	return 0;
-}
-
-#endif /* NEWT_SUPPORT || GTK2_SUPPORT */
-
 int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
 int ui__error_paranoid(void);
 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [tip:perf/core] perf ui/helpline: Introduce ui_helpline__vshow()
  2012-11-14 16:47 ` [PATCH 2/5] perf ui/helpline: Introduce ui_helpline__vshow() Namhyung Kim
@ 2013-01-24 18:37   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 10+ messages in thread
From: tip-bot for Namhyung Kim @ 2013-01-24 18:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, peterz, penberg, namhyung.kim,
	namhyung, jolsa, rostedt, ak, dsahern, tglx

Commit-ID:  b56e53312d445967f6bdb91e5667c56755e47450
Gitweb:     http://git.kernel.org/tip/b56e53312d445967f6bdb91e5667c56755e47450
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Thu, 15 Nov 2012 01:47:41 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sun, 9 Dec 2012 08:46:04 -0300

perf ui/helpline: Introduce ui_helpline__vshow()

The ui_helpline__vshow() will be used for pr_* functions.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1352911664-24620-3-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/ui/gtk/helpline.c | 23 ++++++++++++-----------
 tools/perf/ui/helpline.c     | 12 ++++++++++++
 tools/perf/ui/helpline.h     | 22 ++--------------------
 tools/perf/ui/tui/helpline.c | 29 +++++++++++++++--------------
 tools/perf/util/debug.c      |  6 ++----
 5 files changed, 43 insertions(+), 49 deletions(-)

diff --git a/tools/perf/ui/gtk/helpline.c b/tools/perf/ui/gtk/helpline.c
index 5db4432..3388cbd 100644
--- a/tools/perf/ui/gtk/helpline.c
+++ b/tools/perf/ui/gtk/helpline.c
@@ -24,17 +24,7 @@ static void gtk_helpline_push(const char *msg)
 			   pgctx->statbar_ctx_id, msg);
 }
 
-static struct ui_helpline gtk_helpline_fns = {
-	.pop	= gtk_helpline_pop,
-	.push	= gtk_helpline_push,
-};
-
-void perf_gtk__init_helpline(void)
-{
-	helpline_fns = &gtk_helpline_fns;
-}
-
-int perf_gtk__show_helpline(const char *fmt, va_list ap)
+static int gtk_helpline_show(const char *fmt, va_list ap)
 {
 	int ret;
 	char *ptr;
@@ -54,3 +44,14 @@ int perf_gtk__show_helpline(const char *fmt, va_list ap)
 
 	return ret;
 }
+
+static struct ui_helpline gtk_helpline_fns = {
+	.pop	= gtk_helpline_pop,
+	.push	= gtk_helpline_push,
+	.show	= gtk_helpline_show,
+};
+
+void perf_gtk__init_helpline(void)
+{
+	helpline_fns = &gtk_helpline_fns;
+}
diff --git a/tools/perf/ui/helpline.c b/tools/perf/ui/helpline.c
index a49bcf3..700fb3c 100644
--- a/tools/perf/ui/helpline.c
+++ b/tools/perf/ui/helpline.c
@@ -16,9 +16,16 @@ static void nop_helpline__push(const char *msg __maybe_unused)
 {
 }
 
+static int nop_helpline__show(const char *fmt __maybe_unused,
+			       va_list ap __maybe_unused)
+{
+	return 0;
+}
+
 static struct ui_helpline default_helpline_fns = {
 	.pop	= nop_helpline__pop,
 	.push	= nop_helpline__push,
+	.show	= nop_helpline__show,
 };
 
 struct ui_helpline *helpline_fns = &default_helpline_fns;
@@ -59,3 +66,8 @@ void ui_helpline__puts(const char *msg)
 	ui_helpline__pop();
 	ui_helpline__push(msg);
 }
+
+int ui_helpline__vshow(const char *fmt, va_list ap)
+{
+	return helpline_fns->show(fmt, ap);
+}
diff --git a/tools/perf/ui/helpline.h b/tools/perf/ui/helpline.h
index baa28a4..46181f4 100644
--- a/tools/perf/ui/helpline.h
+++ b/tools/perf/ui/helpline.h
@@ -9,6 +9,7 @@
 struct ui_helpline {
 	void (*pop)(void);
 	void (*push)(const char *msg);
+	int  (*show)(const char *fmt, va_list ap);
 };
 
 extern struct ui_helpline *helpline_fns;
@@ -20,28 +21,9 @@ void ui_helpline__push(const char *msg);
 void ui_helpline__vpush(const char *fmt, va_list ap);
 void ui_helpline__fpush(const char *fmt, ...);
 void ui_helpline__puts(const char *msg);
+int  ui_helpline__vshow(const char *fmt, va_list ap);
 
 extern char ui_helpline__current[512];
-
-#ifdef NEWT_SUPPORT
 extern char ui_helpline__last_msg[];
-int ui_helpline__show_help(const char *format, va_list ap);
-#else
-static inline int ui_helpline__show_help(const char *format __maybe_unused,
-					 va_list ap __maybe_unused)
-{
-	return 0;
-}
-#endif /* NEWT_SUPPORT */
-
-#ifdef GTK2_SUPPORT
-int perf_gtk__show_helpline(const char *format, va_list ap);
-#else
-static inline int perf_gtk__show_helpline(const char *format __maybe_unused,
-					  va_list ap __maybe_unused)
-{
-	return 0;
-}
-#endif /* GTK2_SUPPORT */
 
 #endif /* _PERF_UI_HELPLINE_H_ */
diff --git a/tools/perf/ui/tui/helpline.c b/tools/perf/ui/tui/helpline.c
index 2884d2f..1c8b9af 100644
--- a/tools/perf/ui/tui/helpline.c
+++ b/tools/perf/ui/tui/helpline.c
@@ -8,6 +8,8 @@
 #include "../ui.h"
 #include "../libslang.h"
 
+char ui_helpline__last_msg[1024];
+
 static void tui_helpline__pop(void)
 {
 }
@@ -23,20 +25,7 @@ static void tui_helpline__push(const char *msg)
 	strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0';
 }
 
-struct ui_helpline tui_helpline_fns = {
-	.pop	= tui_helpline__pop,
-	.push	= tui_helpline__push,
-};
-
-void ui_helpline__init(void)
-{
-	helpline_fns = &tui_helpline_fns;
-	ui_helpline__puts(" ");
-}
-
-char ui_helpline__last_msg[1024];
-
-int ui_helpline__show_help(const char *format, va_list ap)
+static int tui_helpline__show(const char *format, va_list ap)
 {
 	int ret;
 	static int backlog;
@@ -55,3 +44,15 @@ int ui_helpline__show_help(const char *format, va_list ap)
 
 	return ret;
 }
+
+struct ui_helpline tui_helpline_fns = {
+	.pop	= tui_helpline__pop,
+	.push	= tui_helpline__push,
+	.show	= tui_helpline__show,
+};
+
+void ui_helpline__init(void)
+{
+	helpline_fns = &tui_helpline_fns;
+	ui_helpline__puts(" ");
+}
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 39861a2a..391c9a9 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -23,10 +23,8 @@ int eprintf(int level, const char *fmt, ...)
 
 	if (verbose >= level) {
 		va_start(args, fmt);
-		if (use_browser == 1)
-			ret = ui_helpline__show_help(fmt, args);
-		else if (use_browser == 2)
-			ret = perf_gtk__show_helpline(fmt, args);
+		if (use_browser > 1)
+			ui_helpline__vshow(fmt, args);
 		else
 			ret = vfprintf(stderr, fmt, args);
 		va_end(args);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-01-24 18:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 16:47 [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Namhyung Kim
2012-11-14 16:47 ` [PATCH 1/5] perf ui: Always compile error printing code Namhyung Kim
2013-01-24 18:36   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-14 16:47 ` [PATCH 2/5] perf ui/helpline: Introduce ui_helpline__vshow() Namhyung Kim
2013-01-24 18:37   ` [tip:perf/core] " tip-bot for Namhyung Kim
2012-11-14 16:47 ` [PATCH 3/5] perf tools: Separate out GTK codes to libperf-gtk.so Namhyung Kim
2012-11-14 16:47 ` [PATCH 4/5] perf tools: Setup GTK browser dynamically Namhyung Kim
2012-11-14 16:47 ` [PATCH 5/5] perf report: Run dynamic loaded GTK browser Namhyung Kim
2012-11-15  7:43 ` [RFC 0/5] perf ui/gtk: Separate out GTK codes to a shared object Pekka Enberg
2012-11-15  8:51   ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).