From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754690AbcESLsZ (ORCPT ); Thu, 19 May 2016 07:48:25 -0400 Received: from szxga04-in.huawei.com ([119.145.14.52]:25934 "EHLO szxga04-in.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754652AbcESLsW (ORCPT ); Thu, 19 May 2016 07:48:22 -0400 From: He Kuang To: , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v4 5/6] perf callchain: Support x86 target platform Date: Thu, 19 May 2016 11:47:41 +0000 Message-ID: <1463658462-85131-6-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1463658462-85131-1-git-send-email-hekuang@huawei.com> References: <1463658462-85131-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.573DA7EF.004A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f7b97fe21d9284821400df6d56dd2dcc Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Support x86(32-bit) cross platform callchain unwind. Signed-off-by: He Kuang --- tools/perf/arch/x86/include/libunwind/libunwind-arch.h | 18 ++++++++++++++++++ tools/perf/arch/x86/util/unwind-libunwind.c | 12 +++++++++--- tools/perf/util/Build | 6 ++++++ tools/perf/util/unwind-libunwind_common.c | 6 ++++-- tools/perf/util/unwind.h | 5 +++++ 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 tools/perf/arch/x86/include/libunwind/libunwind-arch.h diff --git a/tools/perf/arch/x86/include/libunwind/libunwind-arch.h b/tools/perf/arch/x86/include/libunwind/libunwind-arch.h new file mode 100644 index 0000000..265f14d --- /dev/null +++ b/tools/perf/arch/x86/include/libunwind/libunwind-arch.h @@ -0,0 +1,18 @@ +#ifndef _LIBUNWIND_ARCH_H +#define _LIBUNWIND_ARCH_H + +#include +#include <../perf_regs.h> +#include <../../../../../../arch/x86/include/uapi/asm/perf_regs.h> + +#define LIBUNWIND_X86_32 +int libunwind__x86_reg_id(int regnum); + +#include <../../../x86/util/unwind-libunwind.c> + +#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id + +#define UNWT_PREFIX UNW_PASTE(UNW_PASTE(_U, x86), _) +#define UNWT_OBJ(fn) UNW_PASTE(UNWT_PREFIX, fn) + +#endif /* _LIBUNWIND_ARCH_H */ diff --git a/tools/perf/arch/x86/util/unwind-libunwind.c b/tools/perf/arch/x86/util/unwind-libunwind.c index db25e93..a4f5449 100644 --- a/tools/perf/arch/x86/util/unwind-libunwind.c +++ b/tools/perf/arch/x86/util/unwind-libunwind.c @@ -5,7 +5,7 @@ #include "../../util/unwind.h" #include "../../util/debug.h" -#ifdef HAVE_ARCH_X86_64_SUPPORT +#if !defined(LIBUNWIND_X86_32) && defined(HAVE_ARCH_X86_64_SUPPORT) int libunwind__arch_reg_id(int regnum) { int id; @@ -69,8 +69,14 @@ int libunwind__arch_reg_id(int regnum) return id; } -#else +#endif + +#if defined(LIBUNWIND_X86_32) || !defined(HAVE_ARCH_X86_64_SUPPORT) +#ifndef LIBUNWIND_X86_32 int libunwind__arch_reg_id(int regnum) +#else +int libunwind__x86_reg_id(int regnum) +#endif { int id; @@ -109,4 +115,4 @@ int libunwind__arch_reg_id(int regnum) return id; } -#endif /* HAVE_ARCH_X86_64_SUPPORT */ +#endif diff --git a/tools/perf/util/Build b/tools/perf/util/Build index ce69721..2373130 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -1,3 +1,5 @@ +include ../scripts/Makefile.include + libperf-y += alias.o libperf-y += annotate.o libperf-y += build-id.o @@ -101,6 +103,10 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind_common.o +libperf-$(CONFIG_LIBUNWIND_X86) += unwind-libunwind_x86_32.o + +$(OUTPUT)util/unwind-libunwind_x86_32.o: util/unwind-libunwind.c arch/x86/util/unwind-libunwind.c + $(QUIET_CC)$(CC) $(CFLAGS) -DREMOTE_UNWIND_LIBUNWIND -Iarch/x86/include/libunwind -c -o $@ util/unwind-libunwind.c libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o diff --git a/tools/perf/util/unwind-libunwind_common.c b/tools/perf/util/unwind-libunwind_common.c index f44833b..619c6c0 100644 --- a/tools/perf/util/unwind-libunwind_common.c +++ b/tools/perf/util/unwind-libunwind_common.c @@ -82,9 +82,11 @@ void unwind__get_arch(struct thread *thread, struct map *map) if (!strcmp(arch, "x86")) { if (dso_type != DSO__TYPE_64BIT) { #ifdef HAVE_LIBUNWIND_X86_SUPPORT - pr_err("unwind: target platform=%s is not implemented\n", arch); -#endif + register_unwind_libunwind_ops( + &_Ux86_unwind_libunwind_ops, thread); +#else register_null_unwind_libunwind_ops(thread); +#endif use_local_unwind = 0; } } diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h index 1187950..73f4bd9 100644 --- a/tools/perf/util/unwind.h +++ b/tools/perf/util/unwind.h @@ -51,6 +51,11 @@ static inline void unwind__get_arch(struct thread *thread __maybe_unused, static inline void register_null_unwind_libunwind_ops(struct thread *thread __maybe_unused) {} #endif + +#ifdef HAVE_LIBUNWIND_X86_SUPPORT +extern struct unwind_libunwind_ops _Ux86_unwind_libunwind_ops; +#endif + #else static inline int unwind__get_entries(unwind_entry_cb_t cb __maybe_unused, -- 1.8.5.2