Re: [PATCH 4/4] perf tools: Run dynamic loaded GTK browser

2013-08-05 Thread Pekka Enberg
On Tue, Aug 6, 2013 at 8:14 AM, Namhyung Kim  wrote:
> Run GTK hist and annotation browser using libdl.
>
> Cc: Andi Kleen 
> Cc: Pekka Enberg 
> Signed-off-by: Namhyung Kim 

Reviewed-by: Pekka Enberg 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] perf tools: Run dynamic loaded GTK browser

2013-08-05 Thread Namhyung Kim
Run GTK hist and annotation browser using libdl.

Cc: Andi Kleen 
Cc: Pekka Enberg 
Signed-off-by: Namhyung Kim 
---
 tools/perf/builtin-annotate.c | 26 +++---
 tools/perf/builtin-report.c   | 16 ++--
 tools/perf/config/Makefile|  2 +-
 tools/perf/ui/gtk/annotate.c  | 13 ++---
 tools/perf/ui/gtk/gtk.h   | 13 +
 tools/perf/util/annotate.h| 24 
 tools/perf/util/hist.h| 15 ---
 7 files changed, 61 insertions(+), 48 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index db491e9a812b..82469b3ead07 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -30,6 +30,7 @@
 #include "util/tool.h"
 #include "arch/common.h"
 
+#include 
 #include 
 
 struct perf_annotate {
@@ -143,8 +144,18 @@ find_next:
 
if (use_browser == 2) {
int ret;
+   int (*annotate)(struct hist_entry *he,
+   struct perf_evsel *evsel,
+   struct hist_browser_timer *hbt);
+
+   annotate = dlsym(perf_gtk_handle,
+"hist_entry__gtk_annotate");
+   if (annotate == NULL) {
+   ui__error("GTK browser not found!\n");
+   return;
+   }
 
-   ret = hist_entry__gtk_annotate(he, evsel, NULL);
+   ret = annotate(he, evsel, NULL);
if (!ret || !ann->skip_missing)
return;
 
@@ -246,8 +257,17 @@ static int __cmd_annotate(struct perf_annotate *ann)
goto out_delete;
}
 
-   if (use_browser == 2)
-   perf_gtk__show_annotations();
+   if (use_browser == 2) {
+   void (*show_annotations)(void);
+
+   show_annotations = dlsym(perf_gtk_handle,
+"perf_gtk__show_annotations");
+   if (show_annotations == NULL) {
+   ui__error("GTK browser not found!\n");
+   goto out_delete;
+   }
+   show_annotations();
+   }
 
 out_delete:
/*
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d785d89ed226..05c0e80c8ae4 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -35,6 +35,7 @@
 #include "util/hist.h"
 #include "arch/common.h"
 
+#include 
 #include 
 
 struct perf_report {
@@ -592,8 +593,19 @@ static int __cmd_report(struct perf_report *rep)
ret = 0;
 
} else if (use_browser == 2) {
-   perf_evlist__gtk_browse_hists(session->evlist, help,
- NULL, rep->min_percent);
+   int (*hist_browser)(struct perf_evlist *,
+   const char *,
+   struct hist_browser_timer *,
+   float min_pcnt);
+
+   hist_browser = dlsym(perf_gtk_handle,
+"perf_evlist__gtk_browse_hists");
+   if (hist_browser == NULL) {
+   ui__error("GTK browser not found!\n");
+   return ret;
+   }
+   hist_browser(session->evlist, help, NULL,
+rep->min_percent);
}
} else
perf_evlist__tty_browse_hists(session->evlist, rep, help);
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 6bdfd0302c4e..1b6ccb242609 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -269,7 +269,7 @@ 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 += -DGTK2_SUPPORT
+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)
   endif
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
index f538794615db..9c7ff8d31b27 100644
--- a/tools/perf/ui/gtk/annotate.c
+++ b/tools/perf/ui/gtk/annotate.c
@@ -154,9 +154,9 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, 
struct symbol *sym,
return 0;
 }
 
-int symbol__gtk_annotate(struct symbol *sym, struct map *map,
-struct perf_evsel *evsel,
-struct hist_browser_timer *hbt)
+static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
+   struct perf_evsel *evsel,
+   struct hist_browser_timer *h