diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-11 16:21:09 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-11 16:21:09 -0400 |
commit | a43712c4720c8df4bad7d3760c67086168553b05 (patch) | |
tree | c8c3f610c26c507529fd6d7696a261b547351d18 /tools/perf/util/annotate.c | |
parent | 6de783b6f50f7f1db18a3fda0aa34b2e84b5771d (diff) |
perf annotate: Resolve symbols using objdump comment for single op ins
Starting with inc, incl, dec, decl.
Requested-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-jvh0jspefr5jyn0l7qko12st@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 | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 82c7f630f8a8..a6109dc3a81e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -205,6 +205,47 @@ static struct ins_ops mov_ops = { | |||
205 | .scnprintf = mov__scnprintf, | 205 | .scnprintf = mov__scnprintf, |
206 | }; | 206 | }; |
207 | 207 | ||
208 | static int dec__parse(struct ins_operands *ops) | ||
209 | { | ||
210 | char *target, *comment, *s, prev; | ||
211 | |||
212 | target = s = ops->raw; | ||
213 | |||
214 | while (s[0] != '\0' && !isspace(s[0])) | ||
215 | ++s; | ||
216 | prev = *s; | ||
217 | *s = '\0'; | ||
218 | |||
219 | ops->target.raw = strdup(target); | ||
220 | *s = prev; | ||
221 | |||
222 | if (ops->target.raw == NULL) | ||
223 | return -1; | ||
224 | |||
225 | comment = strchr(s, '#'); | ||
226 | if (comment == NULL) | ||
227 | return 0; | ||
228 | |||
229 | while (comment[0] != '\0' && isspace(comment[0])) | ||
230 | ++comment; | ||
231 | |||
232 | comment__symbol(ops->target.raw, comment, &ops->target.addr, &ops->target.name); | ||
233 | |||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | static int dec__scnprintf(struct ins *ins, char *bf, size_t size, | ||
238 | struct ins_operands *ops) | ||
239 | { | ||
240 | return scnprintf(bf, size, "%-6.6s %s", ins->name, | ||
241 | ops->target.name ?: ops->target.raw); | ||
242 | } | ||
243 | |||
244 | static struct ins_ops dec_ops = { | ||
245 | .parse = dec__parse, | ||
246 | .scnprintf = dec__scnprintf, | ||
247 | }; | ||
248 | |||
208 | static int nop__scnprintf(struct ins *ins __used, char *bf, size_t size, | 249 | static int nop__scnprintf(struct ins *ins __used, char *bf, size_t size, |
209 | struct ins_operands *ops __used) | 250 | struct ins_operands *ops __used) |
210 | { | 251 | { |
@@ -232,7 +273,11 @@ static struct ins instructions[] = { | |||
232 | { .name = "cmpq", .ops = &mov_ops, }, | 273 | { .name = "cmpq", .ops = &mov_ops, }, |
233 | { .name = "cmpw", .ops = &mov_ops, }, | 274 | { .name = "cmpw", .ops = &mov_ops, }, |
234 | { .name = "cmpxch", .ops = &mov_ops, }, | 275 | { .name = "cmpxch", .ops = &mov_ops, }, |
276 | { .name = "dec", .ops = &dec_ops, }, | ||
277 | { .name = "decl", .ops = &dec_ops, }, | ||
235 | { .name = "imul", .ops = &mov_ops, }, | 278 | { .name = "imul", .ops = &mov_ops, }, |
279 | { .name = "inc", .ops = &dec_ops, }, | ||
280 | { .name = "incl", .ops = &dec_ops, }, | ||
236 | { .name = "ja", .ops = &jump_ops, }, | 281 | { .name = "ja", .ops = &jump_ops, }, |
237 | { .name = "jae", .ops = &jump_ops, }, | 282 | { .name = "jae", .ops = &jump_ops, }, |
238 | { .name = "jb", .ops = &jump_ops, }, | 283 | { .name = "jb", .ops = &jump_ops, }, |