lkml.org 
[lkml]   [2014]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH -tip v2 6/8] perf-probe: Show appropriate symbol for _stext based kprobes
From
Date
Show appropriate symbol for _stext based kprobes instead
of _stext+offset when perf-probe -l runs without debuginfo.

Without this change:
# ./perf probe -l
probe:t_show (on _stext+889880 with m v)
probe:t_show_1 (on _stext+928568 with m v t)
probe:t_show_2 (on _stext+969512 with m v fmt)
probe:t_show_3 (on _stext+1001416 with m v file)

With this change:
# ./perf probe -l
probe:t_show (on t_show with m v)
probe:t_show_1 (on t_show with m v t)
probe:t_show_2 (on t_show with m v fmt)
probe:t_show_3 (on t_show with m v file)

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
tools/perf/util/probe-event.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b35f047..8db172a 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -125,6 +125,11 @@ static struct symbol *__find_kernel_function_by_name(const char *name,
NULL);
}

+static struct symbol *__find_kernel_function(u64 addr, struct map **mapp)
+{
+ return machine__find_kernel_function(host_machine, addr, mapp, NULL);
+}
+
static struct map *kernel_get_module_map(const char *module)
{
struct rb_node *nd;
@@ -220,12 +225,30 @@ out:
static int convert_to_perf_probe_point(struct probe_trace_point *tp,
struct perf_probe_point *pp)
{
- pp->function = strdup(tp->symbol);
+ struct symbol *sym;
+ struct map *map;
+ u64 addr;
+
+ /* _stext based probe point is solved to absolute address */
+ if (tp->symbol && strcmp(tp->symbol, "_stext") == 0) {
+ sym = __find_kernel_function_by_name(tp->symbol, &map);
+ if (!sym)
+ goto failed;
+ addr = map->unmap_ip(map, sym->start + tp->offset);
+ sym = __find_kernel_function(addr, &map);
+ if (!sym)
+ goto failed;
+ pp->function = strdup(sym->name);
+ pp->offset = addr - map->unmap_ip(map, sym->start);
+ } else {
+failed:
+ pp->function = strdup(tp->symbol);
+ pp->offset = tp->offset;
+ }

if (pp->function == NULL)
return -ENOMEM;

- pp->offset = tp->offset;
pp->retprobe = tp->retprobe;

return 0;



\
 
 \ /
  Last update: 2014-01-29 10:41    [W:0.075 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site