Path: blob/master/tools/perf/arch/arm/annotate/instructions.c
26295 views
// SPDX-License-Identifier: GPL-2.01#include <linux/compiler.h>2#include <linux/zalloc.h>3#include <sys/types.h>4#include <regex.h>5#include <stdlib.h>67struct arm_annotate {8regex_t call_insn,9jump_insn;10};1112static struct ins_ops *arm__associate_instruction_ops(struct arch *arch, const char *name)13{14struct arm_annotate *arm = arch->priv;15struct ins_ops *ops;16regmatch_t match[2];1718if (!regexec(&arm->call_insn, name, 2, match, 0))19ops = &call_ops;20else if (!regexec(&arm->jump_insn, name, 2, match, 0))21ops = &jump_ops;22else23return NULL;2425arch__associate_ins_ops(arch, name, ops);26return ops;27}2829static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)30{31struct arm_annotate *arm;32int err;3334if (arch->initialized)35return 0;3637arm = zalloc(sizeof(*arm));38if (!arm)39return ENOMEM;4041#define ARM_CONDS "(cc|cs|eq|ge|gt|hi|le|ls|lt|mi|ne|pl|vc|vs)"42err = regcomp(&arm->call_insn, "^blx?" ARM_CONDS "?$", REG_EXTENDED);43if (err)44goto out_free_arm;45err = regcomp(&arm->jump_insn, "^bx?" ARM_CONDS "?$", REG_EXTENDED);46if (err)47goto out_free_call;48#undef ARM_CONDS4950arch->initialized = true;51arch->priv = arm;52arch->associate_instruction_ops = arm__associate_instruction_ops;53arch->objdump.comment_char = ';';54arch->objdump.skip_functions_char = '+';55arch->e_machine = EM_ARM;56arch->e_flags = 0;57return 0;5859out_free_call:60regfree(&arm->call_insn);61out_free_arm:62free(arm);63return SYMBOL_ANNOTATE_ERRNO__ARCH_INIT_REGEXP;64}656667