perf util: Parse header_page to get proper long size
authorNamhyung Kim <namhyung.kim@lge.com>
Tue, 4 Jun 2013 05:20:26 +0000 (14:20 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 12 Jul 2013 16:52:24 +0000 (13:52 -0300)
The header_page file describes the format of the ring buffer page
which is used by ftrace (not perf).  And size of "commit" field (I
guess it's older name was 'size') represents the real size of long
type used for kernel.  So update the pevent's long size.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1370323231-14022-12-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/trace-event-read.c

index fa45fca..f211227 100644 (file)
@@ -212,6 +212,7 @@ static int read_ftrace_printk(struct pevent *pevent)
 static int read_header_files(struct pevent *pevent)
 {
        unsigned long long size;
+       char *header_page;
        char buf[BUFSIZ];
        int ret = 0;
 
@@ -224,7 +225,26 @@ static int read_header_files(struct pevent *pevent)
        }
 
        size = read8(pevent);
-       skip(size);
+
+       header_page = malloc(size);
+       if (header_page == NULL)
+               return -1;
+
+       if (do_read(header_page, size) < 0) {
+               pr_debug("did not read header page");
+               free(header_page);
+               return -1;
+       }
+
+       if (!pevent_parse_header_page(pevent, header_page, size,
+                                     pevent_get_long_size(pevent))) {
+               /*
+                * The commit field in the page is of type long,
+                * use that instead, since it represents the kernel.
+                */
+               pevent_set_long_size(pevent, pevent->header_page_size_size);
+       }
+       free(header_page);
 
        if (do_read(buf, 13) < 0)
                return -1;