Add support for remote unwind
Subsystems (2)
v6 cover Add support for remote unwind
v5 url:
http://thread.gmane.org/gmane.linux.kernel/2226821
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 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 1219 [001] 72190.667975: probe:sys_close: (c1169d60)
c1169d61 sys_close ([kernel.kallsyms])
c189c0d7 sysenter_past_esp ([kernel.kallsyms])
b777aba9 [unknown] ([vdso32])after:
(Add vdso into buildid-cache first by 'perf buildid-cache -a' and libraries are provided in symfs dir)
hello 1219 [001] 72190.667975: probe:sys_close: (c1169d60)
c1169d61 sys_close ([kernel.kallsyms])
c189c0d7 sysenter_past_esp ([kernel.kallsyms])
b777aba9 __kernel_vsyscall ([vdso32])
b76971cc close (/lib/libc-2.22.so)
804842e fib (/tmp/hello)
804849d main (/tmp/hello)
b75d746e __libc_start_main (/lib/libc-2.22.so)
8048341 _start (/tmp/hello)For using remote libunwind libraries, reference this:
http://thread.gmane.org/gmane.linux.kernel/2224430
and now we can use LIBUNWIND_DIR to specific custom dirctories containing libunwind libs.
v6:
By following the advises from Jiri Olsa:
- Introducing struct unwind_libunwind_ops for local unwind
- Move unwind__prepare_access from thread_new into thread__insert_map
- Extract local libunwind code out of unwind-libunwind.c
- Other changes mentioned in v5 mails.
Thanks.
He Kuang (11):
perf tools: Use LIBUNWIND_DIR for remote libunwind feature check perf tools: Decouple thread->address_space on libunwind perf tools: Introducing struct unwind_libunwind_ops for local unwind perf tools: Move unwind__prepare_access from thread_new into
thread__insert_map
perf tools: Separate local/remote libunwind config
perf tools: Extract local libunwind code out of unwind-libunwind.c perf tools: Export normalize_arch() function
perf tools: Show warnings for unsupported cross-platform unwind perf tools: Change fixed name of libunwind__arch_reg_id to macro perf callchain: Support x86 target platform
perf callchain: Support aarch64 cross-platform
tools/perf/arch/Build | 2 + tools/perf/arch/arm/util/Build | 2 +- tools/perf/arch/arm64/util/Build | 2 +- tools/perf/arch/arm64/util/unwind-libunwind.c | 4 +- .../perf/arch/arm64/util/unwind-libunwind_arm64.c | 22 + tools/perf/arch/common.c | 2 +- tools/perf/arch/common.h | 1 + tools/perf/arch/x86/util/Build | 2 +- tools/perf/arch/x86/util/unwind-libunwind.c | 7 +- tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 + tools/perf/config/Makefile | 50 +- tools/perf/util/Build | 1 + tools/perf/util/thread.c | 5 +- tools/perf/util/thread.h | 17 +- tools/perf/util/unwind-libunwind-local.c | 681 ++++++++++++++++++++ tools/perf/util/unwind-libunwind.c | 697 ++------------------- tools/perf/util/unwind.h | 41 +- 17 files changed, 884 insertions(+), 673 deletions(-) create mode 100644 tools/perf/arch/arm64/util/unwind-libunwind_arm64.c create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c create mode 100644 tools/perf/util/unwind-libunwind-local.c
Signature · 1 line
1.8.5.2
PATCH v6 1/11 perf tools: Use LIBUNWIND_DIR for remote libunwind feature check
Pass LIBUNWIND_DIR to feature check flags for remote libunwind tests. So perf can be able to detect remote libunwind libraries from arbitrary directory.
--- tools/perf/config/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/perf/config/Makefile +9 -0
@@ -67,9 +67,18 @@ endif # # make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ # + +libunwind_arch_set_flags = $(eval $(libunwind_arch_set_flags_code)) +define libunwind_arch_set_flags_code + FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include + FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib +endef + ifdef LIBUNWIND_DIR LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib + LIBUNWIND_ARCHS = x86 x86_64 arm aarch64 debug-frame-arm debug-frame-aarch64 + $(foreach libunwind_arch,$(LIBUNWIND_ARCHS),$(call libunwind_arch_set_flags,$(libunwind_arch))) endif LIBUNWIND_LDFLAGS += $(LIBUNWIND_LIBS)
Signature · 1 line
1.8.5.2
PATCH v6 2/11 perf tools: Decouple thread->address_space on libunwind
In reply to He KuangCurrently, the type of thread->addr_space is unw_addr_space_t, which is a pointer defined in libunwind headers. For local libunwind, we can simple include "libunwind.h", but for remote libunwind, the header file is depends on the target libunwind platform. This patch uses 'void *' instead to decouple the dependence on libunwind.
--- tools/perf/util/thread.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tools/perf/util/thread.h +1 -4
@@ -9,9 +9,6 @@#include "symbol.h" #include <strlist.h> #include <intlist.h> -#ifdef HAVE_LIBUNWIND_SUPPORT -#include <libunwind.h> -#endif struct thread_stack ;
@@ -36,7 +33,7 @@ struct thread {void *priv;struct thread_stack *ts;#ifdef HAVE_LIBUNWIND_SUPPORT -unw_addr_space_t addr_space; +void *addr_space;#endif };
Signature · 1 line
1.8.5.2
PATCH v6 3/11 perf tools: Introducing struct unwind_libunwind_ops for local unwind
In reply to He KuangCurrently, libunwind operations are fixed, and they are chosen according to the host architecture. This will lead a problem that if a thread is run as x86_32 on x86_64 machine, perf will use libunwind methods for x86_64 to parse the callchain and get wrong result.
This patch changes the fixed methods of libunwind operations to thread/map related, and each thread can have indivadual libunwind operations. Local libunwind methods are registered as default value.
--- tools/perf/util/thread.c | 2 ++ tools/perf/util/thread.h | 14 +++++++++- tools/perf/util/unwind-libunwind.c | 55 ++++++++++++++++++++++++++++++++++---- tools/perf/util/unwind.h | 5 ++++ 4 files changed, 70 insertions(+), 6 deletions(-)
tools/perf/util/thread.c +2 -0
@@ -43,6 +43,8 @@ struct thread *thread__new(pid_t pid, pid_t tid) thread->cpu =-1 ;INIT_LIST_HEAD (&thread->comm_list); +register_local_unwind_libunwind_ops (thread); +if (unwind__prepare_access (thread) <0 ) goto err_thread;
tools/perf/util/thread.h +13 -1
@@ -12,6 +12,17 @@struct thread_stack ; +struct unwind_entry ; +typedef int (*unwind_entry_cb_t )(struct unwind_entry *entry,void *arg); +struct unwind_libunwind_ops { +int (*prepare_access)(struct thread *thread); +void (*flush_access)(struct thread *thread); +void (*finish_access)(struct thread *thread); +int (*get_entries)(unwind_entry_cb_t cb,void *arg, +struct thread *thread, +struct perf_sample *data,int max_stack); +}; + struct thread { union { struct rb_node rb_node;
@@ -33,7 +44,8 @@ struct thread {void *priv;struct thread_stack *ts;#ifdef HAVE_LIBUNWIND_SUPPORT -void *addr_space; +void *addr_space; +struct unwind_libunwind_ops *unwind_libunwind_ops;#endif };
tools/perf/util/unwind-libunwind.c +50 -5
88 lines not on this page · raw message
tools/perf/util/unwind.h +5 -0
@@ -24,6 +24,7 @@ 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 ) {
@@ -32,6 +33,8 @@ 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 ) {} +static inline void +register_local_unwind_libunwind_ops (struct thread *thread__maybe_unused ) {}#endif #else static inline int
@@ -51,5 +54,7 @@ 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 ) {} +static inline void +register_local_unwind_libunwind_ops (struct thread *thread__maybe_unused ) {}#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* __UNWIND_H */
Signature · 1 line
1.8.5.2
Re: [PATCH v6 03/11] perf tools: Introducing struct unwind_libunwind_ops for local unwind
Quoted 39 lines · He Kuang
Currently, libunwind operations are fixed, and they are chosen according to the host architecture. This will lead a problem that if a thread is run as
x86_32onx86_64machine, perf will use libunwind methods forx86_64to parse the callchain and get wrong result.This patch changes the fixed methods of libunwind operations to thread/map related, and each thread can have indivadual libunwind operations. Local libunwind methods are registered as default value.
Signed-off-by He Kuang <[email protected]>--- tools/perf/util/thread.c | 2 ++ tools/perf/util/thread.h | 14 +++++++++- tools/perf/util/unwind-libunwind.c | 55 ++++++++++++++++++++++++++++++++++---- tools/perf/util/unwind.h | 5 ++++ 4 files changed, 70 insertions(+), 6 deletions(-)tools/perf/util/thread.c +2
-0@@ -43,6 +43,8 @@ struct thread *thread__new(pid_t pid, pid_t tid) thread->cpu =-1 ;INIT_LIST_HEAD (&thread->comm_list); +register_local_unwind_libunwind_ops (thread); +if (unwind__prepare_access (thread) <0 ) goto err_thread;tools/perf/util/thread.h +1
-0@@ -12,6 +12,17 @@struct thread_stack ; +struct unwind_entry ;
tools/perf/util/thread.h line 25
Quoted 10 lines
tools/perf/util/thread.h +10
-0+typedef int (*unwind_entry_cb_t )(struct unwind_entry *entry,void *arg); +struct unwind_libunwind_ops { +int (*prepare_access)(struct thread *thread); +void (*flush_access)(struct thread *thread); +void (*finish_access)(struct thread *thread); +int (*get_entries)(unwind_entry_cb_t cb,void *arg, +struct thread *thread, +struct perf_sample *data,int max_stack); +}; +
this should rather go to util/unwind.h
thanks,
jirka
PATCH v6 4/11 perf tools: Move unwind__prepare_access from thread_new into thread__insert_map
In reply to He KuangFor determine the libunwind methods to use, we should get the 32bit/64bit information from maps of a thread. When a thread is newly created, the information is not prepared. This patch moves unwind__prepare_access() into thread__insert_map() so we can get the information we need from maps.
--- tools/perf/util/thread.c | 7 ++----- tools/perf/util/unwind-libunwind.c | 7 +++---- 2 files changed, 5 insertions(+), 9 deletions(-)
tools/perf/util/thread.c +2 -5
@@ -43,11 +43,6 @@ struct thread *thread__new(pid_t pid, pid_t tid) thread->cpu =-1 ;INIT_LIST_HEAD (&thread->comm_list); -register_local_unwind_libunwind_ops (thread); - -if (unwind__prepare_access (thread) <0 ) - goto err_thread; - comm_str =malloc (32 );if (!comm_str) goto err_thread;
@@ -207,6 +202,8 @@ void thread__insert_map(struct thread *thread, struct map *map) {map_groups__fixup_overlappings (thread->mg, map, stderr);map_groups__insert (thread->mg, map); + +unwind__prepare_access (thread); } static int thread__clone_map_groups(struct thread *thread,
tools/perf/util/unwind-libunwind.c +3 -4
@@ -695,10 +695,9 @@ void register_local_unwind_libunwind_ops(struct thread *thread)int unwind__prepare_access (struct thread *thread) { -if (thread->unwind_libunwind_ops) -return thread->unwind_libunwind_ops->prepare_access (thread); -else -return 0 ; +register_local_unwind_libunwind_ops (thread); + +return thread->unwind_libunwind_ops->prepare_access (thread); }void unwind__flush_access (struct thread *thread)
Signature · 1 line
1.8.5.2
Re: [PATCH v6 04/11] perf tools: Move unwind__prepare_access from thread_new into thread__insert_map
Quoted 29 lines · He Kuang
For determine the libunwind methods to use, we should get the 32bit/64bit information from maps of a thread. When a thread is newly created, the information is not prepared. This patch moves
unwind__prepare_access()intothread__insert_map()so we can get the information we need from maps.Signed-off-by He Kuang <[email protected]>--- tools/perf/util/thread.c | 7 ++----- tools/perf/util/unwind-libunwind.c | 7 +++---- 2 files changed, 5 insertions(+), 9 deletions(-)tools/perf/util/thread.c +0
-5@@ -43,11 +43,6 @@ struct thread *thread__new(pid_t pid, pid_t tid) thread->cpu =-1 ;INIT_LIST_HEAD (&thread->comm_list); -register_local_unwind_libunwind_ops (thread); - -if (unwind__prepare_access (thread) <0 ) - goto err_thread; - comm_str =malloc (32 );if (!comm_str) goto err_thread;
tools/perf/util/thread.c void thread__insert_map(struct thread *thread, struct map *map) · line 206
Quoted 5 lines
tools/perf/util/thread.c +2
-0@@ -207,6 +202,8 @@ void thread__insert_map(struct thread *thread, struct map *map) {map_groups__fixup_overlappings (thread->mg, map, stderr);map_groups__insert (thread->mg, map); + +unwind__prepare_access (thread);
so thread__insert_map does not return value,
I think we should change it now when it callsunwind__prepare_access
I was also thinking to keepcall unwind__prepare_access separatelly but this function seems to fit better
thanks,
jirka
PATCH v6 5/11 perf tools: Separate local/remote libunwind config
In reply to He KuangCONFIG_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.
--- 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(-)
tools/perf/arch/arm/util/Build +1 -1
@@ -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
tools/perf/arch/arm64/util/Build +1 -1
@@ -1,2 +1,2 @@ libperf-$(CONFIG_DWARF) += dwarf-regs.o -libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o +libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
tools/perf/arch/x86/util/Build +1 -1
@@ -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
tools/perf/config/Makefile +19 -2
@@ -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);
tools/perf/util/unwind.h +7 -1
@@ -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,
Signature · 1 line
1.8.5.2
Re: [PATCH v6 05/11] perf tools: Separate local/remote libunwind config
On Sat, May 28, 2016 at 11:59:54AM +0000, He Kuang wrote:
SNIP
Quoted 13 lines
tools/perf/config/Makefile +3
-0@@ -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
tools/perf/config/Makefile ifeq ($(ARCH),powerpc) · line 371
Quoted 10 lines
tools/perf/config/Makefile +9
-0+ 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
changelog says it's just switch, then why do we need to add above setup?
jirka
PATCH v6 6/11 perf tools: Extract local libunwind code out of unwind-libunwind.c
In reply to He KuangThis patch extracts codes related to specific arithecture out of unwind-libunwind.c. The extrated part are only built if local libunwind is supported.
--- tools/perf/util/Build | 1 + tools/perf/util/unwind-libunwind-local.c | 677 ++++++++++++++++++++++++++++++ tools/perf/util/unwind-libunwind.c | 694 +------------------------------ 3 files changed, 679 insertions(+), 693 deletions(-) create mode 100644 tools/perf/util/unwind-libunwind-local.c
tools/perf/util/Build +1 -0
@@ -99,6 +99,7 @@ libperf-$(CONFIG_DWARF) += probe-finder.o libperf-$(CONFIG_DWARF) += dwarf-aux.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o +libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind-local.o libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
tools/perf/util/unwind-libunwind-local.c new file +677 -0
677 lines not on this page · raw message
tools/perf/util/unwind-libunwind.c +1 -693
698 lines not on this page · raw message
Signature · 1 line
1.8.5.2
Re: [PATCH v6 06/11] perf tools: Extract local libunwind code out of unwind-libunwind.c
Quoted 4 lines · He Kuang
This patch extracts codes related to specific arithecture out of
unwind-libunwind.c. The extrated part are only built if local libunwind is supported.
Quoted 8 lines
Signed-off-by He Kuang <[email protected]>--- tools/perf/util/Build | 1 + tools/perf/util/unwind-libunwind-local.c | 677 ++++++++++++++++++++++++++++++ tools/perf/util/unwind-libunwind.c | 694 +------------------------------ 3 files changed, 679 insertions(+), 693 deletions(-)create mode 100644
tools/perf/util/unwind-libunwind-local.c
Please use 'git format-patch -M' to avoid such a large patch.
Thank you.
PATCH v6 1/2 perf tools: Rename unwind-libunwind.c to unwind-libunwind-local.c
Since unwind-libunwind.c contains code for specific arithecture, we change it's name to unwind-libunwind-local.c, and let it only be built if local libunwind is supported.
---
tools/perf/util/Build | 2 +-
tools/perf/util/{unwind-libunwind.c => unwind-libunwind-local.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename tools/perf/util/{unwind-libunwind.c => unwind-libunwind-local.c} (100%)tools/perf/util/Build +1 -1
@@ -99,7 +99,7 @@ libperf-$(CONFIG_DWARF) += probe-finder.o libperf-$(CONFIG_DWARF) += dwarf-aux.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o -libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o +libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind-local.o libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
tools/perf/util/unwind-libunwind-local.c renamed from tools/perf/util/unwind-libunwind.c +0 -0
Signature · 1 line
1.8.5.2
PATCH v6 2/2 perf tools: Extract common API out of unwind-libunwind-local.c
This patch extracts common unwind-libunwind APIs out of unwind-libunwind-local.c, this part will be used by both local and remote libunwind.
--- tools/perf/util/Build | 1 + tools/perf/util/unwind-libunwind-local.c | 32 ------------------------------ tools/perf/util/unwind-libunwind.c | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 32 deletions(-) create mode 100644 tools/perf/util/unwind-libunwind.c
tools/perf/util/Build +1 -0
@@ -100,6 +100,7 @@ libperf-$(CONFIG_DWARF) += dwarf-aux.o libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind-local.o +libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind.o libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
tools/perf/util/unwind-libunwind-local.c +0 -32
@@ -692,35 +692,3 @@ void register_local_unwind_libunwind_ops(struct thread *thread) { thread->unwind_libunwind_ops = &_unwind_libunwind_ops; } - -int unwind__prepare_access (struct thread *thread) -{ -register_local_unwind_libunwind_ops (thread); - -return thread->unwind_libunwind_ops->prepare_access (thread); -} - -void unwind__flush_access (struct thread *thread) -{ -if (thread->unwind_libunwind_ops) - thread->unwind_libunwind_ops->flush_access (thread); -} - -void unwind__finish_access (struct thread *thread) -{ -if (thread->unwind_libunwind_ops) - thread->unwind_libunwind_ops->finish_access (thread); -} - -int unwind__get_entries (unwind_entry_cb_t cb,void *arg, -struct thread *thread, -struct perf_sample *data,int max_stack) -{ -if (thread->unwind_libunwind_ops) -return thread->unwind_libunwind_ops->get_entries (cb, arg, - thread, - data, - max_stack); -else -return 0 ; -}
tools/perf/util/unwind-libunwind.c new file +34 -0
@@ -0,0 +1,34 @@ +#include "unwind.h" +#include "thread.h" + +int unwind__prepare_access (struct thread *thread) +{ +register_local_unwind_libunwind_ops (thread); + +return thread->unwind_libunwind_ops->prepare_access (thread); +} + +void unwind__flush_access (struct thread *thread) +{ +if (thread->unwind_libunwind_ops) + thread->unwind_libunwind_ops->flush_access (thread); +} + +void unwind__finish_access (struct thread *thread) +{ +if (thread->unwind_libunwind_ops) + thread->unwind_libunwind_ops->finish_access (thread); +} + +int unwind__get_entries (unwind_entry_cb_t cb,void *arg, +struct thread *thread, +struct perf_sample *data,int max_stack) +{ +if (thread->unwind_libunwind_ops) +return thread->unwind_libunwind_ops->get_entries (cb, arg, + thread, + data, + max_stack); +else +return 0 ; +}
Signature · 1 line
1.8.5.2
Re: [PATCH v6 06/11] perf tools: Extract local libunwind code out of unwind-libunwind.c
In reply to Wangnan (F)Quoted 17 lines · Wangnan (F)
Quoted 5 lines · He Kuang
This patch extracts codes related to specific arithecture out of
unwind-libunwind.c. The extrated part are only built if local libunwind is supported.Signed-off-by He Kuang <[email protected]>Quoted 9 lines
--- tools/perf/util/Build | 1 + tools/perf/util/unwind-libunwind-local.c | 677 ++++++++++++++++++++++++++++++ tools/perf/util/unwind-libunwind.c | 694 +------------------------------ 3 files changed, 679 insertions(+), 693 deletions(-)create mode 100644
tools/perf/util/unwind-libunwind-local.c
Quoted 1 line
Please use 'git format-patch -M' to avoid such a large patch.
Currently is not a 100% similar rename, I split this patch into a rename and a small diff.
Quoted 4 lines
Thank you.
PATCH v6 7/11 perf tools: Export normalize_arch() function
In reply to He KuangExport normalize_arch() function, so other part of perf can get normalized form of arch string.
--- tools/perf/arch/common.c | 2 +- tools/perf/arch/common.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/arch/common.c +1 -1
@@ -102,7 +102,7 @@ static int lookup_triplets(const char *const *triplets, const char *name)* Return architecture name in a normalized form. * The conversion logic comes from the Makefile. */ -static const char *normalize_arch (char *arch) +const char *normalize_arch (char *arch) {if (!strcmp (arch,"x86_64" ))return "x86" ;
tools/perf/arch/common.h +1 -0
@@ -6,5 +6,6 @@extern const char *objdump_path;int perf_env__lookup_objdump (struct perf_env *env); +const char *normalize_arch (char *arch);#endif /* ARCH_PERF_COMMON_H */
Signature · 1 line
1.8.5.2
PATCH v6 8/11 perf tools: Show warnings for unsupported cross-platform unwind
In reply to He KuangCurrently, perf script uses host unwind methods to parse perf.data callchain info regardless of the target architecture. So we get wrong result without any warnings when unwinding callchains of x86(32-bit) on x86(64-bit) machine.
This patch shows warning messages when we do remote unwind x86(32-bit) on other machines. Same thing for other platforms will be added in next patches.
--- tools/perf/config/Makefile | 8 ++++++++ tools/perf/util/thread.c | 2 +- tools/perf/util/unwind-libunwind.c | 30 +++++++++++++++++++++++++++++- tools/perf/util/unwind.h | 5 +++-- 4 files changed, 41 insertions(+), 4 deletions(-)
tools/perf/config/Makefile +8 -0
@@ -355,6 +355,14 @@ endif ifndef NO_LIBUNWIND have_libunwind := + + ifeq ($(feature-libunwind-x86), 1) + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + LDFLAGS += -lunwind-x86 + have_libunwind = 1 + 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
tools/perf/util/thread.c +1 -1
@@ -203,7 +203,7 @@ void thread__insert_map(struct thread *thread, struct map *map)map_groups__fixup_overlappings (thread->mg, map, stderr);map_groups__insert (thread->mg, map); -unwind__prepare_access (thread); +unwind__prepare_access (thread, map); } static int thread__clone_map_groups(struct thread *thread,
tools/perf/util/unwind-libunwind.c +29 -1
@@ -1,8 +1,36 @@#include "unwind.h" #include "thread.h" +#include "session.h" +#include "debug.h" +#include "arch/common.h" -int unwind__prepare_access (struct thread *thread) +int unwind__prepare_access (struct thread *thread,struct map *map) { +const char *arch; +enum dso_type dso_type; + +if (!thread->mg->machine->env) +return -1 ; + + dso_type =dso__type (map->dso, thread->mg->machine); +if (dso_type ==DSO__TYPE_UNKNOWN ) +return -1 ; + +if (thread->addr_space) +pr_debug ("unwind: thread map already set, 64bit is %d, dso=%s\n" , + dso_type ==DSO__TYPE_64BIT , map->dso->name); + + arch =normalize_arch (thread->mg->machine->env->arch); + +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); +#else +pr_err ("unwind: target platform=%s is not supported\n" , arch); +#endif + } +register_local_unwind_libunwind_ops (thread);return thread->unwind_libunwind_ops->prepare_access (thread);
tools/perf/util/unwind.h +3 -2
@@ -22,11 +22,12 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,/* libunwind specific */ #ifdef HAVE_LIBUNWIND_SUPPORT int libunwind__arch_reg_id (int regnum); -int unwind__prepare_access (struct thread *thread); +int unwind__prepare_access (struct thread *thread,struct map *map);void unwind__flush_access (struct thread *thread);void unwind__finish_access (struct thread *thread);#else -static inline int unwind__prepare_access (struct thread *thread__maybe_unused ) +static inline int unwind__prepare_access (struct thread *thread__maybe_unused , +struct map *map__maybe_unused ) {return 0 ; }
Signature · 1 line
1.8.5.2
Re: [PATCH v6 08/11] perf tools: Show warnings for unsupported cross-platform unwind
Quoted 22 lines · He Kuang
Currently, perf script uses host unwind methods to parse perf.data callchain info regardless of the target architecture. So we get wrong result without any warnings when unwinding callchains of x86(32-bit) on x86(64-bit) machine.
This patch shows warning messages when we do remote unwind x86(32-bit) on other machines. Same thing for other platforms will be added in next patches.
Signed-off-by He Kuang <[email protected]>--- tools/perf/config/Makefile | 8 ++++++++ tools/perf/util/thread.c | 2 +- tools/perf/util/unwind-libunwind.c | 30 +++++++++++++++++++++++++++++- tools/perf/util/unwind.h | 5 +++-- 4 files changed, 41 insertions(+), 4 deletions(-)tools/perf/config/Makefile +0
-0
tools/perf/config/Makefile endif · line 364
Quoted 10 lines
tools/perf/config/Makefile +7
-0@@ -355,6 +355,14 @@ endif ifndef NO_LIBUNWIND have_libunwind := + + ifeq ($(feature-libunwind-x86), 1) + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + LDFLAGS += -lunwind-x86 + have_libunwind = 1 + endif
this hunk together with the ifdef inunwind__prepare_access should go to patch:
perf callchain: Support x86 target platform
thanks
jirka
SNIP
Quoted 9 lines
tools/perf/config/Makefile +9
-0+ arch = normalize_arch(thread->mg->machine->env->arch); + + 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); +#else + pr_err("unwind: target platform=%s is not supported\n", arch); +#endif
SNIP
PATCH v6 9/11 perf tools: Change fixed name of libunwind__arch_reg_id to macro
In reply to He KuangFor local libunwind, it uses the fixed methods to convert register id according to the host platform, but in remote libunwind, this convert function should be the one for remote architechture. This patch changes the fixed name to macro and code for each remote platform can be compiled indivadually.
--- tools/perf/util/unwind-libunwind-local.c | 2 +- tools/perf/util/unwind.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/unwind-libunwind-local.c +1 -1
@@ -490,7 +490,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 ;
tools/perf/util/unwind.h +4 -1
@@ -21,7 +21,10 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,/* libunwind specific */ #ifdef HAVE_LIBUNWIND_SUPPORT -int libunwind__arch_reg_id (int regnum); +#ifndef LIBUNWIND__ARCH_REG_ID +#define LIBUNWIND__ARCH_REG_ID libunwind__arch_reg_id +#endif +int LIBUNWIND__ARCH_REG_ID (int regnum);int unwind__prepare_access (struct thread *thread,struct map *map);void unwind__flush_access (struct thread *thread);void unwind__finish_access (struct thread *thread);
Signature · 1 line
1.8.5.2
PATCH v6 10/11 perf callchain: Support x86 target platform
In reply to He KuangSupport x86(32-bit) cross platform callchain unwind.
--- tools/perf/arch/Build | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ tools/perf/util/unwind-libunwind-local.c | 4 ++++ tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ tools/perf/util/unwind.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.c
tools/perf/arch/Build +1 -0
@@ -1,2 +1,3 @@ libperf-y += common.o libperf-y += $(ARCH)/ +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o
tools/perf/arch/x86/util/unwind-libunwind.c +4 -3
@@ -1,12 +1,13 @@ - +#ifndef REMOTE_UNWIND_LIBUNWIND #include <errno.h> #include <libunwind.h> #include "perf_regs.h" #include "../../util/unwind.h" #include "../../util/debug.h" +#endif #ifdef HAVE_ARCH_X86_64_SUPPORT -int libunwind__arch_reg_id (int regnum) +int LIBUNWIND__ARCH_REG_ID (int regnum) {int id;
@@ -70,7 +71,7 @@ int libunwind__arch_reg_id(int regnum) return id; }#else -int libunwind__arch_reg_id (int regnum) +int LIBUNWIND__ARCH_REG_ID (int regnum) {int id;
tools/perf/arch/x86/util/unwind-libunwind_x86_32.c new file +21 -0
@@ -0,0 +1,21 @@ +#define REMOTE_UNWIND_LIBUNWIND + +#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id + +#include "unwind.h" +#include "debug.h" +#include "libunwind-x86.h" +#include <../../../../../arch/x86/include/uapi/asm/perf_regs.h> + +#undef HAVE_ARCH_X86_64_SUPPORT +#include "unwind-libunwind.c" + +#undef NO_LIBUNWIND_DEBUG_FRAME +#define NO_LIBUNWIND_DEBUG_FRAME +#include "util/unwind-libunwind-local.c" + +int register_x86_32_unwind_libunwind_ops (struct thread *thread) +{ + thread->unwind_libunwind_ops = &_unwind_libunwind_ops; +return 0 ; +}
tools/perf/util/unwind-libunwind-local.c +4 -0
@@ -5,7 +5,9 @@#include <unistd.h> #include <sys/mman.h> #include <linux/list.h> +#ifndef REMOTE_UNWIND_LIBUNWIND #include <libunwind.h> +#endif #include "callchain.h" #include "thread.h" #include "session.h"
@@ -671,7 +673,9 @@ _unwind_libunwind_ops = { .get_entries = _unwind__get_entries, }; +#ifndef REMOTE_UNWIND_LIBUNWIND void register_local_unwind_libunwind_ops (struct thread *thread) { thread->unwind_libunwind_ops = &_unwind_libunwind_ops; } +#endif
tools/perf/util/unwind-libunwind.c +13 -6
@@ -8,6 +8,9 @@ int unwind__prepare_access(struct thread *thread, struct map *map) {const char *arch;enum dso_type dso_type; +int use_local_unwind =1 ; +int ret; +int (*register_func)(struct thread *thread) =NULL ;if (!thread->mg->machine->env)return -1 ;
@@ -22,16 +25,20 @@ int unwind__prepare_access(struct thread *thread, struct map *map) arch =normalize_arch (thread->mg->machine->env->arch); -if (!strcmp (arch,"x86" )) { +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); -#else + register_func = register_x86_32_unwind_libunwind_ops; + +if (register_func) { + ret =register_func (thread); +if (!ret) + use_local_unwind =0 ; +else pr_err ("unwind: target platform=%s is not supported\n" , arch); -#endif } -register_local_unwind_libunwind_ops (thread); +if (use_local_unwind) +register_local_unwind_libunwind_ops (thread);return thread->unwind_libunwind_ops->prepare_access (thread); }
tools/perf/util/unwind.h +10 -0
@@ -46,6 +46,16 @@ static inline void register_local_unwind_libunwind_ops(struct thread *thread __maybe_unused) {}#endif +#ifdef HAVE_LIBUNWIND_X86_SUPPORT +int register_x86_32_unwind_libunwind_ops (struct thread *thread); +#else +static inline int +register_x86_32_unwind_libunwind_ops (struct thread *thread__maybe_unused ) +{ +return -1 ; +} +#endif +#else static inline int unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
Signature · 1 line
1.8.5.2
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
On Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote:
SNIP
Quoted 14 lines
tools/perf/arch/x86/util/unwind-libunwind_x86_32.c new file +11
-0@@ -0,0 +1,21 @@ +#define REMOTE_UNWIND_LIBUNWIND + +#define LIBUNWIND__ARCH_REG_ID libunwind__x86_reg_id + +#include "unwind.h" +#include "debug.h" +#include "libunwind-x86.h" +#include <../../../../../arch/x86/include/uapi/asm/perf_regs.h> + +#undef HAVE_ARCH_X86_64_SUPPORT +#include "unwind-libunwind.c"
tools/perf/arch/x86/util/unwind-libunwind_x86_32.c line 21
Quoted 10 lines
tools/perf/arch/x86/util/unwind-libunwind_x86_32.c new file +10
-0+ +#undef NO_LIBUNWIND_DEBUG_FRAME +#define NO_LIBUNWIND_DEBUG_FRAME +#include "util/unwind-libunwind-local.c" + +int register_x86_32_unwind_libunwind_ops (struct thread *thread) +{ + thread->unwind_libunwind_ops = &_unwind_libunwind_ops; +return 0 ; +}
hum, how about export the arch ops:
struct unwind_libunwind_ops *x86_32_unwind_libunwind_ops = &_unwind_libunwind_ops;
and have single unwind__register_ops(ops) function
jirka
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
In reply to He KuangOn Sat, May 28, 2016 at 11:59:59AM +0000, He Kuang wrote:
SNIP
Quoted 15 lines
tools/perf/util/unwind-libunwind-local.c +2
-0@@ -5,7 +5,9 @@#include <unistd.h> #include <sys/mman.h> #include <linux/list.h> +#ifndef REMOTE_UNWIND_LIBUNWIND #include <libunwind.h> +#endif #include "callchain.h" #include "thread.h" #include "session.h"
tools/perf/util/unwind-libunwind-local.c _unwind_libunwind_ops = { · line 681
Quoted 9 lines
tools/perf/util/unwind-libunwind-local.c +2
-0@@ -671,7 +673,9 @@ _unwind_libunwind_ops = { .get_entries = _unwind__get_entries, }; +#ifndef REMOTE_UNWIND_LIBUNWIND void register_local_unwind_libunwind_ops (struct thread *thread) { thread->unwind_libunwind_ops = &_unwind_libunwind_ops; } +#endif
above hunks should go to separate patch
however I still think it'd be more clear if we separate the code like:
code template - util/unwind-libunwind.c
arch template - arch/x86/util/unwind-libunwind.c
wrapper for local - util/unwind-libunwind-local.c
wrapper for x86_32 - arch/x86/util/unwind-libunwind-x86_32.c
wrapper for arm64 - arch/x86/util/unwind-libunwind-arm64.c
jirka
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
In reply to He KuangQuoted 18 lines · He Kuang
Support x86(32-bit) cross platform callchain unwind.
Signed-off-by He Kuang <[email protected]>--- tools/perf/arch/Build | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ tools/perf/util/unwind-libunwind-local.c | 4 ++++ tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ tools/perf/util/unwind.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 tools/perf/arch/x86/util/unwind-libunwind_x86_32.ctools/perf/arch/Build +0
-0
tools/perf/arch/Build line 3
Quoted 3 lines
tools/perf/arch/Build +1
-0@@ -1,2 +1,3 @@ libperf-y += common.o libperf-y += $(ARCH)/ +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o
we have Build file directly in arch/x86/util/
if you do it like this to include generic file easily we better fix the include then
jirka
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
hi
Quoted 24 lines · Jiri Olsa
Quoted 18 lines · He Kuang
Support x86(32-bit) cross platform callchain unwind.
Signed-off-by He Kuang <[email protected]>--- tools/perf/arch/Build | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ tools/perf/util/unwind-libunwind-local.c | 4 ++++ tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ tools/perf/util/unwind.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 9 deletions(-)create mode 100644
tools/perf/arch/x86/util/unwind-libunwind_x86_32.ctools/perf/arch/Build +0
-0tools/perf/arch/Build line 3
Quoted 3 lines
tools/perf/arch/Build +1
-0@@ -1,2 +1,3 @@ libperf-y += common.o libperf-y += $(ARCH)/ +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.owe have Build file directly in
arch/x86/util/
Quoted 2 lines
if you do it like this to include generic file easily we better fix the include then
This is because "libperf-y += $(ARCH)" will only sink into $(ARCH) folder, for example on x86_64, only tools/perf/arch/x86 will be built. But for
remote libunwind, we also need 'tools/perf/arch/arm64/util/unwind-libunwind.o', while arm64 folder is
not added to libperf-y. Is there a gracefull to deal with this?
Quoted 2 lines
jirka
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
Quoted 27 lines · Hekuang
hi
Quoted 24 lines · Jiri Olsa
Quoted 18 lines · He Kuang
Support x86(32-bit) cross platform callchain unwind.
Signed-off-by He Kuang <[email protected]>--- tools/perf/arch/Build | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ tools/perf/util/unwind-libunwind-local.c | 4 ++++ tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ tools/perf/util/unwind.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 9 deletions(-)create mode 100644
tools/perf/arch/x86/util/unwind-libunwind_x86_32.ctools/perf/arch/Build +0
-0tools/perf/arch/Build line 3
Quoted 3 lines
tools/perf/arch/Build +1
-0@@ -1,2 +1,3 @@ libperf-y += common.o libperf-y += $(ARCH)/ +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.owe have Build file directly in
arch/x86/util/
Quoted 8 lines
Quoted 2 lines
if you do it like this to include generic file easily we better fix the include then
This is because "libperf-y += $(ARCH)" will only sink into $(ARCH) folder, for example on
x86_64, onlytools/perf/arch/x86will be built. But for
remote libunwind, we also need 'tools/perf/arch/arm64/util/unwind-libunwind.o', while arm64 folder is
not added to libperf-y. Is there a gracefull to deal with this?
you just need to include the file, right?
I think it's ok to include arch/arm/....c
from arch/x86/util/unwind-libunwind-arm64.c
jirka
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
Quoted 35 lines · Jiri Olsa
Quoted 27 lines · Hekuang
hi
Quoted 24 lines · Jiri Olsa
Quoted 18 lines · He Kuang
Support x86(32-bit) cross platform callchain unwind.
Signed-off-by He Kuang <[email protected]>--- tools/perf/arch/Build | 1 + tools/perf/arch/x86/util/unwind-libunwind.c | 7 ++++--- tools/perf/arch/x86/util/unwind-libunwind_x86_32.c | 21 +++++++++++++++++++++ tools/perf/util/unwind-libunwind-local.c | 4 ++++ tools/perf/util/unwind-libunwind.c | 19 +++++++++++++------ tools/perf/util/unwind.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 9 deletions(-)create mode 100644
tools/perf/arch/x86/util/unwind-libunwind_x86_32.ctools/perf/arch/Build +0
-0tools/perf/arch/Build line 3
Quoted 3 lines
tools/perf/arch/Build +1
-0@@ -1,2 +1,3 @@ libperf-y += common.o libperf-y += $(ARCH)/ +libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.owe have Build file directly in
arch/x86/util/Quoted 7 lines
Quoted 2 lines
if you do it like this to include generic file easily we better fix the include then
This is because "libperf-y += $(ARCH)" will only sink into $(ARCH) folder, for example on
x86_64, onlytools/perf/arch/x86will be built. But for
remote libunwind, we also need 'tools/perf/arch/arm64/util/unwind-libunwind.o', while arm64 folder is
not added to libperf-y. Is there a gracefull to deal with this?
Quoted 6 lines
you just need to include the file, right?
I think it's ok to include
arch/arm/....c
fromarch/x86/util/unwind-libunwind-arm64.cjirka
By following your advise, if ARCH=x86, the file tree will be like this:
arch/x86
- arch/x86/util/unwind-libunwind-arm64.c - arch/x86/util/unwind-libunwind-x86_32.c - arch/x86/util/unwind-libunwind-x86_64.c - arch/x86/util/unwind-libunwind-arm.c
And for ARCH=arm (host machine is arm, it should be considered) arch/arm
- arch/arm/util/unwind-libunwind-arm64.c - arch/arm/util/unwind-libunwind-x86_32.c - arch/arm/util/unwind-libunwind-x86_64.c - arch/arm/util/unwind-libunwind-arm.c
For arm64:arch/arm64
- arch/arm64/util/unwind-libunwind-arm64.c - arch/arm64/util/unwind-libunwind-x86_32.c - arch/arm64/util/unwind-libunwind-x86_64.c - arch/arm64/util/unwind-libunwind-arm.c
But in my patch, the file tree is like this:
arch
- arch/arm64/util/unwind-libunwind-arm64.c - arch/x86/util/unwind-libunwind-x86_64.c - arch/x86/util/unwind-libunwind-x86_32.c - arch/arm/util/unwind-libunwind-arm.c
I admit that
+libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o
is not so good, but do you think the above file tree is too redunctant?
Thank you.
Quoted 1 line
Re: [PATCH v6 10/11] perf callchain: Support x86 target platform
On Mon, May 30, 2016 at 06:58:40PM +0800, Hekuang wrote:
SNIP
Quoted 36 lines
Quoted 4 lines
I think it's ok to include
arch/arm/....c
fromarch/x86/util/unwind-libunwind-arm64.cjirka
By following your advise, if ARCH=x86, the file tree will be like this:
arch/x86(quoted diff) +0
-4- arch/x86/util/unwind-libunwind-arm64.c - arch/x86/util/unwind-libunwind-x86_32.c - arch/x86/util/unwind-libunwind-x86_64.c - arch/x86/util/unwind-libunwind-arm.cAnd for ARCH=arm (host machine is arm, it should be considered)
arch/arm(quoted diff) +0
-4- arch/arm/util/unwind-libunwind-arm64.c - arch/arm/util/unwind-libunwind-x86_32.c - arch/arm/util/unwind-libunwind-x86_64.c - arch/arm/util/unwind-libunwind-arm.cFor arm64:
arch/arm64(quoted diff) +0
-4- arch/arm64/util/unwind-libunwind-arm64.c - arch/arm64/util/unwind-libunwind-x86_32.c - arch/arm64/util/unwind-libunwind-x86_64.c - arch/arm64/util/unwind-libunwind-arm.cBut in my patch, the file tree is like this:
arch
(quoted diff) +0
-4- arch/arm64/util/unwind-libunwind-arm64.c - arch/x86/util/unwind-libunwind-x86_64.c - arch/x86/util/unwind-libunwind-x86_32.c - arch/arm/util/unwind-libunwind-arm.c
Quoted 6 lines
I admit that
+libperf-$(CONFIG_LIBUNWIND_X86) +=
x86/util/unwind-libunwind_x86_32.ois not so good, but do you think the above file tree is too redunctant?
i see.. we could leave it like that, I just wish
it'd be more clear.. one last thought:
how about moving libunwind arch files into special folder:
util/libunwind/arm64.c
util/libunwind/x86_32.c
util/libunwind/x86_64.c
util/libunwind/arm.c
thanks,
jirka
PATCH v6 11/11 perf callchain: Support aarch64 cross-platform
In reply to He KuangSupport aarch64 cross platform callchain unwind.
--- tools/perf/arch/Build | 1 + tools/perf/arch/arm64/util/unwind-libunwind.c | 4 +++- .../perf/arch/arm64/util/unwind-libunwind_arm64.c | 22 ++++++++++++++++++++++ tools/perf/config/Makefile | 12 ++++++++++++ tools/perf/util/unwind-libunwind.c | 6 +++++- tools/perf/util/unwind.h | 10 ++++++++++ 6 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 tools/perf/arch/arm64/util/unwind-libunwind_arm64.c
tools/perf/arch/Build +1 -0
@@ -1,3 +1,4 @@ libperf-y += common.o libperf-y += $(ARCH)/ libperf-$(CONFIG_LIBUNWIND_X86) += x86/util/unwind-libunwind_x86_32.o +libperf-$(CONFIG_LIBUNWIND_AARCH64) += arm64/util/unwind-libunwind_arm64.o
tools/perf/arch/arm64/util/unwind-libunwind.c +3 -1
@@ -1,11 +1,13 @@ +#ifndef REMOTE_UNWIND_LIBUNWIND #include <errno.h> #include <libunwind.h> #include "perf_regs.h" #include "../../util/unwind.h" #include "../../util/debug.h" +#endif -int libunwind__arch_reg_id (int regnum) +int LIBUNWIND__ARCH_REG_ID (int regnum) {switch (regnum) {case UNW_AARCH64_X0 :
tools/perf/arch/arm64/util/unwind-libunwind_arm64.c new file +22 -0
@@ -0,0 +1,22 @@ +#define REMOTE_UNWIND_LIBUNWIND + +#define LIBUNWIND__ARCH_REG_ID libunwind__arm64_reg_id + +#include "unwind.h" +#include "debug.h" +#include "libunwind-aarch64.h" +#include <../../../../../arch/arm64/include/uapi/asm/perf_regs.h> +#include "unwind-libunwind.c" + +#undef NO_LIBUNWIND_DEBUG_FRAME +#ifdef NO_LIBUNWIND_DEBUG_FRAME_AARCH64 +#define NO_LIBUNWIND_DEBUG_FRAME +#endif + +#include "util/unwind-libunwind-local.c" + +int register_arm64_unwind_libunwind_ops (struct thread *thread) +{ + thread->unwind_libunwind_ops = &_unwind_libunwind_ops; +return 0 ; +}
tools/perf/config/Makefile +12 -0
@@ -363,6 +363,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-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
tools/perf/util/unwind-libunwind.c +5 -1
@@ -25,9 +25,13 @@ int unwind__prepare_access(struct thread *thread, struct map *map) arch =normalize_arch (thread->mg->machine->env->arch); -if (!strcmp (arch,"x86" )) +if (!strcmp (arch,"x86" )) {if (dso_type !=DSO__TYPE_64BIT ) register_func = register_x86_32_unwind_libunwind_ops; + }else if (!strcmp (arch,"arm64" ) || !strcmp (arch,"arm" )) { +if (dso_type ==DSO__TYPE_64BIT ) + register_func = register_arm64_unwind_libunwind_ops; + }if (register_func) { ret =register_func (thread);
tools/perf/util/unwind.h +10 -0
@@ -56,6 +56,16 @@ register_x86_32_unwind_libunwind_ops(struct thread *thread __maybe_unused) }#endif +#ifdef HAVE_LIBUNWIND_AARCH64_SUPPORT +int register_arm64_unwind_libunwind_ops (struct thread *thread); +#else +static inline int +register_arm64_unwind_libunwind_ops (struct thread *thread__maybe_unused ) +{ +return -1 ; +} +#endif +#else static inline int unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,
Signature · 1 line
1.8.5.2