diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-19 09:16:27 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-19 09:16:27 -0400 |
commit | 28548d78ad521310f0ae58f791aa796d3d685151 (patch) | |
tree | 381d507e987faec4e1628fecf588c85987adaa35 | |
parent | d86b0597c4bd41ea3edc6446a855306eed34f93b (diff) |
perf annotate: Introduce scnprintf ins_ops method
And implement the jump one, where if the operands string is not passed,
a compact form that uses just the target address is used.
Right now this is toggled via the 'o' option in the annotate browser,
switching from:
0.00 : ffffffff811661e8: je ffffffff81166204 <mem_cgroup_count_vm_event+0x44>
0.00 : ffffffff811661ea: cmp $0xb,%esi
0.00 : ffffffff811661ed: je ffffffff811661f8 <mem_cgroup_count_vm_event+0x38>
To:
0.00 : 28: je 44
0.00 : 2a: cmp $0xb,%esi
0.00 : 2d: je 38
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
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-o88q46yh4kxgpd1chk5gvjl5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 13 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 10 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 46ef966ccc5b..f7d2db3e8464 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -83,7 +83,7 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro | |||
83 | else if (dl->offset == -1) | 83 | else if (dl->offset == -1) |
84 | slsmg_write_nstring(dl->line, width - 18); | 84 | slsmg_write_nstring(dl->line, width - 18); |
85 | else { | 85 | else { |
86 | char bf[64]; | 86 | char bf[256], *line = dl->line; |
87 | u64 addr = dl->offset; | 87 | u64 addr = dl->offset; |
88 | int printed, color = -1; | 88 | int printed, color = -1; |
89 | 89 | ||
@@ -96,7 +96,16 @@ static void annotate_browser__write(struct ui_browser *self, void *entry, int ro | |||
96 | slsmg_write_nstring(bf, printed); | 96 | slsmg_write_nstring(bf, printed); |
97 | if (change_color) | 97 | if (change_color) |
98 | ui_browser__set_color(self, color); | 98 | ui_browser__set_color(self, color); |
99 | slsmg_write_nstring(dl->line, width - 18 - printed); | 99 | if (dl->ins && dl->ins->ops->scnprintf) { |
100 | dl->ins->ops->scnprintf(dl->ins, bf, sizeof(bf), | ||
101 | !ab->use_offset ? dl->operands : NULL, | ||
102 | dl->target); | ||
103 | line = bf; | ||
104 | slsmg_write_nstring(" ", 7); | ||
105 | printed += 7; | ||
106 | } | ||
107 | |||
108 | slsmg_write_nstring(line, width - 18 - printed); | ||
100 | } | 109 | } |
101 | 110 | ||
102 | if (current_entry) | 111 | if (current_entry) |
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index a4296fdd9a68..ed1f89d7044e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -44,8 +44,18 @@ static int jump_ops__parse_target(const char *operands, u64 *target) | |||
44 | return 0; | 44 | return 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | static int jump_ops__scnprintf(struct ins *ins, char *bf, size_t size, | ||
48 | const char *operands, u64 target) | ||
49 | { | ||
50 | if (operands) | ||
51 | return scnprintf(bf, size, "%-6.6s %s", ins->name, operands); | ||
52 | |||
53 | return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, target); | ||
54 | } | ||
55 | |||
47 | static struct ins_ops jump_ops = { | 56 | static struct ins_ops jump_ops = { |
48 | .parse_target = jump_ops__parse_target, | 57 | .parse_target = jump_ops__parse_target, |
58 | .scnprintf = jump_ops__scnprintf, | ||
49 | }; | 59 | }; |
50 | 60 | ||
51 | bool ins__is_jump(const struct ins *ins) | 61 | bool ins__is_jump(const struct ins *ins) |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index a2105f204a42..6314335007f0 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -7,8 +7,12 @@ | |||
7 | #include <linux/list.h> | 7 | #include <linux/list.h> |
8 | #include <linux/rbtree.h> | 8 | #include <linux/rbtree.h> |
9 | 9 | ||
10 | struct ins; | ||
11 | |||
10 | struct ins_ops { | 12 | struct ins_ops { |
11 | int (*parse_target)(const char *operands, u64 *target); | 13 | int (*parse_target)(const char *operands, u64 *target); |
14 | int (*scnprintf)(struct ins *ins, char *bf, size_t size, | ||
15 | const char *operands, u64 target); | ||
12 | }; | 16 | }; |
13 | 17 | ||
14 | struct ins { | 18 | struct ins { |