mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
perf annotate: Adapt arch__dwarf_regnum() for arm64
Currently, arch__dwarf_regnum() assumes that all architectures use a register prefix character (e.g., '%' for x86) defined by arch->objdump.register_char, and uses it to match register names in objdump output. However, this assumption does not hold for arm64, where assembly syntax uses bare register names like 'x0', 'w1' without any prefix. As a result, arm64 builds may fail to correctly recognize register names from objdump disassembly, leading to incomplete or incorrect annotation output. To address this: - Make the register prefix check optional, allowing architectures without a prefix character to be parsed correctly. - Extend the delimiter set in strpbrk() to include the closing square bracket ']'. In arm64 assembly, memory operands often use bracketed syntax such as '[x1, #16]' or '[x2]'. Adding ']' ensures clean extraction of register names like 'x2' without trailing characters. Reviewed-by: Ian Rogers <irogers@google.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Tengda Wu <wutengda@huaweicloud.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
4c42173d98
commit
0ba32f84fc
|
|
@ -2582,19 +2582,21 @@ int annotate_check_args(void)
|
|||
|
||||
int arch__dwarf_regnum(const struct arch *arch, const char *str)
|
||||
{
|
||||
const char *p;
|
||||
const char *p = str;
|
||||
char *regname, *q;
|
||||
int reg;
|
||||
|
||||
p = strchr(str, arch->objdump.register_char);
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
if (arch->objdump.register_char) {
|
||||
p = strchr(str, arch->objdump.register_char);
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
regname = strdup(p);
|
||||
if (regname == NULL)
|
||||
return -1;
|
||||
|
||||
q = strpbrk(regname, ",) ");
|
||||
q = strpbrk(regname, ",)] ");
|
||||
if (q)
|
||||
*q = '\0';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user