diff options
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r-- | tools/perf/util/session.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 60eab8b3ff34..bc84a5217955 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -73,6 +73,8 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc | |||
73 | 73 | ||
74 | if (mode == O_RDONLY && perf_session__open(self, force) < 0) | 74 | if (mode == O_RDONLY && perf_session__open(self, force) < 0) |
75 | goto out_delete; | 75 | goto out_delete; |
76 | |||
77 | self->sample_type = perf_header__sample_type(&self->header); | ||
76 | out: | 78 | out: |
77 | return self; | 79 | return self; |
78 | out_free: | 80 | out_free: |
@@ -302,11 +304,6 @@ int perf_session__process_events(struct perf_session *self, | |||
302 | page_size = getpagesize(); | 304 | page_size = getpagesize(); |
303 | 305 | ||
304 | head = self->header.data_offset; | 306 | head = self->header.data_offset; |
305 | self->sample_type = perf_header__sample_type(&self->header); | ||
306 | |||
307 | err = -EINVAL; | ||
308 | if (ops->sample_type_check && ops->sample_type_check(self) < 0) | ||
309 | goto out_err; | ||
310 | 307 | ||
311 | if (!ops->full_paths) { | 308 | if (!ops->full_paths) { |
312 | char bf[PATH_MAX]; | 309 | char bf[PATH_MAX]; |
@@ -394,13 +391,12 @@ out_err: | |||
394 | return err; | 391 | return err; |
395 | } | 392 | } |
396 | 393 | ||
397 | int perf_session__has_traces(struct perf_session *self) | 394 | bool perf_session__has_traces(struct perf_session *self, const char *msg) |
398 | { | 395 | { |
399 | if (!(self->sample_type & PERF_SAMPLE_RAW)) { | 396 | if (!(self->sample_type & PERF_SAMPLE_RAW)) { |
400 | pr_err("No trace sample to read. Did you call perf record " | 397 | pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg); |
401 | "without -R?"); | 398 | return false; |
402 | return -1; | ||
403 | } | 399 | } |
404 | 400 | ||
405 | return 0; | 401 | return true; |
406 | } | 402 | } |