aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2014-02-06 00:32:18 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-02-18 07:34:51 -0500
commitf90acac75713cc6f18a4b2f1b9162bc1cd893c20 (patch)
tree5a845a8cac58ed20e28fa7c00e2cb798b52bf7ee /tools/perf/util/probe-event.c
parentdfef99cd0b2c8abafb571e5992ce954135be5f40 (diff)
perf probe: Find given address from offline dwarf
Find the given address from offline dwarfs instead of online kernel dwarfs. On the KASLR enabled kernel, the kernel text section is loaded with random offset, and the debuginfo__new_online_kernel can't handle it. So let's move to the offline dwarf loader instead of using the online dwarf loader. As a result, since we don't need debuginfo__new_online_kernel any more, this also removes the functions related to that. Without this change; # ./perf probe -l probe:t_show (on _stext+901288 with m v) probe:t_show_1 (on _stext+939624 with m v t) probe:t_show_2 (on _stext+980296 with m v fmt) probe:t_show_3 (on _stext+1014392 with m v file) With this change; # ./perf probe -l probe:t_show (on t_show@linux-3/kernel/trace/ftrace.c with m v) probe:t_show_1 (on t_show@linux-3/kernel/trace/trace.c with m v t) probe:t_show_2 (on t_show@kernel/trace/trace_printk.c with m v fmt) probe:t_show_3 (on t_show@kernel/trace/trace_events.c with m v file) Changes from v2: - Instead of retrying, directly opens offline dwarf. - Remove debuginfo__new_online_kernel and related functions. - Refer map->reloc to get the correct address of a symbol. - Add a special case for handling ref_reloc_sym based address. Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: David Ahern <dsahern@gmail.com> Cc: "David A. Long" <dave.long@linaro.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: yrl.pp-manager.tt@hitachi.com Link: http://lkml.kernel.org/r/20140206053218.29635.74821.stgit@kbuild-fedora.yrl.intra.hitachi.co.jp Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 1ce2cb9845b6..8e34c8d47813 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -248,6 +248,18 @@ static struct debuginfo *open_debuginfo(const char *module)
248 return debuginfo__new(path); 248 return debuginfo__new(path);
249} 249}
250 250
251static struct ref_reloc_sym *__kernel_get_ref_reloc_sym(void)
252{
253 /* kmap->ref_reloc_sym should be set if host_machine is initialized */
254 struct kmap *kmap;
255
256 if (map__load(host_machine->vmlinux_maps[MAP__FUNCTION], NULL) < 0)
257 return NULL;
258
259 kmap = map__kmap(host_machine->vmlinux_maps[MAP__FUNCTION]);
260 return kmap->ref_reloc_sym;
261}
262
251/* 263/*
252 * Convert trace point to probe point with debuginfo 264 * Convert trace point to probe point with debuginfo
253 * Currently only handles kprobes. 265 * Currently only handles kprobes.
@@ -256,18 +268,27 @@ static int kprobe_convert_to_perf_probe(struct probe_trace_point *tp,
256 struct perf_probe_point *pp) 268 struct perf_probe_point *pp)
257{ 269{
258 struct symbol *sym; 270 struct symbol *sym;
271 struct ref_reloc_sym *reloc_sym;
259 struct map *map; 272 struct map *map;
260 u64 addr; 273 u64 addr = 0;
261 int ret = -ENOENT; 274 int ret = -ENOENT;
262 struct debuginfo *dinfo; 275 struct debuginfo *dinfo;
263 276
264 sym = __find_kernel_function_by_name(tp->symbol, &map); 277 /* ref_reloc_sym is just a label. Need a special fix*/
265 if (sym) { 278 reloc_sym = __kernel_get_ref_reloc_sym();
266 addr = map->unmap_ip(map, sym->start + tp->offset); 279 if (reloc_sym && strcmp(tp->symbol, reloc_sym->name) == 0)
280 addr = reloc_sym->unrelocated_addr + tp->offset;
281 else {
282 sym = __find_kernel_function_by_name(tp->symbol, &map);
283 if (sym)
284 addr = map->unmap_ip(map, sym->start + tp->offset) -
285 map->reloc;
286 }
287 if (addr) {
267 pr_debug("try to find %s+%ld@%" PRIx64 "\n", tp->symbol, 288 pr_debug("try to find %s+%ld@%" PRIx64 "\n", tp->symbol,
268 tp->offset, addr); 289 tp->offset, addr);
269 290
270 dinfo = debuginfo__new_online_kernel(addr); 291 dinfo = open_debuginfo(tp->module);
271 if (dinfo) { 292 if (dinfo) {
272 ret = debuginfo__find_probe_point(dinfo, 293 ret = debuginfo__find_probe_point(dinfo,
273 (unsigned long)addr, pp); 294 (unsigned long)addr, pp);
@@ -383,15 +404,6 @@ static int add_module_to_probe_trace_events(struct probe_trace_event *tevs,
383 return ret; 404 return ret;
384} 405}
385 406
386static struct ref_reloc_sym *__kernel_get_ref_reloc_sym(void)
387{
388 /* kmap->ref_reloc_sym should be set if host_machine is initialized */
389 struct kmap *kmap;
390
391 kmap = map__kmap(host_machine->vmlinux_maps[MAP__FUNCTION]);
392 return kmap->ref_reloc_sym;
393}
394
395/* Post processing the probe events */ 407/* Post processing the probe events */
396static int post_process_probe_trace_events(struct probe_trace_event *tevs, 408static int post_process_probe_trace_events(struct probe_trace_event *tevs,
397 int ntevs, const char *module, 409 int ntevs, const char *module,