Commit fc67297b authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Separate out GTK codes to libperf-gtk.so



Separate out GTK codes to a shared object called libperf-gtk.so.  This
time only GTK codes are built with -fPIC and libperf remains as is.  Now
run GTK hist and annotation browser using libdl.

Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Reviewed-by: default avatarPekka Enberg <penberg@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1379053663-13706-1-git-send-email-namhyung@kernel.org


[ Fix it up wrt Ingo's tools/perf build speedups ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fc2be696
Loading
Loading
Loading
Loading
+31 −11
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
BUILTIN_OBJS =
LIB_H =
LIB_OBJS =
GTK_OBJS =
PYRF_OBJS =
SCRIPT_SH =

@@ -490,13 +491,19 @@ ifndef NO_SLANG
endif

ifndef NO_GTK2
  LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
  LIB_OBJS += $(OUTPUT)ui/gtk/hists.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
  LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o
  ALL_PROGRAMS += $(OUTPUT)libperf-gtk.so

  GTK_OBJS += $(OUTPUT)ui/gtk/browser.o
  GTK_OBJS += $(OUTPUT)ui/gtk/hists.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_OBJS += $(OUTPUT)ui/gtk/annotate.o

install-gtk: $(OUTPUT)libperf-gtk.so
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(libdir_SQ)'
	$(INSTALL) $(OUTPUT)libperf-gtk.so '$(DESTDIR_SQ)$(libdir_SQ)'
endif

ifndef NO_LIBPERL
@@ -550,6 +557,12 @@ $(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS)
	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \
               $(BUILTIN_OBJS) $(LIBS) -o $@

$(GTK_OBJS): $(OUTPUT)%.o: %.c $(LIB_H)
	$(QUIET_CC)$(CC) -o $@ -c -fPIC $(CFLAGS) $(GTK_CFLAGS) $<

$(OUTPUT)libperf-gtk.so: $(GTK_OBJS) $(PERFLIBS)
	$(QUIET_LINK)$(CC) -o $@ -shared $(ALL_LDFLAGS) $(filter %.o,$^) $(GTK_LIBS)

$(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS
	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \
		'-DPERF_HTML_PATH="$(htmldir_SQ)"' \
@@ -632,6 +645,9 @@ $(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS
$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<

$(OUTPUT)ui/setup.o: ui/setup.c $(OUTPUT)PERF-CFLAGS
	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DLIBDIR='"$(libdir_SQ)"' $<

$(OUTPUT)ui/browser.o: ui/browser.c $(OUTPUT)PERF-CFLAGS
	$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) -DENABLE_SLFUTURE_CONST $<

@@ -673,7 +689,8 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)

# we compile into subdirectories. if the target directory is not the source directory, they might not exists. So
# we depend the various files onto their directories.
DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
DIRECTORY_DEPS = $(LIB_OBJS) $(BUILTIN_OBJS) $(GTK_OBJS)
DIRECTORY_DEPS += $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h
$(DIRECTORY_DEPS): | $(sort $(dir $(DIRECTORY_DEPS)))
# In the second step, we make a rule to actually create these directories
$(sort $(dir $(DIRECTORY_DEPS))):
@@ -786,7 +803,9 @@ check: $(OUTPUT)common-cmds.h

### Installation rules

install-bin: all
install-gtk:

install-bin: all install-gtk
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
	$(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)'
	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
@@ -831,7 +850,8 @@ config-clean:
	@$(MAKE) -C config/feature-checks clean

clean: $(LIBTRACEEVENT)-clean $(LIBLK)-clean config-clean
	$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
	$(RM) $(LIB_OBJS) $(BUILTIN_OBJS) $(LIB_FILE) $(GTK_OBJS)
	$(RM) $(OUTPUT)perf-archive $(OUTPUT)perf.o $(LANG_BINDINGS)
	$(RM) $(ALL_PROGRAMS) perf
	$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
	$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
@@ -850,7 +870,7 @@ else
    GIT-HEAD-PHONY =
endif

.PHONY: all install clean config-clean strip
.PHONY: all install clean config-clean strip install-gtk
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope .FORCE-PERF-CFLAGS
+23 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "util/tool.h"
#include "arch/common.h"

#include <dlfcn.h>
#include <linux/bitmap.h>

struct perf_annotate {
@@ -142,8 +143,18 @@ find_next:

		if (use_browser == 2) {
			int ret;
			int (*annotate)(struct hist_entry *he,
					struct perf_evsel *evsel,
					struct hist_browser_timer *hbt);

			ret = hist_entry__gtk_annotate(he, evsel, NULL);
			annotate = dlsym(perf_gtk_handle,
					 "hist_entry__gtk_annotate");
			if (annotate == NULL) {
				ui__error("GTK browser not found!\n");
				return;
			}

			ret = annotate(he, evsel, NULL);
			if (!ret || !ann->skip_missing)
				return;

@@ -247,8 +258,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:
	/*
+14 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "util/hist.h"
#include "arch/common.h"

#include <dlfcn.h>
#include <linux/bitmap.h>

struct perf_report {
@@ -591,8 +592,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);
+9 −3
Original line number Diff line number Diff line
@@ -377,11 +377,11 @@ ifndef NO_GTK2
    NO_GTK2 := 1
  else
    ifeq ($(feature-gtk2-infobar), 1)
      CFLAGS += -DHAVE_GTK_INFO_BAR_SUPPORT
      GTK_CFLAGS := -DHAVE_GTK_INFO_BAR_SUPPORT
    endif
    CFLAGS += -DHAVE_GTK2_SUPPORT
    CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
    EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
    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
endif

@@ -554,7 +554,12 @@ else
sysconfdir = $(prefix)/etc
ETC_PERFCONFIG = etc/perfconfig
endif
ifeq ($(IS_X86_64),1)
lib = lib64
else
lib = lib
endif
libdir = $(prefix)/$(lib)

# Shell quote (do not use $(call) to accommodate ancient setups);
ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG))
@@ -567,6 +572,7 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
htmldir_SQ = $(subst ','\'',$(htmldir))
prefix_SQ = $(subst ','\'',$(prefix))
sysconfdir_SQ = $(subst ','\'',$(sysconfdir))
libdir_SQ = $(subst ','\'',$(libdir))

ifneq ($(filter /%,$(firstword $(perfexecdir))),)
perfexec_instdir = $(perfexecdir)
+10 −3
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,
	return 0;
}

int symbol__gtk_annotate(struct symbol *sym, struct map *map,
static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
				struct perf_evsel *evsel,
				struct hist_browser_timer *hbt)
{
@@ -226,6 +226,13 @@ int symbol__gtk_annotate(struct symbol *sym, struct map *map,
	return 0;
}

int hist_entry__gtk_annotate(struct hist_entry *he,
			     struct perf_evsel *evsel,
			     struct hist_browser_timer *hbt)
{
	return symbol__gtk_annotate(he->ms.sym, he->ms.map, evsel, hbt);
}

void perf_gtk__show_annotations(void)
{
	GtkWidget *window;
Loading