diff options
| -rw-r--r-- | tools/perf/util/annotate.c | 22 | ||||
| -rw-r--r-- | tools/perf/util/annotate.h | 1 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e62b69ea87cd..28cd6a17491b 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
| @@ -282,7 +282,19 @@ bool ins__is_call(const struct ins *ins) | |||
| 282 | return ins->ops == &call_ops || ins->ops == &s390_call_ops; | 282 | return ins->ops == &call_ops || ins->ops == &s390_call_ops; |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms) | 285 | /* |
| 286 | * Prevents from matching commas in the comment section, e.g.: | ||
| 287 | * ffff200008446e70: b.cs ffff2000084470f4 <generic_exec_single+0x314> // b.hs, b.nlast | ||
| 288 | */ | ||
| 289 | static inline const char *validate_comma(const char *c, struct ins_operands *ops) | ||
| 290 | { | ||
| 291 | if (ops->raw_comment && c > ops->raw_comment) | ||
| 292 | return NULL; | ||
| 293 | |||
| 294 | return c; | ||
| 295 | } | ||
| 296 | |||
| 297 | static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms) | ||
| 286 | { | 298 | { |
| 287 | struct map *map = ms->map; | 299 | struct map *map = ms->map; |
| 288 | struct symbol *sym = ms->sym; | 300 | struct symbol *sym = ms->sym; |
| @@ -291,6 +303,10 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op | |||
| 291 | }; | 303 | }; |
| 292 | const char *c = strchr(ops->raw, ','); | 304 | const char *c = strchr(ops->raw, ','); |
| 293 | u64 start, end; | 305 | u64 start, end; |
| 306 | |||
| 307 | ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char); | ||
| 308 | c = validate_comma(c, ops); | ||
| 309 | |||
| 294 | /* | 310 | /* |
| 295 | * Examples of lines to parse for the _cpp_lex_token@@Base | 311 | * Examples of lines to parse for the _cpp_lex_token@@Base |
| 296 | * function: | 312 | * function: |
| @@ -310,6 +326,7 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op | |||
| 310 | ops->target.addr = strtoull(c, NULL, 16); | 326 | ops->target.addr = strtoull(c, NULL, 16); |
| 311 | if (!ops->target.addr) { | 327 | if (!ops->target.addr) { |
| 312 | c = strchr(c, ','); | 328 | c = strchr(c, ','); |
| 329 | c = validate_comma(c, ops); | ||
| 313 | if (c++ != NULL) | 330 | if (c++ != NULL) |
| 314 | ops->target.addr = strtoull(c, NULL, 16); | 331 | ops->target.addr = strtoull(c, NULL, 16); |
| 315 | } | 332 | } |
| @@ -367,9 +384,12 @@ static int jump__scnprintf(struct ins *ins, char *bf, size_t size, | |||
| 367 | return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.sym->name); | 384 | return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.sym->name); |
| 368 | 385 | ||
| 369 | c = strchr(ops->raw, ','); | 386 | c = strchr(ops->raw, ','); |
| 387 | c = validate_comma(c, ops); | ||
| 388 | |||
| 370 | if (c != NULL) { | 389 | if (c != NULL) { |
| 371 | const char *c2 = strchr(c + 1, ','); | 390 | const char *c2 = strchr(c + 1, ','); |
| 372 | 391 | ||
| 392 | c2 = validate_comma(c2, ops); | ||
| 373 | /* check for 3-op insn */ | 393 | /* check for 3-op insn */ |
| 374 | if (c2 != NULL) | 394 | if (c2 != NULL) |
| 375 | c = c2; | 395 | c = c2; |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 005a5fe8a8c6..5399ba2321bb 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
| @@ -22,6 +22,7 @@ struct ins { | |||
| 22 | 22 | ||
| 23 | struct ins_operands { | 23 | struct ins_operands { |
| 24 | char *raw; | 24 | char *raw; |
| 25 | char *raw_comment; | ||
| 25 | struct { | 26 | struct { |
| 26 | char *raw; | 27 | char *raw; |
| 27 | char *name; | 28 | char *name; |
