diff options
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r-- | tools/perf/util/evsel.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e81771364867..2eaae140def2 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) | 20 | #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) |
21 | #define GROUP_FD(group_fd, cpu) (*(int *)xyarray__entry(group_fd, cpu, 0)) | 21 | #define GROUP_FD(group_fd, cpu) (*(int *)xyarray__entry(group_fd, cpu, 0)) |
22 | 22 | ||
23 | int __perf_evsel__sample_size(u64 sample_type) | 23 | static int __perf_evsel__sample_size(u64 sample_type) |
24 | { | 24 | { |
25 | u64 mask = sample_type & PERF_SAMPLE_MASK; | 25 | u64 mask = sample_type & PERF_SAMPLE_MASK; |
26 | int size = 0; | 26 | int size = 0; |
@@ -53,6 +53,7 @@ void perf_evsel__init(struct perf_evsel *evsel, | |||
53 | evsel->attr = *attr; | 53 | evsel->attr = *attr; |
54 | INIT_LIST_HEAD(&evsel->node); | 54 | INIT_LIST_HEAD(&evsel->node); |
55 | hists__init(&evsel->hists); | 55 | hists__init(&evsel->hists); |
56 | evsel->sample_size = __perf_evsel__sample_size(attr->sample_type); | ||
56 | } | 57 | } |
57 | 58 | ||
58 | struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx) | 59 | struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr, int idx) |
@@ -728,10 +729,10 @@ static bool sample_overlap(const union perf_event *event, | |||
728 | return false; | 729 | return false; |
729 | } | 730 | } |
730 | 731 | ||
731 | int perf_event__parse_sample(const union perf_event *event, u64 type, | 732 | int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, |
732 | int sample_size, bool sample_id_all, | ||
733 | struct perf_sample *data, bool swapped) | 733 | struct perf_sample *data, bool swapped) |
734 | { | 734 | { |
735 | u64 type = evsel->attr.sample_type; | ||
735 | const u64 *array; | 736 | const u64 *array; |
736 | 737 | ||
737 | /* | 738 | /* |
@@ -746,14 +747,14 @@ int perf_event__parse_sample(const union perf_event *event, u64 type, | |||
746 | data->period = 1; | 747 | data->period = 1; |
747 | 748 | ||
748 | if (event->header.type != PERF_RECORD_SAMPLE) { | 749 | if (event->header.type != PERF_RECORD_SAMPLE) { |
749 | if (!sample_id_all) | 750 | if (!evsel->attr.sample_id_all) |
750 | return 0; | 751 | return 0; |
751 | return perf_event__parse_id_sample(event, type, data, swapped); | 752 | return perf_event__parse_id_sample(event, type, data, swapped); |
752 | } | 753 | } |
753 | 754 | ||
754 | array = event->sample.array; | 755 | array = event->sample.array; |
755 | 756 | ||
756 | if (sample_size + sizeof(event->header) > event->header.size) | 757 | if (evsel->sample_size + sizeof(event->header) > event->header.size) |
757 | return -EFAULT; | 758 | return -EFAULT; |
758 | 759 | ||
759 | if (type & PERF_SAMPLE_IP) { | 760 | if (type & PERF_SAMPLE_IP) { |
@@ -895,7 +896,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, | |||
895 | u.val32[1] = sample->tid; | 896 | u.val32[1] = sample->tid; |
896 | if (swapped) { | 897 | if (swapped) { |
897 | /* | 898 | /* |
898 | * Inverse of what is done in perf_event__parse_sample | 899 | * Inverse of what is done in perf_evsel__parse_sample |
899 | */ | 900 | */ |
900 | u.val32[0] = bswap_32(u.val32[0]); | 901 | u.val32[0] = bswap_32(u.val32[0]); |
901 | u.val32[1] = bswap_32(u.val32[1]); | 902 | u.val32[1] = bswap_32(u.val32[1]); |
@@ -930,7 +931,7 @@ int perf_event__synthesize_sample(union perf_event *event, u64 type, | |||
930 | u.val32[0] = sample->cpu; | 931 | u.val32[0] = sample->cpu; |
931 | if (swapped) { | 932 | if (swapped) { |
932 | /* | 933 | /* |
933 | * Inverse of what is done in perf_event__parse_sample | 934 | * Inverse of what is done in perf_evsel__parse_sample |
934 | */ | 935 | */ |
935 | u.val32[0] = bswap_32(u.val32[0]); | 936 | u.val32[0] = bswap_32(u.val32[0]); |
936 | u.val64 = bswap_64(u.val64); | 937 | u.val64 = bswap_64(u.val64); |