aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorPekka Enberg <penberg@cs.helsinki.fi>2009-11-22 05:29:44 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-22 06:19:07 -0500
commite57cfcdac6badd846a1cd831de54a1359c2d1eea (patch)
tree58b1c80ad1a888dbc28071e31e92aa2872635648 /tools/perf
parentf3ced7cdb24e7968a353d828955fa2daf4167e72 (diff)
perf symbols: Fix ELF header errors during "perf kmem record"
The write_event() function in builtin-record.c writes out all mmap()'d DSOs including non-ELF files like GNOME resource files and such. Therefore, check for ELF_K_ELF in filename__read_build_id() before attempting to read the ELF header with gelf_getehdr(). Fixes the following error messages when running "perf kmem record": penberg@penberg-laptop:~/src/linux/tools/perf$ perf kmem record ^C[ perf record: Woken up 2 times to write data ] [ perf record: Captured and wrote 0.753 MB perf.data (~32885 samples) ] filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. filename__read_build_id: cannot get elf header. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> LKML-Reference: <1258885784-11709-1-git-send-email-penberg@cs.helsinki.fi> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/symbol.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 86ec6c720f0f..f56158fb4dc9 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -921,6 +921,7 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)
921 GElf_Shdr shdr; 921 GElf_Shdr shdr;
922 Elf_Data *data; 922 Elf_Data *data;
923 Elf_Scn *sec; 923 Elf_Scn *sec;
924 Elf_Kind ek;
924 void *ptr; 925 void *ptr;
925 Elf *elf; 926 Elf *elf;
926 927
@@ -937,6 +938,10 @@ int filename__read_build_id(const char *filename, void *bf, size_t size)
937 goto out_close; 938 goto out_close;
938 } 939 }
939 940
941 ek = elf_kind(elf);
942 if (ek != ELF_K_ELF)
943 goto out_elf_end;
944
940 if (gelf_getehdr(elf, &ehdr) == NULL) { 945 if (gelf_getehdr(elf, &ehdr) == NULL) {
941 pr_err("%s: cannot get elf header.\n", __func__); 946 pr_err("%s: cannot get elf header.\n", __func__);
942 goto out_elf_end; 947 goto out_elf_end;