diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2014-02-06 00:32:27 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-02-18 07:38:44 -0500 |
commit | a15ad2f5360c821f030c53266ebf467738249c68 (patch) | |
tree | cf8be8f908551177cb25e35075ab9c9e2045593a /tools | |
parent | eb948e50831bc64e6bb2589be7575ed7c159a429 (diff) |
perf probe: Support distro-style debuginfo for uprobe
Support distro-style debuginfo supported by dso for setting uprobes.
Note that this tries to find a debuginfo file based on the real path of
the target binary. If the debuginfo is not correctly installed on the
system, this can not find it.
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/20140206053227.29635.54434.stgit@kbuild-fedora.yrl.intra.hitachi.co.jp
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/probe-event.c | 9 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 41 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.h | 1 |
3 files changed, 43 insertions, 8 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 42bec67aaa38..0d1542f33d87 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -256,17 +256,14 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs) | |||
256 | } | 256 | } |
257 | 257 | ||
258 | #ifdef HAVE_DWARF_SUPPORT | 258 | #ifdef HAVE_DWARF_SUPPORT |
259 | |||
259 | /* Open new debuginfo of given module */ | 260 | /* Open new debuginfo of given module */ |
260 | static struct debuginfo *open_debuginfo(const char *module) | 261 | static struct debuginfo *open_debuginfo(const char *module) |
261 | { | 262 | { |
262 | const char *path; | 263 | const char *path = module; |
263 | 264 | ||
264 | /* A file path -- this is an offline module */ | 265 | if (!module || !strchr(module, '/')) { |
265 | if (module && strchr(module, '/')) | ||
266 | path = module; | ||
267 | else { | ||
268 | path = kernel_get_module_path(module); | 266 | path = kernel_get_module_path(module); |
269 | |||
270 | if (!path) { | 267 | if (!path) { |
271 | pr_err("Failed to find path of %s module.\n", | 268 | pr_err("Failed to find path of %s module.\n", |
272 | module ?: "kernel"); | 269 | module ?: "kernel"); |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 4f6e277c457c..df0238654698 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include <linux/bitops.h> | 35 | #include <linux/bitops.h> |
36 | #include "event.h" | 36 | #include "event.h" |
37 | #include "dso.h" | ||
37 | #include "debug.h" | 38 | #include "debug.h" |
38 | #include "intlist.h" | 39 | #include "intlist.h" |
39 | #include "util.h" | 40 | #include "util.h" |
@@ -89,7 +90,7 @@ error: | |||
89 | return -ENOENT; | 90 | return -ENOENT; |
90 | } | 91 | } |
91 | 92 | ||
92 | struct debuginfo *debuginfo__new(const char *path) | 93 | static struct debuginfo *__debuginfo__new(const char *path) |
93 | { | 94 | { |
94 | struct debuginfo *dbg = zalloc(sizeof(*dbg)); | 95 | struct debuginfo *dbg = zalloc(sizeof(*dbg)); |
95 | if (!dbg) | 96 | if (!dbg) |
@@ -97,10 +98,46 @@ struct debuginfo *debuginfo__new(const char *path) | |||
97 | 98 | ||
98 | if (debuginfo__init_offline_dwarf(dbg, path) < 0) | 99 | if (debuginfo__init_offline_dwarf(dbg, path) < 0) |
99 | zfree(&dbg); | 100 | zfree(&dbg); |
100 | 101 | if (dbg) | |
102 | pr_debug("Open Debuginfo file: %s\n", path); | ||
101 | return dbg; | 103 | return dbg; |
102 | } | 104 | } |
103 | 105 | ||
106 | enum dso_binary_type distro_dwarf_types[] = { | ||
107 | DSO_BINARY_TYPE__FEDORA_DEBUGINFO, | ||
108 | DSO_BINARY_TYPE__UBUNTU_DEBUGINFO, | ||
109 | DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO, | ||
110 | DSO_BINARY_TYPE__BUILDID_DEBUGINFO, | ||
111 | DSO_BINARY_TYPE__NOT_FOUND, | ||
112 | }; | ||
113 | |||
114 | struct debuginfo *debuginfo__new(const char *path) | ||
115 | { | ||
116 | enum dso_binary_type *type; | ||
117 | char buf[PATH_MAX], nil = '\0'; | ||
118 | struct dso *dso; | ||
119 | struct debuginfo *dinfo = NULL; | ||
120 | |||
121 | /* Try to open distro debuginfo files */ | ||
122 | dso = dso__new(path); | ||
123 | if (!dso) | ||
124 | goto out; | ||
125 | |||
126 | for (type = distro_dwarf_types; | ||
127 | !dinfo && *type != DSO_BINARY_TYPE__NOT_FOUND; | ||
128 | type++) { | ||
129 | if (dso__read_binary_type_filename(dso, *type, &nil, | ||
130 | buf, PATH_MAX) < 0) | ||
131 | continue; | ||
132 | dinfo = __debuginfo__new(buf); | ||
133 | } | ||
134 | dso__delete(dso); | ||
135 | |||
136 | out: | ||
137 | /* if failed to open all distro debuginfo, open given binary */ | ||
138 | return dinfo ? : __debuginfo__new(path); | ||
139 | } | ||
140 | |||
104 | void debuginfo__delete(struct debuginfo *dbg) | 141 | void debuginfo__delete(struct debuginfo *dbg) |
105 | { | 142 | { |
106 | if (dbg) { | 143 | if (dbg) { |
diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index 3fc597365ce6..92590b2c7e1c 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h | |||
@@ -30,6 +30,7 @@ struct debuginfo { | |||
30 | Dwarf_Addr bias; | 30 | Dwarf_Addr bias; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | /* This also tries to open distro debuginfo */ | ||
33 | extern struct debuginfo *debuginfo__new(const char *path); | 34 | extern struct debuginfo *debuginfo__new(const char *path); |
34 | extern void debuginfo__delete(struct debuginfo *dbg); | 35 | extern void debuginfo__delete(struct debuginfo *dbg); |
35 | 36 | ||