diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-01-14 18:30:06 -0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-01-16 10:58:47 +0100 |
commit | 9e201442de7c954f03710ac76f28c1927d07550c (patch) | |
tree | 7682ebe87ca85468e0ecd28b277013e9359605c0 /tools/perf/util/util.c | |
parent | 8d0591f6ad9edf66697ce29de176fb6f3213b9e3 (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/util.c')
-rw-r--r-- | tools/perf/util/util.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index f3c0798a5e7..f0685849b24 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -32,6 +32,33 @@ int mkdir_p(char *path, mode_t mode) return (stat(path, &st) && mkdir(path, mode)) ? -1 : 0; } +static int slow_copyfile(const char *from, const char *to) +{ + int err = 0; + char *line = NULL; + size_t n; + FILE *from_fp = fopen(from, "r"), *to_fp; + + if (from_fp == NULL) + goto out; + + to_fp = fopen(to, "w"); + if (to_fp == NULL) + goto out_fclose_from; + + while (getline(&line, &n, from_fp) > 0) + if (fputs(line, to_fp) == EOF) + goto out_fclose_to; + err = 0; +out_fclose_to: + fclose(to_fp); + free(line); +out_fclose_from: + fclose(from_fp); +out: + return err; +} + int copyfile(const char *from, const char *to) { int fromfd, tofd; @@ -42,6 +69,9 @@ int copyfile(const char *from, const char *to) if (stat(from, &st)) goto out; + if (st.st_size == 0) /* /proc? do it slowly... */ + return slow_copyfile(from, to); + fromfd = open(from, O_RDONLY); if (fromfd < 0) goto out; |