Commit 27295592 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Ingo Molnar

perf session: Share the common trace sample_check routine as perf_session__has_traces

Signed-off-by: default avatarArnaldo 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-5-git-send-email-acme@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 4a58e611
...@@ -342,22 +342,10 @@ static int process_sample_event(event_t *event, struct perf_session *session) ...@@ -342,22 +342,10 @@ static int process_sample_event(event_t *event, struct perf_session *session)
return 0; return 0;
} }
static int sample_type_check(struct perf_session *session)
{
if (!(session->sample_type & PERF_SAMPLE_RAW)) {
fprintf(stderr,
"No trace sample to read. Did you call perf record "
"without -R?");
return -1;
}
return 0;
}
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.process_sample_event = process_sample_event, .process_sample_event = process_sample_event,
.process_comm_event = event__process_comm, .process_comm_event = event__process_comm,
.sample_type_check = sample_type_check, .sample_type_check = perf_session__has_traces,
}; };
static double fragmentation(unsigned long n_req, unsigned long n_alloc) static double fragmentation(unsigned long n_req, unsigned long n_alloc)
......
...@@ -1653,23 +1653,11 @@ static int process_lost_event(event_t *event __used, ...@@ -1653,23 +1653,11 @@ static int process_lost_event(event_t *event __used,
return 0; return 0;
} }
static int sample_type_check(struct perf_session *session __used)
{
if (!(session->sample_type & PERF_SAMPLE_RAW)) {
fprintf(stderr,
"No trace sample to read. Did you call perf record "
"without -R?");
return -1;
}
return 0;
}
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.process_sample_event = process_sample_event, .process_sample_event = process_sample_event,
.process_comm_event = event__process_comm, .process_comm_event = event__process_comm,
.process_lost_event = process_lost_event, .process_lost_event = process_lost_event,
.sample_type_check = sample_type_check, .sample_type_check = perf_session__has_traces,
}; };
static int read_events(void) static int read_events(void)
......
...@@ -1029,23 +1029,12 @@ static void process_samples(struct perf_session *session) ...@@ -1029,23 +1029,12 @@ static void process_samples(struct perf_session *session)
} }
} }
static int sample_type_check(struct perf_session *session)
{
if (!(session->sample_type & PERF_SAMPLE_RAW)) {
fprintf(stderr, "No trace samples found in the file.\n"
"Have you used 'perf timechart record' to record it?\n");
return -1;
}
return 0;
}
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.process_comm_event = process_comm_event, .process_comm_event = process_comm_event,
.process_fork_event = process_fork_event, .process_fork_event = process_fork_event,
.process_exit_event = process_exit_event, .process_exit_event = process_exit_event,
.process_sample_event = queue_sample_event, .process_sample_event = queue_sample_event,
.sample_type_check = sample_type_check, .sample_type_check = perf_session__has_traces,
}; };
static int __cmd_timechart(void) static int __cmd_timechart(void)
......
...@@ -103,22 +103,10 @@ static int process_sample_event(event_t *event, struct perf_session *session) ...@@ -103,22 +103,10 @@ static int process_sample_event(event_t *event, struct perf_session *session)
return 0; return 0;
} }
static int sample_type_check(struct perf_session *session)
{
if (!(session->sample_type & PERF_SAMPLE_RAW)) {
fprintf(stderr,
"No trace sample to read. Did you call perf record "
"without -R?");
return -1;
}
return 0;
}
static struct perf_event_ops event_ops = { static struct perf_event_ops event_ops = {
.process_sample_event = process_sample_event, .process_sample_event = process_sample_event,
.process_comm_event = event__process_comm, .process_comm_event = event__process_comm,
.sample_type_check = sample_type_check, .sample_type_check = perf_session__has_traces,
}; };
static int __cmd_trace(struct perf_session *session) static int __cmd_trace(struct perf_session *session)
......
...@@ -393,3 +393,14 @@ int perf_session__process_events(struct perf_session *self, ...@@ -393,3 +393,14 @@ int perf_session__process_events(struct perf_session *self,
out_err: out_err:
return err; return err;
} }
int perf_session__has_traces(struct perf_session *self)
{
if (!(self->sample_type & PERF_SAMPLE_RAW)) {
pr_err("No trace sample to read. Did you call perf record "
"without -R?");
return -1;
}
return 0;
}
...@@ -56,6 +56,8 @@ struct symbol **perf_session__resolve_callchain(struct perf_session *self, ...@@ -56,6 +56,8 @@ struct symbol **perf_session__resolve_callchain(struct perf_session *self,
struct ip_callchain *chain, struct ip_callchain *chain,
struct symbol **parent); struct symbol **parent);
int perf_session__has_traces(struct perf_session *self);
int perf_header__read_build_ids(int input, u64 offset, u64 file_size); int perf_header__read_build_ids(int input, u64 offset, u64 file_size);
#endif /* __PERF_SESSION_H */ #endif /* __PERF_SESSION_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment