aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/session.c')
-rw-r--r--tools/perf/util/session.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index fff66741f18d..64500fc78799 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -97,6 +97,7 @@ out:
97void perf_session__update_sample_type(struct perf_session *self) 97void perf_session__update_sample_type(struct perf_session *self)
98{ 98{
99 self->sample_type = perf_evlist__sample_type(self->evlist); 99 self->sample_type = perf_evlist__sample_type(self->evlist);
100 self->sample_size = perf_sample_size(self->sample_type);
100 self->sample_id_all = perf_evlist__sample_id_all(self->evlist); 101 self->sample_id_all = perf_evlist__sample_id_all(self->evlist);
101 perf_session__id_header_size(self); 102 perf_session__id_header_size(self);
102} 103}
@@ -479,6 +480,7 @@ static void flush_sample_queue(struct perf_session *s,
479 struct perf_sample sample; 480 struct perf_sample sample;
480 u64 limit = os->next_flush; 481 u64 limit = os->next_flush;
481 u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL; 482 u64 last_ts = os->last_sample ? os->last_sample->timestamp : 0ULL;
483 int ret;
482 484
483 if (!ops->ordered_samples || !limit) 485 if (!ops->ordered_samples || !limit)
484 return; 486 return;
@@ -487,9 +489,12 @@ static void flush_sample_queue(struct perf_session *s,
487 if (iter->timestamp > limit) 489 if (iter->timestamp > limit)
488 break; 490 break;
489 491
490 perf_session__parse_sample(s, iter->event, &sample); 492 ret = perf_session__parse_sample(s, iter->event, &sample);
491 perf_session_deliver_event(s, iter->event, &sample, ops, 493 if (ret)
492 iter->file_offset); 494 pr_err("Can't parse sample, err = %d\n", ret);
495 else
496 perf_session_deliver_event(s, iter->event, &sample, ops,
497 iter->file_offset);
493 498
494 os->last_flush = iter->timestamp; 499 os->last_flush = iter->timestamp;
495 list_del(&iter->list); 500 list_del(&iter->list);
@@ -805,7 +810,9 @@ static int perf_session__process_event(struct perf_session *session,
805 /* 810 /*
806 * For all kernel events we get the sample data 811 * For all kernel events we get the sample data
807 */ 812 */
808 perf_session__parse_sample(session, event, &sample); 813 ret = perf_session__parse_sample(session, event, &sample);
814 if (ret)
815 return ret;
809 816
810 /* Preprocess sample records - precheck callchains */ 817 /* Preprocess sample records - precheck callchains */
811 if (perf_session__preprocess_sample(session, event, &sample)) 818 if (perf_session__preprocess_sample(session, event, &sample))
@@ -953,6 +960,30 @@ out_err:
953 return err; 960 return err;
954} 961}
955 962
963static union perf_event *
964fetch_mmaped_event(struct perf_session *session,
965 u64 head, size_t mmap_size, char *buf)
966{
967 union perf_event *event;
968
969 /*
970 * Ensure we have enough space remaining to read
971 * the size of the event in the headers.
972 */
973 if (head + sizeof(event->header) > mmap_size)
974 return NULL;
975
976 event = (union perf_event *)(buf + head);
977
978 if (session->header.needs_swap)
979 perf_event_header__bswap(&event->header);
980
981 if (head + event->header.size > mmap_size)
982 return NULL;
983
984 return event;
985}
986
956int __perf_session__process_events(struct perf_session *session, 987int __perf_session__process_events(struct perf_session *session,
957 u64 data_offset, u64 data_size, 988 u64 data_offset, u64 data_size,
958 u64 file_size, struct perf_event_ops *ops) 989 u64 file_size, struct perf_event_ops *ops)
@@ -1007,15 +1038,8 @@ remap:
1007 file_pos = file_offset + head; 1038 file_pos = file_offset + head;
1008 1039
1009more: 1040more:
1010 event = (union perf_event *)(buf + head); 1041 event = fetch_mmaped_event(session, head, mmap_size, buf);
1011 1042 if (!event) {
1012 if (session->header.needs_swap)
1013 perf_event_header__bswap(&event->header);
1014 size = event->header.size;
1015 if (size == 0)
1016 size = 8;
1017
1018 if (head + event->header.size > mmap_size) {
1019 if (mmaps[map_idx]) { 1043 if (mmaps[map_idx]) {
1020 munmap(mmaps[map_idx], mmap_size); 1044 munmap(mmaps[map_idx], mmap_size);
1021 mmaps[map_idx] = NULL; 1045 mmaps[map_idx] = NULL;