[PATCH v6 05/11] perf tools: Separate local/remote libunwind config

From: He Kuang
Date: Sat May 28 2016 - 08:02:38 EST


CONFIG_LIBUNWIND/NO_LIBUNWIND are changed to
CONFIG_LOCAL_LIBUNWIND/NO_LOCAL_LIBUNWIND for retaining local unwind
features.

The new CONFIG_LIBUNWIND stands for either local or remote or both
unwind are supported.

Signed-off-by: He Kuang <hekuang@xxxxxxxxxx>
---
tools/perf/arch/arm/util/Build | 2 +-
tools/perf/arch/arm64/util/Build | 2 +-
tools/perf/arch/x86/util/Build | 2 +-
tools/perf/config/Makefile | 21 +++++++++++++++++++--
tools/perf/util/unwind.h | 8 +++++++-
5 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/tools/perf/arch/arm/util/Build b/tools/perf/arch/arm/util/Build
index d22e3d0..52d0ff8 100644
--- a/tools/perf/arch/arm/util/Build
+++ b/tools/perf/arch/arm/util/Build
@@ -1,4 +1,4 @@
libperf-$(CONFIG_DWARF) += dwarf-regs.o

-libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build
index e58123a8..02f41db 100644
--- a/tools/perf/arch/arm64/util/Build
+++ b/tools/perf/arch/arm64/util/Build
@@ -1,2 +1,2 @@
libperf-$(CONFIG_DWARF) += dwarf-regs.o
-libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
diff --git a/tools/perf/arch/x86/util/Build b/tools/perf/arch/x86/util/Build
index 4659703..1db8abd 100644
--- a/tools/perf/arch/x86/util/Build
+++ b/tools/perf/arch/x86/util/Build
@@ -7,7 +7,7 @@ libperf-y += perf_regs.o
libperf-$(CONFIG_DWARF) += dwarf-regs.o
libperf-$(CONFIG_BPF_PROLOGUE) += dwarf-regs.o

-libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o
+libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o

libperf-$(CONFIG_AUXTRACE) += auxtrace.o
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 6f9f566..3a304a3 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -354,10 +354,24 @@ ifeq ($(ARCH),powerpc)
endif

ifndef NO_LIBUNWIND
+ have_libunwind :=
ifneq ($(feature-libunwind), 1)
msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR);
+ NO_LOCAL_LIBUNWIND := 1
+ else
+ have_libunwind := 1
+ CFLAGS += -DHAVE_LIBUNWIND_LOCAL_SUPPORT
+ $(call detected,CONFIG_LOCAL_LIBUNWIND)
+ endif
+
+ ifneq ($(have_libunwind), 1)
NO_LIBUNWIND := 1
+ else
+ CFLAGS += -I$(LIBUNWIND_DIR)/include
+ LDFLAGS += -L$(LIBUNWIND_DIR)/lib
endif
+else
+ NO_LOCAL_LIBUNWIND := 1
endif

ifndef NO_LIBBPF
@@ -395,7 +409,7 @@ else
NO_DWARF_UNWIND := 1
endif

-ifndef NO_LIBUNWIND
+ifndef NO_LOCAL_LIBUNWIND
ifeq ($(ARCH),$(filter $(ARCH),arm arm64))
$(call feature_check,libunwind-debug-frame)
ifneq ($(feature-libunwind-debug-frame), 1)
@@ -406,12 +420,15 @@ ifndef NO_LIBUNWIND
# non-ARM has no dwarf_find_debug_frame() function:
CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME
endif
- CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
EXTLIBS += $(LIBUNWIND_LIBS)
CFLAGS += $(LIBUNWIND_CFLAGS)
LDFLAGS += $(LIBUNWIND_LDFLAGS)
endif

+ifndef NO_LIBUNWIND
+ CFLAGS += -DHAVE_LIBUNWIND_SUPPORT
+endif
+
ifndef NO_LIBAUDIT
ifneq ($(feature-libaudit), 1)
msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 5f36415..0122797 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -18,13 +18,13 @@ typedef int (*unwind_entry_cb_t)(struct unwind_entry *entry, void *arg);
int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
struct thread *thread,
struct perf_sample *data, int max_stack);
+
/* libunwind specific */
#ifdef HAVE_LIBUNWIND_SUPPORT
int libunwind__arch_reg_id(int regnum);
int unwind__prepare_access(struct thread *thread);
void unwind__flush_access(struct thread *thread);
void unwind__finish_access(struct thread *thread);
-void register_local_unwind_libunwind_ops(struct thread *thread);
#else
static inline int unwind__prepare_access(struct thread *thread __maybe_unused)
{
@@ -33,9 +33,15 @@ static inline int unwind__prepare_access(struct thread *thread __maybe_unused)

static inline void unwind__flush_access(struct thread *thread __maybe_unused) {}
static inline void unwind__finish_access(struct thread *thread __maybe_unused) {}
+#endif
+
+#ifdef HAVE_LIBUNWIND_LOCAL_SUPPORT
+void register_local_unwind_libunwind_ops(struct thread *thread);
+#else
static inline void
register_local_unwind_libunwind_ops(struct thread *thread __maybe_unused) {}
#endif
+
#else
static inline int
unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
--
1.8.5.2