diff options
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r-- | tools/perf/util/session.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index aa8a03120bbd..74cbc64a3a3c 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -385,8 +385,9 @@ static struct thread *perf_session__register_idle_thread(struct perf_session *se | |||
385 | return thread; | 385 | return thread; |
386 | } | 386 | } |
387 | 387 | ||
388 | int perf_session__process_events(struct perf_session *self, | 388 | int __perf_session__process_events(struct perf_session *self, |
389 | struct perf_event_ops *ops) | 389 | u64 data_offset, u64 data_size, |
390 | u64 file_size, struct perf_event_ops *ops) | ||
390 | { | 391 | { |
391 | int err, mmap_prot, mmap_flags; | 392 | int err, mmap_prot, mmap_flags; |
392 | u64 head, shift; | 393 | u64 head, shift; |
@@ -396,32 +397,11 @@ int perf_session__process_events(struct perf_session *self, | |||
396 | uint32_t size; | 397 | uint32_t size; |
397 | char *buf; | 398 | char *buf; |
398 | 399 | ||
399 | if (perf_session__register_idle_thread(self) == NULL) | ||
400 | return -ENOMEM; | ||
401 | |||
402 | perf_event_ops__fill_defaults(ops); | 400 | perf_event_ops__fill_defaults(ops); |
403 | 401 | ||
404 | page_size = sysconf(_SC_PAGESIZE); | 402 | page_size = sysconf(_SC_PAGESIZE); |
405 | 403 | ||
406 | head = self->header.data_offset; | 404 | head = data_offset; |
407 | |||
408 | if (!symbol_conf.full_paths) { | ||
409 | char bf[PATH_MAX]; | ||
410 | |||
411 | if (getcwd(bf, sizeof(bf)) == NULL) { | ||
412 | err = -errno; | ||
413 | out_getcwd_err: | ||
414 | pr_err("failed to get the current directory\n"); | ||
415 | goto out_err; | ||
416 | } | ||
417 | self->cwd = strdup(bf); | ||
418 | if (self->cwd == NULL) { | ||
419 | err = -ENOMEM; | ||
420 | goto out_getcwd_err; | ||
421 | } | ||
422 | self->cwdlen = strlen(self->cwd); | ||
423 | } | ||
424 | |||
425 | shift = page_size * (head / page_size); | 405 | shift = page_size * (head / page_size); |
426 | offset += shift; | 406 | offset += shift; |
427 | head -= shift; | 407 | head -= shift; |
@@ -486,10 +466,10 @@ more: | |||
486 | 466 | ||
487 | head += size; | 467 | head += size; |
488 | 468 | ||
489 | if (offset + head >= self->header.data_offset + self->header.data_size) | 469 | if (offset + head >= data_offset + data_size) |
490 | goto done; | 470 | goto done; |
491 | 471 | ||
492 | if (offset + head < self->size) | 472 | if (offset + head < file_size) |
493 | goto more; | 473 | goto more; |
494 | done: | 474 | done: |
495 | err = 0; | 475 | err = 0; |
@@ -497,6 +477,38 @@ out_err: | |||
497 | return err; | 477 | return err; |
498 | } | 478 | } |
499 | 479 | ||
480 | int perf_session__process_events(struct perf_session *self, | ||
481 | struct perf_event_ops *ops) | ||
482 | { | ||
483 | int err; | ||
484 | |||
485 | if (perf_session__register_idle_thread(self) == NULL) | ||
486 | return -ENOMEM; | ||
487 | |||
488 | if (!symbol_conf.full_paths) { | ||
489 | char bf[PATH_MAX]; | ||
490 | |||
491 | if (getcwd(bf, sizeof(bf)) == NULL) { | ||
492 | err = -errno; | ||
493 | out_getcwd_err: | ||
494 | pr_err("failed to get the current directory\n"); | ||
495 | goto out_err; | ||
496 | } | ||
497 | self->cwd = strdup(bf); | ||
498 | if (self->cwd == NULL) { | ||
499 | err = -ENOMEM; | ||
500 | goto out_getcwd_err; | ||
501 | } | ||
502 | self->cwdlen = strlen(self->cwd); | ||
503 | } | ||
504 | |||
505 | err = __perf_session__process_events(self, self->header.data_offset, | ||
506 | self->header.data_size, | ||
507 | self->size, ops); | ||
508 | out_err: | ||
509 | return err; | ||
510 | } | ||
511 | |||
500 | bool perf_session__has_traces(struct perf_session *self, const char *msg) | 512 | bool perf_session__has_traces(struct perf_session *self, const char *msg) |
501 | { | 513 | { |
502 | if (!(self->sample_type & PERF_SAMPLE_RAW)) { | 514 | if (!(self->sample_type & PERF_SAMPLE_RAW)) { |