diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/evsel.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index fe9581b0323c..c78e42ab9770 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1108,13 +1108,43 @@ u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample, | |||
1108 | const char *name) | 1108 | const char *name) |
1109 | { | 1109 | { |
1110 | struct format_field *field = perf_evsel__field(evsel, name); | 1110 | struct format_field *field = perf_evsel__field(evsel, name); |
1111 | u64 val; | 1111 | void *ptr; |
1112 | u64 value; | ||
1112 | 1113 | ||
1113 | if (!field) | 1114 | if (!field) |
1114 | return 0; | 1115 | return 0; |
1115 | 1116 | ||
1116 | val = pevent_read_number(evsel->tp_format->pevent, | 1117 | ptr = sample->raw_data + field->offset; |
1117 | sample->raw_data + field->offset, field->size); | ||
1118 | return val; | ||
1119 | 1118 | ||
1119 | switch (field->size) { | ||
1120 | case 1: | ||
1121 | return *(u8 *)ptr; | ||
1122 | case 2: | ||
1123 | value = *(u16 *)ptr; | ||
1124 | break; | ||
1125 | case 4: | ||
1126 | value = *(u32 *)ptr; | ||
1127 | break; | ||
1128 | case 8: | ||
1129 | value = *(u64 *)ptr; | ||
1130 | break; | ||
1131 | default: | ||
1132 | return 0; | ||
1133 | } | ||
1134 | |||
1135 | if (!evsel->needs_swap) | ||
1136 | return value; | ||
1137 | |||
1138 | switch (field->size) { | ||
1139 | case 2: | ||
1140 | return bswap_16(value); | ||
1141 | case 4: | ||
1142 | return bswap_32(value); | ||
1143 | case 8: | ||
1144 | return bswap_64(value); | ||
1145 | default: | ||
1146 | return 0; | ||
1147 | } | ||
1148 | |||
1149 | return 0; | ||
1120 | } | 1150 | } |