perf ui/gtk: Separate out GTK codes to a shared object
Namhyung Kim
maintainercover perf ui/gtk: Separate out GTK codes to a shared object
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(-)
Signature · 1 line
1.7.9.2
Namhyung Kim
maintainerPATCH 1/5 perf ui: Always compile error printing code
From: Namhyung Kim <[email protected]>
It is used everywhere so always build it regardless of ui engine.
--- 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(-)
tools/perf/Makefile +5 -9
@@ -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
tools/perf/ui/util.c +10 -0
@@ -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
tools/perf/util/debug.c +0 -22
@@ -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;
tools/perf/util/debug.h +2 -31
@@ -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 );
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui: Always compile error printing code
Commit-ID: 752914208ada0d9ae0a6b3bf2906d43f3605832f Gitweb: http://git.kernel.org/tip/752914208ada0d9ae0a6b3bf2906d43f3605832f Author: Namhyung Kim <[email protected]> AuthorDate: Thu, 15 Nov 2012 01:47:40 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- 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(-)
tools/perf/Makefile +5 -9
@@ -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
tools/perf/ui/util.c +10 -0
@@ -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
tools/perf/util/debug.c +0 -22
@@ -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;
tools/perf/util/debug.h +2 -31
@@ -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 );
Namhyung Kim
maintainerPATCH 2/5 perf ui/helpline: Introduce ui_helpline__vshow()
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The ui_helpline__vshow() will be used for pr_* functions.
--- 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(-)
tools/perf/ui/gtk/helpline.c +12 -11
@@ -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 = >k_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 = >k_helpline_fns; +}
tools/perf/ui/helpline.c +12 -0
@@ -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); +}
tools/perf/ui/helpline.h +2 -20
@@ -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_ */
tools/perf/ui/tui/helpline.c +15 -14
@@ -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 (" " ); +}
tools/perf/util/debug.c +2 -4
@@ -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);
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui/helpline: Introduce ui_helpline__vshow()
Commit-ID: b56e53312d445967f6bdb91e5667c56755e47450 Gitweb: http://git.kernel.org/tip/b56e53312d445967f6bdb91e5667c56755e47450 Author: Namhyung Kim <[email protected]> AuthorDate: Thu, 15 Nov 2012 01:47:41 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- 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(-)
tools/perf/ui/gtk/helpline.c +12 -11
@@ -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 = >k_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 = >k_helpline_fns; +}
tools/perf/ui/helpline.c +12 -0
@@ -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); +}
tools/perf/ui/helpline.h +2 -20
@@ -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_ */
tools/perf/ui/tui/helpline.c +15 -14
@@ -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 (" " ); +}
tools/perf/util/debug.c +2 -4
@@ -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);
Namhyung Kim
maintainerPATCH 3/5 perf tools: Separate out GTK codes to libperf-gtk.so
In reply to Namhyung KimSeparate 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.
--- tools/perf/Makefile | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-)
tools/perf/Makefile +23 -13
@@ -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
Signature · 1 line
1.7.9.2
Namhyung Kim
maintainerPATCH 4/5 perf tools: Setup GTK browser dynamically
In reply to Namhyung KimCall setup/exit GTK browser function using libdl.
--- 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(-)
tools/perf/ui/gtk/gtk.h +3 -0
@@ -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)
tools/perf/ui/setup.c +49 -2
73 lines not on this page · raw message
tools/perf/ui/ui.h +1 -11
@@ -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_ */
Signature · 1 line
1.7.9.2
Namhyung Kim
maintainerPATCH 5/5 perf report: Run dynamic loaded GTK browser
In reply to Namhyung KimRun GTK hist browser using libdl.
--- 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(-)
tools/perf/Makefile +2 -1
@@ -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
tools/perf/builtin-report.c +13 -3
@@ -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);
tools/perf/ui/gtk/gtk.h +5 -0
@@ -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_ */
tools/perf/util/hist.h +0 -13
@@ -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);
Signature · 1 line
1.7.9.2
Quoted 10 lines · Namhyung Kim
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]
Quoted 7 lines
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 --gtkMissing
LD_LIBRARY_PATHwill 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
Namhyung Kim
maintainerQuoted 17 lines · Pekka Enberg
Quoted 10 lines · Namhyung Kim
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]
Quoted 3 lines
To run GTK report browser, you can do it with usual --gtk option but you might need to setup
LD_LIBRARY_PATH.
Quoted 7 lines
Quoted 4 lines
$ LD_LIBRARY_PATH=$PWD ./perf report --gtkMissing
LD_LIBRARY_PATHwill 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_PATHseems 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