perf: Make common SAMPLE_EVENT parser
Currently, sample event data is parsed for each commands, and it is assuming that the data is not including other data. (E.g. timechart, trace, etc. can't parse the event if it has PERF_SAMPLE_CALLCHAIN) So, even if we record the superset data for multiple commands at a time, commands can't parse. etc. To fix it, this makes common sample event parser, and use it to parse sample event correctly. (PERF_SAMPLE_READ is unsupported for now though, it seems to be not using.) Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <87hbs48imv.fsf@devron.myhome.or.jp> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
committed by
Ingo Molnar
parent
028c515253
commit
180f95e29a
@@ -310,3 +310,70 @@ int event__preprocess_sample(const event_t *self, struct addr_location *al,
|
||||
al->level == 'H' ? "[hypervisor]" : "<not found>");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int event__parse_sample(event_t *event, u64 type, struct sample_data *data)
|
||||
{
|
||||
u64 *array = event->sample.array;
|
||||
|
||||
if (type & PERF_SAMPLE_IP) {
|
||||
data->ip = event->ip.ip;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_TID) {
|
||||
u32 *p = (u32 *)array;
|
||||
data->pid = p[0];
|
||||
data->tid = p[1];
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_TIME) {
|
||||
data->time = *array;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_ADDR) {
|
||||
data->addr = *array;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_ID) {
|
||||
data->id = *array;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_STREAM_ID) {
|
||||
data->stream_id = *array;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_CPU) {
|
||||
u32 *p = (u32 *)array;
|
||||
data->cpu = *p;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_PERIOD) {
|
||||
data->period = *array;
|
||||
array++;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_READ) {
|
||||
pr_debug("PERF_SAMPLE_READ is unsuported for now\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_CALLCHAIN) {
|
||||
data->callchain = (struct ip_callchain *)array;
|
||||
array += 1 + data->callchain->nr;
|
||||
}
|
||||
|
||||
if (type & PERF_SAMPLE_RAW) {
|
||||
u32 *p = (u32 *)array;
|
||||
data->raw_size = *p;
|
||||
p++;
|
||||
data->raw_data = p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user