Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1397806 > unrolled thread
| Started by | He Kuang <hekuang@huawei.com> |
|---|---|
| First post | 2016-05-10 09:50 +0200 |
| Last post | 2016-05-10 09:50 +0200 |
| Articles | 7 — 4 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/9] Add support for remote unwind He Kuang <hekuang@huawei.com> - 2016-05-10 09:50 +0200
[PATCH v2 8/9] perf callchain: Support x86 target platform He Kuang <hekuang@huawei.com> - 2016-05-10 09:50 +0200
[PATCH v2 3/9] perf build: Add build-test for libunwind cross-platforms support He Kuang <hekuang@huawei.com> - 2016-05-10 09:50 +0200
Re: [PATCH v2 3/9] perf build: Add build-test for libunwind cross-platforms support Jiri Olsa <jolsa@redhat.com> - 2016-05-11 14:00 +0200
Re: [PATCH v2 3/9] perf build: Add build-test for libunwind cross-platforms support Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-11 15:30 +0200
[tip:perf/core] perf build: Add build-test for libunwind cross-platforms support tip-bot for He Kuang <tipbot@zytor.com> - 2016-05-12 12:30 +0200
[PATCH v2 9/9] perf callchain: Support aarch64 cross-platform He Kuang <hekuang@huawei.com> - 2016-05-10 09:50 +0200
| From | He Kuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-10 09:50 +0200 |
| Subject | [PATCH v2 0/9] Add support for remote unwind |
| Message-ID | <rxaAy-6l0-23@gated-at.bofh.it> |
v1 url:
http://thread.gmane.org/gmane.linux.kernel/2216256
Currently, perf script uses host unwind methods(local unwind) to parse
perf.data callchain info regardless of the target architecture. So we
get wrong result and no promotion when do remote unwind on other
platforms/machines.
This patchset adds build tests for the supported platforms for remote
unwinding, and checks whether a dso is 32-bit or 64-bit according to
elf class info for each thread to let perf use the correct remote
unwind methods instead.
Only x86 and aarch64 is added in this patchset to show the work flow,
other platforms can be added easily.
We can see the right result for unwind info on different machines, for
example: perf.data recorded on i686 qemu with '-g' option and parsed
on x86_64 machine.
before this patchset:
hello 1071 [000] 417.567832: probe:sys_close: (c1169d60)
c1169d61 sys_close ([kernel.kallsyms])
c189c0d7 sysenter_past_esp ([kernel.kallsyms])
b77c8ba9 [unknown] ([vdso32])
after:
hello 1071 [000] 417.567832: probe:sys_close: (c1169d60)
c1169d61 sys_close ([kernel.kallsyms])
c189c0d7 sysenter_past_esp ([kernel.kallsyms])
b77c8ba9 [unknown] ([vdso32])
b76e51cc close (/lib/libc-2.22.so)
804842e fib (/tmp/hello)
804849d main (/tmp/hello)
b762546e __libc_start_main (/lib/libc-2.22.so)
8048341 _start (/tmp/hello)
v2:
- Explain the reason why we can omit dwarf judgement when recording
in commit message.
- Elaborate on why we need to add a custom vdso path option, and
change the type name to DSO_BINARY_TYPE__VDSO.
- Hide the build tests status for cross platform unwind.
- Keep generic version of libunwind-debug-frame test.
- Put 32/64-bit test functions into separate patch.
- Extract unwind related functions to unwind-libunwind.c and add new
file for common parts used by both local and remote unwind.
- Eliminate most of the ifdefs in .c file.
Thanks.
He Kuang (9):
perf tools: Omit DWARF judgement when recording dwarf callchain
perf script: Add options for custom vdso path
perf build: Add build-test for libunwind cross-platforms support
perf build: Add build-test for debug-frame on arm/arm64
perf tools: Add methods to test dso is 64-bit or 32-bit
perf tools: Promote proper messages for cross-platform unwind
perf callchain: Add support for cross-platform unwind
perf callchain: Support x86 target platform
perf callchain: Support aarch64 cross-platform
tools/build/Makefile.feature | 8 +-
tools/build/feature/Makefile | 23 +++++
tools/build/feature/test-libunwind-aarch64.c | 26 +++++
tools/build/feature/test-libunwind-arm.c | 27 +++++
.../feature/test-libunwind-debug-frame-aarch64.c | 16 +++
.../build/feature/test-libunwind-debug-frame-arm.c | 16 +++
tools/build/feature/test-libunwind-x86.c | 27 +++++
tools/build/feature/test-libunwind-x86_64.c | 27 +++++
.../arch/arm64/include/libunwind/libunwind-arch.h | 18 ++++
tools/perf/arch/arm64/util/unwind-libunwind.c | 5 +-
.../arch/x86/include/libunwind/libunwind-arch.h | 18 ++++
tools/perf/arch/x86/util/unwind-libunwind.c | 42 ++++++++
tools/perf/builtin-script.c | 2 +
tools/perf/config/Makefile | 35 ++++++-
tools/perf/util/Build | 13 ++-
tools/perf/util/dso.c | 7 ++
tools/perf/util/dso.h | 1 +
tools/perf/util/symbol-elf.c | 16 +++
tools/perf/util/symbol.c | 50 +++++++++
tools/perf/util/symbol.h | 3 +
tools/perf/util/thread.c | 7 +-
tools/perf/util/thread.h | 14 ++-
tools/perf/util/unwind-libunwind.c | 49 +++++++--
tools/perf/util/unwind-libunwind_common.c | 113 +++++++++++++++++++++
tools/perf/util/unwind.h | 48 +++++++--
tools/perf/util/util.c | 2 -
26 files changed, 585 insertions(+), 28 deletions(-)
create mode 100644 tools/build/feature/test-libunwind-aarch64.c
create mode 100644 tools/build/feature/test-libunwind-arm.c
create mode 100644 tools/build/feature/test-libunwind-debug-frame-aarch64.c
create mode 100644 tools/build/feature/test-libunwind-debug-frame-arm.c
create mode 100644 tools/build/feature/test-libunwind-x86.c
create mode 100644 tools/build/feature/test-libunwind-x86_64.c
create mode 100644 tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
create mode 100644 tools/perf/arch/x86/include/libunwind/libunwind-arch.h
create mode 100644 tools/perf/util/unwind-libunwind_common.c
--
1.8.5.2
[toc] | [next] | [standalone]
| From | He Kuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-10 09:50 +0200 |
| Subject | [PATCH v2 8/9] perf callchain: Support x86 target platform |
| Message-ID | <rxaAB-6l0-67@gated-at.bofh.it> |
| In reply to | #1397806 |
Support x86(32-bit) cross platform callchain unwind.
Signed-off-by: He Kuang <hekuang@huawei.com>
---
.../arch/x86/include/libunwind/libunwind-arch.h | 18 ++++++++++
tools/perf/arch/x86/util/unwind-libunwind.c | 42 ++++++++++++++++++++++
tools/perf/util/Build | 6 ++++
tools/perf/util/unwind-libunwind.c | 2 +-
tools/perf/util/unwind-libunwind_common.c | 7 ++--
tools/perf/util/unwind.h | 5 +++
6 files changed, 76 insertions(+), 4 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 <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);
+
+#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..d422fbf 100644
--- a/tools/perf/arch/x86/util/unwind-libunwind.c
+++ b/tools/perf/arch/x86/util/unwind-libunwind.c
@@ -5,6 +5,7 @@
#include "../../util/unwind.h"
#include "../../util/debug.h"
+#ifndef LIBUNWIND_X86_32
#ifdef HAVE_ARCH_X86_64_SUPPORT
int libunwind__arch_reg_id(int regnum)
{
@@ -110,3 +111,44 @@ int libunwind__arch_reg_id(int regnum)
return id;
}
#endif /* HAVE_ARCH_X86_64_SUPPORT */
+#else
+int libunwind__x86_reg_id(int regnum)
+{
+ int id;
+
+ switch (regnum) {
+ case UNW_X86_EAX:
+ id = PERF_REG_X86_AX;
+ break;
+ case UNW_X86_EDX:
+ id = PERF_REG_X86_DX;
+ break;
+ case UNW_X86_ECX:
+ id = PERF_REG_X86_CX;
+ break;
+ case UNW_X86_EBX:
+ id = PERF_REG_X86_BX;
+ break;
+ case UNW_X86_ESI:
+ id = PERF_REG_X86_SI;
+ break;
+ case UNW_X86_EDI:
+ id = PERF_REG_X86_DI;
+ break;
+ case UNW_X86_EBP:
+ id = PERF_REG_X86_BP;
+ break;
+ case UNW_X86_ESP:
+ id = PERF_REG_X86_SP;
+ break;
+ case UNW_X86_EIP:
+ id = PERF_REG_X86_IP;
+ break;
+ default:
+ pr_err("unwind: invalid reg id %d\n", regnum);
+ return -EINVAL;
+ }
+
+ return id;
+}
+#endif /* LIBUNWIND_X86_32 */
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 2e21529..2dd3939 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
@@ -99,6 +101,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) -DARCH_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.c b/tools/perf/util/unwind-libunwind.c
index 2a8d24e..1844431 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -527,7 +527,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
return 0;
}
- id = libunwind__arch_reg_id(regnum);
+ id = LIBUNWIND__ARCH_REG_ID(regnum);
if (id < 0)
return -EINVAL;
diff --git a/tools/perf/util/unwind-libunwind_common.c b/tools/perf/util/unwind-libunwind_common.c
index 4bdd3b9..d0128f0 100644
--- a/tools/perf/util/unwind-libunwind_common.c
+++ b/tools/perf/util/unwind-libunwind_common.c
@@ -82,10 +82,11 @@ void unwind__get_arch(struct thread *thread, struct map *map)
pr_debug("unwind: thread map is X86, 64bit is %d\n", is_64_bit);
if (!is_64_bit) {
#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
} else
use_local_unwind = 1;
} else {
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index e045600..8f7c4357 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -54,6 +54,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
[toc] | [prev] | [next] | [standalone]
| From | He Kuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-10 09:50 +0200 |
| Subject | [PATCH v2 3/9] perf build: Add build-test for libunwind cross-platforms support |
| Message-ID | <rxaAB-6l0-69@gated-at.bofh.it> |
| In reply to | #1397806 |
Currently only test for local libunwind. We should check all supported
platforms so we can use them to parse perf.data with callchain info on
different machines.
Signed-off-by: He Kuang <hekuang@huawei.com>
---
tools/build/Makefile.feature | 4 ++++
tools/build/feature/Makefile | 16 ++++++++++++++++
tools/build/feature/test-libunwind-aarch64.c | 26 ++++++++++++++++++++++++++
tools/build/feature/test-libunwind-arm.c | 27 +++++++++++++++++++++++++++
tools/build/feature/test-libunwind-x86.c | 27 +++++++++++++++++++++++++++
tools/build/feature/test-libunwind-x86_64.c | 27 +++++++++++++++++++++++++++
6 files changed, 127 insertions(+)
create mode 100644 tools/build/feature/test-libunwind-aarch64.c
create mode 100644 tools/build/feature/test-libunwind-arm.c
create mode 100644 tools/build/feature/test-libunwind-x86.c
create mode 100644 tools/build/feature/test-libunwind-x86_64.c
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 9f87861..7e36e91 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -49,6 +49,10 @@ FEATURE_TESTS_BASIC := \
libslang \
libcrypto \
libunwind \
+ libunwind-x86 \
+ libunwind-x86_64 \
+ libunwind-arm \
+ libunwind-aarch64 \
pthread-attr-setaffinity-np \
stackprotector-all \
timerfd \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 4ae94db..f4fe3bc 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -27,6 +27,10 @@ FILES= \
test-libcrypto.bin \
test-libunwind.bin \
test-libunwind-debug-frame.bin \
+ test-libunwind-x86.bin \
+ test-libunwind-x86_64.bin \
+ test-libunwind-arm.bin \
+ test-libunwind-aarch64.bin \
test-pthread-attr-setaffinity-np.bin \
test-stackprotector-all.bin \
test-timerfd.bin \
@@ -103,6 +107,18 @@ $(OUTPUT)test-libunwind.bin:
$(OUTPUT)test-libunwind-debug-frame.bin:
$(BUILD) -lelf
+$(OUTPUT)test-libunwind-x86.bin:
+ $(BUILD) -lelf -lunwind-x86
+
+$(OUTPUT)test-libunwind-x86_64.bin:
+ $(BUILD) -lelf -lunwind-x86_64
+
+$(OUTPUT)test-libunwind-arm.bin:
+ $(BUILD) -lelf -lunwind-arm
+
+$(OUTPUT)test-libunwind-aarch64.bin:
+ $(BUILD) -lelf -lunwind-aarch64
+
$(OUTPUT)test-libaudit.bin:
$(BUILD) -laudit
diff --git a/tools/build/feature/test-libunwind-aarch64.c b/tools/build/feature/test-libunwind-aarch64.c
new file mode 100644
index 0000000..fc03fb6
--- /dev/null
+++ b/tools/build/feature/test-libunwind-aarch64.c
@@ -0,0 +1,26 @@
+#include <libunwind-aarch64.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
diff --git a/tools/build/feature/test-libunwind-arm.c b/tools/build/feature/test-libunwind-arm.c
new file mode 100644
index 0000000..632d95e
--- /dev/null
+++ b/tools/build/feature/test-libunwind-arm.c
@@ -0,0 +1,27 @@
+#include <libunwind-arm.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
diff --git a/tools/build/feature/test-libunwind-x86.c b/tools/build/feature/test-libunwind-x86.c
new file mode 100644
index 0000000..3561edc
--- /dev/null
+++ b/tools/build/feature/test-libunwind-x86.c
@@ -0,0 +1,27 @@
+#include <libunwind-x86.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
diff --git a/tools/build/feature/test-libunwind-x86_64.c b/tools/build/feature/test-libunwind-x86_64.c
new file mode 100644
index 0000000..5add251
--- /dev/null
+++ b/tools/build/feature/test-libunwind-x86_64.c
@@ -0,0 +1,27 @@
+#include <libunwind-x86_64.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
--
1.8.5.2
[toc] | [prev] | [next] | [standalone]
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Date | 2016-05-11 14:00 +0200 |
| Subject | Re: [PATCH v2 3/9] perf build: Add build-test for libunwind cross-platforms support |
| Message-ID | <rxAY3-7z7-29@gated-at.bofh.it> |
| In reply to | #1397808 |
On Tue, May 10, 2016 at 07:40:31AM +0000, He Kuang wrote: > Currently only test for local libunwind. We should check all supported > platforms so we can use them to parse perf.data with callchain info on > different machines. > > Signed-off-by: He Kuang <hekuang@huawei.com> Acked-by: Jiri Olsa <jolsa@kernel.org> thanks, jirka
[toc] | [prev] | [next] | [standalone]
| From | Arnaldo Carvalho de Melo <acme@kernel.org> |
|---|---|
| Date | 2016-05-11 15:30 +0200 |
| Subject | Re: [PATCH v2 3/9] perf build: Add build-test for libunwind cross-platforms support |
| Message-ID | <rxCn9-F9-35@gated-at.bofh.it> |
| In reply to | #1398984 |
Em Wed, May 11, 2016 at 01:52:30PM +0200, Jiri Olsa escreveu: > On Tue, May 10, 2016 at 07:40:31AM +0000, He Kuang wrote: > > Currently only test for local libunwind. We should check all supported > > platforms so we can use them to parse perf.data with callchain info on > > different machines. > > > > Signed-off-by: He Kuang <hekuang@huawei.com> > > Acked-by: Jiri Olsa <jolsa@kernel.org> Thanks, applied
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for He Kuang <tipbot@zytor.com> |
|---|---|
| Date | 2016-05-12 12:30 +0200 |
| Subject | [tip:perf/core] perf build: Add build-test for libunwind cross-platforms support |
| Message-ID | <rxW2w-3Gh-55@gated-at.bofh.it> |
| In reply to | #1397808 |
Commit-ID: b1d960000ca12508c25776f1fd375ee81578ae1f
Gitweb: http://git.kernel.org/tip/b1d960000ca12508c25776f1fd375ee81578ae1f
Author: He Kuang <hekuang@huawei.com>
AuthorDate: Tue, 10 May 2016 07:40:31 +0000
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 11 May 2016 12:24:58 -0300
perf build: Add build-test for libunwind cross-platforms support
Currently only test for local libunwind. We should check all supported
platforms so we can use them to parse perf.data with callchain info on
different machines.
Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1462866037-30382-4-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/build/Makefile.feature | 4 ++++
tools/build/feature/Makefile | 16 ++++++++++++++++
tools/build/feature/test-libunwind-aarch64.c | 26 ++++++++++++++++++++++++++
tools/build/feature/test-libunwind-arm.c | 27 +++++++++++++++++++++++++++
tools/build/feature/test-libunwind-x86.c | 27 +++++++++++++++++++++++++++
tools/build/feature/test-libunwind-x86_64.c | 27 +++++++++++++++++++++++++++
6 files changed, 127 insertions(+)
diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 9f87861..7e36e91 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -49,6 +49,10 @@ FEATURE_TESTS_BASIC := \
libslang \
libcrypto \
libunwind \
+ libunwind-x86 \
+ libunwind-x86_64 \
+ libunwind-arm \
+ libunwind-aarch64 \
pthread-attr-setaffinity-np \
stackprotector-all \
timerfd \
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 4ae94db..f4fe3bc 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -27,6 +27,10 @@ FILES= \
test-libcrypto.bin \
test-libunwind.bin \
test-libunwind-debug-frame.bin \
+ test-libunwind-x86.bin \
+ test-libunwind-x86_64.bin \
+ test-libunwind-arm.bin \
+ test-libunwind-aarch64.bin \
test-pthread-attr-setaffinity-np.bin \
test-stackprotector-all.bin \
test-timerfd.bin \
@@ -103,6 +107,18 @@ $(OUTPUT)test-libunwind.bin:
$(OUTPUT)test-libunwind-debug-frame.bin:
$(BUILD) -lelf
+$(OUTPUT)test-libunwind-x86.bin:
+ $(BUILD) -lelf -lunwind-x86
+
+$(OUTPUT)test-libunwind-x86_64.bin:
+ $(BUILD) -lelf -lunwind-x86_64
+
+$(OUTPUT)test-libunwind-arm.bin:
+ $(BUILD) -lelf -lunwind-arm
+
+$(OUTPUT)test-libunwind-aarch64.bin:
+ $(BUILD) -lelf -lunwind-aarch64
+
$(OUTPUT)test-libaudit.bin:
$(BUILD) -laudit
diff --git a/tools/build/feature/test-libunwind-aarch64.c b/tools/build/feature/test-libunwind-aarch64.c
new file mode 100644
index 0000000..fc03fb6
--- /dev/null
+++ b/tools/build/feature/test-libunwind-aarch64.c
@@ -0,0 +1,26 @@
+#include <libunwind-aarch64.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
diff --git a/tools/build/feature/test-libunwind-arm.c b/tools/build/feature/test-libunwind-arm.c
new file mode 100644
index 0000000..632d95e
--- /dev/null
+++ b/tools/build/feature/test-libunwind-arm.c
@@ -0,0 +1,27 @@
+#include <libunwind-arm.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
diff --git a/tools/build/feature/test-libunwind-x86.c b/tools/build/feature/test-libunwind-x86.c
new file mode 100644
index 0000000..3561edc
--- /dev/null
+++ b/tools/build/feature/test-libunwind-x86.c
@@ -0,0 +1,27 @@
+#include <libunwind-x86.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
diff --git a/tools/build/feature/test-libunwind-x86_64.c b/tools/build/feature/test-libunwind-x86_64.c
new file mode 100644
index 0000000..5add251
--- /dev/null
+++ b/tools/build/feature/test-libunwind-x86_64.c
@@ -0,0 +1,27 @@
+#include <libunwind-x86_64.h>
+#include <stdlib.h>
+
+extern int UNW_OBJ(dwarf_search_unwind_table) (unw_addr_space_t as,
+ unw_word_t ip,
+ unw_dyn_info_t *di,
+ unw_proc_info_t *pi,
+ int need_unwind_info, void *arg);
+
+
+#define dwarf_search_unwind_table UNW_OBJ(dwarf_search_unwind_table)
+
+static unw_accessors_t accessors;
+
+int main(void)
+{
+ unw_addr_space_t addr_space;
+
+ addr_space = unw_create_addr_space(&accessors, 0);
+ if (addr_space)
+ return 0;
+
+ unw_init_remote(NULL, addr_space, NULL);
+ dwarf_search_unwind_table(addr_space, 0, NULL, NULL, 0, NULL);
+
+ return 0;
+}
[toc] | [prev] | [next] | [standalone]
| From | He Kuang <hekuang@huawei.com> |
|---|---|
| Date | 2016-05-10 09:50 +0200 |
| Subject | [PATCH v2 9/9] perf callchain: Support aarch64 cross-platform |
| Message-ID | <rxaAy-6l0-35@gated-at.bofh.it> |
| In reply to | #1397806 |
Support aarch64 cross platform callchain unwind.
Signed-off-by: He Kuang <hekuang@huawei.com>
---
.../perf/arch/arm64/include/libunwind/libunwind-arch.h | 18 ++++++++++++++++++
tools/perf/arch/arm64/util/unwind-libunwind.c | 5 ++++-
tools/perf/config/Makefile | 12 ++++++++++++
tools/perf/util/Build | 4 ++++
tools/perf/util/unwind-libunwind_common.c | 12 ++++++++++++
tools/perf/util/unwind.h | 3 +++
6 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
diff --git a/tools/perf/arch/arm64/include/libunwind/libunwind-arch.h b/tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
new file mode 100644
index 0000000..7bc8a00
--- /dev/null
+++ b/tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
@@ -0,0 +1,18 @@
+#ifndef _LIBUNWIND_ARCH_H
+#define _LIBUNWIND_ARCH_H
+
+#include <libunwind-aarch64.h>
+#include <../perf_regs.h>
+#include <../../../../../../arch/arm64/include/uapi/asm/perf_regs.h>
+
+#define LIBUNWIND_AARCH64
+int libunwind__aarch64_reg_id(int regnum);
+
+#include <../../../arm64/util/unwind-libunwind.c>
+
+#define LIBUNWIND__ARCH_REG_ID libunwind__aarch64_reg_id
+
+#define UNWT_PREFIX UNW_PASTE(UNW_PASTE(_U, aarch64), _)
+#define UNWT_OBJ(fn) UNW_PASTE(UNWT_PREFIX, fn)
+
+#endif /* _LIBUNWIND_ARCH_H */
diff --git a/tools/perf/arch/arm64/util/unwind-libunwind.c b/tools/perf/arch/arm64/util/unwind-libunwind.c
index a87afa9..5b557a5 100644
--- a/tools/perf/arch/arm64/util/unwind-libunwind.c
+++ b/tools/perf/arch/arm64/util/unwind-libunwind.c
@@ -1,11 +1,14 @@
#include <errno.h>
-#include <libunwind.h>
#include "perf_regs.h"
#include "../../util/unwind.h"
#include "../../util/debug.h"
+#ifndef LIBUNWIND_AARCH64
int libunwind__arch_reg_id(int regnum)
+#else
+int libunwind__aarch64_reg_id(int regnum)
+#endif
{
switch (regnum) {
case UNW_AARCH64_X0:
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 16f14b1..c1bfc5e 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -353,6 +353,18 @@ ifndef NO_LIBUNWIND
have_libunwind = 1
endif
+ ifeq ($(feature-libunwind-aarch64), 1)
+ $(call detected,CONFIG_LIBUNWIND_AARCH64)
+ CFLAGS += -DHAVE_LIBUNWIND_AARCH64_SUPPORT
+ LDFLAGS += -lunwind -lunwind-aarch64
+ have_libunwind = 1
+ $(call feature_check,libunwind-debug-frame-aarch64)
+ ifneq ($(feature-libunwind-debug-frame-aarch64), 1)
+ msg := $(warning No debug_frame support found in libunwind-aarch64);
+ CFLAGS += -DNO_LIBUNWIND_DEBUG_FRAME_AARCH64
+ endif
+ endif
+
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
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 2dd3939..10e42ad 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -102,10 +102,14 @@ 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
+libperf-$(CONFIG_LIBUNWIND_AARCH64) += unwind-libunwind_arm64.o
$(OUTPUT)util/unwind-libunwind_x86_32.o: util/unwind-libunwind.c arch/x86/util/unwind-libunwind.c
$(QUIET_CC)$(CC) $(CFLAGS) -DARCH_UNWIND_LIBUNWIND -Iarch/x86/include/libunwind -c -o $@ util/unwind-libunwind.c
+$(OUTPUT)util/unwind-libunwind_arm64.o: util/unwind-libunwind.c arch/arm64/util/unwind-libunwind.c
+ $(QUIET_CC)$(CC) $(CFLAGS) -DARCH_UNWIND_LIBUNWIND -Iarch/arm64/include/libunwind -c -o $@ util/unwind-libunwind.c
+
libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
libperf-y += scripting-engines/
diff --git a/tools/perf/util/unwind-libunwind_common.c b/tools/perf/util/unwind-libunwind_common.c
index d0128f0..fde42b2 100644
--- a/tools/perf/util/unwind-libunwind_common.c
+++ b/tools/perf/util/unwind-libunwind_common.c
@@ -89,6 +89,18 @@ void unwind__get_arch(struct thread *thread, struct map *map)
#endif
} else
use_local_unwind = 1;
+ } else if (!strcmp(arch, "aarch64") || !strncmp(arch, "arm", 3)) {
+ pr_debug("Thread map is ARM, 64bit is %d, dso=%s\n",
+ is_64_bit, map->dso->name);
+ if (is_64_bit) {
+#ifdef HAVE_LIBUNWIND_AARCH64_SUPPORT
+ register_unwind_libunwind_ops(
+ &_Uaarch64_unwind_libunwind_ops, thread);
+#else
+ register_null_unwind_libunwind_ops(thread);
+#endif
+ } else
+ use_local_unwind = 1;
} else {
use_local_unwind = 1;
}
diff --git a/tools/perf/util/unwind.h b/tools/perf/util/unwind.h
index 8f7c4357..741a53f 100644
--- a/tools/perf/util/unwind.h
+++ b/tools/perf/util/unwind.h
@@ -58,6 +58,9 @@ register_null_unwind_libunwind_ops(struct thread *thread __maybe_unused) {}
#ifdef HAVE_LIBUNWIND_X86_SUPPORT
extern struct unwind_libunwind_ops _Ux86_unwind_libunwind_ops;
#endif
+#ifdef HAVE_LIBUNWIND_AARCH64_SUPPORT
+extern struct unwind_libunwind_ops _Uaarch64_unwind_libunwind_ops;
+#endif
#else
static inline int
--
1.8.5.2
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web