diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2009-12-06 06:08:24 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-06 12:15:01 -0500 |
commit | 180f95e29aa8782c019caa64ede2a28d8ab62564 (patch) | |
tree | eefd1631820b00992f4495cc8cdba66a9155ee6c /tools/perf/util/event.c | |
parent | 028c515253761084c6594bf9ac9b194b51d87065 (diff) |
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>
Diffstat (limited to 'tools/perf/util/event.c')
-rw-r--r-- | tools/perf/util/event.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 414b89d1bde9..4dcecafa85dc 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -310,3 +310,70 @@ int event__preprocess_sample(const event_t *self, struct addr_location *al, | |||
310 | al->level == 'H' ? "[hypervisor]" : "<not found>"); | 310 | al->level == 'H' ? "[hypervisor]" : "<not found>"); |
311 | return 0; | 311 | return 0; |
312 | } | 312 | } |
313 | |||
314 | int event__parse_sample(event_t *event, u64 type, struct sample_data *data) | ||
315 | { | ||
316 | u64 *array = event->sample.array; | ||
317 | |||
318 | if (type & PERF_SAMPLE_IP) { | ||
319 | data->ip = event->ip.ip; | ||
320 | array++; | ||
321 | } | ||
322 | |||
323 | if (type & PERF_SAMPLE_TID) { | ||
324 | u32 *p = (u32 *)array; | ||
325 | data->pid = p[0]; | ||
326 | data->tid = p[1]; | ||
327 | array++; | ||
328 | } | ||
329 | |||
330 | if (type & PERF_SAMPLE_TIME) { | ||
331 | data->time = *array; | ||
332 | array++; | ||
333 | } | ||
334 | |||
335 | if (type & PERF_SAMPLE_ADDR) { | ||
336 | data->addr = *array; | ||
337 | array++; | ||
338 | } | ||
339 | |||
340 | if (type & PERF_SAMPLE_ID) { | ||
341 | data->id = *array; | ||
342 | array++; | ||
343 | } | ||
344 | |||
345 | if (type & PERF_SAMPLE_STREAM_ID) { | ||
346 | data->stream_id = *array; | ||
347 | array++; | ||
348 | } | ||
349 | |||
350 | if (type & PERF_SAMPLE_CPU) { | ||
351 | u32 *p = (u32 *)array; | ||
352 | data->cpu = *p; | ||
353 | array++; | ||
354 | } | ||
355 | |||
356 | if (type & PERF_SAMPLE_PERIOD) { | ||
357 | data->period = *array; | ||
358 | array++; | ||
359 | } | ||
360 | |||
361 | if (type & PERF_SAMPLE_READ) { | ||
362 | pr_debug("PERF_SAMPLE_READ is unsuported for now\n"); | ||
363 | return -1; | ||
364 | } | ||
365 | |||
366 | if (type & PERF_SAMPLE_CALLCHAIN) { | ||
367 | data->callchain = (struct ip_callchain *)array; | ||
368 | array += 1 + data->callchain->nr; | ||
369 | } | ||
370 | |||
371 | if (type & PERF_SAMPLE_RAW) { | ||
372 | u32 *p = (u32 *)array; | ||
373 | data->raw_size = *p; | ||
374 | p++; | ||
375 | data->raw_data = p; | ||
376 | } | ||
377 | |||
378 | return 0; | ||
379 | } | ||