aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-11-10 22:51:05 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-11 01:30:18 -0500
commit4778d2e4f410c6eea32f594cb2be9590bcb28b84 (patch)
tree99625c6a532d83606e0d6c8ec7c812d5d5047e50 /tools/perf
parent57f395a7eabb913d3605d7392be5bdb0837c9f3d (diff)
perf tools: Read the build-ids from the header layer
Keep the build-ids reading implementation in the data mapping but move its call to the headers so that we have a better control on it (offset seeking, size passing, etc..). Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp> LKML-Reference: <1257911467-28276-4-git-send-email-fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/data_map.c8
-rw-r--r--tools/perf/util/data_map.h2
-rw-r--r--tools/perf/util/header.c14
3 files changed, 16 insertions, 8 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index 00a9c114c8d0..66e58aaecce3 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -70,8 +70,8 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
70 } 70 }
71} 71}
72 72
73static int perf_header__read_build_ids(const struct perf_header *self, 73int perf_header__read_build_ids(const struct perf_header *self,
74 int input, off_t file_size) 74 int input, off_t file_size)
75{ 75{
76 off_t offset = self->data_offset + self->data_size; 76 off_t offset = self->data_offset + self->data_size;
77 struct build_id_event bev; 77 struct build_id_event bev;
@@ -163,10 +163,6 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
163 if (curr_handler->sample_type_check(sample_type) < 0) 163 if (curr_handler->sample_type_check(sample_type) < 0)
164 exit(-1); 164 exit(-1);
165 165
166 if (perf_header__has_feat(header, HEADER_BUILD_ID) &&
167 perf_header__read_build_ids(header, input, input_stat.st_size))
168 pr_debug("failed to read buildids, continuing...\n");
169
170 if (load_kernel(NULL) < 0) { 166 if (load_kernel(NULL) < 0) {
171 perror("failed to load kernel symbols"); 167 perror("failed to load kernel symbols");
172 return EXIT_FAILURE; 168 return EXIT_FAILURE;
diff --git a/tools/perf/util/data_map.h b/tools/perf/util/data_map.h
index 716d1053b074..c4122810e489 100644
--- a/tools/perf/util/data_map.h
+++ b/tools/perf/util/data_map.h
@@ -27,5 +27,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
27 int full_paths, 27 int full_paths,
28 int *cwdlen, 28 int *cwdlen,
29 char **cwd); 29 char **cwd);
30int perf_header__read_build_ids(const struct perf_header *self,
31 int input, off_t file_size);
30 32
31#endif 33#endif
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 2f702c23f71a..915b56edbf02 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -9,6 +9,8 @@
9#include "../perf.h" 9#include "../perf.h"
10#include "trace-event.h" 10#include "trace-event.h"
11#include "symbol.h" 11#include "symbol.h"
12#include "data_map.h"
13#include "debug.h"
12 14
13/* 15/*
14 * Create new perf.data header attribute: 16 * Create new perf.data header attribute:
@@ -322,6 +324,14 @@ static void perf_header__adds_read(struct perf_header *self, int fd)
322 trace_report(fd); 324 trace_report(fd);
323 lseek(fd, trace_sec.offset + trace_sec.size, SEEK_SET); 325 lseek(fd, trace_sec.offset + trace_sec.size, SEEK_SET);
324 } 326 }
327
328 if (perf_header__has_feat(self, HEADER_BUILD_ID)) {
329 struct stat input_stat;
330
331 fstat(fd, &input_stat);
332 if (perf_header__read_build_ids(self, fd, input_stat.st_size))
333 pr_debug("failed to read buildids, continuing...\n");
334 }
325}; 335};
326 336
327struct perf_header *perf_header__read(int fd) 337struct perf_header *perf_header__read(int fd)
@@ -382,14 +392,14 @@ struct perf_header *perf_header__read(int fd)
382 392
383 memcpy(&self->adds_features, &f_header.adds_features, sizeof(f_header.adds_features)); 393 memcpy(&self->adds_features, &f_header.adds_features, sizeof(f_header.adds_features));
384 394
385 perf_header__adds_read(self, fd);
386
387 self->event_offset = f_header.event_types.offset; 395 self->event_offset = f_header.event_types.offset;
388 self->event_size = f_header.event_types.size; 396 self->event_size = f_header.event_types.size;
389 397
390 self->data_offset = f_header.data.offset; 398 self->data_offset = f_header.data.offset;
391 self->data_size = f_header.data.size; 399 self->data_size = f_header.data.size;
392 400
401 perf_header__adds_read(self, fd);
402
393 lseek(fd, self->data_offset, SEEK_SET); 403 lseek(fd, self->data_offset, SEEK_SET);
394 404
395 self->frozen = 1; 405 self->frozen = 1;