Add support for remote unwind
Subsystems (2)
v4 cover Add support for remote unwind
v3 url:
http://thread.gmane.org/gmane.linux.kernel/2220387
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)v4:
- Move reference of buildid dir to 'symfs/.debug' if --symfs is given.
- Split makefile changes out of patch 'Add support for cross-platform unwind'.
- Use existing code normalize_arch() for testing the arch of perf.data.
v3:
- Remove --vdso option, store vdso buildid in perf.data and let perf fetch it automatically.
- Use existing dso__type() function to test if dso is 32-bit or 64-bit.
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 (6):
perf tools: Set buildid dir under symfs when --symfs is provided perf tools: Promote proper messages for cross-platform unwind perf tools: Separate local and remote unwind support detection perf callchain: Add support for cross-platform unwind perf callchain: Support x86 target platform
perf callchain: Support aarch64 cross-platform
.../arch/arm64/include/libunwind/libunwind-arch.h | 18 ++++ tools/perf/arch/arm64/util/unwind-libunwind.c | 5 +- tools/perf/arch/common.c | 2 +- tools/perf/arch/common.h | 1 + .../arch/x86/include/libunwind/libunwind-arch.h | 18 ++++ tools/perf/arch/x86/util/unwind-libunwind.c | 12 ++- tools/perf/builtin-annotate.c | 5 +- tools/perf/builtin-diff.c | 5 +- tools/perf/builtin-report.c | 5 +- tools/perf/builtin-script.c | 5 +- tools/perf/builtin-timechart.c | 5 +- tools/perf/config/Makefile | 37 ++++++- tools/perf/util/Build | 13 ++- tools/perf/util/dso.c | 4 +- tools/perf/util/symbol.c | 23 +++++ tools/perf/util/symbol.h | 2 + tools/perf/util/thread.c | 7 +- tools/perf/util/thread.h | 14 ++- tools/perf/util/unwind-libunwind.c | 48 +++++++-- tools/perf/util/unwind-libunwind_common.c | 109 +++++++++++++++++++++ tools/perf/util/unwind.h | 45 +++++++-- 21 files changed, 341 insertions(+), 42 deletions(-) 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
Signature · 1 line
1.8.5.2
PATCH v4 1/6 perf tools: Set buildid dir under symfs when --symfs is provided
This patch moves the reference of buildid dir to 'symfs/.debug' and skips the local buildid dir when '--symfs' is given, so that every single file opened by perf is relateive to symfs directory now.
--- tools/perf/builtin-annotate.c | 5 +++-- tools/perf/builtin-diff.c | 5 +++-- tools/perf/builtin-report.c | 5 +++-- tools/perf/builtin-script.c | 5 +++-- tools/perf/builtin-timechart.c | 5 +++-- tools/perf/util/dso.c | 4 +--- tools/perf/util/symbol.c | 23 +++++++++++++++++++++++ tools/perf/util/symbol.h | 2 ++ 8 files changed, 41 insertions(+), 13 deletions(-)
tools/perf/builtin-annotate.c +3 -2
@@ -324,8 +324,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"skip-missing" , &annotate.skip_missing,"Skip symbols that cannot be annotated" ),OPT_STRING ('C' ,"cpu" , &annotate.cpu_list,"cpu" ,"list of cpus to profile" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_BOOLEAN (0 ,"source" , &symbol_conf.annotate_src,"Interleave source code with assembly code (default)" ), OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
tools/perf/builtin-diff.c +3 -2
@@ -812,8 +812,9 @@ static const struct option options[] = {OPT_STRING_NOEMPTY ('t' ,"field-separator" , &symbol_conf.field_sep,"separator" ,"separator for columns, no spaces will be added between " "columns '.' is reserved." ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_UINTEGER ('o' ,"order" , &sort_compute,"Specify compute sorting." ),OPT_CALLBACK (0 ,"percentage" ,NULL ,"relative|absolute" , "How to display percentage of filtered entries", parse_filter_percentage),
tools/perf/builtin-report.c +3 -2
@@ -770,8 +770,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "columns '.' is reserved."),OPT_BOOLEAN ('U' ,"hide-unresolved" , &symbol_conf.hide_unresolved,"Only display entries resolved to a symbol" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_STRING ('C' ,"cpu" , &report.cpu_list,"cpu" ,"list of cpus to profile" ), OPT_BOOLEAN('I', "show-info", &report.show_full_info,
tools/perf/builtin-script.c +3 -2
@@ -2010,8 +2010,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "file", "kallsyms pathname"),OPT_BOOLEAN ('G' ,"hide-call-graph" , &no_callchain,"When printing symbols do not display call chain" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_CALLBACK ('F' ,"fields" ,NULL ,"str" ,"comma separated output fields prepend with 'type:'. " "Valid types: hw,sw,trace,raw. "
tools/perf/builtin-timechart.c +3 -2
@@ -1945,8 +1945,9 @@ int cmd_timechart(int argc, const char **argv,OPT_CALLBACK ('p' ,"process" ,NULL ,"process" ,"process selector. Pass a pid or process name." , parse_process), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_INTEGER ('n' ,"proc-num" , &tchart.proc_num,"min. number of tasks to print" ), OPT_BOOLEAN('t', "topology", &tchart.topology,
tools/perf/util/dso.c +1 -3
@@ -63,9 +63,7 @@ int dso__read_binary_type_filename(const struct dso *dso, }break ;case DSO_BINARY_TYPE__BUILD_ID_CACHE : -/* skip the locally configured cache if a symfs is given */ -if (symbol_conf.symfs[0 ] || - (dso__build_id_filename (dso, filename, size) ==NULL )) +if (dso__build_id_filename (dso, filename, size) ==NULL ) ret =-1 ;break ;
tools/perf/util/symbol.c +23 -0
@@ -2033,3 +2033,26 @@ void symbol__exit(void) symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list =NULL ; symbol_conf.initialized = false; } + +int symbol__config_symfs (const struct option *opt__maybe_unused , +const char *dir,int unset__maybe_unused ) +{ +char *bf =NULL ; +int ret; + + symbol_conf.symfs =strdup (dir); +if (symbol_conf.symfs ==NULL ) +return -ENOMEM ; + +/* skip the locally configured cache if a symfs is given, and +* config buildid dir to symfs/.debug +*/ + ret =asprintf (&bf,"%s/%s" , dir,".debug" ); +if (ret <0 ) +return -ENOMEM ; + +set_buildid_dir (bf); + +free (bf); +return 0 ; +}
tools/perf/util/symbol.h +2 -0
@@ -290,6 +290,8 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);bool symbol__restricted_filename (const char *filename,const char *restricted_filename);bool symbol__is_idle (struct symbol *sym); +int symbol__config_symfs (const struct option *opt__maybe_unused , +const char *dir,int unset__maybe_unused ); int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, symbol_filter_t filter,
Signature · 1 line
1.8.5.2
Re: [PATCH v4 1/6] perf tools: Set buildid dir under symfs when --symfs is provided
Quoted 5 lines · He Kuang
This patch moves the reference of buildid dir to 'symfs/.debug' and skips the local buildid dir when '--symfs' is given, so that every single file opened by perf is relateive to symfs directory now.
Signed-off-by He Kuang <[email protected]>
Quoted 10 lines
--- tools/perf/builtin-annotate.c | 5 +++-- tools/perf/builtin-diff.c | 5 +++-- tools/perf/builtin-report.c | 5 +++-- tools/perf/builtin-script.c | 5 +++-- tools/perf/builtin-timechart.c | 5 +++-- tools/perf/util/dso.c | 4 +--- tools/perf/util/symbol.c | 23 +++++++++++++++++++++++ tools/perf/util/symbol.h | 2 ++ 8 files changed, 41 insertions(+), 13 deletions(-)
Re: [PATCH v4 1/6] perf tools: Set buildid dir under symfs when --symfs is provided
In reply to He KuangQuoted 5 lines · He Kuang
This patch moves the reference of buildid dir to 'symfs/.debug' and skips the local buildid dir when '--symfs' is given, so that every single file opened by perf is relateive to symfs directory now.
Signed-off-by He Kuang <[email protected]>
thanks,
jirka
tip-bot for He Kuang
merge bot[tip:perf/urgent] perf tools: Set buildid dir under symfs when --symfs is provided
In reply to He Kuangperf tools: Set buildid dir under symfs when --symfs is provided
Commit-ID: a706670900073d236938d539d1109338d64b47bb Gitweb: http://git.kernel.org/tip/a706670900073d236938d539d1109338d64b47bb Author: He Kuang <[email protected]> AuthorDate: Thu, 19 May 2016 11:47:37 +0000 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 20 May 2016 11:43:58 -0300
perf tools: Set buildid dir under symfs when --symfs is provided
This patch moves the reference of buildid dir to 'symfs/.debug' and skips the local buildid dir when '--symfs' is given, so that every single file opened by perf is relative to symfs directory now.
--- tools/perf/builtin-annotate.c | 5 +++-- tools/perf/builtin-diff.c | 5 +++-- tools/perf/builtin-report.c | 5 +++-- tools/perf/builtin-script.c | 5 +++-- tools/perf/builtin-timechart.c | 5 +++-- tools/perf/util/dso.c | 4 +--- tools/perf/util/symbol.c | 23 +++++++++++++++++++++++ tools/perf/util/symbol.h | 2 ++ 8 files changed, 41 insertions(+), 13 deletions(-)
tools/perf/builtin-annotate.c +3 -2
@@ -324,8 +324,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"skip-missing" , &annotate.skip_missing,"Skip symbols that cannot be annotated" ),OPT_STRING ('C' ,"cpu" , &annotate.cpu_list,"cpu" ,"list of cpus to profile" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_BOOLEAN (0 ,"source" , &symbol_conf.annotate_src,"Interleave source code with assembly code (default)" ), OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
tools/perf/builtin-diff.c +3 -2
@@ -812,8 +812,9 @@ static const struct option options[] = {OPT_STRING_NOEMPTY ('t' ,"field-separator" , &symbol_conf.field_sep,"separator" ,"separator for columns, no spaces will be added between " "columns '.' is reserved." ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_UINTEGER ('o' ,"order" , &sort_compute,"Specify compute sorting." ),OPT_CALLBACK (0 ,"percentage" ,NULL ,"relative|absolute" , "How to display percentage of filtered entries", parse_filter_percentage),
tools/perf/builtin-report.c +3 -2
@@ -770,8 +770,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "columns '.' is reserved."),OPT_BOOLEAN ('U' ,"hide-unresolved" , &symbol_conf.hide_unresolved,"Only display entries resolved to a symbol" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_STRING ('C' ,"cpu" , &report.cpu_list,"cpu" ,"list of cpus to profile" ), OPT_BOOLEAN('I', "show-info", &report.show_full_info,
tools/perf/builtin-script.c +3 -2
@@ -2010,8 +2010,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "file", "kallsyms pathname"),OPT_BOOLEAN ('G' ,"hide-call-graph" , &no_callchain,"When printing symbols do not display call chain" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_CALLBACK ('F' ,"fields" ,NULL ,"str" ,"comma separated output fields prepend with 'type:'. " "Valid types: hw,sw,trace,raw. "
tools/perf/builtin-timechart.c +3 -2
@@ -1945,8 +1945,9 @@ int cmd_timechart(int argc, const char **argv,OPT_CALLBACK ('p' ,"process" ,NULL ,"process" ,"process selector. Pass a pid or process name." , parse_process), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_INTEGER ('n' ,"proc-num" , &tchart.proc_num,"min. number of tasks to print" ), OPT_BOOLEAN('t', "topology", &tchart.topology,
tools/perf/util/dso.c +1 -3
@@ -63,9 +63,7 @@ int dso__read_binary_type_filename(const struct dso *dso, }break ;case DSO_BINARY_TYPE__BUILD_ID_CACHE : -/* skip the locally configured cache if a symfs is given */ -if (symbol_conf.symfs[0 ] || - (dso__build_id_filename (dso, filename, size) ==NULL )) +if (dso__build_id_filename (dso, filename, size) ==NULL ) ret =-1 ;break ;
tools/perf/util/symbol.c +23 -0
@@ -2033,3 +2033,26 @@ void symbol__exit(void) symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list =NULL ; symbol_conf.initialized = false; } + +int symbol__config_symfs (const struct option *opt__maybe_unused , +const char *dir,int unset__maybe_unused ) +{ +char *bf =NULL ; +int ret; + + symbol_conf.symfs =strdup (dir); +if (symbol_conf.symfs ==NULL ) +return -ENOMEM ; + +/* skip the locally configured cache if a symfs is given, and +* config buildid dir to symfs/.debug +*/ + ret =asprintf (&bf,"%s/%s" , dir,".debug" ); +if (ret <0 ) +return -ENOMEM ; + +set_buildid_dir (bf); + +free (bf); +return 0 ; +}
tools/perf/util/symbol.h +2 -0
@@ -290,6 +290,8 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);bool symbol__restricted_filename (const char *filename,const char *restricted_filename);bool symbol__is_idle (struct symbol *sym); +int symbol__config_symfs (const struct option *opt__maybe_unused , +const char *dir,int unset__maybe_unused ); int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, symbol_filter_t filter,
PATCH v4 2/6 perf tools: Promote proper messages for 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 and no promotion when unwinding callchains of x86(32-bit) on x86(64-bit) machine.
This patch shows proper error messages when we do remote unwind x86(32-bit) on other machines. Same thing for other platforms will be added in next patches.
Common functions which will be used by both local unwind and remote unwind are separated into new file 'unwind-libunwind_common.c'.
--- tools/perf/arch/common.c | 2 +- tools/perf/arch/common.h | 1 + tools/perf/config/Makefile | 6 ++++++ tools/perf/util/Build | 1 + tools/perf/util/thread.c | 2 ++ tools/perf/util/unwind-libunwind_common.c | 34 +++++++++++++++++++++++++++++++ tools/perf/util/unwind.h | 5 +++++ 7 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/unwind-libunwind_common.c
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 */
tools/perf/config/Makefile +6 -0
@@ -345,6 +345,12 @@ ifeq ($(ARCH),powerpc) endif ifndef NO_LIBUNWIND + ifeq ($(feature-libunwind-x86), 1) + LIBUNWIND_LIBS += -lunwind-x86 + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + endif + ifneq ($(feature-libunwind), 1) msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR); NO_LIBUNWIND := 1
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_LIBUNWIND) += unwind-libunwind.o +libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind_common.o libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
tools/perf/util/thread.c +2 -0
@@ -205,6 +205,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__get_arch (thread, map); } static int thread__clone_map_groups(struct thread *thread,
tools/perf/util/unwind-libunwind_common.c new file +34 -0
@@ -0,0 +1,34 @@ +#include "thread.h" +#include "session.h" +#include "unwind.h" +#include "symbol.h" +#include "debug.h" +#include "arch/common.h" + +void unwind__get_arch (struct thread *thread,struct map *map) +{ +const char *arch; +enum dso_type dso_type; + +if (!thread->mg->machine->env) +return ; + + dso_type =dso__type (map->dso, thread->mg->machine); +if (dso_type ==DSO__TYPE_UNKNOWN ) +return ; + +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 + } +}
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 unwind__get_arch (struct thread *thread,struct map *map);#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 unwind__get_arch (struct thread *thread__maybe_unused , +struct map *map__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 unwind__get_arch (struct thread *thread__maybe_unused , +struct map *map__maybe_unused ) {}#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* __UNWIND_H */
Signature · 1 line
1.8.5.2
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
Em Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang escreveu:
Quoted 3 lines
Currently, perf script uses host unwind methods to parse perf.data callchain info regardless of the target architecture. So we get wrong result and no promotion when unwinding callchains of x86(32-bit) on
What you mean by "promotion" here? Can you use some other synonym so that I can make sense of this description?
Quoted 158 lines
x86(64-bit) machine.
This patch shows proper error messages when we do remote unwind x86(32-bit) on other machines. Same thing for other platforms will be added in next patches.
Common functions which will be used by both local unwind and remote unwind are separated into new file '
unwind-libunwind_common.c'.Signed-off-by He Kuang <[email protected]>--- tools/perf/arch/common.c | 2 +- tools/perf/arch/common.h | 1 + tools/perf/config/Makefile | 6 ++++++ tools/perf/util/Build | 1 + tools/perf/util/thread.c | 2 ++ tools/perf/util/unwind-libunwind_common.c | 34 +++++++++++++++++++++++++++++++ tools/perf/util/unwind.h | 5 +++++ 7 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tools/perf/util/unwind-libunwind_common.ctools/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 */ tools/perf/config/Makefile +6
-0@@ -345,6 +345,12 @@ ifeq ($(ARCH),powerpc) endif ifndef NO_LIBUNWIND + ifeq ($(feature-libunwind-x86), 1) + LIBUNWIND_LIBS += -lunwind-x86 + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + endif + ifneq ($(feature-libunwind), 1) msg := $(warning No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR); NO_LIBUNWIND := 1tools/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_LIBUNWIND) += unwind-libunwind.o +libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind_common.o libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.otools/perf/util/thread.c +2
-0@@ -205,6 +205,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__get_arch (thread, map); } static int thread__clone_map_groups(struct thread *thread,tools/perf/util/unwind-libunwind_common.c new file +34
-0@@ -0,0 +1,34 @@ +#include "thread.h" +#include "session.h" +#include "unwind.h" +#include "symbol.h" +#include "debug.h" +#include "arch/common.h" + +void unwind__get_arch (struct thread *thread,struct map *map) +{ +const char *arch; +enum dso_type dso_type; + +if (!thread->mg->machine->env) +return ; + + dso_type =dso__type (map->dso, thread->mg->machine); +if (dso_type ==DSO__TYPE_UNKNOWN ) +return ; + +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 + } +}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 unwind__get_arch (struct thread *thread,struct map *map);#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 unwind__get_arch (struct thread *thread__maybe_unused , +struct map *map__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 unwind__get_arch (struct thread *thread__maybe_unused , +struct map *map__maybe_unused ) {}#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* __UNWIND_H */ Signature · 1 line
1.8.5.2
Re: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
Quoted 7 lines · Arnaldo Carvalho de Melo
Em Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang escreveu:
Quoted 3 lines
Currently, perf script uses host unwind methods to parse perf.data callchain info regardless of the target architecture. So we get wrong result and no promotion when unwinding callchains of x86(32-bit) on
What you mean by "promotion" here? Can you use some other synonym so that I can make sense of this description?
I'd say something like: s/and no promotion/without any warning/
jirka
Re: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
Quoted 10 lines · Jiri Olsa
Quoted 6 lines · Arnaldo Carvalho de Melo
Em Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang escreveu:
Quoted 3 lines
Currently, perf script uses host unwind methods to parse perf.data callchain info regardless of the target architecture. So we get wrong result and no promotion when unwinding callchains of x86(32-bit) on
What you mean by "promotion" here? Can you use some other synonym so that I can make sense of this description?
I'd say something like: s/and no promotion/without any warning/
jirka
Yes, that's what I want to express.
Re: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
In reply to He KuangOn Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang wrote:
SNIP
Quoted 6 lines
#endif /*
ARCH_PERF_COMMON_H*/tools/perf/config/Makefile +0
-0
tools/perf/config/Makefile ifeq ($(ARCH),powerpc) · line 353
Quoted 9 lines
tools/perf/config/Makefile +6
-0@@ -345,6 +345,12 @@ ifeq ($(ARCH),powerpc) endif ifndef NO_LIBUNWIND + ifeq ($(feature-libunwind-x86), 1) + LIBUNWIND_LIBS += -lunwind-x86 + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + endif +
how does one install that lirary?
thanks,
jirka
Re: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
Quoted 12 lines · Jiri Olsa
On Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang wrote:
SNIP
Quoted 8 lines
#endif /*
ARCH_PERF_COMMON_H*/tools/perf/config/Makefile +0
-0@@ -345,6 +345,12 @@ ifeq ($(ARCH),powerpc) endif
Quoted 9 lines
tools/perf/config/Makefile ifeq ($(ARCH),powerpc) · line 353
Quoted 7 lines
tools/perf/config/Makefile +6
-0ifndef NO_LIBUNWIND + ifeq ($(feature-libunwind-x86), 1) + LIBUNWIND_LIBS += -lunwind-x86 + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + endif +how does one install that lirary?
had to uninstall x86_64..
[jolsa@krava perf]$ rpm -qa | grep libunw
libunwind-devel-1.1-10.fc22.i686
libunwind-1.1-10.fc22.i686
libunwind-1.1-10.fc22.x86_64
however it's still off:
[jolsa@krava perf]$ make VF=1
BUILD: Doing 'make -j4' parallel build
Auto-detecting system features:
SNIP
... libunwind: [ OFF ]
SNIP
... libunwind-x86: [ OFF ]
... libunwind-x86_64: [ OFF ]
... libunwind-arm: [ OFF ]
... libunwind-aarch64: [ OFF ]
... pthread-attr-setaffinity-np: [ on ] ... stackprotector-all: [ on ] ... timerfd: [ on ]
thanks,
jirka
Re: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
In reply to Jiri Olsahi
Quoted 21 lines · Jiri Olsa
On Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang wrote:
SNIP
Quoted 6 lines
#endif /* ARCH_PERF_COMMON_H */tools/perf/config/Makefile +0
-0tools/perf/config/Makefile ifeq ($(ARCH),powerpc) · line 353
Quoted 9 lines
tools/perf/config/Makefile +6
-0@@ -345,6 +345,12 @@ ifeq ($(ARCH),powerpc) endif ifndef NO_LIBUNWIND + ifeq ($(feature-libunwind-x86), 1) + LIBUNWIND_LIBS += -lunwind-x86 + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + endif +how does one install that lirary?
Quoted 2 lines
thanks,
jirka
My work environment is on an old suse distribution, so it's difficult to find libunwind-$arch rpm packages, so I build them from source.
The git repository url is here:
http://git.savannah.gnu.org/r/libunwind.git(master)
Then flow the build step in README, first for i686:
$ ./autogen.sh $ ./configure prefix=/xx/dst_i686 --target=i686-oe-linux CC=x86_64-oe-linux-gcc $ make && make install
Similar for aarch64:
$ make clean $ ./configure prefix=/xx/dst_aarch64 --target=i686-oe-linux CC=x86_64-oe-linux-gcc $ make && make install
NOTICE: the contents in '--target' should be like 'i686-oe-linux', only give 'i686' cause strange build errors.
It looks like that libunwind don't support building for multiple platforms at the same time, so I build them separately into different directories.
Finally, copy the outputs into /usr/include and /usr/lib64, now perf can detect them:
$ make VF=1 ARCH=x86_64 CROSS_COMPILE=x86_64-oe-linux- EXTRA_CFLAGS="-m64" ...
... libunwind-x86: [ on ]
... libunwind-x86_64: [ OFF ]
... libunwind-arm: [ OFF ]
... libunwind-aarch64: [ on ]
Thanks.
Re: [PATCH v4 2/6] perf tools: Promote proper messages for cross-platform unwind
Quoted 50 lines · Hekuang
hi
Quoted 20 lines · Jiri Olsa
On Thu, May 19, 2016 at 11:47:38AM +0000, He Kuang wrote:
SNIP
Quoted 6 lines
#endif /* ARCH_PERF_COMMON_H */tools/perf/config/Makefile +0
-0tools/perf/config/Makefile ifeq ($(ARCH),powerpc) · line 352
Quoted 8 lines
tools/perf/config/Makefile +6
-0@@ -345,6 +345,12 @@ ifeq ($(ARCH),powerpc) endif ifndef NO_LIBUNWIND + ifeq ($(feature-libunwind-x86), 1) + LIBUNWIND_LIBS += -lunwind-x86 + $(call detected,CONFIG_LIBUNWIND_X86) + CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + endif +how does one install that lirary?
Quoted 2 lines
thanks,
jirkaMy work environment is on an old suse distribution, so it's difficult to find libunwind-$arch rpm packages, so I build them from source.
The git repository url is here:
http://git.savannah.gnu.org/r/libunwind.git(master)Then flow the build step in README, first for i686:
$ ./autogen.sh $ ./configure prefix=/xx/dst_i686 --target=i686-oe-linux CC=x86_64-oe-linux-gcc $ make && make installSimilar for aarch64:
$ make clean $ ./configure prefix=/xx/dst_aarch64 --target=i686-oe-linux CC=x86_64-oe-linux-gcc $ make && make installNOTICE: the contents in '--target' should be like 'i686-oe-linux', only give 'i686' cause strange build errors.
Quoted 6 lines
It looks like that libunwind don't support building for multiple platforms at the same time, so I build them separately into different directories.
Finally, copy the outputs into
/usr/includeand/usr/lib64, now perf can detect them:
we will need to extend LIBUNWIND_DIR or add variable, to be able to detect this from arbitrary directory
jirka
PATCH v4 3/6 perf tools: Separate local and remote unwind support detection
In reply to He KuangThis patch changes original CONFIG_LIBUNWIND/NO_LIBUNWIND to CONFIG_LOCAL_LIBUNWIND/NO_LOCAL_LIBUNWIND for retaining local unwind features. CONFIG_LIBUNWIND stands for either local or remote or both unwind are supported and NO_LIBUNWIND means neither local nor remote libunwind are supported.
--- tools/perf/config/Makefile | 21 ++++++++++++++++++--- tools/perf/util/Build | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-)
tools/perf/config/Makefile +18 -3
@@ -345,16 +345,28 @@ ifeq ($(ARCH),powerpc) endif ifndef NO_LIBUNWIND + have_libunwind = ifeq ($(feature-libunwind-x86), 1) - LIBUNWIND_LIBS += -lunwind-x86 $(call detected,CONFIG_LIBUNWIND_X86) CFLAGS += -DHAVE_LIBUNWIND_X86_SUPPORT + LDFLAGS += -lunwind -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 + else + have_libunwind = 1 + CFLAGS += -DHAVE_LIBUNWIND_LOCAL_SUPPORT + $(call detected,CONFIG_LOCAL_LIBUNWIND) + endif + + ifneq ($(have_libunwind), 1) NO_LIBUNWIND := 1 endif +else + NO_LOCAL_LIBUNWIND := 1 endif ifndef NO_LIBBPF
@@ -392,7 +404,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)
@@ -403,12 +415,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/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.o libperf-$(CONFIG_LIBUNWIND) += unwind-libunwind_common.o libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o
Signature · 1 line
1.8.5.2
PATCH v4 4/6 perf callchain: Add support for cross-platform unwind
In reply to He KuangUse thread specific unwind ops to unwind cross-platform callchains.
Before this patch, unwind methods is suitable for local unwind, this patch changes the fixed methods to thread/map related. Each time a map is inserted, we find the target arch and see if this platform can be remote unwind. In this patch, we test for x86 platform and only show proper messages. The real unwind methods are not implemented, will be introduced in next patch.
--- tools/perf/util/thread.c | 5 +-- tools/perf/util/thread.h | 14 +++++- tools/perf/util/unwind-libunwind.c | 48 ++++++++++++++++++--- tools/perf/util/unwind-libunwind_common.c | 71 +++++++++++++++++++++++++++++-- tools/perf/util/unwind.h | 32 +++++++++----- 5 files changed, 145 insertions(+), 25 deletions(-)
tools/perf/util/thread.c +2 -3
@@ -43,9 +43,6 @@ struct thread *thread__new(pid_t pid, pid_t tid) thread->cpu =-1 ;INIT_LIST_HEAD (&thread->comm_list); -if (unwind__prepare_access (thread) <0 ) - goto err_thread; - comm_str =malloc (32 );if (!comm_str) goto err_thread;
@@ -59,6 +56,8 @@ struct thread *thread__new(pid_t pid, pid_t tid)list_add (&comm->list, &thread->comm_list);atomic_set (&thread->refcnt,1 );RB_CLEAR_NODE (&thread->rb_node); + +register_null_unwind_libunwind_ops (thread); }return thread;
tools/perf/util/thread.h +13 -1
@@ -15,6 +15,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;
@@ -36,7 +47,8 @@ struct thread {void *priv;struct thread_stack *ts;#ifdef HAVE_LIBUNWIND_SUPPORT -unw_addr_space_t addr_space; +unw_addr_space_t addr_space; +struct unwind_libunwind_ops *unwind_libunwind_ops;#endif };
tools/perf/util/unwind-libunwind.c +41 -7
93 lines not on this page · raw message
tools/perf/util/unwind-libunwind_common.c +67 -4
95 lines not on this page · raw message
tools/perf/util/unwind.h +22 -10
@@ -21,20 +21,35 @@ 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);void unwind__flush_access (struct thread *thread);void unwind__finish_access (struct thread *thread);void unwind__get_arch (struct thread *thread,struct map *map); -#else -static inline int unwind__prepare_access (struct thread *thread__maybe_unused ) -{ -return 0 ; +void register_unwind_libunwind_ops (struct unwind_libunwind_ops *ops, +struct thread *thread); +void register_null_unwind_libunwind_ops (struct thread *thread); + +#ifndef HAVE_LIBUNWIND_LOCAL_SUPPORT +static inline void +register_local_unwind_libunwind_ops (struct thread *thread) { +register_null_unwind_libunwind_ops (thread); } +#else +void register_local_unwind_libunwind_ops (struct thread *thread); +#endif +#define unwind__get_entries (cb, arg, \ + thread, \ + data, max_stack) \ + thread->unwind_libunwind_ops->get_entries(cb, arg, thread, \ + data, max_stack) + +#else 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 unwind__get_arch (struct thread *thread__maybe_unused ,struct map *map__maybe_unused ) {} +static inline void +register_null_unwind_libunwind_ops (struct thread *thread__maybe_unused ) {}#endif #else static inline int
@@ -47,14 +62,11 @@ unwind__get_entries(unwind_entry_cb_t cb __maybe_unused,return 0 ; } -static inline int unwind__prepare_access (struct thread *thread__maybe_unused ) -{ -return 0 ; -} -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 unwind__get_arch (struct thread *thread__maybe_unused ,struct map *map__maybe_unused ) {} +static inline void +register_null_unwind_libunwind_ops (struct thread *thread__maybe_unused ) {}#endif /* HAVE_DWARF_UNWIND_SUPPORT */ #endif /* __UNWIND_H */
Signature · 1 line
1.8.5.2
PATCH v4 5/6 perf callchain: Support x86 target platform
In reply to He KuangSupport x86(32-bit) cross platform callchain unwind.
--- 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
tools/perf/arch/x86/include/libunwind/libunwind-arch.h new file +18 -0
@@ -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 */
tools/perf/arch/x86/util/unwind-libunwind.c +9 -3
@@ -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
tools/perf/util/Build +6 -0
@@ -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
tools/perf/util/unwind-libunwind_common.c +4 -2
@@ -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 ; } }
tools/perf/util/unwind.h +5 -0
@@ -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,
Signature · 1 line
1.8.5.2
PATCH v4 6/6 perf callchain: Support aarch64 cross-platform
In reply to He KuangSupport aarch64 cross platform callchain unwind.
--- .../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 | 10 ++++++++++ tools/perf/util/unwind.h | 3 +++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tools/perf/arch/arm64/include/libunwind/libunwind-arch.h
tools/perf/arch/arm64/include/libunwind/libunwind-arch.h new file +18 -0
@@ -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 */
tools/perf/arch/arm64/util/unwind-libunwind.c +4 -1
@@ -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 :
tools/perf/config/Makefile +12 -0
@@ -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
tools/perf/util/Build +4 -0
@@ -104,10 +104,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) -DREMOTE_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) -DREMOTE_UNWIND_LIBUNWIND -Iarch/arm64/include/libunwind -c -o $@ util/unwind-libunwind.c + libperf-$(CONFIG_LIBBABELTRACE) += data-convert-bt.o libperf-y += scripting-engines/
tools/perf/util/unwind-libunwind_common.c +10 -0
@@ -89,6 +89,16 @@ void unwind__get_arch(struct thread *thread, struct map *map)#endif use_local_unwind =0 ; } + }else if (!strcmp (arch,"arm64" ) || !strcmp (arch,"arm" )) { +if (dso_type ==DSO__TYPE_64BIT ) { +#ifdef HAVE_LIBUNWIND_AARCH64_SUPPORT +register_unwind_libunwind_ops ( + &_Uaarch64_unwind_libunwind_ops, thread); +#else +register_null_unwind_libunwind_ops (thread); +#endif + use_local_unwind =0 ; + } }if (use_local_unwind)
tools/perf/util/unwind.h +3 -0
@@ -55,6 +55,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
Signature · 1 line
1.8.5.2