From 06c185488f9cdb8b7550976b92e198a76cf91d42 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Sun, 27 Dec 2009 21:37:01 -0200 Subject: [PATCH] --- yaml --- r: 182319 b: refs/heads/master c: 27295592c22e71bbd38110c302da8dbb43912a60 h: refs/heads/master i: 182317: 58f6481dbccb4580332eb585857ac76fa56dedf9 182315: 6bb5099f5b8431f4dcbdae00e1223f895298b65b 182311: b75180e3bf894488c4ab036c19f982e3ecfb2e66 182303: db7f0c74fa7a7a43314d9d92df4613ac66c36d97 v: v3 --- [refs] | 2 +- trunk/tools/perf/builtin-kmem.c | 14 +------------- trunk/tools/perf/builtin-sched.c | 14 +------------- trunk/tools/perf/builtin-timechart.c | 13 +------------ trunk/tools/perf/builtin-trace.c | 14 +------------- trunk/tools/perf/util/session.c | 11 +++++++++++ trunk/tools/perf/util/session.h | 2 ++ 7 files changed, 18 insertions(+), 52 deletions(-) diff --git a/[refs] b/[refs] index a172cd0f576f..ec84590393bb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 4a58e61161074776aa34187ea369414ce4852394 +refs/heads/master: 27295592c22e71bbd38110c302da8dbb43912a60 diff --git a/trunk/tools/perf/builtin-kmem.c b/trunk/tools/perf/builtin-kmem.c index fc21ad79dd83..a85936f09f3e 100644 --- a/trunk/tools/perf/builtin-kmem.c +++ b/trunk/tools/perf/builtin-kmem.c @@ -342,22 +342,10 @@ static int process_sample_event(event_t *event, struct perf_session *session) 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 = { .process_sample_event = process_sample_event, .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) diff --git a/trunk/tools/perf/builtin-sched.c b/trunk/tools/perf/builtin-sched.c index 80209df6cfe8..d65098c42990 100644 --- a/trunk/tools/perf/builtin-sched.c +++ b/trunk/tools/perf/builtin-sched.c @@ -1653,23 +1653,11 @@ static int process_lost_event(event_t *event __used, 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 = { .process_sample_event = process_sample_event, .process_comm_event = event__process_comm, .process_lost_event = process_lost_event, - .sample_type_check = sample_type_check, + .sample_type_check = perf_session__has_traces, }; static int read_events(void) diff --git a/trunk/tools/perf/builtin-timechart.c b/trunk/tools/perf/builtin-timechart.c index a589a43112d6..b42f337c17d9 100644 --- a/trunk/tools/perf/builtin-timechart.c +++ b/trunk/tools/perf/builtin-timechart.c @@ -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 = { .process_comm_event = process_comm_event, .process_fork_event = process_fork_event, .process_exit_event = process_exit_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) diff --git a/trunk/tools/perf/builtin-trace.c b/trunk/tools/perf/builtin-trace.c index 574a215e800b..b0ba2ac37e2c 100644 --- a/trunk/tools/perf/builtin-trace.c +++ b/trunk/tools/perf/builtin-trace.c @@ -103,22 +103,10 @@ static int process_sample_event(event_t *event, struct perf_session *session) 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 = { .process_sample_event = process_sample_event, .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) diff --git a/trunk/tools/perf/util/session.c b/trunk/tools/perf/util/session.c index 736d4fda9272..60eab8b3ff34 100644 --- a/trunk/tools/perf/util/session.c +++ b/trunk/tools/perf/util/session.c @@ -393,3 +393,14 @@ int perf_session__process_events(struct perf_session *self, out_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; +} diff --git a/trunk/tools/perf/util/session.h b/trunk/tools/perf/util/session.h index 32eaa1bada06..a6951d2f700f 100644 --- a/trunk/tools/perf/util/session.h +++ b/trunk/tools/perf/util/session.h @@ -56,6 +56,8 @@ struct symbol **perf_session__resolve_callchain(struct perf_session *self, struct ip_callchain *chain, 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); #endif /* __PERF_SESSION_H */