aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-12-27 18:37:02 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-28 03:03:34 -0500
commitd549c7690190d9739005e19604faad6da4b802ac (patch)
tree1a03376ecc41ecd9495298ed3ad34f72da7ecea0 /tools/perf/util/session.c
parent27295592c22e71bbd38110c302da8dbb43912a60 (diff)
perf session: Remove sample_type_check from event_ops
This is really something tools need to do before asking for the events to be processed, leaving perf_session__process_events to do just that, process events. Also add a msg parameter to perf_session__has_traces() so that the right message can be printed, fixing a regression added by me in the previous cset (right timechart message) and also fixing 'perf kmem', that was not asking if 'perf kmem record' was ran. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1261957026-15580-6-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c16
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);
76out: 78out:
77 return self; 79 return self;
78out_free: 80out_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
397int perf_session__has_traces(struct perf_session *self) 394bool 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}