diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-07 17:54:16 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-07 17:54:16 -0400 |
commit | 5417072bf6b17eaa31f21f12906f381f148b5200 (patch) | |
tree | ee57c5bccfc88ac660369edea9383a8773e1db1b /tools/perf/util | |
parent | 64aa17ca5a4e428fcb6d0806823a99a18c548506 (diff) |
perf annotate browser: Do raw printing in 'o'ffset in a single place
Instead of doing the same in all ins scnprintf methods.
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-8mfairi2n1nentoa852alazv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/annotate.c | 33 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 4 |
2 files changed, 28 insertions, 9 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 5eb34123f55b..0905db4390c1 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -18,6 +18,21 @@ | |||
18 | 18 | ||
19 | const char *disassembler_style; | 19 | const char *disassembler_style; |
20 | 20 | ||
21 | static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size, | ||
22 | struct ins_operands *ops) | ||
23 | { | ||
24 | return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); | ||
25 | } | ||
26 | |||
27 | int ins__scnprintf(struct ins *ins, char *bf, size_t size, | ||
28 | struct ins_operands *ops) | ||
29 | { | ||
30 | if (ins->ops->scnprintf) | ||
31 | return ins->ops->scnprintf(ins, bf, size, ops); | ||
32 | |||
33 | return ins__raw_scnprintf(ins, bf, size, ops); | ||
34 | } | ||
35 | |||
21 | static int call__parse(struct ins_operands *ops) | 36 | static int call__parse(struct ins_operands *ops) |
22 | { | 37 | { |
23 | char *endptr, *tok, *name; | 38 | char *endptr, *tok, *name; |
@@ -50,11 +65,8 @@ indirect_call: | |||
50 | } | 65 | } |
51 | 66 | ||
52 | static int call__scnprintf(struct ins *ins, char *bf, size_t size, | 67 | static int call__scnprintf(struct ins *ins, char *bf, size_t size, |
53 | struct ins_operands *ops, bool addrs) | 68 | struct ins_operands *ops) |
54 | { | 69 | { |
55 | if (addrs) | ||
56 | return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); | ||
57 | |||
58 | if (ops->target.name) | 70 | if (ops->target.name) |
59 | return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target.name); | 71 | return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target.name); |
60 | 72 | ||
@@ -86,11 +98,8 @@ static int jump__parse(struct ins_operands *ops) | |||
86 | } | 98 | } |
87 | 99 | ||
88 | static int jump__scnprintf(struct ins *ins, char *bf, size_t size, | 100 | static int jump__scnprintf(struct ins *ins, char *bf, size_t size, |
89 | struct ins_operands *ops, bool addrs) | 101 | struct ins_operands *ops) |
90 | { | 102 | { |
91 | if (addrs) | ||
92 | return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw); | ||
93 | |||
94 | return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset); | 103 | return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset); |
95 | } | 104 | } |
96 | 105 | ||
@@ -296,6 +305,14 @@ void disasm_line__free(struct disasm_line *dl) | |||
296 | free(dl); | 305 | free(dl); |
297 | } | 306 | } |
298 | 307 | ||
308 | int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw) | ||
309 | { | ||
310 | if (raw || !dl->ins) | ||
311 | return scnprintf(bf, size, "%-6.6s %s", dl->name, dl->ops.raw); | ||
312 | |||
313 | return ins__scnprintf(dl->ins, bf, size, &dl->ops); | ||
314 | } | ||
315 | |||
299 | static void disasm__add(struct list_head *head, struct disasm_line *line) | 316 | static void disasm__add(struct list_head *head, struct disasm_line *line) |
300 | { | 317 | { |
301 | list_add_tail(&line->node, head); | 318 | list_add_tail(&line->node, head); |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 13a21f10dabb..bb0a9f27165b 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -22,7 +22,7 @@ struct ins_operands { | |||
22 | struct ins_ops { | 22 | struct ins_ops { |
23 | int (*parse)(struct ins_operands *ops); | 23 | int (*parse)(struct ins_operands *ops); |
24 | int (*scnprintf)(struct ins *ins, char *bf, size_t size, | 24 | int (*scnprintf)(struct ins *ins, char *bf, size_t size, |
25 | struct ins_operands *ops, bool addrs); | 25 | struct ins_operands *ops); |
26 | }; | 26 | }; |
27 | 27 | ||
28 | struct ins { | 28 | struct ins { |
@@ -32,6 +32,7 @@ struct ins { | |||
32 | 32 | ||
33 | bool ins__is_jump(const struct ins *ins); | 33 | bool ins__is_jump(const struct ins *ins); |
34 | bool ins__is_call(const struct ins *ins); | 34 | bool ins__is_call(const struct ins *ins); |
35 | int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops); | ||
35 | 36 | ||
36 | struct disasm_line { | 37 | struct disasm_line { |
37 | struct list_head node; | 38 | struct list_head node; |
@@ -49,6 +50,7 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl) | |||
49 | 50 | ||
50 | void disasm_line__free(struct disasm_line *dl); | 51 | void disasm_line__free(struct disasm_line *dl); |
51 | struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos); | 52 | struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos); |
53 | int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw); | ||
52 | size_t disasm__fprintf(struct list_head *head, FILE *fp); | 54 | size_t disasm__fprintf(struct list_head *head, FILE *fp); |
53 | 55 | ||
54 | struct sym_hist { | 56 | struct sym_hist { |