From: Ingo Molnar Date: Sun, 14 Jun 2009 12:44:07 +0000 (+0200) Subject: perf report: Print out raw events in hexa X-Git-Tag: Ubuntu-5.2.0-15.16~28943^2~39 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=8465b05046652cfde3d47692cab2e8ba962f140f;p=mirror_ubuntu-eoan-kernel.git perf report: Print out raw events in hexa Print out events in hexa dump format, when -D is specified: 0x4868 [0x48]: event: 1 . . ... raw event: size 72 bytes . 0000: 01 00 00 00 00 00 48 00 d4 72 00 00 d4 72 00 00 ......H..r...r. . 0010: 00 00 40 f2 3e 00 00 00 00 30 01 00 00 00 00 00 ..@.>....0..... . 0020: 00 00 00 00 00 00 00 00 2f 75 73 72 2f 6c 69 62 ......../usr/li . 0030: 36 34 2f 6c 69 62 65 6c 66 2d 30 2e 31 34 31 2e 64/libelf-0.141 . 0040: 73 6f 00 00 00 00 00 00 f-0.141 . 0x4868 [0x48]: PERF_EVENT_MMAP 29396: [0x3ef2400000(0x13000) @ (nil)]: /usr/lib64/libelf-0.141.so This helps the debugging of mis-parsing of data files, and helps the addition of new sample/trace formats. Cc: Peter Zijlstra Cc: Mike Galbraith Cc: Paul Mackerras Cc: Arnaldo Carvalho de Melo LKML-Reference: Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 82fa93b4db99..37515da637f7 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1095,9 +1095,43 @@ process_period_event(event_t *event, unsigned long offset, unsigned long head) return 0; } +static void trace_event(event_t *event) +{ + unsigned char *raw_event = (void *)event; + int i, j; + + if (!dump_trace) + return; + + dprintf(".\n. ... raw event: size %d bytes\n", event->header.size); + + for (i = 0; i < event->header.size; i++) { + if ((i & 15) == 0) + dprintf(". %04x: ", i); + + dprintf(" %02x", raw_event[i]); + + if (((i & 15) == 15) || i == event->header.size-1) { + dprintf(" "); + for (j = 0; j < 15-(i & 15); j++) + dprintf(" "); + for (j = 0; j < (i & 15); j++) { + if (isprint(raw_event[i-15+j])) + dprintf("%c", raw_event[i-15+j]); + else + dprintf("."); + } + dprintf("\n"); + } + } + dprintf(".\n"); +} + static int process_event(event_t *event, unsigned long offset, unsigned long head) { + trace_event(event); + if (event->header.misc & PERF_EVENT_MISC_OVERFLOW) return process_overflow_event(event, offset, head); @@ -1204,7 +1238,7 @@ more: size = event->header.size; - dprintf("%p [%p]: event: %d\n", + dprintf("\n%p [%p]: event: %d\n", (void *)(offset + head), (void *)(long)event->header.size, event->header.type);