aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2016-09-19 16:18:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-09-20 11:28:29 -0400
commitbff5c3061374c37ed1262131eb333f714e5bcdf8 (patch)
tree37447f3e3bcfc8d8123d28966ade2f8a941c4006
parent88a7fcf961a27fbd248e3c914fc9df8327f7cdbb (diff)
perf annotate: Pass the symbol's map/dso to the instruction parsers
So that things like: → callq 0xffffffff993e3230 found while disassembling /proc/kcore can be beautified by later patches, that will resolve that address to a function, looking it up in /proc/kallsyms. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Chris Riyder <chris.ryder@arm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Markus Trippelsdorf <markus@trippelsdorf.de> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Cc: Pawel Moll <pawel.moll@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> Cc: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Taeung Song <treeze.taeung@gmail.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-p76myuke4j7gplg54amaklxk@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/annotate.c23
-rw-r--r--tools/perf/util/annotate.h2
2 files changed, 13 insertions, 12 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 60e915f392a6..aef841706dff 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -54,7 +54,7 @@ int ins__scnprintf(struct ins *ins, char *bf, size_t size,
54 return ins__raw_scnprintf(ins, bf, size, ops); 54 return ins__raw_scnprintf(ins, bf, size, ops);
55} 55}
56 56
57static int call__parse(struct ins_operands *ops) 57static int call__parse(struct ins_operands *ops, struct map *map __maybe_unused)
58{ 58{
59 char *endptr, *tok, *name; 59 char *endptr, *tok, *name;
60 60
@@ -114,7 +114,7 @@ bool ins__is_call(const struct ins *ins)
114 return ins->ops == &call_ops; 114 return ins->ops == &call_ops;
115} 115}
116 116
117static int jump__parse(struct ins_operands *ops) 117static int jump__parse(struct ins_operands *ops, struct map *map __maybe_unused)
118{ 118{
119 const char *s = strchr(ops->raw, '+'); 119 const char *s = strchr(ops->raw, '+');
120 120
@@ -169,7 +169,7 @@ static int comment__symbol(char *raw, char *comment, u64 *addrp, char **namep)
169 return 0; 169 return 0;
170} 170}
171 171
172static int lock__parse(struct ins_operands *ops) 172static int lock__parse(struct ins_operands *ops, struct map *map)
173{ 173{
174 char *name; 174 char *name;
175 175
@@ -190,7 +190,7 @@ static int lock__parse(struct ins_operands *ops)
190 return 0; 190 return 0;
191 191
192 if (ops->locked.ins->ops->parse && 192 if (ops->locked.ins->ops->parse &&
193 ops->locked.ins->ops->parse(ops->locked.ops) < 0) 193 ops->locked.ins->ops->parse(ops->locked.ops, map) < 0)
194 goto out_free_ops; 194 goto out_free_ops;
195 195
196 return 0; 196 return 0;
@@ -233,7 +233,7 @@ static struct ins_ops lock_ops = {
233 .scnprintf = lock__scnprintf, 233 .scnprintf = lock__scnprintf,
234}; 234};
235 235
236static int mov__parse(struct ins_operands *ops) 236static int mov__parse(struct ins_operands *ops, struct map *map __maybe_unused)
237{ 237{
238 char *s = strchr(ops->raw, ','), *target, *comment, prev; 238 char *s = strchr(ops->raw, ','), *target, *comment, prev;
239 239
@@ -300,7 +300,7 @@ static struct ins_ops mov_ops = {
300 .scnprintf = mov__scnprintf, 300 .scnprintf = mov__scnprintf,
301}; 301};
302 302
303static int dec__parse(struct ins_operands *ops) 303static int dec__parse(struct ins_operands *ops, struct map *map __maybe_unused)
304{ 304{
305 char *target, *comment, *s, prev; 305 char *target, *comment, *s, prev;
306 306
@@ -705,7 +705,7 @@ int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
705 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip); 705 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
706} 706}
707 707
708static void disasm_line__init_ins(struct disasm_line *dl) 708static void disasm_line__init_ins(struct disasm_line *dl, struct map *map)
709{ 709{
710 dl->ins = ins__find(dl->name); 710 dl->ins = ins__find(dl->name);
711 711
@@ -715,7 +715,7 @@ static void disasm_line__init_ins(struct disasm_line *dl)
715 if (!dl->ins->ops) 715 if (!dl->ins->ops)
716 return; 716 return;
717 717
718 if (dl->ins->ops->parse && dl->ins->ops->parse(&dl->ops) < 0) 718 if (dl->ins->ops->parse && dl->ins->ops->parse(&dl->ops, map) < 0)
719 dl->ins = NULL; 719 dl->ins = NULL;
720} 720}
721 721
@@ -757,7 +757,8 @@ out_free_name:
757} 757}
758 758
759static struct disasm_line *disasm_line__new(s64 offset, char *line, 759static struct disasm_line *disasm_line__new(s64 offset, char *line,
760 size_t privsize, int line_nr) 760 size_t privsize, int line_nr,
761 struct map *map)
761{ 762{
762 struct disasm_line *dl = zalloc(sizeof(*dl) + privsize); 763 struct disasm_line *dl = zalloc(sizeof(*dl) + privsize);
763 764
@@ -772,7 +773,7 @@ static struct disasm_line *disasm_line__new(s64 offset, char *line,
772 if (disasm_line__parse(dl->line, &dl->name, &dl->ops.raw) < 0) 773 if (disasm_line__parse(dl->line, &dl->name, &dl->ops.raw) < 0)
773 goto out_free_line; 774 goto out_free_line;
774 775
775 disasm_line__init_ins(dl); 776 disasm_line__init_ins(dl, map);
776 } 777 }
777 } 778 }
778 779
@@ -1144,7 +1145,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, struct map *map,
1144 parsed_line = tmp2 + 1; 1145 parsed_line = tmp2 + 1;
1145 } 1146 }
1146 1147
1147 dl = disasm_line__new(offset, parsed_line, privsize, *line_nr); 1148 dl = disasm_line__new(offset, parsed_line, privsize, *line_nr, map);
1148 free(line); 1149 free(line);
1149 (*line_nr)++; 1150 (*line_nr)++;
1150 1151
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index ea44e4ff19c6..5bbcec173b82 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -36,7 +36,7 @@ struct ins_operands {
36 36
37struct ins_ops { 37struct ins_ops {
38 void (*free)(struct ins_operands *ops); 38 void (*free)(struct ins_operands *ops);
39 int (*parse)(struct ins_operands *ops); 39 int (*parse)(struct ins_operands *ops, struct map *map);
40 int (*scnprintf)(struct ins *ins, char *bf, size_t size, 40 int (*scnprintf)(struct ins *ins, char *bf, size_t size,
41 struct ins_operands *ops); 41 struct ins_operands *ops);
42}; 42};