perf annotate: Disassembler instruction parsing
Commit-ID: 4f9d03251b9d202ebce805757360ef0fac5eb74e Gitweb: http://git.kernel.org/tip/4f9d03251b9d202ebce805757360ef0fac5eb74e Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 18 Apr 2012 13:58:34 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 18 Apr 2012 13:58:34 -0300
perf annotate: Disassembler instruction parsing
So that at disassembly time we parse targets, etc.
Supporting jump instructions initially, call functions are next.
Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/ui/browsers/annotate.c | 19 ++--------- tools/perf/util/annotate.c | 63 +++++++++++++++++++++++++++++++++++++ tools/perf/util/annotate.h | 13 +++++++ 3 files changed, 79 insertions(+), 16 deletions(-)
tools/perf/ui/browsers/annotate.c +3 -16
@@ -315,26 +315,13 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browsstatic bool annotate_browser__jump (struct annotate_browser *browser) { -const char *jumps[] = {"je" ,"jne" ,"ja" ,"jmpq" ,"js" ,"jmp" ,NULL };struct disasm_line *dl = browser->selection; -s64 idx, offset; -char *s; -int i =0 ; - -while (jumps[i] &&strcmp (dl->name, jumps[i])) - ++i; +s64 idx; -if (jumps[i] ==NULL ) +if (!dl->ins || !ins__is_jump (dl->ins))return false; - s =strchr (dl->operands,'+' ); -if (s++ ==NULL ) { -ui_helpline__puts ("Invallid jump instruction." ); -return true; - } - - offset =strtoll (s,NULL ,16 ); - dl =annotate_browser__find_offset (browser, offset, &idx); + dl =annotate_browser__find_offset (browser, dl->target, &idx);if (dl ==NULL ) {ui_helpline__puts ("Invallid jump offset" );return true;
tools/perf/util/annotate.c +63 -0
81 lines not on this page · raw message
tools/perf/util/annotate.h +13 -0
@@ -7,11 +7,24 @@#include <linux/list.h> #include <linux/rbtree.h> +struct ins_ops { +int (*parse_target)(const char *operands,u64 *target); +}; + +struct ins { +const char *name; +struct ins_ops *ops; +}; + +bool ins__is_jump (const struct ins *ins); +struct disasm_line {struct list_head node;s64 offset; +u64 target;char *line;char *name; +struct ins *ins;char *operands; };