Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Frederic Weisbecker and committed by
Ingo Molnar
4778d2e4 57f395a7

+16 -8
+2 -6
tools/perf/util/data_map.c
··· 70 70 } 71 71 } 72 72 73 - static int perf_header__read_build_ids(const struct perf_header *self, 74 - int input, off_t file_size) 73 + int perf_header__read_build_ids(const struct perf_header *self, 74 + int input, off_t file_size) 75 75 { 76 76 off_t offset = self->data_offset + self->data_size; 77 77 struct build_id_event bev; ··· 162 162 if (curr_handler->sample_type_check) 163 163 if (curr_handler->sample_type_check(sample_type) < 0) 164 164 exit(-1); 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 165 170 166 if (load_kernel(NULL) < 0) { 171 167 perror("failed to load kernel symbols");
+2
tools/perf/util/data_map.h
··· 27 27 int full_paths, 28 28 int *cwdlen, 29 29 char **cwd); 30 + int perf_header__read_build_ids(const struct perf_header *self, 31 + int input, off_t file_size); 30 32 31 33 #endif
+12 -2
tools/perf/util/header.c
··· 9 9 #include "../perf.h" 10 10 #include "trace-event.h" 11 11 #include "symbol.h" 12 + #include "data_map.h" 13 + #include "debug.h" 12 14 13 15 /* 14 16 * Create new perf.data header attribute: ··· 324 322 trace_report(fd); 325 323 lseek(fd, trace_sec.offset + trace_sec.size, SEEK_SET); 326 324 } 325 + 326 + if (perf_header__has_feat(self, HEADER_BUILD_ID)) { 327 + struct stat input_stat; 328 + 329 + fstat(fd, &input_stat); 330 + if (perf_header__read_build_ids(self, fd, input_stat.st_size)) 331 + pr_debug("failed to read buildids, continuing...\n"); 332 + } 327 333 }; 328 334 329 335 struct perf_header *perf_header__read(int fd) ··· 392 382 393 383 memcpy(&self->adds_features, &f_header.adds_features, sizeof(f_header.adds_features)); 394 384 395 - perf_header__adds_read(self, fd); 396 - 397 385 self->event_offset = f_header.event_types.offset; 398 386 self->event_size = f_header.event_types.size; 399 387 400 388 self->data_offset = f_header.data.offset; 401 389 self->data_size = f_header.data.size; 390 + 391 + perf_header__adds_read(self, fd); 402 392 403 393 lseek(fd, self->data_offset, SEEK_SET); 404 394