summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-04-20 14:38:46 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-04-20 14:38:46 -0300
commitc7e6ead7347813b5833efb9b32908c08ff131259 (patch)
tree4cd53ffe880c0cf15ee9539682623f5aed8f4378 /tools/perf/util/annotate.c
parent3f862fd076275c442dfe295eddb5650a6e0aecd4 (diff)
downloadlinux-c7e6ead7347813b5833efb9b32908c08ff131259.tar.gz
linux-c7e6ead7347813b5833efb9b32908c08ff131259.tar.bz2
linux-c7e6ead7347813b5833efb9b32908c08ff131259.zip
perf annotate: Group operands members
So that the ins_ops can handle them in a single place, instead of adding more and more functions or ins_ops parameters. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-pk4dqaum6ftiz104dvimwgtb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e70cbb4f3bed..7f6c14b3fd7f 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -18,14 +18,14 @@
const char *disassembler_style;
-static int call_ops__parse_target(const char *operands, u64 *target)
+static int call__parse(struct ins_operands *ops)
{
- *target = strtoull(operands, NULL, 16);
+ ops->target = strtoull(ops->raw, NULL, 16);
return 0;
}
static struct ins_ops call_ops = {
- .parse_target = call_ops__parse_target,
+ .parse = call__parse,
};
bool ins__is_call(const struct ins *ins)
@@ -33,29 +33,29 @@ bool ins__is_call(const struct ins *ins)
return ins->ops == &call_ops;
}
-static int jump_ops__parse_target(const char *operands, u64 *target)
+static int jump__parse(struct ins_operands *ops)
{
- const char *s = strchr(operands, '+');
+ const char *s = strchr(ops->raw, '+');
if (s++ == NULL)
return -1;
- *target = strtoll(s, NULL, 16);
+ ops->target = strtoll(s, NULL, 16);
return 0;
}
-static int jump_ops__scnprintf(struct ins *ins, char *bf, size_t size,
- const char *operands, u64 target)
+static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
+ struct ins_operands *ops, bool addrs)
{
- if (operands)
- return scnprintf(bf, size, "%-6.6s %s", ins->name, operands);
+ if (addrs)
+ return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
- return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, target);
+ return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target);
}
static struct ins_ops jump_ops = {
- .parse_target = jump_ops__parse_target,
- .scnprintf = jump_ops__scnprintf,
+ .parse = jump__parse,
+ .scnprintf = jump__scnprintf,
};
bool ins__is_jump(const struct ins *ins)
@@ -190,8 +190,8 @@ static void disasm_line__init_ins(struct disasm_line *dl)
if (!dl->ins->ops)
return;
- if (dl->ins->ops->parse_target)
- dl->ins->ops->parse_target(dl->operands, &dl->target);
+ if (dl->ins->ops->parse)
+ dl->ins->ops->parse(&dl->ops);
}
static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privsize)
@@ -213,25 +213,25 @@ static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privs
if (name[0] == '\0')
goto out_delete;
- dl->operands = name + 1;
+ dl->ops.raw = name + 1;
- while (dl->operands[0] != '\0' &&
- !isspace(dl->operands[0]))
- ++dl->operands;
+ while (dl->ops.raw[0] != '\0' &&
+ !isspace(dl->ops.raw[0]))
+ ++dl->ops.raw;
- tmp = dl->operands[0];
- dl->operands[0] = '\0';
+ tmp = dl->ops.raw[0];
+ dl->ops.raw[0] = '\0';
dl->name = strdup(name);
if (dl->name == NULL)
goto out_free_line;
- dl->operands[0] = tmp;
+ dl->ops.raw[0] = tmp;
- if (dl->operands[0] != '\0') {
- dl->operands++;
- while (isspace(dl->operands[0]))
- ++dl->operands;
+ if (dl->ops.raw[0] != '\0') {
+ dl->ops.raw++;
+ while (isspace(dl->ops.raw[0]))
+ ++dl->ops.raw;
}
disasm_line__init_ins(dl);
@@ -753,9 +753,9 @@ static size_t disasm_line__fprintf(struct disasm_line *dl, FILE *fp)
printed = fprintf(fp, "%#" PRIx64 " %s", dl->offset, dl->name);
- if (dl->operands[0] != '\0') {
+ if (dl->ops.raw[0] != '\0') {
printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ",
- dl->operands);
+ dl->ops.raw);
}
return printed + fprintf(fp, "\n");