diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-15 19:12:07 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-04-16 11:16:39 -0400 |
commit | 657bcaf5097e1aff53d724358deb24ce803f43a4 (patch) | |
tree | 77edb1110c4cbfccf59654265784948dce4877fd /tools | |
parent | 5145418b06fa907883ff1f62301d534a0d26ba18 (diff) |
perf annotate browser: Use the disasm_line instruction name and operand fields
No need to reparse it everytime.
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-90ncot487p4h5rzkn8h2whou@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index bc540b1576c3..0bc3e652b541 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -260,22 +260,16 @@ static bool annotate_browser__callq(struct annotate_browser *browser, | |||
260 | void *arg, int delay_secs) | 260 | void *arg, int delay_secs) |
261 | { | 261 | { |
262 | struct map_symbol *ms = browser->b.priv; | 262 | struct map_symbol *ms = browser->b.priv; |
263 | struct disasm_line *dl = browser->selection; | ||
263 | struct symbol *sym = ms->sym; | 264 | struct symbol *sym = ms->sym; |
264 | struct annotation *notes; | 265 | struct annotation *notes; |
265 | struct symbol *target; | 266 | struct symbol *target; |
266 | char *s = strstr(browser->selection->line, "callq "); | ||
267 | u64 ip; | 267 | u64 ip; |
268 | 268 | ||
269 | if (s == NULL) | 269 | if (strcmp(dl->name, "callq")) |
270 | return false; | 270 | return false; |
271 | 271 | ||
272 | s = strchr(s, ' '); | 272 | ip = strtoull(dl->operands, NULL, 16); |
273 | if (s++ == NULL) { | ||
274 | ui_helpline__puts("Invallid callq instruction."); | ||
275 | return true; | ||
276 | } | ||
277 | |||
278 | ip = strtoull(s, NULL, 16); | ||
279 | ip = ms->map->map_ip(ms->map, ip); | 273 | ip = ms->map->map_ip(ms->map, ip); |
280 | target = map__find_symbol(ms->map, ip, NULL); | 274 | target = map__find_symbol(ms->map, ip, NULL); |
281 | if (target == NULL) { | 275 | if (target == NULL) { |
@@ -321,22 +315,19 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows | |||
321 | 315 | ||
322 | static bool annotate_browser__jump(struct annotate_browser *browser) | 316 | static bool annotate_browser__jump(struct annotate_browser *browser) |
323 | { | 317 | { |
324 | const char *jumps[] = { "je ", "jne ", "ja ", "jmpq ", "js ", "jmp ", NULL }; | 318 | const char *jumps[] = { "je", "jne", "ja", "jmpq", "js", "jmp", NULL }; |
325 | struct disasm_line *dl; | 319 | struct disasm_line *dl = browser->selection; |
326 | s64 idx, offset; | 320 | s64 idx, offset; |
327 | char *s = NULL; | 321 | char *s; |
328 | int i = 0; | 322 | int i = 0; |
329 | 323 | ||
330 | while (jumps[i]) { | 324 | while (jumps[i] && strcmp(dl->name, jumps[i])) |
331 | s = strstr(browser->selection->line, jumps[i++]); | 325 | ++i; |
332 | if (s) | ||
333 | break; | ||
334 | } | ||
335 | 326 | ||
336 | if (s == NULL) | 327 | if (jumps[i] == NULL) |
337 | return false; | 328 | return false; |
338 | 329 | ||
339 | s = strchr(s, '+'); | 330 | s = strchr(dl->operands, '+'); |
340 | if (s++ == NULL) { | 331 | if (s++ == NULL) { |
341 | ui_helpline__puts("Invallid jump instruction."); | 332 | ui_helpline__puts("Invallid jump instruction."); |
342 | return true; | 333 | return true; |