Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304848
b: refs/heads/master
c: d223288
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Apr 20, 2012
1 parent 735e6ab commit 81332c1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 97148a97baf71536e15aa0acf3310b7b1409e2f4
refs/heads/master: d22328855666464731ee95d9e1e8d35dc7a39d8d
43 changes: 41 additions & 2 deletions trunk/tools/perf/util/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,50 @@ const char *disassembler_style;

static int call__parse(struct ins_operands *ops)
{
ops->target = strtoull(ops->raw, NULL, 16);
char *endptr, *tok, *name;

ops->target = strtoull(ops->raw, &endptr, 16);

name = strchr(endptr, '<');
if (name == NULL)
goto indirect_call;

name++;

tok = strchr(name, '>');
if (tok == NULL)
return -1;

*tok = '\0';
ops->target_name = strdup(name);
*tok = '>';

return ops->target_name == NULL ? -1 : 0;

indirect_call:
tok = strchr(endptr, '*');
if (tok == NULL)
return -1;

ops->target = strtoull(tok + 1, NULL, 16);
return 0;
}

static int call__scnprintf(struct ins *ins, char *bf, size_t size,
struct ins_operands *ops, bool addrs)
{
if (addrs)
return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);

if (ops->target_name)
return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target_name);

return scnprintf(bf, size, "%-6.6s *%" PRIx64, ins->name, ops->target);
}

static struct ins_ops call_ops = {
.parse = call__parse,
.parse = call__parse,
.scnprintf = call__scnprintf,
};

bool ins__is_call(const struct ins *ins)
Expand Down Expand Up @@ -251,6 +289,7 @@ void disasm_line__free(struct disasm_line *dl)
{
free(dl->line);
free(dl->name);
free(dl->ops.target_name);
free(dl);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/tools/perf/util/annotate.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct ins;

struct ins_operands {
char *raw;
char *target_name;
u64 target;
};

Expand Down

0 comments on commit 81332c1

Please sign in to comment.