mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: He Kuang <hekuang@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
	<alexander.shishkin@linux.intel.com>, <jolsa@redhat.com>,
	<wangnan0@huawei.com>, <hekuang@huawei.com>,
	<jpoimboe@redhat.com>, <ak@linux.intel.com>, <eranian@google.com>,
	<namhyung@kernel.org>, <adrian.hunter@intel.com>,
	<sukadev@linux.vnet.ibm.com>, <masami.hiramatsu.pt@hitachi.com>,
	<tumanova@linux.vnet.ibm.com>, <kan.liang@intel.com>,
	<penberg@kernel.org>, <dsahern@gmail.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH v5 4/5] perf callchain: Support x86 target platform
Date: Tue, 24 May 2016 09:20:28 +0000	[thread overview]
Message-ID: <1464081629-137191-5-git-send-email-hekuang@huawei.com> (raw)
In-Reply-To: <1464081629-137191-1-git-send-email-hekuang@huawei.com>

Support x86(32-bit) cross platform callchain unwind.

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 .../perf/arch/x86/include/libunwind/libunwind-arch.h  | 18 ++++++++++++++++++
 tools/perf/arch/x86/util/unwind-libunwind.c           | 19 ++++++++++++++-----
 tools/perf/util/Build                                 |  6 ++++++
 tools/perf/util/unwind-libunwind_common.c             |  6 ++++--
 tools/perf/util/unwind.h                              |  5 +++++
 5 files changed, 47 insertions(+), 7 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..be8c675
--- /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 <libunwind-x86.h>
+#include <../perf_regs.h>
+#include <../../../../../../arch/x86/include/uapi/asm/perf_regs.h>
+
+#define LIBUNWIND_X86_32
+int libunwind__x86_reg_id(int regnum);
+
+#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id
+
+#include <../../../x86/util/unwind-libunwind.c>
+
+#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..28831d8 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -1,12 +1,18 @@
 
 #include <errno.h>
+#if defined(LIBUNWIND_X86_32)
+#include <libunwind-x86.h>
+#elif defined(LIBUNWIND_X86_64)
+#include <libunwind-x86_64.h>
+#elif defined(HAVE_LIBUNWIND_LOCAL_SUPPORT)
 #include <libunwind.h>
+#endif
 #include "perf_regs.h"
 #include "../../util/unwind.h"
 #include "../../util/debug.h"
 
-#ifdef HAVE_ARCH_X86_64_SUPPORT
-int libunwind__arch_reg_id(int regnum)
+#if !defined(REMOTE_UNWIND_LIBUNWIND) && defined(HAVE_ARCH_X86_64_SUPPORT)
+int LIBUNWIND__ARCH_REG_ID(int regnum)
 {
 	int id;
 
@@ -69,8 +75,11 @@ int libunwind__arch_reg_id(int regnum)
 
 	return id;
 }
-#else
-int libunwind__arch_reg_id(int regnum)
+#endif
+
+#if !defined(REMOTE_UNWIND_LIBUNWIND) && !defined(HAVE_ARCH_X86_64_SUPPORT) || \
+	defined(LIBUNWIND_X86_32)
+int LIBUNWIND__ARCH_REG_ID(int regnum)
 {
 	int id;
 
@@ -109,4 +118,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 e170be7..7dafb6e 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -56,6 +56,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

  parent reply	other threads:[~2016-05-24  9:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  9:20 [PATCH v5 0/5] Add support for remote unwind He Kuang
2016-05-24  9:20 ` [PATCH v5 1/5] perf tools: Use LIBUNWIND_DIR for remote libunwind feature check He Kuang
2016-05-24  9:20 ` [PATCH v5 2/5] perf tools: Show warnings for unsupported cross-platform unwind He Kuang
2016-05-24  9:20 ` [PATCH v5 3/5] perf callchain: Add support for " He Kuang
2016-05-26 17:42   ` Jiri Olsa
2016-05-27  7:13     ` Hekuang
2016-05-27  7:38       ` Jiri Olsa
2016-05-27  8:02         ` Hekuang
2016-05-27  8:44           ` Jiri Olsa
2016-05-26 17:51   ` Jiri Olsa
2016-05-24  9:20 ` He Kuang [this message]
2016-05-26 17:57   ` [PATCH v5 4/5] perf callchain: Support x86 target platform Jiri Olsa
2016-05-24  9:20 ` [PATCH v5 5/5] perf callchain: Support aarch64 cross-platform He Kuang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464081629-137191-5-git-send-email-hekuang@huawei.com \
    --to=hekuang@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=penberg@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sukadev@linux.vnet.ibm.com \
    --cc=tumanova@linux.vnet.ibm.com \
    --cc=wangnan0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®