diff options
author | Namhyung Kim <[email protected]> | 2023-05-10 23:27:24 -0700 |
---|---|---|
committer | Arnaldo Carvalho de Melo <[email protected]> | 2023-05-15 17:51:27 -0300 |
commit | 94f0705eee70cb256d21c9abe7ce44ffbe093555 (patch) | |
tree | 1879c245fc084ec00f54f74bdef27f0e4eb3ee1b | |
parent | 983034cd0d212b23a63efb48ecc47d55d70ee301 (diff) |
perf annotate: Parse x86 SIB addressing properly
When the source argument of the "mov" instruction looks like below, it
didn't parse the whole operand and just stopped at the first comma.
mov (%rbx,%rax,1),%rcx
Fix it by checking the parentheses and move it to the closing one.
Signed-off-by: Namhyung Kim <[email protected]>
Acked-by: Ian Rogers <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r-- | tools/perf/util/annotate.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 11992cfe271c..b708bbc49c9e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -558,6 +558,19 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_sy return -1; *s = '\0'; + + /* + * x86 SIB addressing has something like 0x8(%rax, %rcx, 1) + * then it needs to have the closing parenthesis. + */ + if (strchr(ops->raw, '(')) { + *s = ','; + s = strchr(ops->raw, ')'); + if (s == NULL || s[1] != ',') + return -1; + *++s = '\0'; + } + ops->source.raw = strdup(ops->raw); *s = ','; |