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>
This commit is contained in:
Arnaldo Carvalho de Melo
2009-12-27 21:37:02 -02:00
committed by Ingo Molnar
parent 27295592c2
commit d549c76901
7 changed files with 31 additions and 27 deletions

View File

@@ -73,6 +73,8 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc
if (mode == O_RDONLY && perf_session__open(self, force) < 0)
goto out_delete;
self->sample_type = perf_header__sample_type(&self->header);
out:
return self;
out_free:
@@ -302,11 +304,6 @@ int perf_session__process_events(struct perf_session *self,
page_size = getpagesize();
head = self->header.data_offset;
self->sample_type = perf_header__sample_type(&self->header);
err = -EINVAL;
if (ops->sample_type_check && ops->sample_type_check(self) < 0)
goto out_err;
if (!ops->full_paths) {
char bf[PATH_MAX];
@@ -394,13 +391,12 @@ out_err:
return err;
}
int perf_session__has_traces(struct perf_session *self)
bool perf_session__has_traces(struct perf_session *self, const char *msg)
{
if (!(self->sample_type & PERF_SAMPLE_RAW)) {
pr_err("No trace sample to read. Did you call perf record "
"without -R?");
return -1;
pr_err("No trace sample to read. Did you call 'perf %s'?\n", msg);
return false;
}
return 0;
return true;
}