perf ui/tui: Move progress.c under ui/tui directory
Namhyung Kim
maintainerPATCH 1/6 perf ui/tui: Move progress.c under ui/tui directory
From: Namhyung Kim <[email protected]>
Current ui_progress functions are implemented for TUI only. So move the file under the tui directory. This is needed for providing an UI- agnostic wrapper.
--- tools/perf/Makefile | 2 +- tools/perf/ui/progress.c | 32 -------------------------------- tools/perf/ui/tui/progress.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 tools/perf/ui/progress.c create mode 100644 tools/perf/ui/tui/progress.c
tools/perf/Makefile +1 -1
@@ -617,11 +617,11 @@ 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/progress.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 + LIB_OBJS += $(OUTPUT)ui/tui/progress.o LIB_H += ui/browser.h LIB_H += ui/browsers/map.h LIB_H += ui/keysyms.h
tools/perf/ui/progress.c deleted +0 -32
@@ -1,32 +0,0 @@ -#include "../cache.h" -#include "progress.h" -#include "libslang.h" -#include "ui.h" -#include "browser.h" - -void ui_progress__update (u64 curr,u64 total,const char *title) -{ -int bar, y; -/* -* FIXME: We should have a per UI backend way of showing progress, -* stdio will just show a percentage as NN%, etc. -*/ -if (use_browser <=0 ) -return ; - -if (total ==0 ) -return ; - -ui__refresh_dimensions (true); -pthread_mutex_lock (&ui__lock); - y = SLtt_Screen_Rows /2 -2 ; -SLsmg_set_color (0 ); -SLsmg_draw_box (y,0 ,3 , SLtt_Screen_Cols); -SLsmg_gotorc (y++,1 ); -SLsmg_write_string ((char *)title); -SLsmg_set_color (HE_COLORSET_SELECTED ); - bar = ((SLtt_Screen_Cols -2 ) * curr) / total; -SLsmg_fill_region (y,1 ,1 , bar,' ' ); -SLsmg_refresh (); -pthread_mutex_unlock (&ui__lock); -}
tools/perf/ui/tui/progress.c new file +32 -0
@@ -0,0 +1,32 @@ +#include "../cache.h" +#include "../progress.h" +#include "../libslang.h" +#include "../ui.h" +#include "../browser.h" + +void ui_progress__update (u64 curr,u64 total,const char *title) +{ +int bar, y; +/* +* FIXME: We should have a per UI backend way of showing progress, +* stdio will just show a percentage as NN%, etc. +*/ +if (use_browser <=0 ) +return ; + +if (total ==0 ) +return ; + +ui__refresh_dimensions (true); +pthread_mutex_lock (&ui__lock); + y = SLtt_Screen_Rows /2 -2 ; +SLsmg_set_color (0 ); +SLsmg_draw_box (y,0 ,3 , SLtt_Screen_Cols); +SLsmg_gotorc (y++,1 ); +SLsmg_write_string ((char *)title); +SLsmg_set_color (HE_COLORSET_SELECTED ); + bar = ((SLtt_Screen_Cols -2 ) * curr) / total; +SLsmg_fill_region (y,1 ,1 , bar,' ' ); +SLsmg_refresh (); +pthread_mutex_unlock (&ui__lock); +}
Signature · 1 line
1.7.9.2
Namhyung Kim
maintainerPATCH 2/6 perf ui: Introduce generic ui_progress helper
From: Namhyung Kim <[email protected]>
Make ui_progress functions generic so that UI frontend code will add its callbacks.
--- tools/perf/Makefile | 1 + tools/perf/ui/gtk/util.c | 11 ----------- tools/perf/ui/progress.c | 20 ++++++++++++++++++++ tools/perf/ui/progress.h | 8 ++++++++ tools/perf/ui/tui/progress.c | 12 +++++++++++- tools/perf/ui/tui/setup.c | 1 + 6 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 tools/perf/ui/progress.c
tools/perf/Makefile +1 -0
@@ -423,6 +423,7 @@ LIB_OBJS += $(OUTPUT)util/vdso.o LIB_OBJS += $(OUTPUT)util/stat.o LIB_OBJS += $(OUTPUT)ui/helpline.o +LIB_OBJS += $(OUTPUT)ui/progress.o LIB_OBJS += $(OUTPUT)ui/hist.o LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
tools/perf/ui/gtk/util.c +0 -11
@@ -111,14 +111,3 @@ struct perf_error_ops perf_gtk_eops = { .warning = perf_gtk__warning_statusbar,#endif }; - -/* -* FIXME: Functions below should be implemented properly. -* For now, just add stubs for NO_NEWT=1 build. -*/ -#ifndef NEWT_SUPPORT -void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused , -const char *title__maybe_unused ) -{ -} -#endif
tools/perf/ui/progress.c new file +20 -0
@@ -0,0 +1,20 @@ +#include "../cache.h" +#include "progress.h" + +static void nop_progress_update (u64 curr__maybe_unused , +u64 total__maybe_unused , +const char *title__maybe_unused ) +{ +} + +static struct ui_progress default_progress_fns = +{ + .update = nop_progress_update, +}; + +struct ui_progress *progress_fns = &default_progress_fns; + +void ui_progress__update (u64 curr,u64 total,const char *title) +{ +return progress_fns->update (curr, total, title); +}
tools/perf/ui/progress.h +8 -0
@@ -3,6 +3,14 @@#include <../types.h> +struct ui_progress { +void (*update)(u64 ,u64 ,const char *); +}; + +extern struct ui_progress *progress_fns; + +void ui_progress__init (void ); +void ui_progress__update (u64 curr,u64 total,const char *title);#endif
tools/perf/ui/tui/progress.c +11 -1
@@ -4,7 +4,7 @@#include "../ui.h" #include "../browser.h" -void ui_progress__update (u64 curr,u64 total,const char *title) +static void tui_progress__update (u64 curr,u64 total,const char *title) {int bar, y;/*
@@ -30,3 +30,13 @@ void ui_progress__update(u64 curr, u64 total, const char *title)SLsmg_refresh ();pthread_mutex_unlock (&ui__lock); } + +static struct ui_progress tui_progress_fns = +{ + .update = tui_progress__update, +}; + +void ui_progress__init (void ) +{ + progress_fns = &tui_progress_fns; +}
tools/perf/ui/tui/setup.c +1 -0
@@ -118,6 +118,7 @@ int ui__init(void)newtSetSuspendCallback (newt_suspend,NULL );ui_helpline__init ();ui_browser__init (); +ui_progress__init ();signal (SIGSEGV , ui__signal);signal (SIGFPE , ui__signal);
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui: Introduce generic ui_progress helper
Commit-ID: 688f2f5b99311b127ea43efdbf47bb2e3c7a2e32 Gitweb: http://git.kernel.org/tip/688f2f5b99311b127ea43efdbf47bb2e3c7a2e32 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 13 Nov 2012 22:30:32 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 14 Nov 2012 16:52:39 -0300
perf ui: Introduce generic ui_progress helper
Make ui_progress functions generic so that UI frontend code will add its callbacks.
--- tools/perf/Makefile | 1 + tools/perf/ui/gtk/util.c | 11 ----------- tools/perf/ui/progress.c | 20 ++++++++++++++++++++ tools/perf/ui/progress.h | 8 ++++++++ tools/perf/ui/tui/progress.c | 12 +++++++++++- tools/perf/ui/tui/setup.c | 1 + 6 files changed, 41 insertions(+), 12 deletions(-)
tools/perf/Makefile +1 -0
@@ -423,6 +423,7 @@ LIB_OBJS += $(OUTPUT)util/vdso.o LIB_OBJS += $(OUTPUT)util/stat.o LIB_OBJS += $(OUTPUT)ui/helpline.o +LIB_OBJS += $(OUTPUT)ui/progress.o LIB_OBJS += $(OUTPUT)ui/hist.o LIB_OBJS += $(OUTPUT)ui/stdio/hist.o
tools/perf/ui/gtk/util.c +0 -11
@@ -111,14 +111,3 @@ struct perf_error_ops perf_gtk_eops = { .warning = perf_gtk__warning_statusbar,#endif }; - -/* -* FIXME: Functions below should be implemented properly. -* For now, just add stubs for NO_NEWT=1 build. -*/ -#ifndef NEWT_SUPPORT -void ui_progress__update (u64 curr__maybe_unused ,u64 total__maybe_unused , -const char *title__maybe_unused ) -{ -} -#endif
tools/perf/ui/progress.c new file +20 -0
@@ -0,0 +1,20 @@ +#include "../cache.h" +#include "progress.h" + +static void nop_progress_update (u64 curr__maybe_unused , +u64 total__maybe_unused , +const char *title__maybe_unused ) +{ +} + +static struct ui_progress default_progress_fns = +{ + .update = nop_progress_update, +}; + +struct ui_progress *progress_fns = &default_progress_fns; + +void ui_progress__update (u64 curr,u64 total,const char *title) +{ +return progress_fns->update (curr, total, title); +}
tools/perf/ui/progress.h +8 -0
@@ -3,6 +3,14 @@#include <../types.h> +struct ui_progress { +void (*update)(u64 ,u64 ,const char *); +}; + +extern struct ui_progress *progress_fns; + +void ui_progress__init (void ); +void ui_progress__update (u64 curr,u64 total,const char *title);#endif
tools/perf/ui/tui/progress.c +11 -1
@@ -4,7 +4,7 @@#include "../ui.h" #include "../browser.h" -void ui_progress__update (u64 curr,u64 total,const char *title) +static void tui_progress__update (u64 curr,u64 total,const char *title) {int bar, y;/*
@@ -30,3 +30,13 @@ void ui_progress__update(u64 curr, u64 total, const char *title)SLsmg_refresh ();pthread_mutex_unlock (&ui__lock); } + +static struct ui_progress tui_progress_fns = +{ + .update = tui_progress__update, +}; + +void ui_progress__init (void ) +{ + progress_fns = &tui_progress_fns; +}
tools/perf/ui/tui/setup.c +1 -0
@@ -118,6 +118,7 @@ int ui__init(void)newtSetSuspendCallback (newt_suspend,NULL );ui_helpline__init ();ui_browser__init (); +ui_progress__init ();signal (SIGSEGV , ui__signal);signal (SIGFPE , ui__signal);
Namhyung Kim
maintainerPATCH 3/6 perf ui/gtk: Implement ui_progress functions
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Implement progress update function for GTK2 front end.
Note that since it will be called before gtk main loop so that we should call gtk event loop handler directly.
--- tools/perf/Makefile | 1 + tools/perf/ui/gtk/gtk.h | 1 + tools/perf/ui/gtk/progress.c | 50 ++++++++++++++++++++++++++++++++++++++++++ tools/perf/ui/gtk/setup.c | 2 ++ 4 files changed, 54 insertions(+) create mode 100644 tools/perf/ui/gtk/progress.c
tools/perf/Makefile +1 -0
@@ -648,6 +648,7 @@ ifndef NO_GTK2 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 # Make sure that it'd be included only once. ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o
tools/perf/ui/gtk/gtk.h +1 -0
@@ -30,6 +30,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);int perf_gtk__deactivate_context (struct perf_gtk_context **ctx);void perf_gtk__init_helpline (void ); +void perf_gtk__init_progress (void );void perf_gtk__init_hpp (void );#ifndef HAVE_GTK_INFO_BAR
tools/perf/ui/gtk/progress.c new file +50 -0
50 lines not on this page · raw message
tools/perf/ui/gtk/setup.c +2 -0
@@ -8,7 +8,9 @@ int perf_gtk__init(void) {perf_error__register (&perf_gtk_eops);perf_gtk__init_helpline (); +perf_gtk__init_progress ();perf_gtk__init_hpp (); +return gtk_init_check (NULL ,NULL ) ?0 :-1 ; }
Signature · 1 line
1.7.9.2
Re: [PATCH 3/6] perf ui/gtk: Implement ui_progress functions
Quoted 47 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Implement progress update function for GTK2 front end.
Note that since it will be called before gtk main loop so that we should call gtk event loop handler directly.
Cc Pekka Enberg <[email protected]>Signed-off-by Namhyung Kim <[email protected]>tools/perf/ui/gtk/progress.c new file +31
-0@@ -0,0 +1,50 @@ +#include <inttypes.h> + +#include "gtk.h" +#include "../progress.h" +#include "util.h" + +static GtkWidget *dialog; +static GtkWidget *progress; + +static void gtk_progress_update (u64 curr,u64 total,const char *title) +{ +double fraction = total ?1.0 * curr / total :0.0 ; +char buf[1024 ]; + +if (dialog ==NULL ) { +GtkWidget *vbox =gtk_vbox_new (TRUE,5 ); +GtkWidget *label =gtk_label_new (title); + + dialog =gtk_window_new (GTK_WINDOW_TOPLEVEL ); + progress =gtk_progress_bar_new (); + +gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE,3 ); +gtk_box_pack_start (GTK_BOX (vbox), progress, TRUE, TRUE,3 ); + +gtk_container_add (GTK_CONTAINER (dialog), vbox); + +gtk_window_set_title (GTK_WINDOW (dialog),"perf" ); +gtk_window_resize (GTK_WINDOW (dialog),300 ,80 ); +gtk_window_set_position (GTK_WINDOW (dialog),GTK_WIN_POS_CENTER ); + +gtk_widget_show_all (dialog);
tools/perf/ui/gtk/progress.c line 41
Quoted 10 lines
tools/perf/ui/gtk/progress.c new file +10
-0+ } + +gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), fraction); +snprintf (buf,sizeof (buf),"%" PRIu64" / %" PRIu64, curr, total); +gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), buf); + +/* we didn't call gtk_main yet, so do it manually */ +while (gtk_events_pending ()) +gtk_main_iteration (); +}
When is the progress bar shown? Why does it need to be a separate dialog? Can't we embed it in the current perf window (and make the other UI components disabled if necessary)?
Pekka
Namhyung Kim
maintainerRe: [PATCH 3/6] perf ui/gtk: Implement ui_progress functions
Hi Pekka,
Quoted 8 lines · Pekka Enberg
Quoted 7 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Implement progress update function for GTK2 front end.
Note that since it will be called before gtk main loop so that we should call gtk event loop handler directly.
[snip]
Quoted 4 lines
When is the progress bar shown? Why does it need to be a separate dialog? Can't we embed it in the current perf window (and make the other UI components disabled if necessary)?
It's called during perf_session__process_events() which is executed before creating the main window.
Thanks,
Namhyung
[tip:perf/core] perf ui gtk: Implement ui_progress functions
In reply to Namhyung KimCommit-ID: a753579c3ec096bba9d24e1594a07dbb25aca8e4 Gitweb: http://git.kernel.org/tip/a753579c3ec096bba9d24e1594a07dbb25aca8e4 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 13 Nov 2012 22:30:33 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 14 Nov 2012 16:52:48 -0300
perf ui gtk: Implement ui_progress functions
Implement progress update function for GTK2 front end.
Note that since it will be called before gtk main loop so that we should call gtk event loop handler directly.
--- tools/perf/Makefile | 1 + tools/perf/ui/gtk/gtk.h | 1 + tools/perf/ui/gtk/progress.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ tools/perf/ui/gtk/setup.c | 2 ++ 4 files changed, 54 insertions(+)
tools/perf/Makefile +1 -0
@@ -648,6 +648,7 @@ ifndef NO_GTK2 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 # Make sure that it'd be included only once. ifeq ($(findstring -DNEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o
tools/perf/ui/gtk/gtk.h +1 -0
@@ -30,6 +30,7 @@ struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);int perf_gtk__deactivate_context (struct perf_gtk_context **ctx);void perf_gtk__init_helpline (void ); +void perf_gtk__init_progress (void );void perf_gtk__init_hpp (void );#ifndef HAVE_GTK_INFO_BAR
tools/perf/ui/gtk/progress.c new file +50 -0
50 lines not on this page · raw message
tools/perf/ui/gtk/setup.c +2 -0
@@ -8,7 +8,9 @@ int perf_gtk__init(void) {perf_error__register (&perf_gtk_eops);perf_gtk__init_helpline (); +perf_gtk__init_progress ();perf_gtk__init_hpp (); +return gtk_init_check (NULL ,NULL ) ?0 :-1 ; }
Namhyung Kim
maintainerPATCH 4/6 perf ui: Add ui_progress__finish()
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
Sometimes we need to know when the progress bar should disappear. Checking curr >= total wasn't enough since there're cases not met that condition for the last call. So add a new ->finish callback to identify this explicitly. Currently only GTK frontend needs it.
--- tools/perf/ui/gtk/progress.c | 9 +++++++++ tools/perf/ui/progress.c | 6 ++++++ tools/perf/ui/progress.h | 2 ++ tools/perf/util/debug.h | 1 + tools/perf/util/session.c | 1 + 5 files changed, 19 insertions(+)
tools/perf/ui/gtk/progress.c +9 -0
@@ -40,8 +40,17 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)gtk_main_iteration (); } +static void gtk_progress_finish (void ) +{ +/* this will also destroy all of its children */ +gtk_widget_destroy (dialog); + + dialog =NULL ; +} +static struct ui_progress gtk_progress_fns = { .update = gtk_progress_update, + .finish = gtk_progress_finish, };void perf_gtk__init_progress (void )
tools/perf/ui/progress.c +6 -0
@@ -18,3 +18,9 @@ void ui_progress__update(u64 curr, u64 total, const char *title) {return progress_fns->update (curr, total, title); } + +void ui_progress__finish (void ) +{ +if (progress_fns->finish) + progress_fns->finish (); +}
tools/perf/ui/progress.h +2 -0
@@ -5,6 +5,7 @@struct ui_progress {void (*update)(u64 ,u64 ,const char *); +void (*finish)(void ); };extern struct ui_progress *progress_fns;
@@ -12,5 +13,6 @@ extern struct ui_progress *progress_fns;void ui_progress__init (void );void ui_progress__update (u64 curr,u64 total,const char *title); +void ui_progress__finish (void );#endif
tools/perf/util/debug.h +1 -0
@@ -26,6 +26,7 @@ int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));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)
tools/perf/util/session.c +1 -0
@@ -1458,6 +1458,7 @@ more: session->ordered_samples.next_flush =ULLONG_MAX ; err =flush_sample_queue (session, tool); out_err: +ui_progress__finish ();perf_session__warn_about_errors (session, tool);perf_session_free_sample_buffers (session);return err;
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui: Add ui_progress__finish()
Commit-ID: a5580f3ecb295a514f9522daf0ef7158f73ec2d6 Gitweb: http://git.kernel.org/tip/a5580f3ecb295a514f9522daf0ef7158f73ec2d6 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 13 Nov 2012 22:30:34 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 14 Nov 2012 16:52:56 -0300
perf ui: Add ui_progress__finish()
Sometimes we need to know when the progress bar should disappear.
Checking curr >= total wasn't enough since there're cases not met that condition for the last call.
So add a new ->finish callback to identify this explicitly. Currently only GTK frontend needs it.
--- tools/perf/ui/gtk/progress.c | 9 +++++++++ tools/perf/ui/progress.c | 6 ++++++ tools/perf/ui/progress.h | 2 ++ tools/perf/util/debug.h | 1 + tools/perf/util/session.c | 1 + 5 files changed, 19 insertions(+)
tools/perf/ui/gtk/progress.c +9 -0
@@ -40,8 +40,17 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)gtk_main_iteration (); } +static void gtk_progress_finish (void ) +{ +/* this will also destroy all of its children */ +gtk_widget_destroy (dialog); + + dialog =NULL ; +} +static struct ui_progress gtk_progress_fns = { .update = gtk_progress_update, + .finish = gtk_progress_finish, };void perf_gtk__init_progress (void )
tools/perf/ui/progress.c +6 -0
@@ -18,3 +18,9 @@ void ui_progress__update(u64 curr, u64 total, const char *title) {return progress_fns->update (curr, total, title); } + +void ui_progress__finish (void ) +{ +if (progress_fns->finish) + progress_fns->finish (); +}
tools/perf/ui/progress.h +2 -0
@@ -5,6 +5,7 @@struct ui_progress {void (*update)(u64 ,u64 ,const char *); +void (*finish)(void ); };extern struct ui_progress *progress_fns;
@@ -12,5 +13,6 @@ extern struct ui_progress *progress_fns;void ui_progress__init (void );void ui_progress__update (u64 curr,u64 total,const char *title); +void ui_progress__finish (void );#endif
tools/perf/util/debug.h +1 -0
@@ -26,6 +26,7 @@ int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));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)
tools/perf/util/session.c +1 -0
@@ -1458,6 +1458,7 @@ more: session->ordered_samples.next_flush =ULLONG_MAX ; err =flush_sample_queue (session, tool); out_err: +ui_progress__finish ();perf_session__warn_about_errors (session, tool);perf_session_free_sample_buffers (session);return err;
Namhyung Kim
maintainerPATCH 5/6 perf ui: Always compile browser setup code
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
We now have proper fallback logic, so always build it regardless of TUI or GTK setting.
--- tools/perf/Makefile | 3 +-- tools/perf/ui/ui.h | 28 ++++++++++++++++++++++++++++ tools/perf/util/cache.h | 39 +-------------------------------------- 3 files changed, 30 insertions(+), 40 deletions(-)
tools/perf/Makefile +1 -2
@@ -422,6 +422,7 @@ LIB_OBJS += $(OUTPUT)util/intlist.o LIB_OBJS += $(OUTPUT)util/vdso.o 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/hist.o
@@ -612,7 +613,6 @@ ifndef NO_NEWT BASIC_CFLAGS += -I/usr/include/slang BASIC_CFLAGS += -DNEWT_SUPPORT EXTLIBS += -lnewt -lslang - LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/browser.o LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
@@ -651,7 +651,6 @@ ifndef NO_GTK2 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/setup.o LIB_OBJS += $(OUTPUT)ui/util.o endif endif
tools/perf/ui/ui.h +28 -0
@@ -3,9 +3,37 @@#include <pthread.h> #include <stdbool.h> +#include <linux/compiler.h> extern pthread_mutex_t ui__lock; +extern int use_browser; + +void setup_browser (bool fallback_to_pager); +void exit_browser (bool wait_for_ok); + +#ifdef NEWT_SUPPORT +int ui__init (void ); +void ui__exit (bool wait_for_ok); +#else +static inline int ui__init (void ) +{ +return -1 ; +} +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_ */
tools/perf/util/cache.h +1 -38
@@ -5,6 +5,7 @@#include "util.h" #include "strbuf.h" #include "../perf.h" +#include "../ui/ui.h" #define CMD_EXEC_PATH "--exec-path"#define CMD_PERF_DIR "--perf-dir="
@@ -31,44 +32,6 @@ extern const char *pager_program;extern int pager_in_use (void );extern int pager_use_color; -extern int use_browser; - -#if defined(NEWT_SUPPORT ) || defined(GTK2_SUPPORT ) -void setup_browser (bool fallback_to_pager); -void exit_browser (bool wait_for_ok); - -#ifdef NEWT_SUPPORT -int ui__init (void ); -void ui__exit (bool wait_for_ok); -#else -static inline int ui__init (void ) -{ -return -1 ; -} -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 - -#else /* NEWT_SUPPORT || GTK2_SUPPORT */ - -static inline void setup_browser (bool fallback_to_pager) -{ -if (fallback_to_pager) -setup_pager (); -} -static inline void exit_browser (bool wait_for_ok__maybe_unused ) {} -#endif /* NEWT_SUPPORT || GTK2_SUPPORT */ -char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui: Always compile browser setup code
Commit-ID: 59ed16b315681a08cf8aa13ee949e9405801f442 Gitweb: http://git.kernel.org/tip/59ed16b315681a08cf8aa13ee949e9405801f442 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 13 Nov 2012 22:30:35 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 14 Nov 2012 16:53:03 -0300
perf ui: Always compile browser setup code
We now have proper fallback logic, so always build it regardless of TUI or GTK setting.
--- tools/perf/Makefile | 3 +-- tools/perf/ui/ui.h | 28 ++++++++++++++++++++++++++++ tools/perf/util/cache.h | 39 +-------------------------------------- 3 files changed, 30 insertions(+), 40 deletions(-)
tools/perf/Makefile +1 -2
@@ -422,6 +422,7 @@ LIB_OBJS += $(OUTPUT)util/intlist.o LIB_OBJS += $(OUTPUT)util/vdso.o 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/hist.o
@@ -612,7 +613,6 @@ ifndef NO_NEWT BASIC_CFLAGS += -I/usr/include/slang BASIC_CFLAGS += -DNEWT_SUPPORT EXTLIBS += -lnewt -lslang - LIB_OBJS += $(OUTPUT)ui/setup.o LIB_OBJS += $(OUTPUT)ui/browser.o LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o LIB_OBJS += $(OUTPUT)ui/browsers/hists.o
@@ -651,7 +651,6 @@ ifndef NO_GTK2 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/setup.o LIB_OBJS += $(OUTPUT)ui/util.o endif endif
tools/perf/ui/ui.h +28 -0
@@ -3,9 +3,37 @@#include <pthread.h> #include <stdbool.h> +#include <linux/compiler.h> extern pthread_mutex_t ui__lock; +extern int use_browser; + +void setup_browser (bool fallback_to_pager); +void exit_browser (bool wait_for_ok); + +#ifdef NEWT_SUPPORT +int ui__init (void ); +void ui__exit (bool wait_for_ok); +#else +static inline int ui__init (void ) +{ +return -1 ; +} +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_ */
tools/perf/util/cache.h +1 -38
@@ -5,6 +5,7 @@#include "util.h" #include "strbuf.h" #include "../perf.h" +#include "../ui/ui.h" #define CMD_EXEC_PATH "--exec-path"#define CMD_PERF_DIR "--perf-dir="
@@ -31,44 +32,6 @@ extern const char *pager_program;extern int pager_in_use (void );extern int pager_use_color; -extern int use_browser; - -#if defined(NEWT_SUPPORT ) || defined(GTK2_SUPPORT ) -void setup_browser (bool fallback_to_pager); -void exit_browser (bool wait_for_ok); - -#ifdef NEWT_SUPPORT -int ui__init (void ); -void ui__exit (bool wait_for_ok); -#else -static inline int ui__init (void ) -{ -return -1 ; -} -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 - -#else /* NEWT_SUPPORT || GTK2_SUPPORT */ - -static inline void setup_browser (bool fallback_to_pager) -{ -if (fallback_to_pager) -setup_pager (); -} -static inline void exit_browser (bool wait_for_ok__maybe_unused ) {} -#endif /* NEWT_SUPPORT || GTK2_SUPPORT */ -char *alias_lookup (const char *alias);int split_cmdline (char *cmdline,const char ***argv);
Namhyung Kim
maintainerPATCH 6/6 perf ui: Always compile error printing code
In reply to Namhyung KimFrom: 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 tui: Move progress.c under ui/ tui directory
In reply to Namhyung KimCommit-ID: 7da5c85dd34dd67846fec965e4bf1f761eecca05 Gitweb: http://git.kernel.org/tip/7da5c85dd34dd67846fec965e4bf1f761eecca05 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 13 Nov 2012 22:30:31 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 14 Nov 2012 16:52:33 -0300
perf ui tui: Move progress.c under ui/tui directory
Current ui_progress functions are implemented for TUI only. So move the file under the tui directory. This is needed for providing an UI- agnostic wrapper.
---
tools/perf/Makefile | 2 +-
tools/perf/ui/{ => tui}/progress.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)tools/perf/Makefile +1 -1
@@ -617,11 +617,11 @@ 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/progress.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 + LIB_OBJS += $(OUTPUT)ui/tui/progress.o LIB_H += ui/browser.h LIB_H += ui/browsers/map.h LIB_H += ui/keysyms.h
tools/perf/ui/tui/progress.c renamed from tools/perf/ui/progress.c +4 -4
@@ -1,8 +1,8 @@#include "../cache.h" -#include "progress.h" -#include "libslang.h" -#include "ui.h" -#include "browser.h" +#include "../progress.h" +#include "../libslang.h" +#include "../ui.h" +#include "../browser.h" void ui_progress__update (u64 curr,u64 total,const char *title) {