diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-20 13:38:46 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-20 13:38:46 -0400 |
commit | c7e6ead7347813b5833efb9b32908c08ff131259 (patch) | |
tree | 4cd53ffe880c0cf15ee9539682623f5aed8f4378 /tools/perf/util/annotate.c | |
parent | 3f862fd076275c442dfe295eddb5650a6e0aecd4 (diff) |
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.c | 56 |
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 @@ | |||
18 | 18 | ||
19 | const char *disassembler_style; | 19 | const char *disassembler_style; |
20 | 20 | ||
21 | static int call_ops__parse_target(const char *operands, u64 *target) | 21 | static int call__parse(struct ins_operands *ops) |
22 | { | 22 | { |
23 | *target = strtoull(operands, NULL, 16); | 23 | ops->target = strtoull(ops->raw, NULL, 16); |
24 | return 0; | 24 | return 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | static struct ins_ops call_ops = { | 27 | static struct ins_ops call_ops = { |
28 | .parse_target = call_ops__parse_target, | 28 | .parse = call__parse, |
29 | }; | 29 | }; |
30 | 30 | ||
31 | bool ins__is_call(const struct ins *ins) | 31 | bool ins__is_call(const struct ins *ins) |
@@ -33,29 +33,29 @@ bool ins__is_call(const struct ins *ins) | |||
33 | return ins->ops == &call_ops; | 33 | return ins->ops == &call_ops; |
34 | } | 34 | } |
35 | 35 | ||
36 | static int jump_ops__parse_target(const char *operands, u64 *target) | 36 | static int jump__parse(struct ins_operands *ops) |
37 | { | 37 | { |
38 | const char *s = strchr(operands, '+'); | 38 | const char *s = strchr(ops->raw, '+'); |
39 | 39 | ||
40 | if (s++ == NULL) | 40 | if (s++ == NULL) |
41 | return -1; | 41 | return -1; |
42 | 42 | ||
43 | *target = strtoll(s, NULL, 16); | 43 | ops->target = strtoll(s, NULL, 16); |
44 | return 0; | 44 | return 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | static int jump_ops__scnprintf(struct ins *ins, char *bf, size_t size, | 47 | static int jump__scnprintf(struct ins *ins, char *bf, size_t size, |
48 | const char *operands, u64 target) | 48 | struct ins_operands *ops, bool addrs) |
49 | { | 49 | { |
50 | if (operands) | 50 | if (addrs) |
51 | return scnprintf(bf, size, "%-6.6s %s", ins->name, operands); | 51 | return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); |
52 | 52 | ||
53 | return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, target); | 53 | return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target); |
54 | } | 54 | } |
55 | 55 | ||
56 | static struct ins_ops jump_ops = { | 56 | static struct ins_ops jump_ops = { |
57 | .parse_target = jump_ops__parse_target, | 57 | .parse = jump__parse, |
58 | .scnprintf = jump_ops__scnprintf, | 58 | .scnprintf = jump__scnprintf, |
59 | }; | 59 | }; |
60 | 60 | ||
61 | bool ins__is_jump(const struct ins *ins) | 61 | bool ins__is_jump(const struct ins *ins) |
@@ -190,8 +190,8 @@ static void disasm_line__init_ins(struct disasm_line *dl) | |||
190 | if (!dl->ins->ops) | 190 | if (!dl->ins->ops) |
191 | return; | 191 | return; |
192 | 192 | ||
193 | if (dl->ins->ops->parse_target) | 193 | if (dl->ins->ops->parse) |
194 | dl->ins->ops->parse_target(dl->operands, &dl->target); | 194 | dl->ins->ops->parse(&dl->ops); |
195 | } | 195 | } |
196 | 196 | ||
197 | static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privsize) | 197 | 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 | |||
213 | if (name[0] == '\0') | 213 | if (name[0] == '\0') |
214 | goto out_delete; | 214 | goto out_delete; |
215 | 215 | ||
216 | dl->operands = name + 1; | 216 | dl->ops.raw = name + 1; |
217 | 217 | ||
218 | while (dl->operands[0] != '\0' && | 218 | while (dl->ops.raw[0] != '\0' && |
219 | !isspace(dl->operands[0])) | 219 | !isspace(dl->ops.raw[0])) |
220 | ++dl->operands; | 220 | ++dl->ops.raw; |
221 | 221 | ||
222 | tmp = dl->operands[0]; | 222 | tmp = dl->ops.raw[0]; |
223 | dl->operands[0] = '\0'; | 223 | dl->ops.raw[0] = '\0'; |
224 | dl->name = strdup(name); | 224 | dl->name = strdup(name); |
225 | 225 | ||
226 | if (dl->name == NULL) | 226 | if (dl->name == NULL) |
227 | goto out_free_line; | 227 | goto out_free_line; |
228 | 228 | ||
229 | dl->operands[0] = tmp; | 229 | dl->ops.raw[0] = tmp; |
230 | 230 | ||
231 | if (dl->operands[0] != '\0') { | 231 | if (dl->ops.raw[0] != '\0') { |
232 | dl->operands++; | 232 | dl->ops.raw++; |
233 | while (isspace(dl->operands[0])) | 233 | while (isspace(dl->ops.raw[0])) |
234 | ++dl->operands; | 234 | ++dl->ops.raw; |
235 | } | 235 | } |
236 | 236 | ||
237 | disasm_line__init_ins(dl); | 237 | disasm_line__init_ins(dl); |
@@ -753,9 +753,9 @@ static size_t disasm_line__fprintf(struct disasm_line *dl, FILE *fp) | |||
753 | 753 | ||
754 | printed = fprintf(fp, "%#" PRIx64 " %s", dl->offset, dl->name); | 754 | printed = fprintf(fp, "%#" PRIx64 " %s", dl->offset, dl->name); |
755 | 755 | ||
756 | if (dl->operands[0] != '\0') { | 756 | if (dl->ops.raw[0] != '\0') { |
757 | printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ", | 757 | printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ", |
758 | dl->operands); | 758 | dl->ops.raw); |
759 | } | 759 | } |
760 | 760 | ||
761 | return printed + fprintf(fp, "\n"); | 761 | return printed + fprintf(fp, "\n"); |