aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 20061cf42288..28cd6a17491b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -246,8 +246,14 @@ find_target:
246 246
247indirect_call: 247indirect_call:
248 tok = strchr(endptr, '*'); 248 tok = strchr(endptr, '*');
249 if (tok != NULL) 249 if (tok != NULL) {
250 ops->target.addr = strtoull(tok + 1, NULL, 16); 250 endptr++;
251
252 /* Indirect call can use a non-rip register and offset: callq *0x8(%rbx).
253 * Do not parse such instruction. */
254 if (strstr(endptr, "(%r") == NULL)
255 ops->target.addr = strtoull(endptr, NULL, 16);
256 }
251 goto find_target; 257 goto find_target;
252} 258}
253 259
@@ -276,7 +282,19 @@ bool ins__is_call(const struct ins *ins)
276 return ins->ops == &call_ops || ins->ops == &s390_call_ops; 282 return ins->ops == &call_ops || ins->ops == &s390_call_ops;
277} 283}
278 284
279static 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 */
289static 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
297static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
280{ 298{
281 struct map *map = ms->map; 299 struct map *map = ms->map;
282 struct symbol *sym = ms->sym; 300 struct symbol *sym = ms->sym;
@@ -285,6 +303,10 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op
285 }; 303 };
286 const char *c = strchr(ops->raw, ','); 304 const char *c = strchr(ops->raw, ',');
287 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
288 /* 310 /*
289 * Examples of lines to parse for the _cpp_lex_token@@Base 311 * Examples of lines to parse for the _cpp_lex_token@@Base
290 * function: 312 * function:
@@ -304,6 +326,7 @@ static int jump__parse(struct arch *arch __maybe_unused, struct ins_operands *op
304 ops->target.addr = strtoull(c, NULL, 16); 326 ops->target.addr = strtoull(c, NULL, 16);
305 if (!ops->target.addr) { 327 if (!ops->target.addr) {
306 c = strchr(c, ','); 328 c = strchr(c, ',');
329 c = validate_comma(c, ops);
307 if (c++ != NULL) 330 if (c++ != NULL)
308 ops->target.addr = strtoull(c, NULL, 16); 331 ops->target.addr = strtoull(c, NULL, 16);
309 } 332 }
@@ -361,9 +384,12 @@ static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
361 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);
362 385
363 c = strchr(ops->raw, ','); 386 c = strchr(ops->raw, ',');
387 c = validate_comma(c, ops);
388
364 if (c != NULL) { 389 if (c != NULL) {
365 const char *c2 = strchr(c + 1, ','); 390 const char *c2 = strchr(c + 1, ',');
366 391
392 c2 = validate_comma(c2, ops);
367 /* check for 3-op insn */ 393 /* check for 3-op insn */
368 if (c2 != NULL) 394 if (c2 != NULL)
369 c = c2; 395 c = c2;