diff options
-rw-r--r-- | tools/perf/builtin-kmem.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 13 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 14 | ||||
-rw-r--r-- | tools/perf/util/session.c | 11 | ||||
-rw-r--r-- | 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 fc21ad79dd83..a85936f09f3e 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) | |||
342 | return 0; | 342 | return 0; |
343 | } | 343 | } |
344 | 344 | ||
345 | static int sample_type_check(struct perf_session *session) | ||
346 | { | ||
347 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { | ||
348 | fprintf(stderr, | ||
349 | "No trace sample to read. Did you call perf record " | ||
350 | "without -R?"); | ||
351 | return -1; | ||
352 | } | ||
353 | |||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | static struct perf_event_ops event_ops = { | 345 | static struct perf_event_ops event_ops = { |
358 | .process_sample_event = process_sample_event, | 346 | .process_sample_event = process_sample_event, |
359 | .process_comm_event = event__process_comm, | 347 | .process_comm_event = event__process_comm, |
360 | .sample_type_check = sample_type_check, | 348 | .sample_type_check = perf_session__has_traces, |
361 | }; | 349 | }; |
362 | 350 | ||
363 | static double fragmentation(unsigned long n_req, unsigned long n_alloc) | 351 | 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 80209df6cfe8..d65098c42990 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, | |||
1653 | return 0; | 1653 | return 0; |
1654 | } | 1654 | } |
1655 | 1655 | ||
1656 | static int sample_type_check(struct perf_session *session __used) | ||
1657 | { | ||
1658 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { | ||
1659 | fprintf(stderr, | ||
1660 | "No trace sample to read. Did you call perf record " | ||
1661 | "without -R?"); | ||
1662 | return -1; | ||
1663 | } | ||
1664 | |||
1665 | return 0; | ||
1666 | } | ||
1667 | |||
1668 | static struct perf_event_ops event_ops = { | 1656 | static struct perf_event_ops event_ops = { |
1669 | .process_sample_event = process_sample_event, | 1657 | .process_sample_event = process_sample_event, |
1670 | .process_comm_event = event__process_comm, | 1658 | .process_comm_event = event__process_comm, |
1671 | .process_lost_event = process_lost_event, | 1659 | .process_lost_event = process_lost_event, |
1672 | .sample_type_check = sample_type_check, | 1660 | .sample_type_check = perf_session__has_traces, |
1673 | }; | 1661 | }; |
1674 | 1662 | ||
1675 | static int read_events(void) | 1663 | static int read_events(void) |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index a589a43112d6..b42f337c17d9 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) | |||
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static int sample_type_check(struct perf_session *session) | ||
1033 | { | ||
1034 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { | ||
1035 | fprintf(stderr, "No trace samples found in the file.\n" | ||
1036 | "Have you used 'perf timechart record' to record it?\n"); | ||
1037 | return -1; | ||
1038 | } | ||
1039 | |||
1040 | return 0; | ||
1041 | } | ||
1042 | |||
1043 | static struct perf_event_ops event_ops = { | 1032 | static struct perf_event_ops event_ops = { |
1044 | .process_comm_event = process_comm_event, | 1033 | .process_comm_event = process_comm_event, |
1045 | .process_fork_event = process_fork_event, | 1034 | .process_fork_event = process_fork_event, |
1046 | .process_exit_event = process_exit_event, | 1035 | .process_exit_event = process_exit_event, |
1047 | .process_sample_event = queue_sample_event, | 1036 | .process_sample_event = queue_sample_event, |
1048 | .sample_type_check = sample_type_check, | 1037 | .sample_type_check = perf_session__has_traces, |
1049 | }; | 1038 | }; |
1050 | 1039 | ||
1051 | static int __cmd_timechart(void) | 1040 | static int __cmd_timechart(void) |
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 574a215e800b..b0ba2ac37e2c 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) | |||
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | 105 | ||
106 | static int sample_type_check(struct perf_session *session) | ||
107 | { | ||
108 | if (!(session->sample_type & PERF_SAMPLE_RAW)) { | ||
109 | fprintf(stderr, | ||
110 | "No trace sample to read. Did you call perf record " | ||
111 | "without -R?"); | ||
112 | return -1; | ||
113 | } | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static struct perf_event_ops event_ops = { | 106 | static struct perf_event_ops event_ops = { |
119 | .process_sample_event = process_sample_event, | 107 | .process_sample_event = process_sample_event, |
120 | .process_comm_event = event__process_comm, | 108 | .process_comm_event = event__process_comm, |
121 | .sample_type_check = sample_type_check, | 109 | .sample_type_check = perf_session__has_traces, |
122 | }; | 110 | }; |
123 | 111 | ||
124 | static int __cmd_trace(struct perf_session *session) | 112 | static int __cmd_trace(struct perf_session *session) |
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 736d4fda9272..60eab8b3ff34 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -393,3 +393,14 @@ done: | |||
393 | out_err: | 393 | out_err: |
394 | return err; | 394 | return err; |
395 | } | 395 | } |
396 | |||
397 | int perf_session__has_traces(struct perf_session *self) | ||
398 | { | ||
399 | if (!(self->sample_type & PERF_SAMPLE_RAW)) { | ||
400 | pr_err("No trace sample to read. Did you call perf record " | ||
401 | "without -R?"); | ||
402 | return -1; | ||
403 | } | ||
404 | |||
405 | return 0; | ||
406 | } | ||
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 32eaa1bada06..a6951d2f700f 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, | |||
56 | struct ip_callchain *chain, | 56 | struct ip_callchain *chain, |
57 | struct symbol **parent); | 57 | struct symbol **parent); |
58 | 58 | ||
59 | int perf_session__has_traces(struct perf_session *self); | ||
60 | |||
59 | int perf_header__read_build_ids(int input, u64 offset, u64 file_size); | 61 | int perf_header__read_build_ids(int input, u64 offset, u64 file_size); |
60 | 62 | ||
61 | #endif /* __PERF_SESSION_H */ | 63 | #endif /* __PERF_SESSION_H */ |