From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Mike Galbraith" <efault@gmx.de>,
"Peter Zijlstra" <a.p.zijlstra@chello.nl>,
"Paul Mackerras" <paulus@samba.org>
Subject: [PATCH 05/10] perf session: Share the common trace sample_check routine as perf_session__has_traces
Date: Sun, 27 Dec 2009 21:37:01 -0200 [thread overview]
Message-ID: <1261957026-15580-5-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1261957026-15580-1-git-send-email-acme@infradead.org>
From: 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>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-kmem.c | 14 +-------------
tools/perf/builtin-sched.c | 14 +-------------
tools/perf/builtin-timechart.c | 13 +------------
tools/perf/builtin-trace.c | 14 +-------------
tools/perf/util/session.c | 11 +++++++++++
tools/perf/util/session.h | 2 ++
6 files changed, 17 insertions(+), 51 deletions(-)
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index fc21ad7..a85936f 100644
--- a/tools/perf/builtin-kmem.c
+++ b/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/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 80209df..d65098c 100644
--- a/tools/perf/builtin-sched.c
+++ b/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/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index a589a43..b42f337 100644
--- a/tools/perf/builtin-timechart.c
+++ b/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/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 574a215..b0ba2ac 100644
--- a/tools/perf/builtin-trace.c
+++ b/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/tools/perf/util/session.c b/tools/perf/util/session.c
index 736d4fd..60eab8b 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -393,3 +393,14 @@ done:
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/tools/perf/util/session.h b/tools/perf/util/session.h
index 32eaa1b..a6951d2 100644
--- a/tools/perf/util/session.h
+++ b/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 */
--
1.6.2.5
next prev parent reply other threads:[~2009-12-27 23:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-27 23:36 [PATCH 01/10] perf record: We should fork only if a program was specified to run Arnaldo Carvalho de Melo
2009-12-27 23:36 ` [PATCH 02/10] perf tools: Add missing header files to LIB_H Makefile variable Arnaldo Carvalho de Melo
2009-12-27 23:36 ` [PATCH 03/10] perf session: Move the event processing routines to session.c Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 04/10] perf tools: Move the map class definition to a separate header Arnaldo Carvalho de Melo
2009-12-27 23:37 ` Arnaldo Carvalho de Melo [this message]
2009-12-27 23:37 ` [PATCH 06/10] perf session: Remove sample_type_check from event_ops Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 07/10] perf session: Move total_unknown to perf_session->unknown events Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 08/10] perf session: Move full_paths config to symbol_conf Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 09/10] perf session: Remove redundant prefix & suffix from perf_event_ops Arnaldo Carvalho de Melo
2009-12-27 23:37 ` [PATCH 10/10] perf record: Introduce a symtab cache Arnaldo Carvalho de Melo
2009-12-27 23:40 ` Arnaldo Carvalho de Melo
2009-12-28 8:04 ` Ingo Molnar
2009-12-28 8:05 ` [PATCH 01/10] perf record: We should fork only if a program was specified to run Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1261957026-15580-5-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®