Skip to content

Commit

Permalink
perf tools: Read the build-ids from the header layer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Nov 11, 2009
1 parent 57f395a commit 4778d2e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
8 changes: 2 additions & 6 deletions tools/perf/util/data_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
}
}

static int perf_header__read_build_ids(const struct perf_header *self,
int input, off_t file_size)
int perf_header__read_build_ids(const struct perf_header *self,
int input, off_t file_size)
{
off_t offset = self->data_offset + self->data_size;
struct build_id_event bev;
Expand Down Expand Up @@ -163,10 +163,6 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
if (curr_handler->sample_type_check(sample_type) < 0)
exit(-1);

if (perf_header__has_feat(header, HEADER_BUILD_ID) &&
perf_header__read_build_ids(header, input, input_stat.st_size))
pr_debug("failed to read buildids, continuing...\n");

if (load_kernel(NULL) < 0) {
perror("failed to load kernel symbols");
return EXIT_FAILURE;
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/data_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
int full_paths,
int *cwdlen,
char **cwd);
int perf_header__read_build_ids(const struct perf_header *self,
int input, off_t file_size);

#endif
14 changes: 12 additions & 2 deletions tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "../perf.h"
#include "trace-event.h"
#include "symbol.h"
#include "data_map.h"
#include "debug.h"

/*
* Create new perf.data header attribute:
Expand Down Expand Up @@ -322,6 +324,14 @@ static void perf_header__adds_read(struct perf_header *self, int fd)
trace_report(fd);
lseek(fd, trace_sec.offset + trace_sec.size, SEEK_SET);
}

if (perf_header__has_feat(self, HEADER_BUILD_ID)) {
struct stat input_stat;

fstat(fd, &input_stat);
if (perf_header__read_build_ids(self, fd, input_stat.st_size))
pr_debug("failed to read buildids, continuing...\n");
}
};

struct perf_header *perf_header__read(int fd)
Expand Down Expand Up @@ -382,14 +392,14 @@ struct perf_header *perf_header__read(int fd)

memcpy(&self->adds_features, &f_header.adds_features, sizeof(f_header.adds_features));

perf_header__adds_read(self, fd);

self->event_offset = f_header.event_types.offset;
self->event_size = f_header.event_types.size;

self->data_offset = f_header.data.offset;
self->data_size = f_header.data.size;

perf_header__adds_read(self, fd);

lseek(fd, self->data_offset, SEEK_SET);

self->frozen = 1;
Expand Down

0 comments on commit 4778d2e

Please sign in to comment.