diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-probe.c | 5 | ||||
-rw-r--r-- | tools/perf/util/header.c | 10 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 2 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 15 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 85 | ||||
-rw-r--r-- | tools/perf/util/string.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 4 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 |
9 files changed, 85 insertions, 43 deletions
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 44a47e13bd67..c49837de7d3f 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -36,7 +36,6 @@ static const struct option options[] = { | |||
36 | 36 | ||
37 | static int __cmd_buildid_list(void) | 37 | static int __cmd_buildid_list(void) |
38 | { | 38 | { |
39 | int err = -1; | ||
40 | struct perf_session *session; | 39 | struct perf_session *session; |
41 | 40 | ||
42 | session = perf_session__new(input_name, O_RDONLY, force, false); | 41 | session = perf_session__new(input_name, O_RDONLY, force, false); |
@@ -49,7 +48,7 @@ static int __cmd_buildid_list(void) | |||
49 | perf_session__fprintf_dsos_buildid(session, stdout, with_hits); | 48 | perf_session__fprintf_dsos_buildid(session, stdout, with_hits); |
50 | 49 | ||
51 | perf_session__delete(session); | 50 | perf_session__delete(session); |
52 | return err; | 51 | return 0; |
53 | } | 52 | } |
54 | 53 | ||
55 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) | 54 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) |
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 2e000c068cc5..add163c9f0e7 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -249,6 +249,11 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
249 | !params.show_lines)) | 249 | !params.show_lines)) |
250 | usage_with_options(probe_usage, options); | 250 | usage_with_options(probe_usage, options); |
251 | 251 | ||
252 | /* | ||
253 | * Only consider the user's kernel image path if given. | ||
254 | */ | ||
255 | symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); | ||
256 | |||
252 | if (params.list_events) { | 257 | if (params.list_events) { |
253 | if (params.mod_events) { | 258 | if (params.mod_events) { |
254 | pr_err(" Error: Don't use --list with --add/--del.\n"); | 259 | pr_err(" Error: Don't use --list with --add/--del.\n"); |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 64a85bafde63..7cba0551a565 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -265,15 +265,16 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
265 | const char *name, bool is_kallsyms) | 265 | const char *name, bool is_kallsyms) |
266 | { | 266 | { |
267 | const size_t size = PATH_MAX; | 267 | const size_t size = PATH_MAX; |
268 | char *filename = malloc(size), | 268 | char *realname = realpath(name, NULL), |
269 | *filename = malloc(size), | ||
269 | *linkname = malloc(size), *targetname; | 270 | *linkname = malloc(size), *targetname; |
270 | int len, err = -1; | 271 | int len, err = -1; |
271 | 272 | ||
272 | if (filename == NULL || linkname == NULL) | 273 | if (realname == NULL || filename == NULL || linkname == NULL) |
273 | goto out_free; | 274 | goto out_free; |
274 | 275 | ||
275 | len = snprintf(filename, size, "%s%s%s", | 276 | len = snprintf(filename, size, "%s%s%s", |
276 | debugdir, is_kallsyms ? "/" : "", name); | 277 | debugdir, is_kallsyms ? "/" : "", realname); |
277 | if (mkdir_p(filename, 0755)) | 278 | if (mkdir_p(filename, 0755)) |
278 | goto out_free; | 279 | goto out_free; |
279 | 280 | ||
@@ -283,7 +284,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
283 | if (is_kallsyms) { | 284 | if (is_kallsyms) { |
284 | if (copyfile("/proc/kallsyms", filename)) | 285 | if (copyfile("/proc/kallsyms", filename)) |
285 | goto out_free; | 286 | goto out_free; |
286 | } else if (link(name, filename) && copyfile(name, filename)) | 287 | } else if (link(realname, filename) && copyfile(name, filename)) |
287 | goto out_free; | 288 | goto out_free; |
288 | } | 289 | } |
289 | 290 | ||
@@ -300,6 +301,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
300 | if (symlink(targetname, linkname) == 0) | 301 | if (symlink(targetname, linkname) == 0) |
301 | err = 0; | 302 | err = 0; |
302 | out_free: | 303 | out_free: |
304 | free(realname); | ||
303 | free(filename); | 305 | free(filename); |
304 | free(linkname); | 306 | free(linkname); |
305 | return err; | 307 | return err; |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 2022e8740994..76bcc35cf9b1 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -356,7 +356,7 @@ static size_t ipchain__fprintf_graph_line(FILE *fp, int depth, int depth_mask, | |||
356 | 356 | ||
357 | static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, | 357 | static size_t ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, |
358 | int depth, int depth_mask, int period, | 358 | int depth, int depth_mask, int period, |
359 | u64 total_samples, int hits, | 359 | u64 total_samples, u64 hits, |
360 | int left_margin) | 360 | int left_margin) |
361 | { | 361 | { |
362 | int i; | 362 | int i; |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 3b6a5297bf16..61191c6cbe7a 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -114,6 +114,8 @@ static struct symbol *__find_kernel_function_by_name(const char *name, | |||
114 | const char *kernel_get_module_path(const char *module) | 114 | const char *kernel_get_module_path(const char *module) |
115 | { | 115 | { |
116 | struct dso *dso; | 116 | struct dso *dso; |
117 | struct map *map; | ||
118 | const char *vmlinux_name; | ||
117 | 119 | ||
118 | if (module) { | 120 | if (module) { |
119 | list_for_each_entry(dso, &machine.kernel_dsos, node) { | 121 | list_for_each_entry(dso, &machine.kernel_dsos, node) { |
@@ -123,10 +125,17 @@ const char *kernel_get_module_path(const char *module) | |||
123 | } | 125 | } |
124 | pr_debug("Failed to find module %s.\n", module); | 126 | pr_debug("Failed to find module %s.\n", module); |
125 | return NULL; | 127 | return NULL; |
128 | } | ||
129 | |||
130 | map = machine.vmlinux_maps[MAP__FUNCTION]; | ||
131 | dso = map->dso; | ||
132 | |||
133 | vmlinux_name = symbol_conf.vmlinux_name; | ||
134 | if (vmlinux_name) { | ||
135 | if (dso__load_vmlinux(dso, map, vmlinux_name, NULL) <= 0) | ||
136 | return NULL; | ||
126 | } else { | 137 | } else { |
127 | dso = machine.vmlinux_maps[MAP__FUNCTION]->dso; | 138 | if (dso__load_vmlinux_path(dso, map, NULL) <= 0) { |
128 | if (dso__load_vmlinux_path(dso, | ||
129 | machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) { | ||
130 | pr_debug("Failed to load kernel map.\n"); | 139 | pr_debug("Failed to load kernel map.\n"); |
131 | return NULL; | 140 | return NULL; |
132 | } | 141 | } |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 3991d73d1cff..ddf4d4556321 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -117,28 +117,6 @@ static void line_list__free(struct list_head *head) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | /* Dwarf FL wrappers */ | 119 | /* Dwarf FL wrappers */ |
120 | |||
121 | static int __linux_kernel_find_elf(Dwfl_Module *mod, | ||
122 | void **userdata, | ||
123 | const char *module_name, | ||
124 | Dwarf_Addr base, | ||
125 | char **file_name, Elf **elfp) | ||
126 | { | ||
127 | int fd; | ||
128 | const char *path = kernel_get_module_path(module_name); | ||
129 | |||
130 | if (path) { | ||
131 | fd = open(path, O_RDONLY); | ||
132 | if (fd >= 0) { | ||
133 | *file_name = strdup(path); | ||
134 | return fd; | ||
135 | } | ||
136 | } | ||
137 | /* If failed, try to call standard method */ | ||
138 | return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base, | ||
139 | file_name, elfp); | ||
140 | } | ||
141 | |||
142 | static char *debuginfo_path; /* Currently dummy */ | 120 | static char *debuginfo_path; /* Currently dummy */ |
143 | 121 | ||
144 | static const Dwfl_Callbacks offline_callbacks = { | 122 | static const Dwfl_Callbacks offline_callbacks = { |
@@ -151,14 +129,6 @@ static const Dwfl_Callbacks offline_callbacks = { | |||
151 | .find_elf = dwfl_build_id_find_elf, | 129 | .find_elf = dwfl_build_id_find_elf, |
152 | }; | 130 | }; |
153 | 131 | ||
154 | static const Dwfl_Callbacks kernel_callbacks = { | ||
155 | .find_debuginfo = dwfl_standard_find_debuginfo, | ||
156 | .debuginfo_path = &debuginfo_path, | ||
157 | |||
158 | .find_elf = __linux_kernel_find_elf, | ||
159 | .section_address = dwfl_linux_kernel_module_section_address, | ||
160 | }; | ||
161 | |||
162 | /* Get a Dwarf from offline image */ | 132 | /* Get a Dwarf from offline image */ |
163 | static Dwarf *dwfl_init_offline_dwarf(int fd, Dwfl **dwflp, Dwarf_Addr *bias) | 133 | static Dwarf *dwfl_init_offline_dwarf(int fd, Dwfl **dwflp, Dwarf_Addr *bias) |
164 | { | 134 | { |
@@ -185,6 +155,38 @@ error: | |||
185 | return dbg; | 155 | return dbg; |
186 | } | 156 | } |
187 | 157 | ||
158 | #if _ELFUTILS_PREREQ(0, 148) | ||
159 | /* This method is buggy if elfutils is older than 0.148 */ | ||
160 | static int __linux_kernel_find_elf(Dwfl_Module *mod, | ||
161 | void **userdata, | ||
162 | const char *module_name, | ||
163 | Dwarf_Addr base, | ||
164 | char **file_name, Elf **elfp) | ||
165 | { | ||
166 | int fd; | ||
167 | const char *path = kernel_get_module_path(module_name); | ||
168 | |||
169 | pr_debug2("Use file %s for %s\n", path, module_name); | ||
170 | if (path) { | ||
171 | fd = open(path, O_RDONLY); | ||
172 | if (fd >= 0) { | ||
173 | *file_name = strdup(path); | ||
174 | return fd; | ||
175 | } | ||
176 | } | ||
177 | /* If failed, try to call standard method */ | ||
178 | return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base, | ||
179 | file_name, elfp); | ||
180 | } | ||
181 | |||
182 | static const Dwfl_Callbacks kernel_callbacks = { | ||
183 | .find_debuginfo = dwfl_standard_find_debuginfo, | ||
184 | .debuginfo_path = &debuginfo_path, | ||
185 | |||
186 | .find_elf = __linux_kernel_find_elf, | ||
187 | .section_address = dwfl_linux_kernel_module_section_address, | ||
188 | }; | ||
189 | |||
188 | /* Get a Dwarf from live kernel image */ | 190 | /* Get a Dwarf from live kernel image */ |
189 | static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, | 191 | static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, |
190 | Dwarf_Addr *bias) | 192 | Dwarf_Addr *bias) |
@@ -205,11 +207,34 @@ static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, | |||
205 | dbg = dwfl_addrdwarf(*dwflp, addr, bias); | 207 | dbg = dwfl_addrdwarf(*dwflp, addr, bias); |
206 | /* Here, check whether we could get a real dwarf */ | 208 | /* Here, check whether we could get a real dwarf */ |
207 | if (!dbg) { | 209 | if (!dbg) { |
210 | pr_debug("Failed to find kernel dwarf at %lx\n", | ||
211 | (unsigned long)addr); | ||
208 | dwfl_end(*dwflp); | 212 | dwfl_end(*dwflp); |
209 | *dwflp = NULL; | 213 | *dwflp = NULL; |
210 | } | 214 | } |
211 | return dbg; | 215 | return dbg; |
212 | } | 216 | } |
217 | #else | ||
218 | /* With older elfutils, this just support kernel module... */ | ||
219 | static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr __used, Dwfl **dwflp, | ||
220 | Dwarf_Addr *bias) | ||
221 | { | ||
222 | int fd; | ||
223 | const char *path = kernel_get_module_path("kernel"); | ||
224 | |||
225 | if (!path) { | ||
226 | pr_err("Failed to find vmlinux path\n"); | ||
227 | return NULL; | ||
228 | } | ||
229 | |||
230 | pr_debug2("Use file %s for debuginfo\n", path); | ||
231 | fd = open(path, O_RDONLY); | ||
232 | if (fd < 0) | ||
233 | return NULL; | ||
234 | |||
235 | return dwfl_init_offline_dwarf(fd, dwflp, bias); | ||
236 | } | ||
237 | #endif | ||
213 | 238 | ||
214 | /* Dwarf wrappers */ | 239 | /* Dwarf wrappers */ |
215 | 240 | ||
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index 0409fc7c0058..8fc0bd3a3a4a 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c | |||
@@ -259,7 +259,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space) | |||
259 | if (!*pat) /* Tail wild card matches all */ | 259 | if (!*pat) /* Tail wild card matches all */ |
260 | return true; | 260 | return true; |
261 | while (*str) | 261 | while (*str) |
262 | if (strglobmatch(str++, pat)) | 262 | if (__match_glob(str++, pat, ignore_space)) |
263 | return true; | 263 | return true; |
264 | } | 264 | } |
265 | return !*str && !*pat; | 265 | return !*str && !*pat; |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index d628c8d1cf5e..439ab947daf4 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1780,8 +1780,8 @@ out_failure: | |||
1780 | return -1; | 1780 | return -1; |
1781 | } | 1781 | } |
1782 | 1782 | ||
1783 | static int dso__load_vmlinux(struct dso *self, struct map *map, | 1783 | int dso__load_vmlinux(struct dso *self, struct map *map, |
1784 | const char *vmlinux, symbol_filter_t filter) | 1784 | const char *vmlinux, symbol_filter_t filter) |
1785 | { | 1785 | { |
1786 | int err = -1, fd; | 1786 | int err = -1, fd; |
1787 | 1787 | ||
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 038f2201ee09..6c6eafdb932d 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -166,6 +166,8 @@ void dso__sort_by_name(struct dso *self, enum map_type type); | |||
166 | struct dso *__dsos__findnew(struct list_head *head, const char *name); | 166 | struct dso *__dsos__findnew(struct list_head *head, const char *name); |
167 | 167 | ||
168 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); | 168 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); |
169 | int dso__load_vmlinux(struct dso *self, struct map *map, | ||
170 | const char *vmlinux, symbol_filter_t filter); | ||
169 | int dso__load_vmlinux_path(struct dso *self, struct map *map, | 171 | int dso__load_vmlinux_path(struct dso *self, struct map *map, |
170 | symbol_filter_t filter); | 172 | symbol_filter_t filter); |
171 | int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, | 173 | int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, |