aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-01-14 15:30:06 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-16 04:58:47 -0500
commit9e201442de7c954f03710ac76f28c1927d07550c (patch)
tree7682ebe87ca85468e0ecd28b277013e9359605c0 /tools/perf/util/header.c
parent8d0591f6ad9edf66697ce29de176fb6f3213b9e3 (diff)
perf symbols: Cache /proc/kallsyms files by build-id
So that when we don't have a vmlinux handy we can store the kallsyms for later use by 'perf report'. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1263501006-14185-3-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index b31e0ae4b8d..1b65fed0dd2 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -237,11 +237,13 @@ static int dso__cache_build_id(struct dso *self, const char *debugdir)
237 char *filename = malloc(size), 237 char *filename = malloc(size),
238 *linkname = malloc(size), *targetname, *sbuild_id; 238 *linkname = malloc(size), *targetname, *sbuild_id;
239 int len, err = -1; 239 int len, err = -1;
240 bool is_kallsyms = self->kernel && self->long_name[0] != '/';
240 241
241 if (filename == NULL || linkname == NULL) 242 if (filename == NULL || linkname == NULL)
242 goto out_free; 243 goto out_free;
243 244
244 len = snprintf(filename, size, "%s%s", debugdir, self->long_name); 245 len = snprintf(filename, size, "%s%s%s",
246 debugdir, is_kallsyms ? "/" : "", self->long_name);
245 if (mkdir_p(filename, 0755)) 247 if (mkdir_p(filename, 0755))
246 goto out_free; 248 goto out_free;
247 249
@@ -249,9 +251,14 @@ static int dso__cache_build_id(struct dso *self, const char *debugdir)
249 sbuild_id = filename + len; 251 sbuild_id = filename + len;
250 build_id__sprintf(self->build_id, sizeof(self->build_id), sbuild_id); 252 build_id__sprintf(self->build_id, sizeof(self->build_id), sbuild_id);
251 253
252 if (access(filename, F_OK) && link(self->long_name, filename) && 254 if (access(filename, F_OK)) {
253 copyfile(self->long_name, filename)) 255 if (is_kallsyms) {
254 goto out_free; 256 if (copyfile("/proc/kallsyms", filename))
257 goto out_free;
258 } else if (link(self->long_name, filename) &&
259 copyfile(self->long_name, filename))
260 goto out_free;
261 }
255 262
256 len = snprintf(linkname, size, "%s/.build-id/%.2s", 263 len = snprintf(linkname, size, "%s/.build-id/%.2s",
257 debugdir, sbuild_id); 264 debugdir, sbuild_id);