perf annotate: Fix arch specific ->init() failure errors
Subsystems (2)
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: 42d7a9107d83223a5fcecc6732d626a6c074cbc2 Gitweb: https://git.kernel.org/tip/42d7a9107d83223a5fcecc6732d626a6c074cbc2 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 30 Sep 2019 15:48:12 -03:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Mon, 30 Sep 2019 17:30:03 -03:00
perf annotate: Fix arch specific ->init() failure errors
They are called from symbol__annotate() and to propagate errors that can help understand the problem make them return what symbol__strerror_disassemble() known, i.e. errno codes and other annotation specific errors in a special, out of errnos, range.
Cc Adrian Hunter <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>,
Cc Will Deacon <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/arch/arm/annotate/instructions.c | 4 ++-- tools/perf/arch/arm64/annotate/instructions.c | 4 ++-- tools/perf/arch/s390/annotate/instructions.c | 6 ++++-- tools/perf/arch/x86/annotate/instructions.c | 6 ++++-- tools/perf/util/annotate.c | 6 ++++++ tools/perf/util/annotate.h | 2 ++ 6 files changed, 20 insertions(+), 8 deletions(-)
tools/perf/arch/arm/annotate/instructions.c +2 -2
@@ -37,7 +37,7 @@ static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused) arm =zalloc (sizeof (*arm));if (!arm) -return -1 ; +return ENOMEM ;#define ARM_CONDS "(cc|cs|eq|ge|gt|hi|le|ls|lt|mi|ne|pl|vc|vs)" err =regcomp (&arm->call_insn,"^blx?" ARM_CONDS "?$" ,REG_EXTENDED );
@@ -59,5 +59,5 @@ out_free_call:regfree (&arm->call_insn); out_free_arm:free (arm); -return -1 ; +return SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP ; }
tools/perf/arch/arm64/annotate/instructions.c +2 -2
@@ -95,7 +95,7 @@ static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused) arm =zalloc (sizeof (*arm));if (!arm) -return -1 ; +return ENOMEM ;/* bl, blr */ err =regcomp (&arm->call_insn,"^blr?$" ,REG_EXTENDED );
@@ -118,5 +118,5 @@ out_free_call:regfree (&arm->call_insn); out_free_arm:free (arm); -return -1 ; +return SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP ; }
tools/perf/arch/s390/annotate/instructions.c +4 -2
@@ -164,8 +164,10 @@ static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)if (!arch->initialized) { arch->initialized = true; arch->associate_instruction_ops = s390__associate_ins_ops; -if (cpuid) - err =s390__cpuid_parse (arch, cpuid); +if (cpuid) { +if (s390__cpuid_parse (arch, cpuid)) + err =SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING ; + } }return err;
tools/perf/arch/x86/annotate/instructions.c +4 -2
@@ -196,8 +196,10 @@ static int x86__annotate_init(struct arch *arch, char *cpuid)if (arch->initialized)return 0 ; -if (cpuid) - err =x86__cpuid_parse (arch, cpuid); +if (cpuid) { +if (x86__cpuid_parse (arch, cpuid)) + err =SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING ; + } arch->initialized = true;return err;
tools/perf/util/annotate.c +6 -0
@@ -1631,6 +1631,12 @@ int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map *case SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF :scnprintf (buf, buflen,"Please link with binutils's libopcode to enable BPF annotation" );break ; +case SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP : +scnprintf (buf, buflen,"Problems with arch specific instruction name regular expressions." ); +break ; +case SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING : +scnprintf (buf, buflen,"Problems while parsing the CPUID in the arch specific initialization." ); +break ;default :scnprintf (buf, buflen,"Internal error: Invalid %d error code\n" , errnum);break ;
tools/perf/util/annotate.h +2 -0
@@ -370,6 +370,8 @@ enum symbol_disassemble_errno {SYMBOL_ANNOTATE_ERRNO__NO_VMLINUX = __SYMBOL_ANNOTATE_ERRNO__START,SYMBOL_ANNOTATE_ERRNO__NO_LIBOPCODES_FOR_BPF , +SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_CPUID_PARSING , +SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP , __SYMBOL_ANNOTATE_ERRNO__END, };