aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-08-07 09:20:44 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-08-10 15:46:07 -0400
commit6a40cd90f5deb6dec322eeb54587ae55a934db2c (patch)
tree88e77297d85457427bb12c31d2e06d2eb8b237b1
parent2bcd355b71dafa5793a680c5db043abe9f708418 (diff)
perf tools: Add libunwind dependency for DWARF CFI unwinding
Adding libunwind to be linked with perf if available. It's required for the to get dwarf cfi unwinding support. Also building perf with the dwarf call frame informations by default, so that we can unwind callchains in perf itself. Adding LIBUNWIND_DIR Makefile variable allowing user to specify the directory with libunwind to be linked. This is used for debug purposes. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Original-patch-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: "Frank Ch. Eigler" <fche@redhat.com> Cc: Arun Sharma <asharma@fb.com> Cc: Benjamin Redelings <benjamin.redelings@nescent.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: Frank Ch. Eigler <fche@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Robert Richter <robert.richter@amd.com> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> Cc: Ulrich Drepper <drepper@gmail.com> Link: http://lkml.kernel.org/r/1344345647-11536-10-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Makefile29
-rw-r--r--tools/perf/config/feature-tests.mak25
2 files changed, 53 insertions, 1 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 27ae84bb5e4c..0aee6a916493 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -43,6 +43,8 @@ include config/utilities.mak
43# 43#
44# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds) 44# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
45# 45#
46# Define NO_LIBUNWIND if you do not want libunwind dependency for dwarf
47# backtrace post unwind.
46 48
47$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE 49$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
48 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) 50 @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT)
@@ -64,6 +66,7 @@ AR = $(CROSS_COMPILE)ar
64ifeq ($(ARCH),i386) 66ifeq ($(ARCH),i386)
65 ARCH := x86 67 ARCH := x86
66 NO_PERF_REGS := 0 68 NO_PERF_REGS := 0
69 LIBUNWIND_LIBS = -lunwind -lunwind-x86
67endif 70endif
68ifeq ($(ARCH),x86_64) 71ifeq ($(ARCH),x86_64)
69 ARCH := x86 72 ARCH := x86
@@ -77,6 +80,7 @@ ifeq ($(ARCH),x86_64)
77 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S 80 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
78 endif 81 endif
79 NO_PERF_REGS := 0 82 NO_PERF_REGS := 0
83 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64
80endif 84endif
81 85
82# Treat warnings as errors unless directed not to 86# Treat warnings as errors unless directed not to
@@ -97,7 +101,7 @@ ifdef PARSER_DEBUG
97 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG 101 PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG
98endif 102endif
99 103
100CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) 104CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS)
101EXTLIBS = -lpthread -lrt -lelf -lm 105EXTLIBS = -lpthread -lrt -lelf -lm
102ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE 106ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
103ALL_LDFLAGS = $(LDFLAGS) 107ALL_LDFLAGS = $(LDFLAGS)
@@ -476,6 +480,21 @@ ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y)
476endif 480endif
477endif # NO_LIBELF 481endif # NO_LIBELF
478 482
483ifndef NO_LIBUNWIND
484# for linking with debug library, run like:
485# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/
486ifdef LIBUNWIND_DIR
487 LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include
488 LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib
489endif
490
491FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(ALL_CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS)
492ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND)),y)
493 msg := $(warning No libunwind found. Please install libunwind >= 0.99);
494 NO_LIBUNWIND := 1
495endif # Libunwind support
496endif # NO_LIBUNWIND
497
479-include arch/$(ARCH)/Makefile 498-include arch/$(ARCH)/Makefile
480 499
481ifneq ($(OUTPUT),) 500ifneq ($(OUTPUT),)
@@ -522,6 +541,14 @@ endif # PERF_HAVE_DWARF_REGS
522endif # NO_DWARF 541endif # NO_DWARF
523endif # NO_LIBELF 542endif # NO_LIBELF
524 543
544ifdef NO_LIBUNWIND
545 BASIC_CFLAGS += -DNO_LIBUNWIND_SUPPORT
546else
547 EXTLIBS += $(LIBUNWIND_LIBS)
548 BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS)
549 BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS)
550endif
551
525ifdef NO_NEWT 552ifdef NO_NEWT
526 BASIC_CFLAGS += -DNO_NEWT_SUPPORT 553 BASIC_CFLAGS += -DNO_NEWT_SUPPORT
527else 554else
diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak
index 6c18785a6417..2f1156a62ab7 100644
--- a/tools/perf/config/feature-tests.mak
+++ b/tools/perf/config/feature-tests.mak
@@ -154,3 +154,28 @@ int main(void)
154 return 0; 154 return 0;
155} 155}
156endef 156endef
157
158ifndef NO_LIBUNWIND
159define SOURCE_LIBUNWIND
160#include <libunwind.h>
161#include <stdlib.h>
162
163extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
164 unw_word_t ip,
165 unw_dyn_info_t *di,
166 unw_proc_info_t *pi,
167 int need_unwind_info, void *arg);
168
169
170#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
171
172int main(void)
173{
174 unw_addr_space_t addr_space;
175 addr_space = unw_create_addr_space(NULL, 0);
176 unw_init_remote(NULL, addr_space, NULL);
177 dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
178 return 0;
179}
180endef
181endif